Skip to content

Commit 3948eb6

Browse files
committed
[eslint config] [base] [breaking] re-order rules
1 parent 10f4dd8 commit 3948eb6

File tree

8 files changed

+79
-86
lines changed

8 files changed

+79
-86
lines changed

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: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ module.exports = {
2626
// http://eslint.org/docs/rules/arrow-spacing
2727
'arrow-spacing': [2, { 'before': true, 'after': true }],
2828

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

@@ -60,19 +57,13 @@ module.exports = {
6057
// http://eslint.org/docs/rules/no-new-symbol
6158
'no-new-symbol': 2,
6259

63-
// disallow specific globals
64-
'no-restricted-globals': 0,
65-
6660
// disallow specific imports
6761
// http://eslint.org/docs/rules/no-restricted-imports
6862
'no-restricted-imports': 0,
6963

7064
// disallow to use this/super before super() calling in constructors.
7165
'no-this-before-super': 0,
7266

73-
// require let or const instead of var
74-
'no-var': 2,
75-
7667
// disallow useless computed property keys
7768
// http://eslint.org/docs/rules/no-useless-computed-key
7869
'no-useless-computed-key': 2,
@@ -81,6 +72,9 @@ module.exports = {
8172
// http://eslint.org/docs/rules/no-useless-constructor
8273
'no-useless-constructor': 2,
8374

75+
// require let or const instead of var
76+
'no-var': 2,
77+
8478
// require method and property shorthand syntax for object literals
8579
// http://eslint.org/docs/rules/object-shorthand
8680
'object-shorthand': [2, 'always', {
@@ -100,16 +94,16 @@ module.exports = {
10094
'ignoreReadBeforeAssign': true,
10195
}],
10296

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

109100
// use rest parameters instead of arguments
110101
// http://eslint.org/docs/rules/prefer-rest-params
111102
'prefer-rest-params': 2,
112103

104+
// suggest using the spread operator instead of .apply()
105+
'prefer-spread': 0,
106+
113107
// suggest using template literals instead of string concatenation
114108
// http://eslint.org/docs/rules/prefer-template
115109
'prefer-template': 2,

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

Lines changed: 0 additions & 21 deletions
This file was deleted.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ module.exports = {
2626
// disallow string concatenation with __dirname and __filename
2727
'no-path-concat': 0,
2828

29+
// disallow use of process.env
30+
'no-process-env': 0,
31+
2932
// disallow process.exit()
3033
'no-process-exit': 0,
3134

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

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@ module.exports = {
3434
// enforces use of function declarations or expressions
3535
'func-style': 0,
3636

37+
// Blacklist certain identifiers to prevent them being used
38+
// http://eslint.org/docs/rules/id-blacklist
39+
'id-blacklist': 0,
40+
3741
// this option enforces minimum and maximum identifier lengths
3842
// (variable names, property names etc.)
3943
'id-length': 0,
4044

45+
// require identifiers to match the provided regular expression
46+
'id-match': 0,
47+
4148
// this option sets a specific tab width for your code
4249
// http://eslint.org/docs/rules/indent
4350
'indent': [2, 2, { 'SwitchCase': 1, 'VariableDeclarator': 1 }],
@@ -60,11 +67,14 @@ module.exports = {
6067
}
6168
}],
6269

70+
// disallow mixed 'LF' and 'CRLF' as linebreaks
71+
'linebreak-style': 0,
72+
6373
// enforces empty lines around comments
6474
'lines-around-comment': 0,
6575

66-
// disallow mixed 'LF' and 'CRLF' as linebreaks
67-
'linebreak-style': 0,
76+
// specify the maximum depth that blocks can be nested
77+
'max-depth': [0, 4],
6878

6979
// specify the maximum length of a line in your program
7080
// http://eslint.org/docs/rules/max-len
@@ -76,6 +86,12 @@ module.exports = {
7686
// specify the maximum depth callbacks can be nested
7787
'max-nested-callbacks': 0,
7888

89+
// limits the number of parameters that can be used in the function declaration.
90+
'max-params': [0, 3],
91+
92+
// specify the maximum number of statement allowed in a function
93+
'max-statements': [0, 10],
94+
7995
// restrict the number of statements per line
8096
// http://eslint.org/docs/rules/max-statements-per-line
8197
'max-statements-per-line': [0, { 'max': 1 }],
@@ -100,6 +116,9 @@ module.exports = {
100116
// disallow use of the Array constructor
101117
'no-array-constructor': 2,
102118

119+
// disallow use of bitwise operators
120+
'no-bitwise': 0,
121+
103122
// disallow use of the continue statement
104123
'no-continue': 0,
105124

@@ -125,6 +144,19 @@ module.exports = {
125144
// disallow use of the Object constructor
126145
'no-new-object': 2,
127146

147+
// disallow use of unary operators, ++ and --
148+
'no-plusplus': 0,
149+
150+
// disallow certain syntax forms
151+
// http://eslint.org/docs/rules/no-restricted-syntax
152+
'no-restricted-syntax': [
153+
2,
154+
'DebuggerStatement',
155+
'ForInStatement',
156+
'LabeledStatement',
157+
'WithStatement',
158+
],
159+
128160
// disallow space between function identifier and application
129161
'no-spaced-func': 2,
130162

@@ -179,19 +211,16 @@ module.exports = {
179211
// specify whether double or single quotes should be used
180212
'quotes': [2, 'single', 'avoid-escape'],
181213

182-
// require identifiers to match the provided regular expression
183-
'id-match': 0,
184-
185214
// do not require jsdoc
186215
// http://eslint.org/docs/rules/require-jsdoc
187216
'require-jsdoc': 0,
188217

189-
// enforce spacing before and after semicolons
190-
'semi-spacing': [2, { 'before': false, 'after': true }],
191-
192218
// require or disallow use of semicolons instead of ASI
193219
'semi': [2, 'always'],
194220

221+
// enforce spacing before and after semicolons
222+
'semi-spacing': [2, { 'before': false, 'after': true }],
223+
195224
// sort variables within the same declaration block
196225
'sort-vars': 0,
197226

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,24 @@ module.exports = {
99
// disallow deletion of variables
1010
'no-delete-var': 2,
1111

12-
// disallow var and named functions in global scope
13-
// http://eslint.org/docs/rules/no-implicit-globals
14-
'no-implicit-globals': 0,
15-
1612
// disallow labels that share a name with a variable
1713
'no-label-var': 0,
1814

19-
// disallow self assignment
20-
// http://eslint.org/docs/rules/no-self-assign
21-
'no-self-assign': 2,
22-
23-
// disallow shadowing of names such as arguments
24-
'no-shadow-restricted-names': 2,
15+
// disallow specific globals
16+
'no-restricted-globals': 0,
2517

2618
// disallow declaration of variables already declared in the outer scope
2719
'no-shadow': 2,
2820

29-
// disallow use of undefined when initializing variables
30-
'no-undef-init': 0,
21+
// disallow shadowing of names such as arguments
22+
'no-shadow-restricted-names': 2,
3123

3224
// disallow use of undeclared variables unless mentioned in a /*global */ block
3325
'no-undef': 2,
3426

27+
// disallow use of undefined when initializing variables
28+
'no-undef-init': 0,
29+
3530
// disallow use of undefined variable
3631
'no-undefined': 0,
3732

0 commit comments

Comments
 (0)