Skip to content

Commit 5acae06

Browse files
committed
Add whitespace between rules
I found these rules all smashed together with comments a little difficult to mentally parse, partly because it is ambiguous which line the comment applies to. Separating with some whitespace helps a lot here, and will also reduce the likelihood of merge conflicts in this code.
1 parent db73278 commit 5acae06

File tree

8 files changed

+273
-0
lines changed

8 files changed

+273
-0
lines changed

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

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,59 @@ module.exports = {
22
'rules': {
33
// enforces getter/setter pairs in objects
44
'accessor-pairs': 0,
5+
56
// enforces return statements in callbacks of array's methods
67
// http://eslint.org/docs/rules/array-callback-return
78
'array-callback-return': 2,
9+
810
// treat var statements as if they were block scoped
911
'block-scoped-var': 2,
12+
1013
// specify the maximum cyclomatic complexity allowed in a program
1114
'complexity': [0, 11],
15+
1216
// require return statements to either always or never specify values
1317
'consistent-return': 2,
18+
1419
// specify curly brace conventions for all control statements
1520
'curly': [2, 'multi-line'],
21+
1622
// require default case in switch statements
1723
'default-case': [2, { 'commentPattern': '^no default$' }],
24+
1825
// encourages use of dot notation whenever possible
1926
'dot-notation': [2, { 'allowKeywords': true }],
27+
2028
// enforces consistent newlines before or after dots
2129
'dot-location': 0,
30+
2231
// require the use of === and !==
2332
// http://eslint.org/docs/rules/eqeqeq
2433
'eqeqeq': [2, 'allow-null'],
34+
2535
// make sure for-in loops have an if statement
2636
'guard-for-in': 2,
37+
2738
// Blacklist certain identifiers to prevent them being used
2839
// http://eslint.org/docs/rules/id-blacklist
2940
'id-blacklist': 0,
41+
3042
// disallow the use of alert, confirm, and prompt
3143
'no-alert': 1,
44+
3245
// disallow use of arguments.caller or arguments.callee
3346
'no-caller': 2,
47+
3448
// disallow lexical declarations in case/default clauses
3549
// http://eslint.org/docs/rules/no-case-declarations.html
3650
'no-case-declarations': 2,
51+
3752
// disallow division operators explicitly at beginning of regular expression
3853
'no-div-regex': 0,
54+
3955
// disallow else after a return in an if
4056
'no-else-return': 2,
57+
4158
// disallow empty functions, except for standalone funcs/arrows
4259
// http://eslint.org/docs/rules/no-empty-function
4360
'no-empty-function': [2, {
@@ -47,38 +64,54 @@ module.exports = {
4764
'methods',
4865
]
4966
}],
67+
5068
// disallow empty destructuring patterns
5169
// http://eslint.org/docs/rules/no-empty-pattern
5270
'no-empty-pattern': 2,
71+
5372
// disallow Unnecessary Labels
5473
// http://eslint.org/docs/rules/no-extra-label
5574
'no-extra-label': 2,
75+
5676
// disallow comparisons to null without a type-checking operator
5777
'no-eq-null': 0,
78+
5879
// disallow use of eval()
5980
'no-eval': 2,
81+
6082
// disallow adding to native types
6183
'no-extend-native': 2,
84+
6285
// disallow unnecessary function binding
6386
'no-extra-bind': 2,
87+
6488
// disallow fallthrough of case statements
6589
'no-fallthrough': 2,
90+
6691
// disallow the use of leading or trailing decimal points in numeric literals
6792
'no-floating-decimal': 2,
93+
6894
// disallow the type conversions with shorter notations
6995
'no-implicit-coercion': 0,
96+
7097
// disallow use of eval()-like methods
7198
'no-implied-eval': 2,
99+
72100
// disallow this keywords outside of classes or class-like objects
73101
'no-invalid-this': 0,
102+
74103
// disallow usage of __iterator__ property
75104
'no-iterator': 2,
105+
76106
// disallow use of labels for anything other then loops and switches
77107
'no-labels': [2, { 'allowLoop': false, 'allowSwitch': false }],
108+
78109
// disallow unnecessary nested blocks
79110
'no-lone-blocks': 2,
111+
80112
// disallow creation of functions within loops
81113
'no-loop-func': 2,
114+
82115
// disallow magic numbers
83116
// http://eslint.org/docs/rules/no-magic-numbers
84117
'no-magic-numbers': [0, {
@@ -87,33 +120,46 @@ module.exports = {
87120
'enforceConst': true,
88121
'detectObjects': false,
89122
}],
123+
90124
// disallow use of multiple spaces
91125
'no-multi-spaces': 2,
126+
92127
// disallow use of multiline strings
93128
'no-multi-str': 2,
129+
94130
// disallow reassignments of native objects
95131
'no-native-reassign': 2,
132+
96133
// disallow use of new operator when not part of the assignment or comparison
97134
'no-new': 2,
135+
98136
// disallow use of new operator for Function object
99137
'no-new-func': 2,
138+
100139
// disallows creating new instances of String, Number, and Boolean
101140
'no-new-wrappers': 2,
141+
102142
// disallow use of (old style) octal literals
103143
'no-octal': 2,
144+
104145
// disallow use of octal escape sequences in string literals, such as
105146
// var foo = 'Copyright \251';
106147
'no-octal-escape': 2,
148+
107149
// disallow reassignment of function parameters
108150
// disallow parameter object manipulation
109151
// rule: http://eslint.org/docs/rules/no-param-reassign.html
110152
'no-param-reassign': [2, { 'props': true }],
153+
111154
// disallow use of process.env
112155
'no-process-env': 0,
156+
113157
// disallow usage of __proto__ property
114158
'no-proto': 2,
159+
115160
// disallow declaring the same variable more then once
116161
'no-redeclare': 2,
162+
117163
// disallow certain syntax forms
118164
// http://eslint.org/docs/rules/no-restricted-syntax
119165
'no-restricted-syntax': [
@@ -123,48 +169,67 @@ module.exports = {
123169
'LabeledStatement',
124170
'WithStatement',
125171
],
172+
126173
// disallow use of assignment in return statement
127174
'no-return-assign': 2,
175+
128176
// disallow use of `javascript:` urls.
129177
'no-script-url': 2,
178+
130179
// disallow comparisons where both sides are exactly the same
131180
'no-self-compare': 2,
181+
132182
// disallow use of comma operator
133183
'no-sequences': 2,
184+
134185
// restrict what can be thrown as an exception
135186
'no-throw-literal': 2,
187+
136188
// disallow unmodified conditions of loops
137189
// http://eslint.org/docs/rules/no-unmodified-loop-condition
138190
'no-unmodified-loop-condition': 0,
191+
139192
// disallow return/throw/break/continue inside finally blocks
140193
// http://eslint.org/docs/rules/no-unsafe-finally
141194
'no-unsafe-finally': 2,
195+
142196
// disallow usage of expressions in statement position
143197
'no-unused-expressions': 2,
198+
144199
// disallow unused labels
145200
// http://eslint.org/docs/rules/no-unused-labels
146201
'no-unused-labels': 2,
202+
147203
// disallow unnecessary .call() and .apply()
148204
'no-useless-call': 0,
205+
149206
// disallow useless string concatenation
150207
// http://eslint.org/docs/rules/no-useless-concat
151208
'no-useless-concat': 2,
209+
152210
// disallow unnecessary string escaping
153211
// http://eslint.org/docs/rules/no-useless-escape
154212
'no-useless-escape': 2,
213+
155214
// disallow use of void operator
156215
'no-void': 0,
216+
157217
// disallow usage of configurable warning terms in comments: e.g. todo
158218
'no-warning-comments': [0, { 'terms': ['todo', 'fixme', 'xxx'], 'location': 'start' }],
219+
159220
// disallow use of the with statement
160221
'no-with': 2,
222+
161223
// require use of the second argument for parseInt()
162224
'radix': 2,
225+
163226
// requires to declare all vars on top of their containing scope
164227
'vars-on-top': 2,
228+
165229
// require immediate function invocation to be wrapped in parentheses
166230
// http://eslint.org/docs/rules/wrap-iife.html
167231
'wrap-iife': [2, 'outside'],
232+
168233
// require or disallow Yoda conditions
169234
'yoda': 2
170235
}

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,87 @@ module.exports = {
22
'rules': {
33
// disallow assignment in conditional expressions
44
'no-cond-assign': [2, 'always'],
5+
56
// disallow use of console
67
'no-console': 1,
8+
79
// disallow use of constant expressions in conditions
810
'no-constant-condition': 1,
11+
912
// disallow control characters in regular expressions
1013
'no-control-regex': 2,
14+
1115
// disallow use of debugger
1216
'no-debugger': 2,
17+
1318
// disallow duplicate arguments in functions
1419
'no-dupe-args': 2,
20+
1521
// disallow duplicate keys when creating object literals
1622
'no-dupe-keys': 2,
23+
1724
// disallow a duplicate case label.
1825
'no-duplicate-case': 2,
26+
1927
// disallow the use of empty character classes in regular expressions
2028
'no-empty-character-class': 2,
29+
2130
// disallow empty statements
2231
'no-empty': 2,
32+
2333
// disallow assigning to the exception in a catch block
2434
'no-ex-assign': 2,
35+
2536
// disallow double-negation boolean casts in a boolean context
2637
'no-extra-boolean-cast': 0,
38+
2739
// disallow unnecessary parentheses
2840
// http://eslint.org/docs/rules/no-extra-parens
2941
'no-extra-parens': [0, 'all', {
3042
'conditionalAssign': true,
3143
'nestedBinaryExpressions': false,
3244
}],
45+
3346
// disallow unnecessary semicolons
3447
'no-extra-semi': 2,
48+
3549
// disallow overwriting functions written as function declarations
3650
'no-func-assign': 2,
51+
3752
// disallow function or variable declarations in nested blocks
3853
'no-inner-declarations': 2,
54+
3955
// disallow invalid regular expression strings in the RegExp constructor
4056
'no-invalid-regexp': 2,
57+
4158
// disallow irregular whitespace outside of strings and comments
4259
'no-irregular-whitespace': 2,
60+
4361
// disallow negation of the left operand of an in expression
4462
'no-negated-in-lhs': 2,
63+
4564
// disallow the use of object properties of the global object (Math and JSON) as functions
4665
'no-obj-calls': 2,
66+
4767
// disallow multiple spaces in a regular expression literal
4868
'no-regex-spaces': 2,
69+
4970
// disallow sparse arrays
5071
'no-sparse-arrays': 2,
72+
5173
// disallow unreachable statements after a return, throw, continue, or break statement
5274
'no-unreachable': 2,
75+
5376
// disallow comparisons with the value NaN
5477
'use-isnan': 2,
78+
5579
// ensure JSDoc comments are valid
5680
// http://eslint.org/docs/rules/valid-jsdoc
5781
'valid-jsdoc': 0,
82+
5883
// ensure that the results of typeof are compared against a valid string
5984
'valid-typeof': 2,
85+
6086
// Avoid code that looks like two expressions but is actually one
6187
'no-unexpected-multiline': 0
6288
}

0 commit comments

Comments
 (0)