@w5s/eslint-config 3.0.2 → 3.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.
- package/dist/index.d.ts +539 -415
- package/dist/index.js +554 -3033
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/src/config/createRules.ts +7 -3
- package/src/config/es.ts +5 -1
- package/src/config/stylistic.ts +2 -2
- package/src/rules/esRules/bestPractices.ts +424 -0
- package/src/rules/esRules/errors.ts +189 -0
- package/src/rules/esRules/overrides.ts +28 -0
- package/src/rules/esRules.ts +8 -0
- package/src/typegen/import.d.ts +0 -1
- package/src/typegen/jsdoc.d.ts +0 -1
- package/src/typegen/jsonc.d.ts +0 -1
- package/src/typegen/node.d.ts +0 -1
- package/src/typegen/style.d.ts +291 -188
- package/src/typegen/test.d.ts +0 -1
- package/src/typegen/ts.d.ts +0 -1
- package/src/typegen/unicorn.d.ts +248 -220
- package/src/typegen/yml.d.ts +0 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
|
|
3
|
+
export const errors = () => ({
|
|
4
|
+
// Enforce “for” loop update clause moving the counter in the right direction
|
|
5
|
+
// https://eslint.org/docs/rules/for-direction
|
|
6
|
+
'for-direction': 'error',
|
|
7
|
+
|
|
8
|
+
// Enforces that a return statement is present in property getters
|
|
9
|
+
// https://eslint.org/docs/rules/getter-return
|
|
10
|
+
'getter-return': ['error', { allowImplicit: true }],
|
|
11
|
+
|
|
12
|
+
// disallow using an async function as a Promise executor
|
|
13
|
+
// https://eslint.org/docs/rules/no-async-promise-executor
|
|
14
|
+
'no-async-promise-executor': 'error',
|
|
15
|
+
|
|
16
|
+
// Disallow await inside of loops
|
|
17
|
+
// https://eslint.org/docs/rules/no-await-in-loop
|
|
18
|
+
'no-await-in-loop': 'error',
|
|
19
|
+
|
|
20
|
+
// Disallow comparisons to negative zero
|
|
21
|
+
// https://eslint.org/docs/rules/no-compare-neg-zero
|
|
22
|
+
'no-compare-neg-zero': 'error',
|
|
23
|
+
|
|
24
|
+
// disallow assignment in conditional expressions
|
|
25
|
+
'no-cond-assign': ['error', 'always'],
|
|
26
|
+
|
|
27
|
+
// disallow use of console
|
|
28
|
+
'no-console': 'warn',
|
|
29
|
+
|
|
30
|
+
// Disallows expressions where the operation doesn't affect the value
|
|
31
|
+
// https://eslint.org/docs/rules/no-constant-binary-expression
|
|
32
|
+
// TODO: semver-major, enable
|
|
33
|
+
'no-constant-binary-expression': 'off',
|
|
34
|
+
|
|
35
|
+
// disallow use of constant expressions in conditions
|
|
36
|
+
'no-constant-condition': 'warn',
|
|
37
|
+
|
|
38
|
+
// disallow control characters in regular expressions
|
|
39
|
+
'no-control-regex': 'error',
|
|
40
|
+
|
|
41
|
+
// disallow use of debugger
|
|
42
|
+
'no-debugger': 'error',
|
|
43
|
+
|
|
44
|
+
// disallow duplicate arguments in functions
|
|
45
|
+
'no-dupe-args': 'error',
|
|
46
|
+
|
|
47
|
+
// Disallow duplicate conditions in if-else-if chains
|
|
48
|
+
// https://eslint.org/docs/rules/no-dupe-else-if
|
|
49
|
+
'no-dupe-else-if': 'error',
|
|
50
|
+
|
|
51
|
+
// disallow duplicate keys when creating object literals
|
|
52
|
+
'no-dupe-keys': 'error',
|
|
53
|
+
|
|
54
|
+
// disallow a duplicate case label.
|
|
55
|
+
'no-duplicate-case': 'error',
|
|
56
|
+
|
|
57
|
+
// disallow empty statements
|
|
58
|
+
'no-empty': 'error',
|
|
59
|
+
|
|
60
|
+
// disallow the use of empty character classes in regular expressions
|
|
61
|
+
'no-empty-character-class': 'error',
|
|
62
|
+
|
|
63
|
+
// disallow assigning to the exception in a catch block
|
|
64
|
+
'no-ex-assign': 'error',
|
|
65
|
+
|
|
66
|
+
// disallow double-negation boolean casts in a boolean context
|
|
67
|
+
// https://eslint.org/docs/rules/no-extra-boolean-cast
|
|
68
|
+
'no-extra-boolean-cast': 'error',
|
|
69
|
+
|
|
70
|
+
// disallow unnecessary parentheses
|
|
71
|
+
// https://eslint.org/docs/rules/no-extra-parens
|
|
72
|
+
'no-extra-parens': ['off', 'all', {
|
|
73
|
+
conditionalAssign: true,
|
|
74
|
+
nestedBinaryExpressions: false,
|
|
75
|
+
returnAssign: false,
|
|
76
|
+
ignoreJSX: 'all', // delegate to eslint-plugin-react
|
|
77
|
+
enforceForArrowConditionals: false,
|
|
78
|
+
}],
|
|
79
|
+
|
|
80
|
+
// disallow unnecessary semicolons
|
|
81
|
+
'no-extra-semi': 'error',
|
|
82
|
+
|
|
83
|
+
// disallow overwriting functions written as function declarations
|
|
84
|
+
'no-func-assign': 'error',
|
|
85
|
+
|
|
86
|
+
// https://eslint.org/docs/rules/no-import-assign
|
|
87
|
+
'no-import-assign': 'error',
|
|
88
|
+
|
|
89
|
+
// disallow function or variable declarations in nested blocks
|
|
90
|
+
'no-inner-declarations': 'error',
|
|
91
|
+
|
|
92
|
+
// disallow invalid regular expression strings in the RegExp constructor
|
|
93
|
+
'no-invalid-regexp': 'error',
|
|
94
|
+
|
|
95
|
+
// disallow irregular whitespace outside of strings and comments
|
|
96
|
+
'no-irregular-whitespace': 'error',
|
|
97
|
+
|
|
98
|
+
// Disallow Number Literals That Lose Precision
|
|
99
|
+
// https://eslint.org/docs/rules/no-loss-of-precision
|
|
100
|
+
'no-loss-of-precision': 'error',
|
|
101
|
+
|
|
102
|
+
// Disallow characters which are made with multiple code points in character class syntax
|
|
103
|
+
// https://eslint.org/docs/rules/no-misleading-character-class
|
|
104
|
+
'no-misleading-character-class': 'error',
|
|
105
|
+
|
|
106
|
+
// disallow the use of object properties of the global object (Math and JSON) as functions
|
|
107
|
+
'no-obj-calls': 'error',
|
|
108
|
+
|
|
109
|
+
// Disallow new operators with global non-constructor functions
|
|
110
|
+
// https://eslint.org/docs/latest/rules/no-new-native-nonconstructor
|
|
111
|
+
// TODO: semver-major, enable
|
|
112
|
+
'no-new-native-nonconstructor': 'off',
|
|
113
|
+
|
|
114
|
+
// Disallow returning values from Promise executor functions
|
|
115
|
+
// https://eslint.org/docs/rules/no-promise-executor-return
|
|
116
|
+
'no-promise-executor-return': 'error',
|
|
117
|
+
|
|
118
|
+
// disallow use of Object.prototypes builtins directly
|
|
119
|
+
// https://eslint.org/docs/rules/no-prototype-builtins
|
|
120
|
+
'no-prototype-builtins': 'error',
|
|
121
|
+
|
|
122
|
+
// disallow multiple spaces in a regular expression literal
|
|
123
|
+
'no-regex-spaces': 'error',
|
|
124
|
+
|
|
125
|
+
// Disallow returning values from setters
|
|
126
|
+
// https://eslint.org/docs/rules/no-setter-return
|
|
127
|
+
'no-setter-return': 'error',
|
|
128
|
+
|
|
129
|
+
// disallow sparse arrays
|
|
130
|
+
'no-sparse-arrays': 'error',
|
|
131
|
+
|
|
132
|
+
// Disallow template literal placeholder syntax in regular strings
|
|
133
|
+
// https://eslint.org/docs/rules/no-template-curly-in-string
|
|
134
|
+
'no-template-curly-in-string': 'error',
|
|
135
|
+
|
|
136
|
+
// Avoid code that looks like two expressions but is actually one
|
|
137
|
+
// https://eslint.org/docs/rules/no-unexpected-multiline
|
|
138
|
+
'no-unexpected-multiline': 'error',
|
|
139
|
+
|
|
140
|
+
// disallow unreachable statements after a return, throw, continue, or break statement
|
|
141
|
+
'no-unreachable': 'error',
|
|
142
|
+
|
|
143
|
+
// Disallow loops with a body that allows only one iteration
|
|
144
|
+
// https://eslint.org/docs/rules/no-unreachable-loop
|
|
145
|
+
'no-unreachable-loop': ['error', {
|
|
146
|
+
ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
|
|
147
|
+
}],
|
|
148
|
+
|
|
149
|
+
// disallow return/throw/break/continue inside finally blocks
|
|
150
|
+
// https://eslint.org/docs/rules/no-unsafe-finally
|
|
151
|
+
'no-unsafe-finally': 'error',
|
|
152
|
+
|
|
153
|
+
// disallow negating the left operand of relational operators
|
|
154
|
+
// https://eslint.org/docs/rules/no-unsafe-negation
|
|
155
|
+
'no-unsafe-negation': 'error',
|
|
156
|
+
|
|
157
|
+
// disallow use of optional chaining in contexts where the undefined value is not allowed
|
|
158
|
+
// https://eslint.org/docs/rules/no-unsafe-optional-chaining
|
|
159
|
+
'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
|
|
160
|
+
|
|
161
|
+
// Disallow Unused Private Class Members
|
|
162
|
+
// https://eslint.org/docs/rules/no-unused-private-class-members
|
|
163
|
+
// TODO: enable once eslint 7 is dropped (which is semver-major)
|
|
164
|
+
'no-unused-private-class-members': 'off',
|
|
165
|
+
|
|
166
|
+
// Disallow useless backreferences in regular expressions
|
|
167
|
+
// https://eslint.org/docs/rules/no-useless-backreference
|
|
168
|
+
'no-useless-backreference': 'error',
|
|
169
|
+
|
|
170
|
+
// disallow negation of the left operand of an in expression
|
|
171
|
+
// deprecated in favor of no-unsafe-negation
|
|
172
|
+
'no-negated-in-lhs': 'off',
|
|
173
|
+
|
|
174
|
+
// Disallow assignments that can lead to race conditions due to usage of await or yield
|
|
175
|
+
// https://eslint.org/docs/rules/require-atomic-updates
|
|
176
|
+
// note: not enabled because it is very buggy
|
|
177
|
+
'require-atomic-updates': 'off',
|
|
178
|
+
|
|
179
|
+
// disallow comparisons with the value NaN
|
|
180
|
+
'use-isnan': 'error',
|
|
181
|
+
|
|
182
|
+
// ensure JSDoc comments are valid
|
|
183
|
+
// https://eslint.org/docs/rules/valid-jsdoc
|
|
184
|
+
'valid-jsdoc': 'off',
|
|
185
|
+
|
|
186
|
+
// ensure that the results of typeof are compared against a valid string
|
|
187
|
+
// https://eslint.org/docs/rules/valid-typeof
|
|
188
|
+
'valid-typeof': ['error', { requireStringLiterals: true }],
|
|
189
|
+
} satisfies Linter.RulesRecord);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
|
|
3
|
+
export const overrides = () => ({
|
|
4
|
+
// Too many errors in components
|
|
5
|
+
'class-methods-use-this': 'off',
|
|
6
|
+
// Annoying because it is not always wanted
|
|
7
|
+
'default-case': 'off',
|
|
8
|
+
// We do not want console.* in production. Disable this rule on a per line basis if needed
|
|
9
|
+
'no-console': 'error',
|
|
10
|
+
// Often useful in jsx
|
|
11
|
+
'no-nested-ternary': 'off',
|
|
12
|
+
// Too strict, for pure code prefer the functional plugin
|
|
13
|
+
'no-param-reassign': ['error', { props: false }],
|
|
14
|
+
// Allow for-of syntax
|
|
15
|
+
// 'no-restricted-syntax': baseConfig.rules['no-restricted-syntax'].filter(
|
|
16
|
+
// // @ts-ignore No typing available
|
|
17
|
+
// ({ selector }) => selector !== 'ForOfStatement',
|
|
18
|
+
// ),
|
|
19
|
+
// underscore is often used (mongodb, etc)
|
|
20
|
+
'no-underscore-dangle': 'off',
|
|
21
|
+
// Ignore underscore case arguments
|
|
22
|
+
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
23
|
+
// Allow in some cases https://github.com/airbnb/javascript/issues/1089#issuecomment-1024351821
|
|
24
|
+
'no-use-before-define': ['error', 'nofunc'],
|
|
25
|
+
// Allow statements, to be compatible with '@typescript-eslint/no-floating-promises' fix
|
|
26
|
+
'no-void': ['error', { allowAsStatement: true }],
|
|
27
|
+
'unicode-bom': ['error', 'never'],
|
|
28
|
+
} satisfies Linter.RulesRecord);
|
package/src/typegen/import.d.ts
CHANGED
package/src/typegen/jsdoc.d.ts
CHANGED
package/src/typegen/jsonc.d.ts
CHANGED
package/src/typegen/node.d.ts
CHANGED