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