eslint-config-airbnb-extended 0.0.9 → 0.1.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/base/index.ts +21 -0
  3. package/base/recommended.ts +17 -0
  4. package/index.ts +25 -0
  5. package/package.json +12 -31
  6. package/react/index.ts +11 -0
  7. package/react/recommended.ts +6 -0
  8. package/rules/best-practices.ts +462 -0
  9. package/rules/errors.ts +199 -0
  10. package/rules/es6.ts +224 -0
  11. package/rules/imports.ts +308 -0
  12. package/rules/node.ts +49 -0
  13. package/rules/react-a11y.ts +295 -0
  14. package/rules/react-hooks.ts +26 -0
  15. package/rules/react.ts +692 -0
  16. package/rules/strict.ts +9 -0
  17. package/rules/style.ts +632 -0
  18. package/rules/typescript.ts +312 -0
  19. package/rules/variables.ts +76 -0
  20. package/tsconfig.json +22 -0
  21. package/typescript/index.ts +7 -0
  22. package/typescript/recommended.ts +30 -0
  23. package/README.md +0 -1
  24. package/dist/base/index.d.ts +0 -841
  25. package/dist/base/index.js +0 -23
  26. package/dist/base/recommended.d.ts +0 -2
  27. package/dist/base/recommended.js +0 -19
  28. package/dist/index.d.ts +0 -2654
  29. package/dist/index.js +0 -29
  30. package/dist/react/index.d.ts +0 -1798
  31. package/dist/react/index.js +0 -13
  32. package/dist/react/recommended.d.ts +0 -2
  33. package/dist/react/recommended.js +0 -8
  34. package/dist/rules/best-practices.d.ts +0 -177
  35. package/dist/rules/best-practices.js +0 -379
  36. package/dist/rules/errors.d.ts +0 -69
  37. package/dist/rules/errors.js +0 -151
  38. package/dist/rules/es6.d.ts +0 -146
  39. package/dist/rules/es6.js +0 -192
  40. package/dist/rules/imports.d.ts +0 -157
  41. package/dist/rules/imports.js +0 -256
  42. package/dist/rules/node.d.ts +0 -90
  43. package/dist/rules/node.js +0 -39
  44. package/dist/rules/react-a11y.d.ts +0 -117
  45. package/dist/rules/react-a11y.js +0 -255
  46. package/dist/rules/react-hooks.d.ts +0 -19
  47. package/dist/rules/react-hooks.js +0 -57
  48. package/dist/rules/react.d.ts +0 -1664
  49. package/dist/rules/react.js +0 -586
  50. package/dist/rules/strict.d.ts +0 -7
  51. package/dist/rules/strict.js +0 -9
  52. package/dist/rules/style.d.ts +0 -320
  53. package/dist/rules/style.js +0 -530
  54. package/dist/rules/typescript.d.ts +0 -4
  55. package/dist/rules/typescript.js +0 -264
  56. package/dist/rules/variables.d.ts +0 -35
  57. package/dist/rules/variables.js +0 -65
  58. package/dist/typescript/index.d.ts +0 -5
  59. package/dist/typescript/index.js +0 -9
  60. package/dist/typescript/recommended.d.ts +0 -6
  61. package/dist/typescript/recommended.js +0 -62
  62. package/dist/utils/index.d.ts +0 -1
  63. package/dist/utils/index.js +0 -4
