@jsse/eslint-config 0.4.9 → 0.4.11
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/cli.js +9 -6
- package/dist/index.d.ts +2 -1
- package/dist/index.js +29 -123
- package/dist/version-Cmu7XVG1.js +39 -0
- package/package.json +12 -9
- package/dist/esm/cli.d.ts +0 -1
- package/dist/esm/cli.js +0 -121
- package/dist/esm/config-fns.d.ts +0 -138
- package/dist/esm/config-fns.js +0 -161
- package/dist/esm/configs/antfu.d.ts +0 -4
- package/dist/esm/configs/antfu.js +0 -30
- package/dist/esm/configs/command.d.ts +0 -10
- package/dist/esm/configs/command.js +0 -17
- package/dist/esm/configs/de-morgan.d.ts +0 -2
- package/dist/esm/configs/de-morgan.js +0 -9
- package/dist/esm/configs/eslint-comments.d.ts +0 -2
- package/dist/esm/configs/eslint-comments.js +0 -16
- package/dist/esm/configs/gql.d.ts +0 -2
- package/dist/esm/configs/gql.js +0 -4
- package/dist/esm/configs/ignores.d.ts +0 -2
- package/dist/esm/configs/ignores.js +0 -9
- package/dist/esm/configs/imports.d.ts +0 -2
- package/dist/esm/configs/imports.js +0 -28
- package/dist/esm/configs/javascript.d.ts +0 -6
- package/dist/esm/configs/javascript.js +0 -262
- package/dist/esm/configs/jsdoc.d.ts +0 -2
- package/dist/esm/configs/jsdoc.js +0 -31
- package/dist/esm/configs/jsonc.d.ts +0 -4
- package/dist/esm/configs/jsonc.js +0 -76
- package/dist/esm/configs/markdown.d.ts +0 -4
- package/dist/esm/configs/markdown.js +0 -122
- package/dist/esm/configs/n.d.ts +0 -2
- package/dist/esm/configs/n.js +0 -21
- package/dist/esm/configs/no-only-tests.d.ts +0 -4
- package/dist/esm/configs/no-only-tests.js +0 -31
- package/dist/esm/configs/perfectionist.d.ts +0 -7
- package/dist/esm/configs/perfectionist.js +0 -60
- package/dist/esm/configs/pnpm.d.ts +0 -2
- package/dist/esm/configs/pnpm.js +0 -34
- package/dist/esm/configs/prettier.d.ts +0 -7
- package/dist/esm/configs/prettier.js +0 -126
- package/dist/esm/configs/react.d.ts +0 -6
- package/dist/esm/configs/react.js +0 -300
- package/dist/esm/configs/sort-package-json.d.ts +0 -7
- package/dist/esm/configs/sort-package-json.js +0 -102
- package/dist/esm/configs/sort-tsconfig.d.ts +0 -14
- package/dist/esm/configs/sort-tsconfig.js +0 -135
- package/dist/esm/configs/stylistic.d.ts +0 -2
- package/dist/esm/configs/stylistic.js +0 -39
- package/dist/esm/configs/tailwind.d.ts +0 -1
- package/dist/esm/configs/tailwind.js +0 -81
- package/dist/esm/configs/toml.d.ts +0 -2
- package/dist/esm/configs/toml.js +0 -50
- package/dist/esm/configs/ts/parser.d.ts +0 -7
- package/dist/esm/configs/ts/parser.js +0 -71
- package/dist/esm/configs/ts/requires-type-checking.d.ts +0 -1
- package/dist/esm/configs/ts/requires-type-checking.js +0 -61
- package/dist/esm/configs/ts/typescript-language-options.d.ts +0 -2
- package/dist/esm/configs/ts/typescript-language-options.js +0 -22
- package/dist/esm/configs/ts/typescript-rules.d.ts +0 -11
- package/dist/esm/configs/ts/typescript-rules.js +0 -379
- package/dist/esm/configs/ts/typescript.d.ts +0 -4
- package/dist/esm/configs/ts/typescript.js +0 -123
- package/dist/esm/configs/tsdoc.d.ts +0 -2
- package/dist/esm/configs/tsdoc.js +0 -16
- package/dist/esm/configs/unicorn.d.ts +0 -2
- package/dist/esm/configs/unicorn.js +0 -114
- package/dist/esm/configs/vitest.d.ts +0 -4
- package/dist/esm/configs/vitest.js +0 -29
- package/dist/esm/configs/yml.d.ts +0 -4
- package/dist/esm/configs/yml.js +0 -51
- package/dist/esm/const.d.ts +0 -5
- package/dist/esm/const.js +0 -25
- package/dist/esm/define-config.d.ts +0 -7
- package/dist/esm/define-config.js +0 -256
- package/dist/esm/dev.d.ts +0 -4
- package/dist/esm/dev.js +0 -25
- package/dist/esm/fixable.d.ts +0 -2
- package/dist/esm/fixable.js +0 -4
- package/dist/esm/generated/fixable-rules-map.d.ts +0 -2
- package/dist/esm/generated/fixable-rules-map.js +0 -443
- package/dist/esm/generated/version.d.ts +0 -1
- package/dist/esm/generated/version.js +0 -1
- package/dist/esm/globs.d.ts +0 -25
- package/dist/esm/globs.js +0 -73
- package/dist/esm/index.d.ts +0 -9
- package/dist/esm/index.js +0 -8
- package/dist/esm/lager.d.ts +0 -32
- package/dist/esm/lager.js +0 -87
- package/dist/esm/log.d.ts +0 -2
- package/dist/esm/log.js +0 -2
- package/dist/esm/plugins-all.d.ts +0 -26
- package/dist/esm/plugins-all.js +0 -120
- package/dist/esm/plugins.d.ts +0 -1570
- package/dist/esm/plugins.js +0 -97
- package/dist/esm/presets.d.ts +0 -18
- package/dist/esm/presets.js +0 -75
- package/dist/esm/types.d.ts +0 -287
- package/dist/esm/types.js +0 -1
- package/dist/esm/utils.d.ts +0 -51
- package/dist/esm/utils.js +0 -156
- package/dist/version-DNhPWuQE.js +0 -5
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
/* eslint-disable perfectionist/sort-objects */
|
|
2
|
-
import tseslint, {} from "typescript-eslint";
|
|
3
|
-
import { dbg } from "../../lager.js";
|
|
4
|
-
const extractRules = (configs) => {
|
|
5
|
-
const rules = configs
|
|
6
|
-
.filter((config) => config.rules !== undefined)
|
|
7
|
-
.map((config) => config.rules ?? {});
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
9
|
-
return Object.assign({}, ...rules);
|
|
10
|
-
};
|
|
11
|
-
export function typescriptRulesTypeAware(props) {
|
|
12
|
-
const tsRecomendedRulesTypeChecked = props?.strict
|
|
13
|
-
? extractRules(tseslint.configs.strictTypeChecked)
|
|
14
|
-
: extractRules(tseslint.configs.recommendedTypeChecked);
|
|
15
|
-
return {
|
|
16
|
-
...tsRecomendedRulesTypeChecked,
|
|
17
|
-
"@typescript-eslint/await-thenable": "error",
|
|
18
|
-
"@typescript-eslint/no-for-in-array": "error",
|
|
19
|
-
"no-implied-eval": "off",
|
|
20
|
-
"@typescript-eslint/consistent-type-exports": [
|
|
21
|
-
"error",
|
|
22
|
-
{
|
|
23
|
-
fixMixedExportsWithInlineTypeSpecifier: true,
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
"dot-notation": "off",
|
|
27
|
-
"@typescript-eslint/dot-notation": [
|
|
28
|
-
"error",
|
|
29
|
-
{
|
|
30
|
-
allowPattern: "^_",
|
|
31
|
-
allowKeywords: true,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
"@typescript-eslint/no-implied-eval": "error",
|
|
35
|
-
"@typescript-eslint/no-misused-promises": "error",
|
|
36
|
-
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
37
|
-
"@typescript-eslint/no-unnecessary-type-arguments": "off",
|
|
38
|
-
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
39
|
-
// "@typescript-eslint/no-useless-template-literals": "error",
|
|
40
|
-
"no-throw-literal": "off",
|
|
41
|
-
"@typescript-eslint/only-throw-error": "error",
|
|
42
|
-
"@typescript-eslint/no-unsafe-argument": "error",
|
|
43
|
-
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
44
|
-
"@typescript-eslint/no-unsafe-call": "error",
|
|
45
|
-
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
46
|
-
"@typescript-eslint/no-unsafe-return": "error",
|
|
47
|
-
"@typescript-eslint/restrict-plus-operands": "error",
|
|
48
|
-
"@typescript-eslint/restrict-template-expressions": "error",
|
|
49
|
-
"@typescript-eslint/unbound-method": "error",
|
|
50
|
-
"@typescript-eslint/no-redundant-type-constituents": "warn",
|
|
51
|
-
"@typescript-eslint/require-array-sort-compare": [
|
|
52
|
-
"error",
|
|
53
|
-
{ ignoreStringArrays: true },
|
|
54
|
-
],
|
|
55
|
-
"@typescript-eslint/naming-convention": [
|
|
56
|
-
"error",
|
|
57
|
-
{
|
|
58
|
-
selector: ["variable"],
|
|
59
|
-
modifiers: ["global"],
|
|
60
|
-
format: ["camelCase", "snake_case", "UPPER_CASE", "PascalCase"],
|
|
61
|
-
leadingUnderscore: "allowSingleOrDouble",
|
|
62
|
-
trailingUnderscore: "allow",
|
|
63
|
-
filter: {
|
|
64
|
-
regex: "[- ]",
|
|
65
|
-
match: false,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
selector: [
|
|
70
|
-
"classProperty",
|
|
71
|
-
"objectLiteralProperty",
|
|
72
|
-
"typeProperty",
|
|
73
|
-
"classMethod",
|
|
74
|
-
"objectLiteralMethod",
|
|
75
|
-
"typeMethod",
|
|
76
|
-
"accessor",
|
|
77
|
-
"enumMember",
|
|
78
|
-
],
|
|
79
|
-
// eslint-disable-next-line unicorn/no-null
|
|
80
|
-
format: null,
|
|
81
|
-
modifiers: ["requiresQuotes"],
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
selector: [
|
|
85
|
-
"variable",
|
|
86
|
-
"function",
|
|
87
|
-
"classProperty",
|
|
88
|
-
"objectLiteralProperty",
|
|
89
|
-
"parameterProperty",
|
|
90
|
-
"classMethod",
|
|
91
|
-
"objectLiteralMethod",
|
|
92
|
-
"typeMethod",
|
|
93
|
-
"accessor",
|
|
94
|
-
],
|
|
95
|
-
format: ["camelCase", "snake_case", "PascalCase"],
|
|
96
|
-
leadingUnderscore: "allowSingleOrDouble",
|
|
97
|
-
trailingUnderscore: "allow",
|
|
98
|
-
filter: {
|
|
99
|
-
// also allow when '/' is in object key
|
|
100
|
-
regex: "^[0-9]|[- ]|[/]",
|
|
101
|
-
match: false,
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
selector: "typeLike",
|
|
106
|
-
format: ["PascalCase"],
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
selector: "variable",
|
|
110
|
-
types: ["boolean"],
|
|
111
|
-
format: ["PascalCase", "camelCase"],
|
|
112
|
-
prefix: ["is", "has", "can", "should", "will", "did"],
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
selector: "interface",
|
|
116
|
-
format: ["PascalCase"],
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
selector: "typeParameter",
|
|
120
|
-
filter: "^T$|^[A-Z][a-zA-Z]+$",
|
|
121
|
-
format: ["PascalCase"],
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
"@typescript-eslint/no-floating-promises": [
|
|
125
|
-
"error",
|
|
126
|
-
{
|
|
127
|
-
ignoreVoid: true,
|
|
128
|
-
ignoreIIFE: true,
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
export function typescriptRulesTypeOblivious(props) {
|
|
134
|
-
const tseslintBaseRules = props?.strict
|
|
135
|
-
? extractRules(tseslint.configs.strict)
|
|
136
|
-
: extractRules(tseslint.configs.recommended);
|
|
137
|
-
return {
|
|
138
|
-
...tseslintBaseRules,
|
|
139
|
-
eqeqeq: "error",
|
|
140
|
-
camelcase: "off",
|
|
141
|
-
yoda: "error",
|
|
142
|
-
"arrow-parens": "off",
|
|
143
|
-
"no-console": [
|
|
144
|
-
"warn",
|
|
145
|
-
{
|
|
146
|
-
allow: ["warn", "error"],
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
"object-curly-spacing": "off",
|
|
150
|
-
"@typescript-eslint/object-curly-spacing": "off",
|
|
151
|
-
"@typescript-eslint/no-inferrable-types": "off",
|
|
152
|
-
"@typescript-eslint/prefer-ts-expect-error": "error",
|
|
153
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
154
|
-
"error",
|
|
155
|
-
{
|
|
156
|
-
prefer: "type-imports",
|
|
157
|
-
fixStyle: "separate-type-imports",
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
161
|
-
"@typescript-eslint/consistent-type-assertions": "error",
|
|
162
|
-
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
|
163
|
-
"@typescript-eslint/member-ordering": [
|
|
164
|
-
"warn",
|
|
165
|
-
{
|
|
166
|
-
default: "never",
|
|
167
|
-
classes: ["field", "constructor", "method"],
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
"no-array-constructor": "off",
|
|
171
|
-
"@typescript-eslint/no-array-constructor": "error",
|
|
172
|
-
"@typescript-eslint/no-explicit-any": "error",
|
|
173
|
-
"@typescript-eslint/no-misused-new": "error",
|
|
174
|
-
"@typescript-eslint/no-namespace": [
|
|
175
|
-
"error",
|
|
176
|
-
{
|
|
177
|
-
allowDeclarations: false,
|
|
178
|
-
allowDefinitionFiles: false,
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
"no-unused-vars": "off",
|
|
182
|
-
"@typescript-eslint/no-unused-vars": [
|
|
183
|
-
"warn",
|
|
184
|
-
{
|
|
185
|
-
vars: "all",
|
|
186
|
-
args: "none",
|
|
187
|
-
argsIgnorePattern: "^_",
|
|
188
|
-
varsIgnorePattern: "^_",
|
|
189
|
-
caughtErrorsIgnorePattern: "^_",
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
"no-use-before-define": "off",
|
|
193
|
-
"@typescript-eslint/no-use-before-define": [
|
|
194
|
-
"error",
|
|
195
|
-
{
|
|
196
|
-
functions: true,
|
|
197
|
-
classes: true,
|
|
198
|
-
variables: true,
|
|
199
|
-
enums: true,
|
|
200
|
-
typedefs: true,
|
|
201
|
-
},
|
|
202
|
-
],
|
|
203
|
-
"@typescript-eslint/prefer-namespace-keyword": "warn",
|
|
204
|
-
"@typescript-eslint/typedef": [
|
|
205
|
-
"warn",
|
|
206
|
-
{
|
|
207
|
-
arrayDestructuring: false,
|
|
208
|
-
arrowParameter: false,
|
|
209
|
-
memberVariableDeclaration: true,
|
|
210
|
-
objectDestructuring: false,
|
|
211
|
-
parameter: true,
|
|
212
|
-
propertyDeclaration: true,
|
|
213
|
-
variableDeclaration: false,
|
|
214
|
-
variableDeclarationIgnoreFunction: true,
|
|
215
|
-
},
|
|
216
|
-
],
|
|
217
|
-
"accessor-pairs": "error",
|
|
218
|
-
"for-direction": "warn",
|
|
219
|
-
"guard-for-in": "error",
|
|
220
|
-
"max-lines": [
|
|
221
|
-
"warn",
|
|
222
|
-
{
|
|
223
|
-
max: 2000,
|
|
224
|
-
},
|
|
225
|
-
],
|
|
226
|
-
"no-async-promise-executor": "error",
|
|
227
|
-
"no-bitwise": "off", // bit ops are so hot right now
|
|
228
|
-
"no-caller": "error",
|
|
229
|
-
"no-compare-neg-zero": "error",
|
|
230
|
-
"no-cond-assign": "error",
|
|
231
|
-
"no-constant-condition": "warn",
|
|
232
|
-
"no-control-regex": "error",
|
|
233
|
-
"no-debugger": "warn",
|
|
234
|
-
"no-delete-var": "error",
|
|
235
|
-
"no-duplicate-case": "error",
|
|
236
|
-
"no-empty": "warn",
|
|
237
|
-
"no-empty-character-class": "error",
|
|
238
|
-
"no-empty-pattern": "warn",
|
|
239
|
-
"no-eval": "warn",
|
|
240
|
-
"no-ex-assign": "error",
|
|
241
|
-
"no-extend-native": "error",
|
|
242
|
-
"no-extra-boolean-cast": "warn",
|
|
243
|
-
"no-extra-label": "warn",
|
|
244
|
-
"no-fallthrough": "error",
|
|
245
|
-
"no-func-assign": "warn",
|
|
246
|
-
"no-implied-eval": "error",
|
|
247
|
-
"no-invalid-regexp": "error",
|
|
248
|
-
"no-label-var": "error",
|
|
249
|
-
"no-lone-blocks": "warn",
|
|
250
|
-
"no-misleading-character-class": "error",
|
|
251
|
-
"no-multi-str": "error",
|
|
252
|
-
"no-new": "warn",
|
|
253
|
-
"no-new-func": "error",
|
|
254
|
-
"no-new-wrappers": "warn",
|
|
255
|
-
"no-octal": "error",
|
|
256
|
-
"no-octal-escape": "error",
|
|
257
|
-
"no-regex-spaces": "error",
|
|
258
|
-
"no-return-assign": "error",
|
|
259
|
-
"no-script-url": "warn",
|
|
260
|
-
"no-self-assign": "error",
|
|
261
|
-
"no-self-compare": "error",
|
|
262
|
-
"no-sequences": "error",
|
|
263
|
-
"no-shadow-restricted-names": "error",
|
|
264
|
-
"no-sparse-arrays": "error",
|
|
265
|
-
"no-unmodified-loop-condition": "warn",
|
|
266
|
-
"no-unsafe-finally": "error",
|
|
267
|
-
"no-unused-expressions": "off",
|
|
268
|
-
"@typescript-eslint/no-unused-expressions": "error",
|
|
269
|
-
"no-unused-labels": "error",
|
|
270
|
-
"no-useless-catch": "warn",
|
|
271
|
-
"no-useless-concat": "error",
|
|
272
|
-
"no-var": "error",
|
|
273
|
-
"no-void": [
|
|
274
|
-
"error",
|
|
275
|
-
{
|
|
276
|
-
allowAsStatement: true,
|
|
277
|
-
},
|
|
278
|
-
],
|
|
279
|
-
"no-with": "error",
|
|
280
|
-
"prefer-const": "error",
|
|
281
|
-
"require-atomic-updates": "error",
|
|
282
|
-
"require-yield": "warn",
|
|
283
|
-
strict: ["error", "never"],
|
|
284
|
-
"use-isnan": "error",
|
|
285
|
-
"no-useless-constructor": "off",
|
|
286
|
-
"@typescript-eslint/no-useless-constructor": "error",
|
|
287
|
-
"@typescript-eslint/no-unnecessary-type-constraint": "error",
|
|
288
|
-
"@typescript-eslint/brace-style": [
|
|
289
|
-
"error",
|
|
290
|
-
"1tbs",
|
|
291
|
-
{
|
|
292
|
-
allowSingleLine: false,
|
|
293
|
-
},
|
|
294
|
-
],
|
|
295
|
-
"comma-spacing": "off",
|
|
296
|
-
"@typescript-eslint/comma-spacing": [
|
|
297
|
-
"error",
|
|
298
|
-
{
|
|
299
|
-
before: false,
|
|
300
|
-
after: true,
|
|
301
|
-
},
|
|
302
|
-
],
|
|
303
|
-
"default-param-last": "off",
|
|
304
|
-
"@typescript-eslint/default-param-last": "error",
|
|
305
|
-
// "func-call-spacing": "off",
|
|
306
|
-
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
|
307
|
-
// "keyword-spacing": "off",
|
|
308
|
-
"@typescript-eslint/keyword-spacing": "error",
|
|
309
|
-
// "lines-between-class-members": "off",
|
|
310
|
-
// "@typescript-eslint/lines-between-class-members": [
|
|
311
|
-
// "error",
|
|
312
|
-
// "always",
|
|
313
|
-
// {
|
|
314
|
-
// exceptAfterSingleLine: true,
|
|
315
|
-
// },
|
|
316
|
-
// ],
|
|
317
|
-
"no-dupe-class-members": "off",
|
|
318
|
-
"@typescript-eslint/no-dupe-class-members": "error",
|
|
319
|
-
"no-empty-function": "off",
|
|
320
|
-
"@typescript-eslint/no-empty-function": "error",
|
|
321
|
-
// "no-extra-parens": "off",
|
|
322
|
-
// "no-extra-semi": "off",
|
|
323
|
-
"@typescript-eslint/no-extra-semi": "error",
|
|
324
|
-
"no-loop-func": "off",
|
|
325
|
-
"@typescript-eslint/no-loop-func": "error",
|
|
326
|
-
"no-loss-of-precision": "off",
|
|
327
|
-
"no-redeclare": "off",
|
|
328
|
-
"@typescript-eslint/no-redeclare": "error",
|
|
329
|
-
"no-restricted-imports": "off",
|
|
330
|
-
"@typescript-eslint/no-restricted-imports": [
|
|
331
|
-
"error",
|
|
332
|
-
{
|
|
333
|
-
paths: [
|
|
334
|
-
"error",
|
|
335
|
-
"domain",
|
|
336
|
-
"freelist",
|
|
337
|
-
"smalloc",
|
|
338
|
-
"punycode",
|
|
339
|
-
"sys",
|
|
340
|
-
"querystring",
|
|
341
|
-
"colors",
|
|
342
|
-
],
|
|
343
|
-
},
|
|
344
|
-
],
|
|
345
|
-
// "padding-line-between-statements": "off",
|
|
346
|
-
"@typescript-eslint/padding-line-between-statements": "off",
|
|
347
|
-
// quotes: "off",
|
|
348
|
-
"@typescript-eslint/quotes": "off",
|
|
349
|
-
// "space-before-function-paren": "off",
|
|
350
|
-
"@typescript-eslint/space-before-function-paren": "off",
|
|
351
|
-
// "space-infix-ops": "off",
|
|
352
|
-
"@typescript-eslint/space-infix-ops": "error",
|
|
353
|
-
// semi: "off",
|
|
354
|
-
"@typescript-eslint/semi": ["error", "always"],
|
|
355
|
-
// "space-before-blocks": "off",
|
|
356
|
-
"@typescript-eslint/space-before-blocks": ["error", "always"],
|
|
357
|
-
"no-undef": "off",
|
|
358
|
-
"no-duplicate-imports": "off",
|
|
359
|
-
"@typescript-eslint/method-signature-style": "warn",
|
|
360
|
-
/**
|
|
361
|
-
* @todo
|
|
362
|
-
*/
|
|
363
|
-
// "@typescript-eslint/explicit-function-return-type": [
|
|
364
|
-
// "warn",
|
|
365
|
-
// { allowExpressions: true, allowTypedFunctionExpressions: true },
|
|
366
|
-
// ],
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
export function typescriptRules(props) {
|
|
370
|
-
const normalized = { typeAware: false, strict: false, ...props };
|
|
371
|
-
dbg("building typescript rules: %O", normalized);
|
|
372
|
-
if (normalized.typeAware) {
|
|
373
|
-
return {
|
|
374
|
-
...typescriptRulesTypeOblivious({ strict: normalized.strict }),
|
|
375
|
-
...typescriptRulesTypeAware({ strict: normalized.strict }),
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
return typescriptRulesTypeOblivious({ strict: normalized.strict });
|
|
379
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { EslintConfigFn, OptionsComponentExts, OptionsOverrides, OptionsPrefix, OptionsReact, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes } from "../../types.js";
|
|
2
|
-
type TypescriptOptions = OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & OptionsReact & OptionsPrefix;
|
|
3
|
-
export declare const typescript: EslintConfigFn<TypescriptOptions>;
|
|
4
|
-
export {};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { GLOB_MARKDOWN, GLOB_TS, GLOB_TSX } from "../../globs.js";
|
|
2
|
-
import { dbg } from "../../lager.js";
|
|
3
|
-
import { pluginImportLite, pluginTs } from "../../plugins.js";
|
|
4
|
-
import { renameRules } from "../../utils.js";
|
|
5
|
-
import { typescriptParser } from "./parser.js";
|
|
6
|
-
import { typescriptRules } from "./typescript-rules.js";
|
|
7
|
-
export const typescript = async (options) => {
|
|
8
|
-
dbg("typescript-options: %O", options);
|
|
9
|
-
const { componentExts = [], filesTypeAware = [GLOB_TS, GLOB_TSX], ignoresTypeAware = [GLOB_MARKDOWN], overrides = {}, parserOptions = {}, prefix, react = false, strict = false, tsconfig: tsconfigPath, typeAware = true, } = options ?? {};
|
|
10
|
-
const parserConfigs = typeAware
|
|
11
|
-
? [
|
|
12
|
-
typescriptParser({
|
|
13
|
-
filesTypeAware,
|
|
14
|
-
ignoresTypeAware,
|
|
15
|
-
parserOptions,
|
|
16
|
-
react,
|
|
17
|
-
tsconfig: tsconfigPath,
|
|
18
|
-
typeAware: true,
|
|
19
|
-
}),
|
|
20
|
-
typescriptParser({
|
|
21
|
-
filesTypeAware,
|
|
22
|
-
ignoresTypeAware,
|
|
23
|
-
parserOptions,
|
|
24
|
-
react,
|
|
25
|
-
tsconfig: tsconfigPath,
|
|
26
|
-
typeAware: false,
|
|
27
|
-
}),
|
|
28
|
-
]
|
|
29
|
-
: [
|
|
30
|
-
typescriptParser({
|
|
31
|
-
filesTypeAware,
|
|
32
|
-
ignoresTypeAware,
|
|
33
|
-
parserOptions,
|
|
34
|
-
react,
|
|
35
|
-
tsconfig: tsconfigPath,
|
|
36
|
-
typeAware: false,
|
|
37
|
-
}),
|
|
38
|
-
];
|
|
39
|
-
const tsPrefix = prefix?.from ?? "@typescript-eslint";
|
|
40
|
-
const tsPrefixTo = prefix?.to ?? "@typescript-eslint";
|
|
41
|
-
const tsRules = {
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
43
|
-
...(pluginTs.configs["eslint-recommended"]?.overrides ?? [])[0]?.rules,
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
45
|
-
...pluginTs.configs.strict?.rules,
|
|
46
|
-
"no-invalid-this": "off",
|
|
47
|
-
...typescriptRules({
|
|
48
|
-
strict,
|
|
49
|
-
typeAware,
|
|
50
|
-
}),
|
|
51
|
-
...overrides,
|
|
52
|
-
};
|
|
53
|
-
// =========================================================================
|
|
54
|
-
// BUILD THE CONFIG ARRAYS
|
|
55
|
-
// =========================================================================
|
|
56
|
-
const tsEslintConfigs = [
|
|
57
|
-
{
|
|
58
|
-
// Install the plugins without globs, so they can be configured separately.
|
|
59
|
-
name: "jsse/typescript/setup",
|
|
60
|
-
plugins: {
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
62
|
-
import: pluginImportLite,
|
|
63
|
-
[tsPrefixTo]: pluginTs,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
...parserConfigs,
|
|
67
|
-
// ========================================================================
|
|
68
|
-
// RULES - NOT TYPE AWARE
|
|
69
|
-
// ========================================================================
|
|
70
|
-
{
|
|
71
|
-
// only apply ts rules to ts files!
|
|
72
|
-
files: [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
|
|
73
|
-
name: "jsse/typescript/rules",
|
|
74
|
-
// may not need to rename all rules here........
|
|
75
|
-
rules: renameRules(tsRules, tsPrefix, tsPrefixTo),
|
|
76
|
-
},
|
|
77
|
-
];
|
|
78
|
-
// =========================================================================
|
|
79
|
-
// RULES - TYPE AWARE
|
|
80
|
-
// =========================================================================
|
|
81
|
-
if (typeAware) {
|
|
82
|
-
tsEslintConfigs.push({
|
|
83
|
-
files: filesTypeAware,
|
|
84
|
-
ignores: ignoresTypeAware,
|
|
85
|
-
name: "jsse/typescript/rules-type-aware",
|
|
86
|
-
rules: renameRules({
|
|
87
|
-
...typescriptRules({
|
|
88
|
-
strict,
|
|
89
|
-
typeAware: true,
|
|
90
|
-
}),
|
|
91
|
-
...overrides,
|
|
92
|
-
}, tsPrefix, tsPrefixTo),
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
// =========================================================================
|
|
96
|
-
// OVERRIDES
|
|
97
|
-
// =========================================================================
|
|
98
|
-
tsEslintConfigs.push({
|
|
99
|
-
files: ["**/*.d.ts"],
|
|
100
|
-
name: "jsse/typescript:disables/dts",
|
|
101
|
-
rules: {
|
|
102
|
-
"eslint-comments/no-unlimited-disable": "off",
|
|
103
|
-
"import/no-duplicates": "off",
|
|
104
|
-
"no-restricted-syntax": ["error", "[declare=true]"],
|
|
105
|
-
"unused-imports/no-unused-vars": "off",
|
|
106
|
-
},
|
|
107
|
-
}, {
|
|
108
|
-
files: ["**/*.{test,spec}.ts?(x)"],
|
|
109
|
-
name: "jsse/typescript:disable/test",
|
|
110
|
-
rules: {
|
|
111
|
-
"@typescript-eslint/no-unused-expressions": "off",
|
|
112
|
-
"no-unused-expressions": "off",
|
|
113
|
-
},
|
|
114
|
-
}, {
|
|
115
|
-
files: ["**/*.js", "**/*.cjs"],
|
|
116
|
-
name: "jsse/typescript/javascript-overrides",
|
|
117
|
-
rules: {
|
|
118
|
-
"@typescript-eslint/no-require-imports": "off",
|
|
119
|
-
"@typescript-eslint/no-var-requires": "off",
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
return tsEslintConfigs;
|
|
123
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { importPluginTsdoc } from "../plugins.js";
|
|
2
|
-
export const tsdoc = async () => {
|
|
3
|
-
const { pluginTsdoc } = await importPluginTsdoc();
|
|
4
|
-
return [
|
|
5
|
-
{
|
|
6
|
-
files: ["*.ts", "*.tsx"],
|
|
7
|
-
name: "jsse/tsdoc",
|
|
8
|
-
plugins: {
|
|
9
|
-
tsdoc: pluginTsdoc,
|
|
10
|
-
},
|
|
11
|
-
rules: {
|
|
12
|
-
"tsdoc/syntax": "warn",
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
];
|
|
16
|
-
};
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { GLOB_TESTS } from "src/globs.js";
|
|
2
|
-
import { pluginUnicorn } from "../plugins.js";
|
|
3
|
-
function unicornOff() {
|
|
4
|
-
return {
|
|
5
|
-
"unicorn/catch-error-name": "off",
|
|
6
|
-
"unicorn/consistent-destructuring": "off",
|
|
7
|
-
"unicorn/no-array-reduce": "off",
|
|
8
|
-
"unicorn/no-nested-ternary": "off", // conflicts with prettier
|
|
9
|
-
"unicorn/no-process-exit": "off",
|
|
10
|
-
"unicorn/prefer-module": "off",
|
|
11
|
-
"unicorn/prefer-optional-catch-binding": "off",
|
|
12
|
-
"unicorn/prefer-top-level-await": "off",
|
|
13
|
-
"unicorn/prevent-abbreviations": "off", // Super insanely annoying rule
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function unicornRecommended(pluginUnicorn) {
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
|
|
18
|
-
const rules = pluginUnicorn.configs.recommended.rules;
|
|
19
|
-
if (rules === undefined) {
|
|
20
|
-
throw new Error("Expected rules to be defined in unicorn plugin");
|
|
21
|
-
}
|
|
22
|
-
return rules;
|
|
23
|
-
}
|
|
24
|
-
export const unicorn = async () => {
|
|
25
|
-
return [
|
|
26
|
-
{
|
|
27
|
-
name: "jsse/unicorn",
|
|
28
|
-
plugins: {
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
30
|
-
unicorn: pluginUnicorn,
|
|
31
|
-
},
|
|
32
|
-
rules: {
|
|
33
|
-
...unicornRecommended(pluginUnicorn),
|
|
34
|
-
...unicornOff(),
|
|
35
|
-
"unicorn/better-regex": "error",
|
|
36
|
-
"unicorn/consistent-empty-array-spread": "error",
|
|
37
|
-
"unicorn/custom-error-definition": "error",
|
|
38
|
-
// Pass error message when throwing errors
|
|
39
|
-
"unicorn/error-message": "error",
|
|
40
|
-
// Uppercase regex escapes
|
|
41
|
-
"unicorn/escape-case": "error",
|
|
42
|
-
"unicorn/explicit-length-check": "error",
|
|
43
|
-
"unicorn/filename-case": "error",
|
|
44
|
-
"unicorn/new-for-builtins": "error",
|
|
45
|
-
"unicorn/no-array-callback-reference": "error",
|
|
46
|
-
"unicorn/no-array-method-this-argument": "error",
|
|
47
|
-
"unicorn/no-array-push-push": "error",
|
|
48
|
-
"unicorn/no-console-spaces": "error",
|
|
49
|
-
"unicorn/no-for-loop": "error",
|
|
50
|
-
"unicorn/no-hex-escape": "error",
|
|
51
|
-
// Array.isArray instead of instanceof
|
|
52
|
-
"unicorn/no-instanceof-array": "error",
|
|
53
|
-
"unicorn/no-invalid-remove-event-listener": "error",
|
|
54
|
-
"unicorn/no-lonely-if": "error",
|
|
55
|
-
// conflicts with prettier
|
|
56
|
-
// Ban `new Array` as `Array` constructor's params are ambiguous
|
|
57
|
-
"unicorn/no-new-array": "error",
|
|
58
|
-
// Prevent deprecated `new Buffer()`
|
|
59
|
-
"unicorn/no-new-buffer": "error",
|
|
60
|
-
"unicorn/no-static-only-class": "error",
|
|
61
|
-
"unicorn/no-unnecessary-await": "error",
|
|
62
|
-
// Keep regex literals safe!
|
|
63
|
-
"unicorn/no-zero-fractions": "error",
|
|
64
|
-
// Lowercase number formatting for octal, hex, binary (0x1ERROR instead of 0X1'error')
|
|
65
|
-
"unicorn/number-literal-case": "error",
|
|
66
|
-
"unicorn/prefer-add-event-listener": "error",
|
|
67
|
-
"unicorn/prefer-array-find": "error",
|
|
68
|
-
"unicorn/prefer-array-flat-map": "error",
|
|
69
|
-
"unicorn/prefer-array-index-of": "error",
|
|
70
|
-
"unicorn/prefer-array-some": "error",
|
|
71
|
-
"unicorn/prefer-at": "error",
|
|
72
|
-
"unicorn/prefer-blob-reading-methods": "error",
|
|
73
|
-
"unicorn/prefer-date-now": "error",
|
|
74
|
-
"unicorn/prefer-dom-node-append": "error",
|
|
75
|
-
"unicorn/prefer-dom-node-dataset": "error",
|
|
76
|
-
"unicorn/prefer-dom-node-remove": "error",
|
|
77
|
-
// textContent instead of innerText
|
|
78
|
-
"unicorn/prefer-dom-node-text-content": "error",
|
|
79
|
-
// includes over indexOf when checking for existence
|
|
80
|
-
"unicorn/prefer-includes": "error",
|
|
81
|
-
"unicorn/prefer-keyboard-event-key": "error",
|
|
82
|
-
"unicorn/prefer-math-trunc": "error",
|
|
83
|
-
"unicorn/prefer-modern-dom-apis": "error",
|
|
84
|
-
"unicorn/prefer-modern-math-apis": "error",
|
|
85
|
-
"unicorn/prefer-negative-index": "error",
|
|
86
|
-
// Prefer using the node: protocol
|
|
87
|
-
"unicorn/prefer-node-protocol": "error",
|
|
88
|
-
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
89
|
-
"unicorn/prefer-number-properties": "error",
|
|
90
|
-
"unicorn/prefer-prototype-methods": "error",
|
|
91
|
-
"unicorn/prefer-query-selector": "error",
|
|
92
|
-
"unicorn/prefer-reflect-apply": "error",
|
|
93
|
-
"unicorn/prefer-regexp-test": "error",
|
|
94
|
-
"unicorn/prefer-string-replace-all": "error",
|
|
95
|
-
"unicorn/prefer-string-slice": "error",
|
|
96
|
-
// String methods startsWith/endsWith instead of more complicated stuff
|
|
97
|
-
"unicorn/prefer-string-starts-ends-with": "error",
|
|
98
|
-
"unicorn/prefer-string-trim-start-end": "error",
|
|
99
|
-
// Enforce throwing type error when throwing error while checking typeof
|
|
100
|
-
"unicorn/prefer-type-error": "error",
|
|
101
|
-
// Use new when throwing error
|
|
102
|
-
"unicorn/throw-new-error": "error",
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
files: GLOB_TESTS,
|
|
107
|
-
name: "jsse/unicorn/tests",
|
|
108
|
-
rules: {
|
|
109
|
-
"unicorn/no-null": "off",
|
|
110
|
-
"unicorn/no-unused-properties": "off",
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
];
|
|
114
|
-
};
|