diff --git a/src/rules/order.js b/src/rules/order.js index 3cc706645b..b79ce39103 100644 --- a/src/rules/order.js +++ b/src/rules/order.js @@ -1,6 +1,5 @@ 'use strict'; -import { min } from 'lodash'; import minimatch from 'minimatch'; import importType from '../core/importType'; import isStaticRequire from '../core/staticRequire'; @@ -258,10 +257,10 @@ function getSorter(ascending) { } else { const A = importA.split('/'); const B = importB.split('/'); - const a = A.length - const b = B.length + const a = A.length; + const b = B.length; - for (var i = 0; i < min([a, b]); i++) { + for (let i = 0; i < Math.min(a, b); i++) { if (A[i] < B[i]) { result = -1; break; @@ -271,8 +270,8 @@ function getSorter(ascending) { } } - if (!result && a != b) { - result = a < b ? -1 : 1 + if (!result && a !== b) { + result = a < b ? -1 : 1; } } diff --git a/tests/src/rules/order.js b/tests/src/rules/order.js index 35cd1d99be..1661f4a912 100644 --- a/tests/src/rules/order.js +++ b/tests/src/rules/order.js @@ -683,8 +683,8 @@ ruleTester.run('order', rule, { import d from "foo/barfoo"; import b from "foo-bar";`, options: [{ - alphabetize: { order: 'asc' }, - }], + alphabetize: { order: 'asc' }, + }], }), // Option alphabetize: {order: 'asc'} and move nested import entries closer to the main import entry test({ @@ -694,8 +694,8 @@ ruleTester.run('order', rule, { import d from "foo/foobar/barfoo"; import b from "foo-bar";`, options: [{ - alphabetize: { order: 'asc' }, - }], + alphabetize: { order: 'asc' }, + }], }), // Option alphabetize: {order: 'desc'} and move nested import entries closer to the main import entry test({ @@ -705,8 +705,8 @@ ruleTester.run('order', rule, { import c from "foo/bar"; import a from "foo";`, options: [{ - alphabetize: { order: 'desc' }, - }], + alphabetize: { order: 'desc' }, + }], }), // Option alphabetize with newlines-between: {order: 'asc', newlines-between: 'always'} test({ @@ -2272,7 +2272,7 @@ ruleTester.run('order', rule, { import d from "foo/barfoo"; `, options: [{ - alphabetize: { order: 'asc' }, + alphabetize: { order: 'asc' }, }], output: ` import a from "foo"; @@ -2280,9 +2280,9 @@ ruleTester.run('order', rule, { import d from "foo/barfoo"; import b from "foo-bar"; `, - errors: [ - { message: '`foo-bar` import should occur after import of `foo/barfoo`'} - ] + errors: [{ + message: '`foo-bar` import should occur after import of `foo/barfoo`', + },] }), // Option alphabetize {order: 'asc': caseInsensitive: true} test({