diff --git a/CHANGELOG.md b/CHANGELOG.md index 8195b57aa..6959a8469 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel - add [`no-extraneous-dependencies`] rule ([#241], thanks [@jfmengels]) - add [`extensions`] rule ([#250], thanks [@lo1tuma]) - add [`no-nodejs-modules`] rule ([#261], thanks [@jfmengels]) -- add [`import-order`] rule ([#247], thanks [@jfmengels]) +- add [`order`] rule ([#247], thanks [@jfmengels]) - consider `resolve.fallback` config option in the webpack resolver ([#254]) ### Changed diff --git a/README.md b/README.md index 71a19da15..67d63d779 100644 --- a/README.md +++ b/README.md @@ -53,13 +53,13 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a * Report repeated import of the same module in multiple places ([`no-duplicates`]) * Report namespace imports ([`no-namespace`]) * Ensure consistent use of file extension within the import path ([`extensions`]) -* Enforce a convention in module import order ([`import-order`]) +* Enforce a convention in module import order ([`order`]) [`imports-first`]: ./docs/rules/imports-first.md [`no-duplicates`]: ./docs/rules/no-duplicates.md [`no-namespace`]: ./docs/rules/no-namespace.md [`extensions`]: ./docs/rules/extensions.md -[`import-order`]: ./docs/rules/import-order.md +[`order`]: ./docs/rules/order.md ## Installation diff --git a/docs/rules/import-order.md b/docs/rules/order.md similarity index 94% rename from docs/rules/import-order.md rename to docs/rules/order.md index 3a3862825..e84971374 100644 --- a/docs/rules/import-order.md +++ b/docs/rules/order.md @@ -74,5 +74,5 @@ The default value is `["builtin", "external", "internal", "parent", "sibling", " You can set the options like this: ```js -"import-order/import-order": ["error", {"groups": ["index", "sibling", "parent", "internal", "external", "builtin"]}] +"import/order": ["error", {"groups": ["index", "sibling", "parent", "internal", "external", "builtin"]}] ``` diff --git a/src/index.js b/src/index.js index 38df7a0a7..50f6ebfbf 100644 --- a/src/index.js +++ b/src/index.js @@ -16,7 +16,7 @@ export const rules = { 'imports-first': require('./rules/imports-first'), 'no-extraneous-dependencies': require('./rules/no-extraneous-dependencies'), 'no-nodejs-modules': require('./rules/no-nodejs-modules'), - 'import-order': require('./rules/import-order'), + 'order': require('./rules/order'), // metadata-based 'no-deprecated': require('./rules/no-deprecated'), diff --git a/src/rules/import-order.js b/src/rules/order.js similarity index 100% rename from src/rules/import-order.js rename to src/rules/order.js diff --git a/tests/src/rules/import-order.js b/tests/src/rules/order.js similarity index 93% rename from tests/src/rules/import-order.js rename to tests/src/rules/order.js index f533e6c76..ce2e0cd55 100644 --- a/tests/src/rules/import-order.js +++ b/tests/src/rules/order.js @@ -3,9 +3,9 @@ import { test } from '../utils' import { RuleTester } from 'eslint' const ruleTester = new RuleTester() - , rule = require('rules/import-order') + , rule = require('rules/order') -ruleTester.run('import-order', rule, { +ruleTester.run('order', rule, { valid: [ // Default order using require test({ @@ -168,7 +168,7 @@ ruleTester.run('import-order', rule, { var fs = require('fs'); `, errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`fs` import should occur before import of `async`', }], }), @@ -179,7 +179,7 @@ ruleTester.run('import-order', rule, { import fs from 'fs'; `, errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`fs` import should occur before import of `async`', }], }), @@ -190,7 +190,7 @@ ruleTester.run('import-order', rule, { import fs from 'fs'; `, errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`fs` import should occur before import of `async`', }], }), @@ -201,7 +201,7 @@ ruleTester.run('import-order', rule, { var async = require('async'); `, errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`async` import should occur before import of `../parent`', }], }), @@ -212,7 +212,7 @@ ruleTester.run('import-order', rule, { var parent = require('../parent'); `, errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`../parent` import should occur before import of `./sibling`', }], }), @@ -223,7 +223,7 @@ ruleTester.run('import-order', rule, { var sibling = require('./sibling'); `, errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`./sibling` import should occur before import of `./`', }], }), @@ -235,10 +235,10 @@ ruleTester.run('import-order', rule, { var fs = require('fs'); `, errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`async` import should occur before import of `./sibling`', }, { - ruleId: 'import-order', + ruleId: 'order', message: '`fs` import should occur before import of `./sibling`', }], }), @@ -253,7 +253,7 @@ ruleTester.run('import-order', rule, { var bar = require('bar'); `, errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`./` import should occur after import of `bar`', }], }), @@ -265,7 +265,7 @@ ruleTester.run('import-order', rule, { `, options: [{groups: ['index', 'sibling', 'parent', 'external', 'builtin']}], errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`./` import should occur before import of `fs`', }], }), @@ -276,7 +276,7 @@ ruleTester.run('import-order', rule, { var fs = require('fs'); `, errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`fs` import should occur before import of `./foo`', }], }), @@ -287,7 +287,7 @@ ruleTester.run('import-order', rule, { var fs = require('fs'); `, errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`fs` import should occur before import of `./foo`', }], }), @@ -304,7 +304,7 @@ ruleTester.run('import-order', rule, { ['sibling', 'parent', 'external'], ]}], errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`path` import should occur before import of `./foo`', }], }), @@ -320,7 +320,7 @@ ruleTester.run('import-order', rule, { // missing 'builtin' ]}], errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: '`async` import should occur before import of `path`', }], }), @@ -336,7 +336,7 @@ ruleTester.run('import-order', rule, { ['sibling', 'parent', 'UNKNOWN', 'internal'], ]}], errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: 'Incorrect configuration of the rule: Unknown type `"UNKNOWN"`', }], }), @@ -351,7 +351,7 @@ ruleTester.run('import-order', rule, { ['sibling', 'parent', ['builtin'], 'internal'], ]}], errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: 'Incorrect configuration of the rule: Unknown type `["builtin"]`', }], }), @@ -366,7 +366,7 @@ ruleTester.run('import-order', rule, { ['sibling', 'parent', 2, 'internal'], ]}], errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: 'Incorrect configuration of the rule: Unknown type `2`', }], }), @@ -381,7 +381,7 @@ ruleTester.run('import-order', rule, { ['sibling', 'parent', 'parent', 'internal'], ]}], errors: [{ - ruleId: 'import-order', + ruleId: 'order', message: 'Incorrect configuration of the rule: `parent` is duplicated', }], }),