Skip to content

Commit e32079d

Browse files
committed
Merge pull request airbnb#881 from akai/re-order-rules
[eslint config] [base] [breaking] Rearrange rules/rule files.
2 parents 10f4dd8 + 34ccf90 commit e32079d

File tree

10 files changed

+206
-208
lines changed

10 files changed

+206
-208
lines changed

packages/eslint-config-airbnb-base/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
extends: [
33
'./legacy',
44
'./rules/es6',
5+
'./rules/imports',
56
].map(require.resolve),
67
parserOptions: {
78
ecmaVersion: 7,

packages/eslint-config-airbnb-base/legacy.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module.exports = {
22
extends: [
33
'./rules/best-practices',
44
'./rules/errors',
5-
'./rules/legacy',
65
'./rules/node',
76
'./rules/style',
87
'./rules/variables'

packages/eslint-config-airbnb-base/rules/best-practices.js

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ module.exports = {
3535
// make sure for-in loops have an if statement
3636
'guard-for-in': 2,
3737

38-
// Blacklist certain identifiers to prevent them being used
39-
// http://eslint.org/docs/rules/id-blacklist
40-
'id-blacklist': 0,
41-
4238
// disallow the use of alert, confirm, and prompt
4339
'no-alert': 1,
4440

@@ -69,10 +65,6 @@ module.exports = {
6965
// http://eslint.org/docs/rules/no-empty-pattern
7066
'no-empty-pattern': 2,
7167

72-
// disallow Unnecessary Labels
73-
// http://eslint.org/docs/rules/no-extra-label
74-
'no-extra-label': 2,
75-
7668
// disallow comparisons to null without a type-checking operator
7769
'no-eq-null': 0,
7870

@@ -85,6 +77,10 @@ module.exports = {
8577
// disallow unnecessary function binding
8678
'no-extra-bind': 2,
8779

80+
// disallow Unnecessary Labels
81+
// http://eslint.org/docs/rules/no-extra-label
82+
'no-extra-label': 2,
83+
8884
// disallow fallthrough of case statements
8985
'no-fallthrough': 2,
9086

@@ -94,6 +90,10 @@ module.exports = {
9490
// disallow the type conversions with shorter notations
9591
'no-implicit-coercion': 0,
9692

93+
// disallow var and named functions in global scope
94+
// http://eslint.org/docs/rules/no-implicit-globals
95+
'no-implicit-globals': 0,
96+
9797
// disallow use of eval()-like methods
9898
'no-implied-eval': 2,
9999

@@ -151,31 +151,22 @@ module.exports = {
151151
// rule: http://eslint.org/docs/rules/no-param-reassign.html
152152
'no-param-reassign': [2, { 'props': true }],
153153

154-
// disallow use of process.env
155-
'no-process-env': 0,
156-
157154
// disallow usage of __proto__ property
158155
'no-proto': 2,
159156

160157
// disallow declaring the same variable more then once
161158
'no-redeclare': 2,
162159

163-
// disallow certain syntax forms
164-
// http://eslint.org/docs/rules/no-restricted-syntax
165-
'no-restricted-syntax': [
166-
2,
167-
'DebuggerStatement',
168-
'ForInStatement',
169-
'LabeledStatement',
170-
'WithStatement',
171-
],
172-
173160
// disallow use of assignment in return statement
174161
'no-return-assign': 2,
175162

176163
// disallow use of `javascript:` urls.
177164
'no-script-url': 2,
178165

166+
// disallow self assignment
167+
// http://eslint.org/docs/rules/no-self-assign
168+
'no-self-assign': 2,
169+
179170
// disallow comparisons where both sides are exactly the same
180171
'no-self-compare': 2,
181172

@@ -189,10 +180,6 @@ module.exports = {
189180
// http://eslint.org/docs/rules/no-unmodified-loop-condition
190181
'no-unmodified-loop-condition': 0,
191182

192-
// disallow return/throw/break/continue inside finally blocks
193-
// http://eslint.org/docs/rules/no-unsafe-finally
194-
'no-unsafe-finally': 2,
195-
196183
// disallow usage of expressions in statement position
197184
'no-unused-expressions': 2,
198185

packages/eslint-config-airbnb-base/rules/errors.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module.exports = {
22
'rules': {
3+
// require trailing commas in multiline object literals
4+
'comma-dangle': [2, 'always-multiline'],
5+
36
// disallow assignment in conditional expressions
47
'no-cond-assign': [2, 'always'],
58

@@ -24,12 +27,12 @@ module.exports = {
2427
// disallow a duplicate case label.
2528
'no-duplicate-case': 2,
2629

27-
// disallow the use of empty character classes in regular expressions
28-
'no-empty-character-class': 2,
29-
3030
// disallow empty statements
3131
'no-empty': 2,
3232

33+
// disallow the use of empty character classes in regular expressions
34+
'no-empty-character-class': 2,
35+
3336
// disallow assigning to the exception in a catch block
3437
'no-ex-assign': 2,
3538

@@ -71,9 +74,16 @@ module.exports = {
7174
// disallow sparse arrays
7275
'no-sparse-arrays': 2,
7376

77+
// Avoid code that looks like two expressions but is actually one
78+
'no-unexpected-multiline': 0,
79+
7480
// disallow unreachable statements after a return, throw, continue, or break statement
7581
'no-unreachable': 2,
7682

83+
// disallow return/throw/break/continue inside finally blocks
84+
// http://eslint.org/docs/rules/no-unsafe-finally
85+
'no-unsafe-finally': 2,
86+
7787
// disallow comparisons with the value NaN
7888
'use-isnan': 2,
7989

@@ -82,9 +92,6 @@ module.exports = {
8292
'valid-jsdoc': 0,
8393

8494
// ensure that the results of typeof are compared against a valid string
85-
'valid-typeof': 2,
86-
87-
// Avoid code that looks like two expressions but is actually one
88-
'no-unexpected-multiline': 0
95+
'valid-typeof': 2
8996
}
9097
};

packages/eslint-config-airbnb-base/rules/es6.js

Lines changed: 7 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ module.exports = {
1010
'objectLiteralDuplicateProperties': false
1111
}
1212
},
13-
'plugins': [
14-
'import'
15-
],
1613

1714
'rules': {
1815
// enforces no braces where they can be omitted
@@ -26,9 +23,6 @@ module.exports = {
2623
// http://eslint.org/docs/rules/arrow-spacing
2724
'arrow-spacing': [2, { 'before': true, 'after': true }],
2825

29-
// require trailing commas in multiline object literals
30-
'comma-dangle': [2, 'always-multiline'],
31-
3226
// verify super() callings in constructors
3327
'constructor-super': 0,
3428

@@ -60,19 +54,13 @@ module.exports = {
6054
// http://eslint.org/docs/rules/no-new-symbol
6155
'no-new-symbol': 2,
6256

63-
// disallow specific globals
64-
'no-restricted-globals': 0,
65-
6657
// disallow specific imports
6758
// http://eslint.org/docs/rules/no-restricted-imports
6859
'no-restricted-imports': 0,
6960

7061
// disallow to use this/super before super() calling in constructors.
7162
'no-this-before-super': 0,
7263

73-
// require let or const instead of var
74-
'no-var': 2,
75-
7664
// disallow useless computed property keys
7765
// http://eslint.org/docs/rules/no-useless-computed-key
7866
'no-useless-computed-key': 2,
@@ -81,6 +69,9 @@ module.exports = {
8169
// http://eslint.org/docs/rules/no-useless-constructor
8270
'no-useless-constructor': 2,
8371

72+
// require let or const instead of var
73+
'no-var': 2,
74+
8475
// require method and property shorthand syntax for object literals
8576
// http://eslint.org/docs/rules/object-shorthand
8677
'object-shorthand': [2, 'always', {
@@ -100,16 +91,16 @@ module.exports = {
10091
'ignoreReadBeforeAssign': true,
10192
}],
10293

103-
// suggest using the spread operator instead of .apply()
104-
'prefer-spread': 0,
105-
10694
// suggest using Reflect methods where applicable
10795
'prefer-reflect': 0,
10896

10997
// use rest parameters instead of arguments
11098
// http://eslint.org/docs/rules/prefer-rest-params
11199
'prefer-rest-params': 2,
112100

101+
// suggest using the spread operator instead of .apply()
102+
'prefer-spread': 0,
103+
113104
// suggest using template literals instead of string concatenation
114105
// http://eslint.org/docs/rules/prefer-template
115106
'prefer-template': 2,
@@ -127,108 +118,6 @@ module.exports = {
127118

128119
// enforce spacing around the * in yield* expressions
129120
// http://eslint.org/docs/rules/yield-star-spacing
130-
'yield-star-spacing': [2, 'after'],
131-
132-
// disallow invalid exports, e.g. multiple defaults
133-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md
134-
'import/export': 2,
135-
136-
// ensure default import coupled with default export
137-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
138-
'import/default': 0,
139-
140-
// Ensure consistent use of file extension within the import path
141-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
142-
// TODO: enable
143-
'import/extensions': [0, 'never'],
144-
145-
// ensure named imports coupled with named exports
146-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
147-
'import/named': 0,
148-
149-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md
150-
'import/namespace': 0,
151-
152-
// Forbid the use of extraneous packages
153-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
154-
// TODO: enable
155-
'import/no-extraneous-dependencies': [0, {
156-
'devDependencies': false,
157-
'optionalDependencies': false,
158-
}],
159-
160-
// ensure imports point to files/modules that can be resolved
161-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
162-
'import/no-unresolved': [2, { 'commonjs': true }],
163-
164-
// do not allow a default import name to match a named export
165-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
166-
// TODO: enable
167-
'import/no-named-as-default': 0,
168-
169-
// disallow require()
170-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
171-
'import/no-commonjs': 0,
172-
173-
// disallow AMD require/define
174-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md
175-
'import/no-amd': 2,
176-
177-
// disallow non-import statements appearing before import statements
178-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md
179-
// TODO: enable?
180-
'import/imports-first': [0, 'absolute-first'],
181-
182-
// disallow duplicate imports
183-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
184-
'import/no-duplicates': 2,
185-
186-
// disallow use of jsdoc-marked-deprecated imports
187-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
188-
'import/no-deprecated': 0,
189-
190-
// disallow namespace imports
191-
// TODO: enable?
192-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
193-
'import/no-namespace': 0,
194-
195-
// warn on accessing default export property names that are also named exports
196-
// TODO: enable?
197-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
198-
'import/no-named-as-default-member': 0,
199-
200-
// No Node.js builtin modules
201-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
202-
'import/no-nodejs-modules': 0,
203-
204-
// Enforce a convention in module import order
205-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
206-
// TODO: enable?
207-
'import/order': [0, {
208-
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
209-
'newlines-between': 'never',
210-
}],
211-
212-
// Require modules with a single export to use a default export
213-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
214-
// TODO: enable
215-
'import/prefer-default-export': 0,
216-
217-
// Require a newline after the last import/require in a group
218-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
219-
// TODO: enable
220-
'import/newline-after-import': 0,
221-
222-
// Forbid mutable exports
223-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
224-
'import/no-mutable-exports': 2,
225-
},
226-
227-
'settings': {
228-
'import/resolver': {
229-
'node': {
230-
'extensions': ['.js', '.json']
231-
}
232-
}
121+
'yield-star-spacing': [2, 'after']
233122
}
234123
};

0 commit comments

Comments
 (0)