eslint-stylistic-airbnb 1.0.0

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.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # eslint-stylistic-airbnb
2
+
3
+ Airbnb config for ESLint with style rules via @stylistic plugin
4
+
5
+ # Installation
6
+
7
+ Install all required dependencies
8
+
9
+ ```shell
10
+ npm install -D eslint @stylistic/eslint-plugin eslint-stylistic-airbnb
11
+ ```
12
+
13
+ Add following to your eslint config:
14
+
15
+ ```javascript
16
+ // Flat config eslint.config.mjs
17
+ import stylistic from '@stylistic/eslint-plugin';
18
+ import airbnb from 'eslint-stylistic-airbnb';
19
+
20
+ export default [
21
+ ...airbnb,
22
+ {
23
+ files: ['**/*.{js,mjs,cjs,ts}'],
24
+ plugins: {
25
+ '@stylistic': stylistic,
26
+ },
27
+ },
28
+ ];
29
+ ```
30
+
31
+ If you use typescript, install additional dependency:
32
+
33
+ ```shell
34
+ npm install -D typescript-eslint
35
+ ```
36
+
37
+ And add following to your eslint config:
38
+
39
+ ```javascript
40
+ // Flat config eslint.config.mjs
41
+ import tseslint from 'typescript-eslint';
42
+ import stylistic from '@stylistic/eslint-plugin';
43
+ import airbnb from 'eslint-stylistic-airbnb';
44
+
45
+ export default [
46
+ ...airbnb,
47
+ ...tseslint.configs.recommended,
48
+ {
49
+ files: ['**/*.{js,mjs,cjs,ts}'],
50
+ plugins: {
51
+ '@stylistic': stylistic,
52
+ },
53
+ },
54
+ ];
55
+ ```
56
+
57
+ # Notes
58
+
59
+ This config is created from the base airbnb config as is, with no changes to original rules
60
+
61
+ - rules that required newer eslint version are enabled
62
+ - node related rules are not implemented
63
+ - import rules are not implemented
64
+ - react rules are not implemented (except of some jsx style options)
65
+ - `func-style` rule is turned off, just like in original config (airbnb config contradicts with airbnb styleguide, this
66
+ option set to be "backward-compatible")
package/index.js ADDED
@@ -0,0 +1,15 @@
1
+ const bestPractices = require('./rules/best-practices.js');
2
+ const errors = require('./rules/errors.js');
3
+ const es6 = require('./rules/es6.js');
4
+ const strict = require('./rules/strict.js');
5
+ const style = require('./rules/style.js');
6
+ const variables = require('./rules/variables.js');
7
+
8
+ module.exports = [
9
+ bestPractices,
10
+ errors,
11
+ es6,
12
+ strict,
13
+ style,
14
+ variables,
15
+ ];
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "eslint-stylistic-airbnb",
3
+ "version": "1.0.0",
4
+ "description": "Airbnb config for eslint using stylistic plugin",
5
+ "main": "index.js",
6
+ "keywords": [
7
+ "eslint",
8
+ "stylistic",
9
+ "airbnb",
10
+ "config"
11
+ ],
12
+ "files": [
13
+ "index.js",
14
+ "rules"
15
+ ],
16
+ "author": "",
17
+ "license": "MIT",
18
+ "dependencies": {
19
+ "confusing-browser-globals": "^1.0.11"
20
+ },
21
+ "peerDependencies": {
22
+ "eslint": ">=8.40.0",
23
+ "@stylistic/eslint-plugin": ">=2.0.0"
24
+ }
25
+ }
@@ -0,0 +1,425 @@
1
+ module.exports = {
2
+ rules: {
3
+ // enforces getter/setter pairs in objects
4
+ // https://eslint.org/docs/rules/accessor-pairs
5
+ 'accessor-pairs': 'off',
6
+
7
+ // enforces return statements in callbacks of array's methods
8
+ // https://eslint.org/docs/rules/array-callback-return
9
+ 'array-callback-return': ['error', { allowImplicit: true }],
10
+
11
+ // treat var statements as if they were block scoped
12
+ // https://eslint.org/docs/rules/block-scoped-var
13
+ 'block-scoped-var': 'error',
14
+
15
+ // specify the maximum cyclomatic complexity allowed in a program
16
+ // https://eslint.org/docs/rules/complexity
17
+ complexity: ['off', 20],
18
+
19
+ // enforce that class methods use "this"
20
+ // https://eslint.org/docs/rules/class-methods-use-this
21
+ 'class-methods-use-this': ['error', {
22
+ exceptMethods: [],
23
+ }],
24
+
25
+ // require return statements to either always or never specify values
26
+ // https://eslint.org/docs/rules/consistent-return
27
+ 'consistent-return': 'error',
28
+
29
+ // specify curly brace conventions for all control statements
30
+ // https://eslint.org/docs/rules/curly
31
+ curly: ['error', 'multi-line'], // multiline
32
+
33
+ // require default case in switch statements
34
+ // https://eslint.org/docs/rules/default-case
35
+ 'default-case': ['error', { commentPattern: '^no default$' }],
36
+
37
+ // Enforce default clauses in switch statements to be last
38
+ // https://eslint.org/docs/rules/default-case-last
39
+ 'default-case-last': 'error',
40
+
41
+ // https://eslint.org/docs/rules/default-param-last
42
+ 'default-param-last': 'error',
43
+
44
+ // encourages use of dot notation whenever possible
45
+ // https://eslint.org/docs/rules/dot-notation
46
+ 'dot-notation': ['error', { allowKeywords: true }],
47
+
48
+ // enforces consistent newlines before or after dots
49
+ // https://eslint.org/docs/rules/dot-location
50
+ // https://eslint.style/rules/js/dot-location
51
+ '@stylistic/dot-location': ['error', 'property'],
52
+
53
+ // require the use of === and !==
54
+ // https://eslint.org/docs/rules/eqeqeq
55
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
56
+
57
+ // Require grouped accessor pairs in object literals and classes
58
+ // https://eslint.org/docs/rules/grouped-accessor-pairs
59
+ 'grouped-accessor-pairs': 'error',
60
+
61
+ // make sure for-in loops have an if statement
62
+ // https://eslint.org/docs/rules/guard-for-in
63
+ 'guard-for-in': 'error',
64
+
65
+ // enforce a maximum number of classes per file
66
+ // https://eslint.org/docs/rules/max-classes-per-file
67
+ 'max-classes-per-file': ['error', 1],
68
+
69
+ // disallow the use of alert, confirm, and prompt
70
+ // https://eslint.org/docs/rules/no-alert
71
+ // TODO: enable, semver-major
72
+ 'no-alert': 'warn',
73
+
74
+ // disallow use of arguments.caller or arguments.callee
75
+ // https://eslint.org/docs/rules/no-caller
76
+ 'no-caller': 'error',
77
+
78
+ // disallow lexical declarations in case/default clauses
79
+ // https://eslint.org/docs/rules/no-case-declarations
80
+ 'no-case-declarations': 'error',
81
+
82
+ // Disallow returning value in constructor
83
+ // https://eslint.org/docs/rules/no-constructor-return
84
+ 'no-constructor-return': 'error',
85
+
86
+ // disallow division operators explicitly at beginning of regular expression
87
+ // https://eslint.org/docs/rules/no-div-regex
88
+ 'no-div-regex': 'off',
89
+
90
+ // disallow else after a return in an if
91
+ // https://eslint.org/docs/rules/no-else-return
92
+ 'no-else-return': ['error', { allowElseIf: false }],
93
+
94
+ // disallow empty functions, except for standalone funcs/arrows
95
+ // https://eslint.org/docs/rules/no-empty-function
96
+ 'no-empty-function': ['error', {
97
+ allow: [
98
+ 'arrowFunctions',
99
+ 'functions',
100
+ 'methods',
101
+ ]
102
+ }],
103
+
104
+ // disallow empty destructuring patterns
105
+ // https://eslint.org/docs/rules/no-empty-pattern
106
+ 'no-empty-pattern': 'error',
107
+
108
+ // Disallow empty static blocks
109
+ // https://eslint.org/docs/latest/rules/no-empty-static-block
110
+ // TODO: semver-major, enable
111
+ 'no-empty-static-block': 'off',
112
+
113
+ // disallow comparisons to null without a type-checking operator
114
+ // https://eslint.org/docs/rules/no-eq-null
115
+ 'no-eq-null': 'off',
116
+
117
+ // disallow use of eval()
118
+ // https://eslint.org/docs/rules/no-eval
119
+ 'no-eval': 'error',
120
+
121
+ // disallow adding to native types
122
+ // https://eslint.org/docs/rules/no-extend-native
123
+ 'no-extend-native': 'error',
124
+
125
+ // disallow unnecessary function binding
126
+ // https://eslint.org/docs/rules/no-extra-bind
127
+ 'no-extra-bind': 'error',
128
+
129
+ // disallow Unnecessary Labels
130
+ // https://eslint.org/docs/rules/no-extra-label
131
+ 'no-extra-label': 'error',
132
+
133
+ // disallow fallthrough of case statements
134
+ // https://eslint.org/docs/rules/no-fallthrough
135
+ 'no-fallthrough': 'error',
136
+
137
+ // disallow the use of leading or trailing decimal points in numeric literals
138
+ // https://eslint.org/docs/rules/no-floating-decimal
139
+ 'no-floating-decimal': 'error',
140
+
141
+ // disallow reassignments of native objects or read-only globals
142
+ // https://eslint.org/docs/rules/no-global-assign
143
+ 'no-global-assign': ['error', { exceptions: [] }],
144
+
145
+ // deprecated in favor of no-global-assign
146
+ // https://eslint.org/docs/rules/no-native-reassign
147
+ 'no-native-reassign': 'off',
148
+
149
+ // disallow implicit type conversions
150
+ // https://eslint.org/docs/rules/no-implicit-coercion
151
+ 'no-implicit-coercion': ['off', {
152
+ boolean: false,
153
+ number: true,
154
+ string: true,
155
+ allow: [],
156
+ }],
157
+
158
+ // disallow var and named functions in global scope
159
+ // https://eslint.org/docs/rules/no-implicit-globals
160
+ 'no-implicit-globals': 'off',
161
+
162
+ // disallow use of eval()-like methods
163
+ // https://eslint.org/docs/rules/no-implied-eval
164
+ 'no-implied-eval': 'error',
165
+
166
+ // disallow this keywords outside of classes or class-like objects
167
+ // https://eslint.org/docs/rules/no-invalid-this
168
+ 'no-invalid-this': 'off',
169
+
170
+ // disallow usage of __iterator__ property
171
+ // https://eslint.org/docs/rules/no-iterator
172
+ 'no-iterator': 'error',
173
+
174
+ // disallow use of labels for anything other than loops and switches
175
+ // https://eslint.org/docs/rules/no-labels
176
+ 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
177
+
178
+ // disallow unnecessary nested blocks
179
+ // https://eslint.org/docs/rules/no-lone-blocks
180
+ 'no-lone-blocks': 'error',
181
+
182
+ // disallow creation of functions within loops
183
+ // https://eslint.org/docs/rules/no-loop-func
184
+ 'no-loop-func': 'error',
185
+
186
+ // disallow magic numbers
187
+ // https://eslint.org/docs/rules/no-magic-numbers
188
+ 'no-magic-numbers': ['off', {
189
+ ignore: [],
190
+ ignoreArrayIndexes: true,
191
+ enforceConst: true,
192
+ detectObjects: false,
193
+ }],
194
+
195
+ // disallow use of multiple spaces
196
+ // https://eslint.org/docs/rules/no-multi-spaces
197
+ 'no-multi-spaces': ['error', {
198
+ ignoreEOLComments: false,
199
+ }],
200
+
201
+ // disallow use of multiline strings
202
+ // https://eslint.org/docs/rules/no-multi-str
203
+ 'no-multi-str': 'error',
204
+
205
+ // disallow use of new operator when not part of the assignment or comparison
206
+ // https://eslint.org/docs/rules/no-new
207
+ 'no-new': 'error',
208
+
209
+ // disallow use of new operator for Function object
210
+ // https://eslint.org/docs/rules/no-new-func
211
+ 'no-new-func': 'error',
212
+
213
+ // disallows creating new instances of String, Number, and Boolean
214
+ // https://eslint.org/docs/rules/no-new-wrappers
215
+ 'no-new-wrappers': 'error',
216
+
217
+ // Disallow \8 and \9 escape sequences in string literals
218
+ // https://eslint.org/docs/rules/no-nonoctal-decimal-escape
219
+ 'no-nonoctal-decimal-escape': 'error',
220
+
221
+ // Disallow calls to the Object constructor without an argument
222
+ // https://eslint.org/docs/latest/rules/no-object-constructor
223
+ // TODO: enable, semver-major
224
+ 'no-object-constructor': 'off',
225
+
226
+ // disallow use of (old style) octal literals
227
+ // https://eslint.org/docs/rules/no-octal
228
+ 'no-octal': 'error',
229
+
230
+ // disallow use of octal escape sequences in string literals, such as
231
+ // var foo = 'Copyright \251';
232
+ // https://eslint.org/docs/rules/no-octal-escape
233
+ 'no-octal-escape': 'error',
234
+
235
+ // disallow reassignment of function parameters
236
+ // disallow parameter object manipulation except for specific exclusions
237
+ // rule: https://eslint.org/docs/rules/no-param-reassign.html
238
+ 'no-param-reassign': ['error', {
239
+ props: true,
240
+ ignorePropertyModificationsFor: [
241
+ 'acc', // for reduce accumulators
242
+ 'accumulator', // for reduce accumulators
243
+ 'e', // for e.returnvalue
244
+ 'ctx', // for Koa routing
245
+ 'context', // for Koa routing
246
+ 'req', // for Express requests
247
+ 'request', // for Express requests
248
+ 'res', // for Express responses
249
+ 'response', // for Express responses
250
+ '$scope', // for Angular 1 scopes
251
+ 'staticContext', // for ReactRouter context
252
+ ]
253
+ }],
254
+
255
+ // disallow usage of __proto__ property
256
+ // https://eslint.org/docs/rules/no-proto
257
+ 'no-proto': 'error',
258
+
259
+ // disallow declaring the same variable more than once
260
+ // https://eslint.org/docs/rules/no-redeclare
261
+ 'no-redeclare': 'error',
262
+
263
+ // disallow certain object properties
264
+ // https://eslint.org/docs/rules/no-restricted-properties
265
+ 'no-restricted-properties': ['error', {
266
+ object: 'arguments',
267
+ property: 'callee',
268
+ message: 'arguments.callee is deprecated',
269
+ }, {
270
+ object: 'global',
271
+ property: 'isFinite',
272
+ message: 'Please use Number.isFinite instead',
273
+ }, {
274
+ object: 'self',
275
+ property: 'isFinite',
276
+ message: 'Please use Number.isFinite instead',
277
+ }, {
278
+ object: 'window',
279
+ property: 'isFinite',
280
+ message: 'Please use Number.isFinite instead',
281
+ }, {
282
+ object: 'global',
283
+ property: 'isNaN',
284
+ message: 'Please use Number.isNaN instead',
285
+ }, {
286
+ object: 'self',
287
+ property: 'isNaN',
288
+ message: 'Please use Number.isNaN instead',
289
+ }, {
290
+ object: 'window',
291
+ property: 'isNaN',
292
+ message: 'Please use Number.isNaN instead',
293
+ }, {
294
+ property: '__defineGetter__',
295
+ message: 'Please use Object.defineProperty instead.',
296
+ }, {
297
+ property: '__defineSetter__',
298
+ message: 'Please use Object.defineProperty instead.',
299
+ }, {
300
+ object: 'Math',
301
+ property: 'pow',
302
+ message: 'Use the exponentiation operator (**) instead.',
303
+ }],
304
+
305
+ // disallow use of assignment in return statement
306
+ // https://eslint.org/docs/rules/no-return-assign
307
+ 'no-return-assign': ['error', 'always'],
308
+
309
+ // disallow redundant `return await`
310
+ // https://eslint.org/docs/rules/no-return-await
311
+ 'no-return-await': 'error',
312
+
313
+ // disallow use of `javascript:` urls.
314
+ // https://eslint.org/docs/rules/no-script-url
315
+ 'no-script-url': 'error',
316
+
317
+ // disallow self assignment
318
+ // https://eslint.org/docs/rules/no-self-assign
319
+ 'no-self-assign': ['error', {
320
+ props: true,
321
+ }],
322
+
323
+ // disallow comparisons where both sides are exactly the same
324
+ // https://eslint.org/docs/rules/no-self-compare
325
+ 'no-self-compare': 'error',
326
+
327
+ // disallow use of comma operator
328
+ // https://eslint.org/docs/rules/no-sequences
329
+ 'no-sequences': 'error',
330
+
331
+ // restrict what can be thrown as an exception
332
+ // https://eslint.org/docs/rules/no-throw-literal
333
+ 'no-throw-literal': 'error',
334
+
335
+ // disallow unmodified conditions of loops
336
+ // https://eslint.org/docs/rules/no-unmodified-loop-condition
337
+ 'no-unmodified-loop-condition': 'off',
338
+
339
+ // disallow usage of expressions in statement position
340
+ // https://eslint.org/docs/rules/no-unused-expressions
341
+ 'no-unused-expressions': ['error', {
342
+ allowShortCircuit: false,
343
+ allowTernary: false,
344
+ allowTaggedTemplates: false,
345
+ }],
346
+
347
+ // disallow unused labels
348
+ // https://eslint.org/docs/rules/no-unused-labels
349
+ 'no-unused-labels': 'error',
350
+
351
+ // disallow unnecessary .call() and .apply()
352
+ // https://eslint.org/docs/rules/no-useless-call
353
+ 'no-useless-call': 'off',
354
+
355
+ // Disallow unnecessary catch clauses
356
+ // https://eslint.org/docs/rules/no-useless-catch
357
+ 'no-useless-catch': 'error',
358
+
359
+ // disallow useless string concatenation
360
+ // https://eslint.org/docs/rules/no-useless-concat
361
+ 'no-useless-concat': 'error',
362
+
363
+ // disallow unnecessary string escaping
364
+ // https://eslint.org/docs/rules/no-useless-escape
365
+ 'no-useless-escape': 'error',
366
+
367
+ // disallow redundant return; keywords
368
+ // https://eslint.org/docs/rules/no-useless-return
369
+ 'no-useless-return': 'error',
370
+
371
+ // disallow use of void operator
372
+ // https://eslint.org/docs/rules/no-void
373
+ 'no-void': 'error',
374
+
375
+ // disallow usage of configurable warning terms in comments: e.g. todo
376
+ // https://eslint.org/docs/rules/no-warning-comments
377
+ 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
378
+
379
+ // disallow use of the with statement
380
+ // https://eslint.org/docs/rules/no-with
381
+ 'no-with': 'error',
382
+
383
+ // require using Error objects as Promise rejection reasons
384
+ // https://eslint.org/docs/rules/prefer-promise-reject-errors
385
+ 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
386
+
387
+ // Suggest using named capture group in regular expression
388
+ // https://eslint.org/docs/rules/prefer-named-capture-group
389
+ 'prefer-named-capture-group': 'off',
390
+
391
+ // Prefer Object.hasOwn() over Object.prototype.hasOwnProperty.call()
392
+ // https://eslint.org/docs/rules/prefer-object-has-own
393
+ // TODO: semver-major: enable thus rule, once eslint v8.5.0 is required
394
+ 'prefer-object-has-own': 'off',
395
+
396
+ // https://eslint.org/docs/rules/prefer-regex-literals
397
+ 'prefer-regex-literals': ['error', {
398
+ disallowRedundantWrapping: true,
399
+ }],
400
+
401
+ // require use of the second argument for parseInt()
402
+ // https://eslint.org/docs/rules/radix
403
+ radix: 'error',
404
+
405
+ // require `await` in `async function` (note: this is a horrible rule that should never be used)
406
+ // https://eslint.org/docs/rules/require-await
407
+ 'require-await': 'off',
408
+
409
+ // Enforce the use of u flag on RegExp
410
+ // https://eslint.org/docs/rules/require-unicode-regexp
411
+ 'require-unicode-regexp': 'off',
412
+
413
+ // requires to declare all vars on top of their containing scope
414
+ // https://eslint.org/docs/rules/vars-on-top
415
+ 'vars-on-top': 'error',
416
+
417
+ // require immediate function invocation to be wrapped in parentheses
418
+ // https://eslint.org/docs/rules/wrap-iife.html
419
+ 'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }],
420
+
421
+ // require or disallow Yoda conditions
422
+ // https://eslint.org/docs/rules/yoda
423
+ yoda: 'error'
424
+ }
425
+ };