@@ -0,0 +1,199 @@
1
+ import type { Linter } from 'eslint';
2
+
3
+ export default {
4
+ name: 'airbnb/config/errors',
5
+ rules: {
6
+ // Enforce “for” loop update clause moving the counter in the right direction
7
+ // https://eslint.org/docs/rules/for-direction
8
+ 'for-direction': 'error',
9
+
10
+ // Enforces that a return statement is present in property getters
11
+ // https://eslint.org/docs/rules/getter-return
12
+ 'getter-return': ['error', { allowImplicit: true }],
13
+
14
+ // disallow using an async function as a Promise executor
15
+ // https://eslint.org/docs/rules/no-async-promise-executor
16
+ 'no-async-promise-executor': 'error',
17
+
18
+ // Disallow await inside of loops
19
+ // https://eslint.org/docs/rules/no-await-in-loop
20
+ 'no-await-in-loop': 'error',
21
+
22
+ // Disallow comparisons to negative zero
23
+ // https://eslint.org/docs/rules/no-compare-neg-zero
24
+ 'no-compare-neg-zero': 'error',
25
+
26
+ // disallow assignment in conditional expressions
27
+ 'no-cond-assign': ['error', 'always'],
28
+
29
+ // disallow use of console
30
+ 'no-console': 'warn',
31
+
32
+ // Disallows expressions where the operation doesn't affect the value
33
+ // https://eslint.org/docs/rules/no-constant-binary-expression
34
+ // TODO: semver-major, enable
35
+ 'no-constant-binary-expression': 'off',
36
+
37
+ // disallow use of constant expressions in conditions
38
+ 'no-constant-condition': 'warn',
39
+
40
+ // disallow control characters in regular expressions
41
+ 'no-control-regex': 'error',
42
+
43
+ // disallow use of debugger
44
+ 'no-debugger': 'error',
45
+
46
+ // disallow duplicate arguments in functions
47
+ 'no-dupe-args': 'error',
48
+
49
+ // Disallow duplicate conditions in if-else-if chains
50
+ // https://eslint.org/docs/rules/no-dupe-else-if
51
+ 'no-dupe-else-if': 'error',
52
+
53
+ // disallow duplicate keys when creating object literals
54
+ 'no-dupe-keys': 'error',
55
+
56
+ // disallow a duplicate case label.
57
+ 'no-duplicate-case': 'error',
58
+
59
+ // disallow empty statements
60
+ 'no-empty': 'error',
61
+
62
+ // disallow the use of empty character classes in regular expressions
63
+ 'no-empty-character-class': 'error',
64
+
65
+ // disallow assigning to the exception in a catch block
66
+ 'no-ex-assign': 'error',
67
+
68
+ // disallow double-negation boolean casts in a boolean context
69
+ // https://eslint.org/docs/rules/no-extra-boolean-cast
70
+ 'no-extra-boolean-cast': 'error',
71
+
72
+ // disallow unnecessary parentheses
73
+ // https://eslint.org/docs/rules/no-extra-parens
74
+ 'no-extra-parens': [
75
+ 'off',
76
+ 'all',
77
+ {
78
+ conditionalAssign: true,
79
+ nestedBinaryExpressions: false,
80
+ returnAssign: false,
81
+ ignoreJSX: 'all', // delegate to eslint-plugin-react
82
+ enforceForArrowConditionals: false,
83
+ },
84
+ ],
85
+
86
+ // disallow unnecessary semicolons
87
+ 'no-extra-semi': 'error',
88
+
89
+ // disallow overwriting functions written as function declarations
90
+ 'no-func-assign': 'error',
91
+
92
+ // https://eslint.org/docs/rules/no-import-assign
93
+ 'no-import-assign': 'error',
94
+
95
+ // disallow function or variable declarations in nested blocks
96
+ 'no-inner-declarations': 'error',
97
+
98
+ // disallow invalid regular expression strings in the RegExp constructor
99
+ 'no-invalid-regexp': 'error',
100
+
101
+ // disallow irregular whitespace outside of strings and comments
102
+ 'no-irregular-whitespace': 'error',
103
+
104
+ // Disallow Number Literals That Lose Precision
105
+ // https://eslint.org/docs/rules/no-loss-of-precision
106
+ 'no-loss-of-precision': 'error',
107
+
108
+ // Disallow characters which are made with multiple code points in character class syntax
109
+ // https://eslint.org/docs/rules/no-misleading-character-class
110
+ 'no-misleading-character-class': 'error',
111
+
112
+ // disallow the use of object properties of the global object (Math and JSON) as functions
113
+ 'no-obj-calls': 'error',
114
+
115
+ // Disallow new operators with global non-constructor functions
116
+ // https://eslint.org/docs/latest/rules/no-new-native-nonconstructor
117
+ // TODO: semver-major, enable
118
+ 'no-new-native-nonconstructor': 'off',
119
+
120
+ // Disallow returning values from Promise executor functions
121
+ // https://eslint.org/docs/rules/no-promise-executor-return
122
+ 'no-promise-executor-return': 'error',
123
+
124
+ // disallow use of Object.prototypes builtins directly
125
+ // https://eslint.org/docs/rules/no-prototype-builtins
126
+ 'no-prototype-builtins': 'error',
127
+
128
+ // disallow multiple spaces in a regular expression literal
129
+ 'no-regex-spaces': 'error',
130
+
131
+ // Disallow returning values from setters
132
+ // https://eslint.org/docs/rules/no-setter-return
133
+ 'no-setter-return': 'error',
134
+
135
+ // disallow sparse arrays
136
+ 'no-sparse-arrays': 'error',
137
+
138
+ // Disallow template literal placeholder syntax in regular strings
139
+ // https://eslint.org/docs/rules/no-template-curly-in-string
140
+ 'no-template-curly-in-string': 'error',
141
+
142
+ // Avoid code that looks like two expressions but is actually one
143
+ // https://eslint.org/docs/rules/no-unexpected-multiline
144
+ 'no-unexpected-multiline': 'error',
145
+
146
+ // disallow unreachable statements after a return, throw, continue, or break statement
147
+ 'no-unreachable': 'error',
148
+
149
+ // Disallow loops with a body that allows only one iteration
150
+ // https://eslint.org/docs/rules/no-unreachable-loop
151
+ 'no-unreachable-loop': [
152
+ 'error',
153
+ {
154
+ ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
155
+ },
156
+ ],
157
+
158
+ // disallow return/throw/break/continue inside finally blocks
159
+ // https://eslint.org/docs/rules/no-unsafe-finally
160
+ 'no-unsafe-finally': 'error',
161
+
162
+ // disallow negating the left operand of relational operators
163
+ // https://eslint.org/docs/rules/no-unsafe-negation
164
+ 'no-unsafe-negation': 'error',
165
+
166
+ // disallow use of optional chaining in contexts where the undefined value is not allowed
167
+ // https://eslint.org/docs/rules/no-unsafe-optional-chaining
168
+ 'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
169
+
170
+ // Disallow Unused Private Class Members
171
+ // https://eslint.org/docs/rules/no-unused-private-class-members
172
+ // TODO: enable once eslint 7 is dropped (which is semver-major)
173
+ 'no-unused-private-class-members': 'off',
174
+
175
+ // Disallow useless backreferences in regular expressions
176
+ // https://eslint.org/docs/rules/no-useless-backreference
177
+ 'no-useless-backreference': 'error',
178
+
179
+ // disallow negation of the left operand of an in expression
180
+ // deprecated in favor of no-unsafe-negation
181
+ 'no-negated-in-lhs': 'off',
182
+
183
+ // Disallow assignments that can lead to race conditions due to usage of await or yield
184
+ // https://eslint.org/docs/rules/require-atomic-updates
185
+ // note: not enabled because it is very buggy
186
+ 'require-atomic-updates': 'off',
187
+
188
+ // disallow comparisons with the value NaN
189
+ 'use-isnan': 'error',
190
+
191
+ // ensure JSDoc comments are valid
192
+ // https://eslint.org/docs/rules/valid-jsdoc
193
+ 'valid-jsdoc': 'off',
194
+
195
+ // ensure that the results of typeof are compared against a valid string
196
+ // https://eslint.org/docs/rules/valid-typeof
197
+ 'valid-typeof': ['error', { requireStringLiterals: true }],
198
+ },
199
+ } satisfies Linter.Config;
package/rules/es6.ts ADDED
@@ -0,0 +1,224 @@
1
+ import globals from 'globals';
2
+
3
+ import type { Linter } from 'eslint';
4
+
5
+ export default {
6
+ name: 'airbnb/config/es6',
7
+ languageOptions: {
8
+ globals: {
9
+ ...globals.es2015,
10
+ },
11
+ parserOptions: {
12
+ ecmaVersion: 6,
13
+ sourceType: 'module',
14
+ ecmaFeatures: {
15
+ generators: false,
16
+ objectLiteralDuplicateProperties: false,
17
+ },
18
+ },
19
+ },
20
+ rules: {
21
+ // enforces no braces where they can be omitted
22
+ // https://eslint.org/docs/rules/arrow-body-style
23
+ // TODO: enable requireReturnForObjectLiteral?
24
+ 'arrow-body-style': [
25
+ 'error',
26
+ 'as-needed',
27
+ {
28
+ requireReturnForObjectLiteral: false,
29
+ },
30
+ ],
31
+
32
+ // require parens in arrow function arguments
33
+ // https://eslint.org/docs/rules/arrow-parens
34
+ 'arrow-parens': ['error', 'always'],
35
+
36
+ // require space before/after arrow function's arrow
37
+ // https://eslint.org/docs/rules/arrow-spacing
38
+ 'arrow-spacing': ['error', { before: true, after: true }],
39
+
40
+ // verify super() callings in constructors
41
+ 'constructor-super': 'error',
42
+
43
+ // enforce the spacing around the * in generator functions
44
+ // https://eslint.org/docs/rules/generator-star-spacing
45
+ 'generator-star-spacing': ['error', { before: false, after: true }],
46
+
47
+ // disallow modifying variables of class declarations
48
+ // https://eslint.org/docs/rules/no-class-assign
49
+ 'no-class-assign': 'error',
50
+
51
+ // disallow arrow functions where they could be confused with comparisons
52
+ // https://eslint.org/docs/rules/no-confusing-arrow
53
+ 'no-confusing-arrow': [
54
+ 'error',
55
+ {
56
+ allowParens: true,
57
+ },
58
+ ],
59
+
60
+ // disallow modifying variables that are declared using const
61
+ 'no-const-assign': 'error',
62
+
63
+ // disallow duplicate class members
64
+ // https://eslint.org/docs/rules/no-dupe-class-members
65
+ 'no-dupe-class-members': 'error',
66
+
67
+ // disallow importing from the same path more than once
68
+ // https://eslint.org/docs/rules/no-duplicate-imports
69
+ // replaced by https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
70
+ 'no-duplicate-imports': 'off',
71
+
72
+ // disallow symbol constructor
73
+ // https://eslint.org/docs/rules/no-new-symbol
74
+ 'no-new-symbol': 'error',
75
+
76
+ // Disallow specified names in exports
77
+ // https://eslint.org/docs/rules/no-restricted-exports
78
+ 'no-restricted-exports': [
79
+ 'error',
80
+ {
81
+ restrictedNamedExports: [
82
+ 'default', // use `export default` to provide a default export
83
+ 'then', // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
84
+ ],
85
+ },
86
+ ],
87
+
88
+ // disallow specific imports
89
+ // https://eslint.org/docs/rules/no-restricted-imports
90
+ 'no-restricted-imports': [
91
+ 'off',
92
+ {
93
+ paths: [],
94
+ patterns: [],
95
+ },
96
+ ],
97
+
98
+ // disallow to use this/super before super() calling in constructors.
99
+ // https://eslint.org/docs/rules/no-this-before-super
100
+ 'no-this-before-super': 'error',
101
+
102
+ // disallow useless computed property keys
103
+ // https://eslint.org/docs/rules/no-useless-computed-key
104
+ 'no-useless-computed-key': 'error',
105
+
106
+ // disallow unnecessary constructor
107
+ // https://eslint.org/docs/rules/no-useless-constructor
108
+ 'no-useless-constructor': 'error',
109
+
110
+ // disallow renaming import, export, and destructured assignments to the same name
111
+ // https://eslint.org/docs/rules/no-useless-rename
112
+ 'no-useless-rename': [
113
+ 'error',
114
+ {
115
+ ignoreDestructuring: false,
116
+ ignoreImport: false,
117
+ ignoreExport: false,
118
+ },
119
+ ],
120
+
121
+ // require let or const instead of var
122
+ 'no-var': 'error',
123
+
124
+ // require method and property shorthand syntax for object literals
125
+ // https://eslint.org/docs/rules/object-shorthand
126
+ 'object-shorthand': [
127
+ 'error',
128
+ 'always',
129
+ {
130
+ ignoreConstructors: false,
131
+ avoidQuotes: true,
132
+ },
133
+ ],
134
+
135
+ // suggest using arrow functions as callbacks
136
+ 'prefer-arrow-callback': [
137
+ 'error',
138
+ {
139
+ allowNamedFunctions: false,
140
+ allowUnboundThis: true,
141
+ },
142
+ ],
143
+
144
+ // suggest using of const declaration for variables that are never modified after declared
145
+ 'prefer-const': [
146
+ 'error',
147
+ {
148
+ destructuring: 'any',
149
+ ignoreReadBeforeAssign: true,
150
+ },
151
+ ],
152
+
153
+ // Prefer destructuring from arrays and objects
154
+ // https://eslint.org/docs/rules/prefer-destructuring
155
+ 'prefer-destructuring': [
156
+ 'error',
157
+ {
158
+ VariableDeclarator: {
159
+ array: false,
160
+ object: true,
161
+ },
162
+ AssignmentExpression: {
163
+ array: true,
164
+ object: false,
165
+ },
166
+ },
167
+ {
168
+ enforceForRenamedProperties: false,
169
+ },
170
+ ],
171
+
172
+ // disallow parseInt() in favor of binary, octal, and hexadecimal literals
173
+ // https://eslint.org/docs/rules/prefer-numeric-literals
174
+ 'prefer-numeric-literals': 'error',
175
+
176
+ // suggest using Reflect methods where applicable
177
+ // https://eslint.org/docs/rules/prefer-reflect
178
+ 'prefer-reflect': 'off',
179
+
180
+ // use rest parameters instead of arguments
181
+ // https://eslint.org/docs/rules/prefer-rest-params
182
+ 'prefer-rest-params': 'error',
183
+
184
+ // suggest using the spread syntax instead of .apply()
185
+ // https://eslint.org/docs/rules/prefer-spread
186
+ 'prefer-spread': 'error',
187
+
188
+ // suggest using template literals instead of string concatenation
189
+ // https://eslint.org/docs/rules/prefer-template
190
+ 'prefer-template': 'error',
191
+
192
+ // disallow generator functions that do not have yield
193
+ // https://eslint.org/docs/rules/require-yield
194
+ 'require-yield': 'error',
195
+
196
+ // enforce spacing between object rest-spread
197
+ // https://eslint.org/docs/rules/rest-spread-spacing
198
+ 'rest-spread-spacing': ['error', 'never'],
199
+
200
+ // import sorting
201
+ // https://eslint.org/docs/rules/sort-imports
202
+ 'sort-imports': [
203
+ 'off',
204
+ {
205
+ ignoreCase: false,
206
+ ignoreDeclarationSort: false,
207
+ ignoreMemberSort: false,
208
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
209
+ },
210
+ ],
211
+
212
+ // require a Symbol description
213
+ // https://eslint.org/docs/rules/symbol-description
214
+ 'symbol-description': 'error',
215
+
216
+ // enforce usage of spacing in template strings
217
+ // https://eslint.org/docs/rules/template-curly-spacing
218
+ 'template-curly-spacing': 'error',
219
+
220
+ // enforce spacing around the * in yield* expressions
221
+ // https://eslint.org/docs/rules/yield-star-spacing
222
+ 'yield-star-spacing': ['error', 'after'],
223
+ },
224
+ } satisfies Linter.Config;