diff --git a/__test__/rules/sort-named-imports.spec.js b/__test__/rules/sort-named-imports.spec.js index 8a7bdd1..86b196b 100644 --- a/__test__/rules/sort-named-imports.spec.js +++ b/__test__/rules/sort-named-imports.spec.js @@ -18,6 +18,23 @@ ruleTester.run('codebox/sort-named-imports', sortNamedImportsRule, { `, options: [{ ignoreCase: true }], }, + { + code: ` + import { a, B, c } from 'fs' + `, + options: [{ ignoreCase: true }], + }, + { + code: ` + import { a, B, c } from 'fs' + `, + }, + { + code: ` + import { B, a, c } from 'fs' + `, + options: [{ ignoreCase: false }], + }, ], invalid: [ { @@ -30,5 +47,15 @@ ruleTester.run('codebox/sort-named-imports', sortNamedImportsRule, { import { a, b, c } from 'fs' `, }, + { + code: ` + import { a, B, c } from 'fs' + `, + errors: [{ message: `Member 'B' of the import declaration should be sorted alphabetically` }], + options: [{ ignoreCase: false }], + output: ` + import { B, a, c } from 'fs' + `, + }, ], }) diff --git a/src/rules/sort-named-imports.js b/src/rules/sort-named-imports.js index 75b4698..b3081a9 100644 --- a/src/rules/sort-named-imports.js +++ b/src/rules/sort-named-imports.js @@ -26,7 +26,7 @@ module.exports = { create(context) { const sourceCode = context.getSourceCode() const config = context.options[0] || {} - const ignoreCase = config.ignoreCase || true + const ignoreCase = config.ignoreCase !== undefined ? config.ignoreCase : true; return { ImportDeclaration(node) { const importSpecifiers = node.specifiers.filter(