eslint-config-gristow 2.0.20 → 3.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,319 @@
1
+ /**
2
+ * Airbnb Best Practices Rules
3
+ * Extracted from eslint-config-airbnb-base for ESLint 9 compatibility
4
+ * @see https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/best-practices.js
5
+ */
6
+ export default {
7
+ // Enforces getter/setter pairs in objects
8
+ 'accessor-pairs': 'off',
9
+
10
+ // Enforces return statements in callbacks of array's methods
11
+ 'array-callback-return': ['error', { allowImplicit: true, checkForEach: false }],
12
+
13
+ // Treat var statements as if they were block scoped
14
+ 'block-scoped-var': 'error',
15
+
16
+ // Specify the maximum cyclomatic complexity allowed in a program
17
+ 'complexity': ['off', 20],
18
+
19
+ // Enforce that class methods use "this"
20
+ 'class-methods-use-this': ['error', { exceptMethods: [] }],
21
+
22
+ // Require return statements to either always or never specify values
23
+ 'consistent-return': 'error',
24
+
25
+ // Specify curly brace conventions for all control statements
26
+ 'curly': ['error', 'multi-line'],
27
+
28
+ // Require default case in switch statements
29
+ 'default-case': ['error', { commentPattern: '^no default$' }],
30
+
31
+ // Enforce default clauses in switch statements to be last
32
+ 'default-case-last': 'error',
33
+
34
+ // Enforce default parameters to be last
35
+ 'default-param-last': 'error',
36
+
37
+ // Encourages use of dot notation whenever possible
38
+ 'dot-notation': ['error', { allowKeywords: true }],
39
+
40
+ // Require the use of === and !==
41
+ 'eqeqeq': ['error', 'always', { null: 'ignore' }],
42
+
43
+ // Require grouped accessor pairs in object literals and classes
44
+ 'grouped-accessor-pairs': 'error',
45
+
46
+ // Make sure for-in loops have an if statement
47
+ 'guard-for-in': 'error',
48
+
49
+ // Enforce a maximum number of classes per file
50
+ 'max-classes-per-file': ['error', 1],
51
+
52
+ // Disallow the use of alert, confirm, and prompt
53
+ 'no-alert': 'warn',
54
+
55
+ // Disallow use of arguments.caller or arguments.callee
56
+ 'no-caller': 'error',
57
+
58
+ // Disallow lexical declarations in case/default clauses
59
+ 'no-case-declarations': 'error',
60
+
61
+ // Disallow returning value in constructor
62
+ 'no-constructor-return': 'error',
63
+
64
+ // Disallow division operators explicitly at beginning of regular expression
65
+ 'no-div-regex': 'off',
66
+
67
+ // Disallow else after a return in an if
68
+ 'no-else-return': ['error', { allowElseIf: false }],
69
+
70
+ // Disallow empty functions, except for standalone funcs/arrows
71
+ 'no-empty-function': ['error', {
72
+ allow: [
73
+ 'arrowFunctions',
74
+ 'functions',
75
+ 'methods',
76
+ ],
77
+ }],
78
+
79
+ // Disallow empty destructuring patterns
80
+ 'no-empty-pattern': 'error',
81
+
82
+ // Disallow empty static blocks
83
+ 'no-empty-static-block': 'error',
84
+
85
+ // Disallow comparisons to null without a type-checking operator
86
+ 'no-eq-null': 'off',
87
+
88
+ // Disallow use of eval()
89
+ 'no-eval': 'error',
90
+
91
+ // Disallow adding to native types
92
+ 'no-extend-native': 'error',
93
+
94
+ // Disallow unnecessary function binding
95
+ 'no-extra-bind': 'error',
96
+
97
+ // Disallow Unnecessary Labels
98
+ 'no-extra-label': 'error',
99
+
100
+ // Disallow fallthrough of case statements
101
+ 'no-fallthrough': 'error',
102
+
103
+ // Disallow reassignments of native objects or read-only globals
104
+ 'no-global-assign': ['error', { exceptions: [] }],
105
+
106
+ // Disallow implicit type conversions
107
+ 'no-implicit-coercion': ['off', {
108
+ boolean: false,
109
+ number: true,
110
+ string: true,
111
+ allow: [],
112
+ }],
113
+
114
+ // Disallow var and named functions in global scope
115
+ 'no-implicit-globals': 'off',
116
+
117
+ // Disallow use of eval()-like methods
118
+ 'no-implied-eval': 'error',
119
+
120
+ // Disallow this keywords outside of classes or class-like objects
121
+ 'no-invalid-this': 'off',
122
+
123
+ // Disallow usage of __iterator__ property
124
+ 'no-iterator': 'error',
125
+
126
+ // Disallow use of labels for anything other than loops and switches
127
+ 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
128
+
129
+ // Disallow unnecessary nested blocks
130
+ 'no-lone-blocks': 'error',
131
+
132
+ // Disallow creation of functions within loops
133
+ 'no-loop-func': 'error',
134
+
135
+ // Disallow magic numbers
136
+ 'no-magic-numbers': ['off', {
137
+ ignore: [],
138
+ ignoreArrayIndexes: true,
139
+ enforceConst: true,
140
+ detectObjects: false,
141
+ }],
142
+
143
+ // Disallow use of multiple spaces
144
+ 'no-multi-spaces': ['error', { ignoreEOLComments: false }],
145
+
146
+ // Disallow use of multiline strings
147
+ 'no-multi-str': 'error',
148
+
149
+ // Disallow use of new operator when not part of the assignment or comparison
150
+ 'no-new': 'error',
151
+
152
+ // Disallow use of new operator for Function object
153
+ 'no-new-func': 'error',
154
+
155
+ // Disallows creating new instances of String, Number, and Boolean
156
+ 'no-new-wrappers': 'error',
157
+
158
+ // Disallow \8 and \9 escape sequences in string literals
159
+ 'no-nonoctal-decimal-escape': 'error',
160
+
161
+ // Disallow calls to the Object constructor without an argument
162
+ 'no-object-constructor': 'error',
163
+
164
+ // Disallow use of (old style) octal literals
165
+ 'no-octal': 'error',
166
+
167
+ // Disallow use of octal escape sequences in string literals
168
+ 'no-octal-escape': 'error',
169
+
170
+ // Disallow reassignment of function parameters
171
+ 'no-param-reassign': ['error', {
172
+ props: true,
173
+ ignorePropertyModificationsFor: [
174
+ 'acc', // for reduce accumulators
175
+ 'accumulator', // for reduce accumulators
176
+ 'e', // for e.returnvalue
177
+ 'ctx', // for Koa routing
178
+ 'context', // for Koa routing
179
+ 'req', // for Express requests
180
+ 'request', // for Express requests
181
+ 'res', // for Express responses
182
+ 'response', // for Express responses
183
+ '$scope', // for Angular 1 scopes
184
+ 'staticContext', // for ReactRouter context
185
+ ],
186
+ }],
187
+
188
+ // Disallow usage of __proto__ property
189
+ 'no-proto': 'error',
190
+
191
+ // Disallow declaring the same variable more than once
192
+ 'no-redeclare': 'error',
193
+
194
+ // Disallow certain object properties
195
+ 'no-restricted-properties': ['error', {
196
+ object: 'arguments',
197
+ property: 'callee',
198
+ message: 'arguments.callee is deprecated',
199
+ }, {
200
+ object: 'global',
201
+ property: 'isFinite',
202
+ message: 'Please use Number.isFinite instead',
203
+ }, {
204
+ object: 'self',
205
+ property: 'isFinite',
206
+ message: 'Please use Number.isFinite instead',
207
+ }, {
208
+ object: 'window',
209
+ property: 'isFinite',
210
+ message: 'Please use Number.isFinite instead',
211
+ }, {
212
+ object: 'global',
213
+ property: 'isNaN',
214
+ message: 'Please use Number.isNaN instead',
215
+ }, {
216
+ object: 'self',
217
+ property: 'isNaN',
218
+ message: 'Please use Number.isNaN instead',
219
+ }, {
220
+ object: 'window',
221
+ property: 'isNaN',
222
+ message: 'Please use Number.isNaN instead',
223
+ }, {
224
+ property: '__defineGetter__',
225
+ message: 'Please use Object.defineProperty instead.',
226
+ }, {
227
+ property: '__defineSetter__',
228
+ message: 'Please use Object.defineProperty instead.',
229
+ }, {
230
+ object: 'Math',
231
+ property: 'pow',
232
+ message: 'Use the exponentiation operator (**) instead.',
233
+ }],
234
+
235
+ // Disallow use of assignment in return statement
236
+ 'no-return-assign': ['error', 'always'],
237
+
238
+ // Disallow use of `javascript:` urls.
239
+ 'no-script-url': 'error',
240
+
241
+ // Disallow self assignment
242
+ 'no-self-assign': ['error', { props: true }],
243
+
244
+ // Disallow comparisons where both sides are exactly the same
245
+ 'no-self-compare': 'error',
246
+
247
+ // Disallow use of comma operator
248
+ 'no-sequences': 'error',
249
+
250
+ // Restrict what can be thrown as an exception
251
+ 'no-throw-literal': 'error',
252
+
253
+ // Disallow unmodified conditions of loops
254
+ 'no-unmodified-loop-condition': 'off',
255
+
256
+ // Disallow usage of expressions in statement position
257
+ 'no-unused-expressions': ['error', {
258
+ allowShortCircuit: false,
259
+ allowTernary: false,
260
+ allowTaggedTemplates: false,
261
+ }],
262
+
263
+ // Disallow unused labels
264
+ 'no-unused-labels': 'error',
265
+
266
+ // Disallow unnecessary .call() and .apply()
267
+ 'no-useless-call': 'off',
268
+
269
+ // Disallow unnecessary catch clauses
270
+ 'no-useless-catch': 'error',
271
+
272
+ // Disallow useless string concatenation
273
+ 'no-useless-concat': 'error',
274
+
275
+ // Disallow unnecessary string escaping
276
+ 'no-useless-escape': 'error',
277
+
278
+ // Disallow redundant return; keywords
279
+ 'no-useless-return': 'error',
280
+
281
+ // Disallow use of void operator
282
+ 'no-void': 'error',
283
+
284
+ // Disallow usage of configurable warning terms in comments: e.g. todo
285
+ 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
286
+
287
+ // Disallow use of the with statement
288
+ 'no-with': 'error',
289
+
290
+ // Require using Error objects as Promise rejection reasons
291
+ 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
292
+
293
+ // Suggest using named capture group in regular expression
294
+ 'prefer-named-capture-group': 'off',
295
+
296
+ // Prefer Object.hasOwn() over Object.prototype.hasOwnProperty.call()
297
+ 'prefer-object-has-own': 'error',
298
+
299
+ // Disallow use of the RegExp constructor in favor of regular expression literals
300
+ 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
301
+
302
+ // Require use of the second argument for parseInt()
303
+ 'radix': 'error',
304
+
305
+ // Require `await` in `async function`
306
+ 'require-await': 'off',
307
+
308
+ // Enforce the use of u or v flag on RegExp
309
+ 'require-unicode-regexp': 'off',
310
+
311
+ // Requires to declare all vars on top of their containing scope
312
+ 'vars-on-top': 'error',
313
+
314
+ // Require immediate function invocation to be wrapped in parentheses
315
+ 'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }],
316
+
317
+ // Require or disallow Yoda conditions
318
+ 'yoda': 'error',
319
+ };
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Airbnb Errors Rules
3
+ * Extracted from eslint-config-airbnb-base for ESLint 9 compatibility
4
+ * @see https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/errors.js
5
+ */
6
+ export default {
7
+ // Enforce "for" loop update clause moving the counter in the right direction
8
+ 'for-direction': 'error',
9
+
10
+ // Enforces that a return statement is present in property getters
11
+ 'getter-return': ['error', { allowImplicit: true }],
12
+
13
+ // Disallow using an async function as a Promise executor
14
+ 'no-async-promise-executor': 'error',
15
+
16
+ // Disallow await inside of loops
17
+ 'no-await-in-loop': 'error',
18
+
19
+ // Disallow comparisons to negative zero
20
+ 'no-compare-neg-zero': 'error',
21
+
22
+ // Disallow assignment in conditional expressions
23
+ 'no-cond-assign': ['error', 'always'],
24
+
25
+ // Disallow use of console
26
+ 'no-console': 'warn',
27
+
28
+ // Disallow expressions where the operation doesn't affect the value
29
+ 'no-constant-binary-expression': 'error',
30
+
31
+ // Disallow use of constant expressions in conditions
32
+ 'no-constant-condition': 'warn',
33
+
34
+ // Disallow control characters in regular expressions
35
+ 'no-control-regex': 'error',
36
+
37
+ // Disallow use of debugger
38
+ 'no-debugger': 'error',
39
+
40
+ // Disallow duplicate arguments in functions
41
+ 'no-dupe-args': 'error',
42
+
43
+ // Disallow duplicate conditions in if-else-if chains
44
+ 'no-dupe-else-if': 'error',
45
+
46
+ // Disallow duplicate keys when creating object literals
47
+ 'no-dupe-keys': 'error',
48
+
49
+ // Disallow a duplicate case label
50
+ 'no-duplicate-case': 'error',
51
+
52
+ // Disallow empty statements
53
+ 'no-empty': 'error',
54
+
55
+ // Disallow the use of empty character classes in regular expressions
56
+ 'no-empty-character-class': 'error',
57
+
58
+ // Disallow assigning to the exception in a catch block
59
+ 'no-ex-assign': 'error',
60
+
61
+ // Disallow double-negation boolean casts in a boolean context
62
+ 'no-extra-boolean-cast': 'error',
63
+
64
+ // Disallow overwriting functions written as function declarations
65
+ 'no-func-assign': 'error',
66
+
67
+ // Disallow assigning to imported bindings
68
+ 'no-import-assign': 'error',
69
+
70
+ // Disallow function or variable declarations in nested blocks
71
+ 'no-inner-declarations': 'error',
72
+
73
+ // Disallow invalid regular expression strings in the RegExp constructor
74
+ 'no-invalid-regexp': 'error',
75
+
76
+ // Disallow irregular whitespace outside of strings and comments
77
+ 'no-irregular-whitespace': 'error',
78
+
79
+ // Disallow Number Literals That Lose Precision
80
+ 'no-loss-of-precision': 'error',
81
+
82
+ // Disallow characters which are made with multiple code points in character class syntax
83
+ 'no-misleading-character-class': 'error',
84
+
85
+ // Disallow the use of object properties of the global object (Math and JSON) as functions
86
+ 'no-obj-calls': 'error',
87
+
88
+ // Disallow new operators with global non-constructor functions
89
+ 'no-new-native-nonconstructor': 'error',
90
+
91
+ // Disallow returning values from Promise executor functions
92
+ 'no-promise-executor-return': ['error', { allowVoid: true }],
93
+
94
+ // Disallow use of Object.prototypes builtins directly
95
+ 'no-prototype-builtins': 'error',
96
+
97
+ // Disallow multiple spaces in a regular expression literal
98
+ 'no-regex-spaces': 'error',
99
+
100
+ // Disallow returning values from setters
101
+ 'no-setter-return': 'error',
102
+
103
+ // Disallow sparse arrays
104
+ 'no-sparse-arrays': 'error',
105
+
106
+ // Disallow template literal placeholder syntax in regular strings
107
+ 'no-template-curly-in-string': 'error',
108
+
109
+ // Avoid code that looks like two expressions but is actually one
110
+ 'no-unexpected-multiline': 'error',
111
+
112
+ // Disallow unreachable statements after a return, throw, continue, or break statement
113
+ 'no-unreachable': 'error',
114
+
115
+ // Disallow loops with a body that allows only one iteration
116
+ 'no-unreachable-loop': ['error', { ignore: [] }],
117
+
118
+ // Disallow return/throw/break/continue inside finally blocks
119
+ 'no-unsafe-finally': 'error',
120
+
121
+ // Disallow negating the left operand of relational operators
122
+ 'no-unsafe-negation': 'error',
123
+
124
+ // Disallow use of optional chaining in contexts where the undefined value is not allowed
125
+ 'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
126
+
127
+ // Disallow Unused Private Class Members
128
+ 'no-unused-private-class-members': 'error',
129
+
130
+ // Disallow useless backreferences in regular expressions
131
+ 'no-useless-backreference': 'error',
132
+
133
+ // Disallow assignments that can lead to race conditions due to usage of await or yield
134
+ 'require-atomic-updates': 'off',
135
+
136
+ // Disallow comparisons with the value NaN
137
+ 'use-isnan': 'error',
138
+
139
+ // Ensure that the results of typeof are compared against a valid string
140
+ 'valid-typeof': ['error', { requireStringLiterals: true }],
141
+ };
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Airbnb ES6 Rules
3
+ * Extracted from eslint-config-airbnb-base for ESLint 9 compatibility
4
+ * @see https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/es6.js
5
+ */
6
+ export default {
7
+ // Enforces no braces where they can be omitted
8
+ 'arrow-body-style': ['error', 'as-needed', { requireReturnForObjectLiteral: false }],
9
+
10
+ // Verify super() callings in constructors
11
+ 'constructor-super': 'error',
12
+
13
+ // Disallow modifying variables of class declarations
14
+ 'no-class-assign': 'error',
15
+
16
+ // Disallow arrow functions where they could be confused with comparisons
17
+ 'no-confusing-arrow': ['error', { allowParens: true, onlyOneSimpleParam: false }],
18
+
19
+ // Disallow modifying variables that are declared using const
20
+ 'no-const-assign': 'error',
21
+
22
+ // Disallow duplicate class members
23
+ 'no-dupe-class-members': 'error',
24
+
25
+ // Disallow importing from the same path more than once
26
+ // (replaced by import/no-duplicates)
27
+ 'no-duplicate-imports': 'off',
28
+
29
+ // Disallow symbol constructor
30
+ 'no-new-symbol': 'error',
31
+
32
+ // Disallow specified names in exports
33
+ 'no-restricted-exports': ['error', {
34
+ restrictedNamedExports: [
35
+ 'default', // use `export default` to provide a default export
36
+ 'then', // this will cause tons of confusion when your module is dynamically `import()`ed
37
+ ],
38
+ }],
39
+
40
+ // Disallow specific imports
41
+ 'no-restricted-imports': ['off', { paths: [], patterns: [] }],
42
+
43
+ // Disallow to use this/super before super() calling in constructors
44
+ 'no-this-before-super': 'error',
45
+
46
+ // Disallow useless computed property keys
47
+ 'no-useless-computed-key': 'error',
48
+
49
+ // Disallow unnecessary constructor
50
+ 'no-useless-constructor': 'error',
51
+
52
+ // Disallow renaming import, export, and destructured assignments to the same name
53
+ 'no-useless-rename': ['error', {
54
+ ignoreDestructuring: false,
55
+ ignoreImport: false,
56
+ ignoreExport: false,
57
+ }],
58
+
59
+ // Require let or const instead of var
60
+ 'no-var': 'error',
61
+
62
+ // Require method and property shorthand syntax for object literals
63
+ 'object-shorthand': ['error', 'always', {
64
+ ignoreConstructors: false,
65
+ avoidQuotes: true,
66
+ }],
67
+
68
+ // Suggest using arrow functions as callbacks
69
+ 'prefer-arrow-callback': ['error', {
70
+ allowNamedFunctions: false,
71
+ allowUnboundThis: true,
72
+ }],
73
+
74
+ // Suggest using of const declaration for variables that are never modified after declared
75
+ 'prefer-const': ['error', {
76
+ destructuring: 'any',
77
+ ignoreReadBeforeAssign: true,
78
+ }],
79
+
80
+ // Prefer destructuring from arrays and objects
81
+ 'prefer-destructuring': ['error', {
82
+ VariableDeclarator: {
83
+ array: false,
84
+ object: true,
85
+ },
86
+ AssignmentExpression: {
87
+ array: true,
88
+ object: false,
89
+ },
90
+ }, {
91
+ enforceForRenamedProperties: false,
92
+ }],
93
+
94
+ // Disallow parseInt() in favor of binary, octal, and hexadecimal literals
95
+ 'prefer-numeric-literals': 'error',
96
+
97
+ // Suggest using the rest parameters instead of arguments
98
+ 'prefer-rest-params': 'error',
99
+
100
+ // Suggest using the spread syntax instead of .apply()
101
+ 'prefer-spread': 'error',
102
+
103
+ // Suggest using template literals instead of string concatenation
104
+ 'prefer-template': 'error',
105
+
106
+ // Disallow generator functions that do not have yield
107
+ 'require-yield': 'error',
108
+
109
+ // Enforce a convention in module import order
110
+ 'sort-imports': ['off', {
111
+ ignoreCase: false,
112
+ ignoreDeclarationSort: false,
113
+ ignoreMemberSort: false,
114
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
115
+ }],
116
+
117
+ // Require a Symbol description
118
+ 'symbol-description': 'error',
119
+ };