Skip to content

Commit b15d902

Browse files
committed
add fixes
1 parent de52c4b commit b15d902

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

Diff for: src/rules/order.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
import { min } from 'lodash';
43
import minimatch from 'minimatch';
54
import importType from '../core/importType';
65
import isStaticRequire from '../core/staticRequire';
@@ -258,10 +257,10 @@ function getSorter(ascending) {
258257
} else {
259258
const A = importA.split('/');
260259
const B = importB.split('/');
261-
const a = A.length
262-
const b = B.length
260+
const a = A.length;
261+
const b = B.length;
263262

264-
for (var i = 0; i < min([a, b]); i++) {
263+
for (let i = 0; i < Math.min(a, b); i++) {
265264
if (A[i] < B[i]) {
266265
result = -1;
267266
break;
@@ -271,8 +270,8 @@ function getSorter(ascending) {
271270
}
272271
}
273272

274-
if (!result && a != b) {
275-
result = a < b ? -1 : 1
273+
if (!result && a !== b) {
274+
result = a < b ? -1 : 1;
276275
}
277276
}
278277

Diff for: tests/src/rules/order.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,8 @@ ruleTester.run('order', rule, {
683683
import d from "foo/barfoo";
684684
import b from "foo-bar";`,
685685
options: [{
686-
alphabetize: { order: 'asc' },
687-
}],
686+
alphabetize: { order: 'asc' },
687+
}],
688688
}),
689689
// Option alphabetize: {order: 'asc'} and move nested import entries closer to the main import entry
690690
test({
@@ -694,8 +694,8 @@ ruleTester.run('order', rule, {
694694
import d from "foo/foobar/barfoo";
695695
import b from "foo-bar";`,
696696
options: [{
697-
alphabetize: { order: 'asc' },
698-
}],
697+
alphabetize: { order: 'asc' },
698+
}],
699699
}),
700700
// Option alphabetize: {order: 'desc'} and move nested import entries closer to the main import entry
701701
test({
@@ -705,8 +705,8 @@ ruleTester.run('order', rule, {
705705
import c from "foo/bar";
706706
import a from "foo";`,
707707
options: [{
708-
alphabetize: { order: 'desc' },
709-
}],
708+
alphabetize: { order: 'desc' },
709+
}],
710710
}),
711711
// Option alphabetize with newlines-between: {order: 'asc', newlines-between: 'always'}
712712
test({
@@ -2272,17 +2272,17 @@ ruleTester.run('order', rule, {
22722272
import d from "foo/barfoo";
22732273
`,
22742274
options: [{
2275-
alphabetize: { order: 'asc' },
2275+
alphabetize: { order: 'asc' },
22762276
}],
22772277
output: `
22782278
import a from "foo";
22792279
import c from "foo/bar";
22802280
import d from "foo/barfoo";
22812281
import b from "foo-bar";
22822282
`,
2283-
errors: [
2284-
{ message: '`foo-bar` import should occur after import of `foo/barfoo`'}
2285-
]
2283+
errors: [{
2284+
message: '`foo-bar` import should occur after import of `foo/barfoo`',
2285+
},]
22862286
}),
22872287
// Option alphabetize {order: 'asc': caseInsensitive: true}
22882288
test({

0 commit comments

Comments
 (0)