diff --git a/CHANGELOG.md b/CHANGELOG.md index bb937fbe92..094b61b0f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel ### Added - [`no-named-as-default-member`] to `warnings` canned config - add [`no-extraneous-dependencies`] rule ([#241], thanks [@jfmengels]) -- add [`import-order`] rule ([#247], thanks [@jfmengels]) +- add [`order`] rule ([#247], thanks [@jfmengels]) ## [1.5.0] - 2016-04-18 ### Added diff --git a/README.md b/README.md index 057f66ebc4..23448b44da 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,12 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a * Ensure all imports appear before other statements ([`imports-first`]) * Report repeated import of the same module in multiple places ([`no-duplicates`]) * Report namespace imports ([`no-namespace`]) -* 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 -[`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 3a38628254..e849713744 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 d423d3df36..b468774f3b 100644 --- a/src/index.js +++ b/src/index.js @@ -14,7 +14,7 @@ export const rules = { 'no-duplicates': require('./rules/no-duplicates'), 'imports-first': require('./rules/imports-first'), 'no-extraneous-dependencies': require('./rules/no-extraneous-dependencies'), - '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 f533e6c763..ce2e0cd556 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', }], }),