@comment-labs/oxlint-config 1.0.0-beta.2 → 1.0.0-beta.20
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 +11 -0
- package/dist/index.d.mts +2 -17
- package/dist/index.mjs +188 -267
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/brettz9.d.mts +2 -0
- package/dist/plugins/brettz9.mjs +2 -0
- package/dist/plugins/e18e.d.mts +2 -0
- package/dist/plugins/e18e.mjs +2 -0
- package/dist/plugins/i18next.d.mts +2 -0
- package/dist/plugins/i18next.mjs +2 -0
- package/dist/plugins/import-zod.d.mts +2 -0
- package/dist/plugins/import-zod.mjs +2 -0
- package/dist/plugins/jsdoc.d.mts +2 -0
- package/dist/plugins/jsdoc.mjs +2 -0
- package/dist/plugins/labs.d.mts +13 -0
- package/dist/plugins/labs.mjs +149 -0
- package/dist/plugins/labs.mjs.map +1 -0
- package/dist/plugins/playwright.d.mts +2 -0
- package/dist/plugins/playwright.mjs +2 -0
- package/dist/plugins/react-hooks.d.mts +2 -0
- package/dist/plugins/react-hooks.mjs +2 -0
- package/dist/plugins/react-native.d.mts +2 -0
- package/dist/plugins/react-native.mjs +2 -0
- package/dist/plugins/react-refresh.d.mts +2 -0
- package/dist/plugins/react-refresh.mjs +2 -0
- package/dist/plugins/regexp.d.mts +2 -0
- package/dist/plugins/regexp.mjs +2 -0
- package/dist/plugins/security.d.mts +2 -0
- package/dist/plugins/security.mjs +2 -0
- package/dist/plugins/stylistic.d.mts +2 -0
- package/dist/plugins/stylistic.mjs +2 -0
- package/dist/plugins/unicorn.d.mts +2 -0
- package/dist/plugins/unicorn.mjs +2 -0
- package/package.json +24 -19
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ Create an `oxlint.config.ts` file in your project root:
|
|
|
16
16
|
import { defineConfig } from 'oxlint'
|
|
17
17
|
import { config } from '@comment-labs/oxlint-config'
|
|
18
18
|
|
|
19
|
+
|
|
19
20
|
export default defineConfig(config)
|
|
20
21
|
```
|
|
21
22
|
|
|
@@ -26,6 +27,16 @@ export default defineConfig(config)
|
|
|
26
27
|
- Vitest compatibility
|
|
27
28
|
- Optimized for correctness and performance
|
|
28
29
|
|
|
30
|
+
Add a lint script to `package.json`:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"scripts": {
|
|
35
|
+
"lint": "oxlint"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
29
40
|
## License
|
|
30
41
|
|
|
31
42
|
[Apache-2.0](https://github.com/comment-team/comment-labs/blob/main/LICENSE)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import { OxlintConfig } from "oxlint";
|
|
2
|
-
|
|
3
|
-
//#region src/utils.d.ts
|
|
4
|
-
type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/plugin/index.d.ts
|
|
7
|
-
declare const commentLabsJs: {
|
|
8
|
-
meta: {
|
|
9
|
-
name: string;
|
|
10
|
-
version: string;
|
|
11
|
-
};
|
|
12
|
-
rules: {
|
|
13
|
-
'no-self-assign': Rule.RuleModule;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
//#endregion
|
|
17
2
|
//#region src/index.d.ts
|
|
18
|
-
declare const config:
|
|
3
|
+
declare const config: OxlintConfig;
|
|
19
4
|
//#endregion
|
|
20
|
-
export { config
|
|
5
|
+
export { config };
|
|
21
6
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { defineConfig } from "oxlint";
|
|
2
1
|
import globalsPkg from "globals";
|
|
3
2
|
import { access, readFile } from "node:fs/promises";
|
|
4
3
|
import { join } from "node:path";
|
|
5
4
|
import { cwd } from "node:process";
|
|
6
5
|
import { up } from "empathic/find";
|
|
7
|
-
import { defu } from "defu";
|
|
8
6
|
//#region src/categories.ts
|
|
9
7
|
const categories = {
|
|
10
8
|
correctness: "error",
|
|
@@ -20,7 +18,7 @@ const categories = {
|
|
|
20
18
|
const baseRules = {
|
|
21
19
|
"array-type": "off",
|
|
22
20
|
"capitalized-comments": "off",
|
|
23
|
-
"class-methods-use-this": "
|
|
21
|
+
"class-methods-use-this": "off",
|
|
24
22
|
"consistent-indexed-object-style": "off",
|
|
25
23
|
"consistent-type-definitions": "off",
|
|
26
24
|
"complexity": ["warn", { max: 50 }],
|
|
@@ -90,15 +88,32 @@ const baseRules = {
|
|
|
90
88
|
"typescript/parameter-properties": ["warn", { prefer: "parameter-property" }],
|
|
91
89
|
"typescript/prefer-readonly-parameter-types": "off",
|
|
92
90
|
"typescript/require-await": "warn",
|
|
93
|
-
"typescript/
|
|
91
|
+
"typescript/non-nullable-type-assertion-style": "warn",
|
|
92
|
+
"typescript/explicit-member-accessibility": "off",
|
|
93
|
+
"typescript/return-await": ["warn", "always"],
|
|
94
|
+
"typescript/no-confusing-void-expression": ["warn", { ignoreArrowShorthand: true }],
|
|
94
95
|
"import/no-unassigned-import": "warn",
|
|
95
96
|
"import/consistent-type-specifier-style": "off",
|
|
96
97
|
"import/no-anonymous-default-export": "off",
|
|
97
98
|
"import/no-cycle": "off",
|
|
98
99
|
"import/no-nodejs-modules": "off",
|
|
99
100
|
"import/unambiguous": "off",
|
|
101
|
+
"node/no-top-level-await": "off",
|
|
102
|
+
"node/no-sync": ["warn", { ignores: ["execSync"] }],
|
|
103
|
+
"react/react-in-jsx-scope": "off",
|
|
104
|
+
"react/jsx-filename-extension": ["error", { extensions: ["jsx", "tsx"] }],
|
|
100
105
|
"jest/require-hook": "off",
|
|
101
106
|
"jest/no-conditional-in-test": "off",
|
|
107
|
+
"jest/prefer-expect-assertions": "off",
|
|
108
|
+
"vitest/prefer-called-times": "off",
|
|
109
|
+
"vitest/prefer-strict-boolean-matchers": "off",
|
|
110
|
+
"vitest/prefer-expect-assertions": ["warn", {
|
|
111
|
+
onlyFunctionsWithExpectInCallback: true,
|
|
112
|
+
onlyFunctionsWithExpectInLoop: true
|
|
113
|
+
}],
|
|
114
|
+
"vitest/require-test-timeout": "off",
|
|
115
|
+
"vitest/no-importing-vitest-globals": "off",
|
|
116
|
+
"vitest/no-conditional-in-test": "off",
|
|
102
117
|
"jsdoc/require-param-type": "off",
|
|
103
118
|
"jsdoc/require-returns": "off",
|
|
104
119
|
"jsdoc/require-param": "off",
|
|
@@ -106,7 +121,21 @@ const baseRules = {
|
|
|
106
121
|
"unicorn/switch-case-braces": ["warn", "avoid"],
|
|
107
122
|
"unicorn/no-array-method-this-argument": "warn",
|
|
108
123
|
"unicorn/no-await-expression-member": "warn",
|
|
109
|
-
"
|
|
124
|
+
"unicorn/no-invalid-fetch-options": "off",
|
|
125
|
+
"unicorn/import-style": ["warn", {
|
|
126
|
+
extendDefaultStyles: false,
|
|
127
|
+
styles: {
|
|
128
|
+
"path": {
|
|
129
|
+
named: true,
|
|
130
|
+
default: false
|
|
131
|
+
},
|
|
132
|
+
"util": {
|
|
133
|
+
named: true,
|
|
134
|
+
default: false
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}],
|
|
138
|
+
"unicorn/max-nested-calls": ["warn", { max: 5 }],
|
|
110
139
|
"comment-labs-js/no-self-assign": "error",
|
|
111
140
|
"brettz9-js/arrow-parens": "off",
|
|
112
141
|
"brettz9-js/block-scoped-var": "off",
|
|
@@ -116,7 +145,6 @@ const baseRules = {
|
|
|
116
145
|
"brettz9-js/no-use-ignored-vars": "warn",
|
|
117
146
|
"brettz9-js/no-useless-rest-spread": "warn",
|
|
118
147
|
"brettz9-js/prefer-for-of": "off",
|
|
119
|
-
"i18next-js/no-literal-string": "warn",
|
|
120
148
|
"import-zod-js/prefer-zod-namespace": "warn",
|
|
121
149
|
"security-js/detect-unsafe-regex": "error",
|
|
122
150
|
"security-js/detect-non-literal-regexp": "error",
|
|
@@ -142,6 +170,106 @@ const baseRules = {
|
|
|
142
170
|
"unicorn-js/prefer-switch": "warn",
|
|
143
171
|
"unicorn-js/switch-case-break-position": "warn",
|
|
144
172
|
"unicorn-js/prefer-single-call": "warn",
|
|
173
|
+
"jsdoc-js/check-alignment": "warn",
|
|
174
|
+
"jsdoc-js/check-indentation": "warn",
|
|
175
|
+
"jsdoc-js/check-line-alignment": "warn",
|
|
176
|
+
"jsdoc-js/check-param-names": "warn",
|
|
177
|
+
"jsdoc-js/check-types": "warn",
|
|
178
|
+
"jsdoc-js/check-values": "warn",
|
|
179
|
+
"jsdoc-js/multiline-blocks": "warn",
|
|
180
|
+
"jsdoc-js/no-multi-asterisks": "warn",
|
|
181
|
+
"jsdoc-js/no-undefined-types": "warn",
|
|
182
|
+
"jsdoc-js/require-returns-check": "warn",
|
|
183
|
+
"jsdoc-js/require-yields-check": "warn",
|
|
184
|
+
"jsdoc-js/tag-lines": "warn",
|
|
185
|
+
"jsdoc-js/valid-types": "warn",
|
|
186
|
+
"e18e-js/prefer-array-at": "error",
|
|
187
|
+
"e18e-js/prefer-array-fill": "error",
|
|
188
|
+
"e18e-js/prefer-includes": "error",
|
|
189
|
+
"e18e-js/prefer-array-to-reversed": "error",
|
|
190
|
+
"e18e-js/prefer-array-to-sorted": "error",
|
|
191
|
+
"e18e-js/prefer-array-to-spliced": "error",
|
|
192
|
+
"e18e-js/prefer-nullish-coalescing": "error",
|
|
193
|
+
"e18e-js/prefer-object-has-own": "error",
|
|
194
|
+
"e18e-js/prefer-spread-syntax": "error",
|
|
195
|
+
"e18e-js/prefer-url-canparse": "error",
|
|
196
|
+
"e18e-js/ban-dependencies": "error",
|
|
197
|
+
"e18e-js/prefer-array-from-map": "error",
|
|
198
|
+
"e18e-js/prefer-timer-args": "error",
|
|
199
|
+
"e18e-js/prefer-date-now": "error",
|
|
200
|
+
"e18e-js/prefer-regex-test": "error",
|
|
201
|
+
"e18e-js/prefer-array-some": "error",
|
|
202
|
+
"e18e-js/prefer-static-regex": "error",
|
|
203
|
+
"no-control-regex": "error",
|
|
204
|
+
"no-misleading-character-class": "error",
|
|
205
|
+
"no-regex-spaces": "error",
|
|
206
|
+
"no-invalid-regexp": "off",
|
|
207
|
+
"no-useless-backreference": "off",
|
|
208
|
+
"no-empty-character-class": "off",
|
|
209
|
+
"regexp-js/confusing-quantifier": "warn",
|
|
210
|
+
"regexp-js/control-character-escape": "error",
|
|
211
|
+
"regexp-js/match-any": "error",
|
|
212
|
+
"regexp-js/negation": "error",
|
|
213
|
+
"regexp-js/no-contradiction-with-assertion": "error",
|
|
214
|
+
"regexp-js/no-dupe-characters-character-class": "error",
|
|
215
|
+
"regexp-js/no-dupe-disjunctions": "error",
|
|
216
|
+
"regexp-js/no-empty-alternative": "warn",
|
|
217
|
+
"regexp-js/no-empty-capturing-group": "error",
|
|
218
|
+
"regexp-js/no-empty-character-class": "error",
|
|
219
|
+
"regexp-js/no-empty-group": "error",
|
|
220
|
+
"regexp-js/no-empty-lookarounds-assertion": "error",
|
|
221
|
+
"regexp-js/no-empty-string-literal": "error",
|
|
222
|
+
"regexp-js/no-escape-backspace": "error",
|
|
223
|
+
"regexp-js/no-extra-lookaround-assertions": "error",
|
|
224
|
+
"regexp-js/no-invalid-regexp": "error",
|
|
225
|
+
"regexp-js/no-invisible-character": "error",
|
|
226
|
+
"regexp-js/no-lazy-ends": "warn",
|
|
227
|
+
"regexp-js/no-legacy-features": "error",
|
|
228
|
+
"regexp-js/no-misleading-capturing-group": "error",
|
|
229
|
+
"regexp-js/no-misleading-unicode-character": "error",
|
|
230
|
+
"regexp-js/no-missing-g-flag": "error",
|
|
231
|
+
"regexp-js/no-non-standard-flag": "error",
|
|
232
|
+
"regexp-js/no-obscure-range": "error",
|
|
233
|
+
"regexp-js/no-optional-assertion": "error",
|
|
234
|
+
"regexp-js/no-potentially-useless-backreference": "warn",
|
|
235
|
+
"regexp-js/no-super-linear-backtracking": "error",
|
|
236
|
+
"regexp-js/no-trivially-nested-assertion": "error",
|
|
237
|
+
"regexp-js/no-trivially-nested-quantifier": "error",
|
|
238
|
+
"regexp-js/no-unused-capturing-group": "error",
|
|
239
|
+
"regexp-js/no-useless-assertions": "error",
|
|
240
|
+
"regexp-js/no-useless-backreference": "error",
|
|
241
|
+
"regexp-js/no-useless-character-class": "error",
|
|
242
|
+
"regexp-js/no-useless-dollar-replacements": "error",
|
|
243
|
+
"regexp-js/no-useless-escape": "error",
|
|
244
|
+
"regexp-js/no-useless-flag": "warn",
|
|
245
|
+
"regexp-js/no-useless-lazy": "error",
|
|
246
|
+
"regexp-js/no-useless-non-capturing-group": "error",
|
|
247
|
+
"regexp-js/no-useless-quantifier": "error",
|
|
248
|
+
"regexp-js/no-useless-range": "error",
|
|
249
|
+
"regexp-js/no-useless-set-operand": "error",
|
|
250
|
+
"regexp-js/no-useless-string-literal": "error",
|
|
251
|
+
"regexp-js/no-useless-two-nums-quantifier": "error",
|
|
252
|
+
"regexp-js/no-zero-quantifier": "error",
|
|
253
|
+
"regexp-js/optimal-lookaround-quantifier": "warn",
|
|
254
|
+
"regexp-js/optimal-quantifier-concatenation": "error",
|
|
255
|
+
"regexp-js/prefer-character-class": "error",
|
|
256
|
+
"regexp-js/prefer-d": "error",
|
|
257
|
+
"regexp-js/prefer-plus-quantifier": "error",
|
|
258
|
+
"regexp-js/prefer-predefined-assertion": "error",
|
|
259
|
+
"regexp-js/prefer-question-quantifier": "error",
|
|
260
|
+
"regexp-js/prefer-range": "error",
|
|
261
|
+
"regexp-js/prefer-set-operation": "error",
|
|
262
|
+
"regexp-js/prefer-star-quantifier": "error",
|
|
263
|
+
"regexp-js/prefer-unicode-codepoint-escapes": "error",
|
|
264
|
+
"regexp-js/prefer-w": "error",
|
|
265
|
+
"regexp-js/simplify-set-operations": "error",
|
|
266
|
+
"regexp-js/sort-flags": "error",
|
|
267
|
+
"regexp-js/strict": "error",
|
|
268
|
+
"regexp-js/use-ignore-case": "error"
|
|
269
|
+
};
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region src/stylistic-rules.ts
|
|
272
|
+
const stylisticRules = {
|
|
145
273
|
"stylistic-js/type-generic-spacing": "warn",
|
|
146
274
|
"stylistic-js/type-named-tuple-spacing": "warn",
|
|
147
275
|
"stylistic-js/function-call-spacing": ["warn", "never"],
|
|
@@ -386,104 +514,7 @@ const baseRules = {
|
|
|
386
514
|
prev: "multiline-block-like",
|
|
387
515
|
next: "*"
|
|
388
516
|
}
|
|
389
|
-
]
|
|
390
|
-
"jsdoc-js/check-alignment": "warn",
|
|
391
|
-
"jsdoc-js/check-indentation": "warn",
|
|
392
|
-
"jsdoc-js/check-line-alignment": "warn",
|
|
393
|
-
"jsdoc-js/check-param-names": "warn",
|
|
394
|
-
"jsdoc-js/check-types": "warn",
|
|
395
|
-
"jsdoc-js/check-values": "warn",
|
|
396
|
-
"jsdoc-js/multiline-blocks": "warn",
|
|
397
|
-
"jsdoc-js/no-multi-asterisks": "warn",
|
|
398
|
-
"jsdoc-js/no-undefined-types": "warn",
|
|
399
|
-
"jsdoc-js/require-returns-check": "warn",
|
|
400
|
-
"jsdoc-js/require-yields-check": "warn",
|
|
401
|
-
"jsdoc-js/tag-lines": "warn",
|
|
402
|
-
"jsdoc-js/valid-types": "warn",
|
|
403
|
-
"e18e-js/prefer-array-at": "error",
|
|
404
|
-
"e18e-js/prefer-array-fill": "error",
|
|
405
|
-
"e18e-js/prefer-includes": "error",
|
|
406
|
-
"e18e-js/prefer-array-to-reversed": "error",
|
|
407
|
-
"e18e-js/prefer-array-to-sorted": "error",
|
|
408
|
-
"e18e-js/prefer-array-to-spliced": "error",
|
|
409
|
-
"e18e-js/prefer-nullish-coalescing": "error",
|
|
410
|
-
"e18e-js/prefer-object-has-own": "error",
|
|
411
|
-
"e18e-js/prefer-spread-syntax": "error",
|
|
412
|
-
"e18e-js/prefer-url-canparse": "error",
|
|
413
|
-
"e18e-js/ban-dependencies": "error",
|
|
414
|
-
"e18e-js/prefer-array-from-map": "error",
|
|
415
|
-
"e18e-js/prefer-timer-args": "error",
|
|
416
|
-
"e18e-js/prefer-date-now": "error",
|
|
417
|
-
"e18e-js/prefer-regex-test": "error",
|
|
418
|
-
"e18e-js/prefer-array-some": "error",
|
|
419
|
-
"e18e-js/prefer-static-regex": "error",
|
|
420
|
-
"no-control-regex": "error",
|
|
421
|
-
"no-misleading-character-class": "error",
|
|
422
|
-
"no-regex-spaces": "error",
|
|
423
|
-
"prefer-regex-literals": "error",
|
|
424
|
-
"no-invalid-regexp": "off",
|
|
425
|
-
"no-useless-backreference": "off",
|
|
426
|
-
"no-empty-character-class": "off",
|
|
427
|
-
"regexp-js/confusing-quantifier": "warn",
|
|
428
|
-
"regexp-js/control-character-escape": "error",
|
|
429
|
-
"regexp-js/match-any": "error",
|
|
430
|
-
"regexp-js/negation": "error",
|
|
431
|
-
"regexp-js/no-contradiction-with-assertion": "error",
|
|
432
|
-
"regexp-js/no-dupe-characters-character-class": "error",
|
|
433
|
-
"regexp-js/no-dupe-disjunctions": "error",
|
|
434
|
-
"regexp-js/no-empty-alternative": "warn",
|
|
435
|
-
"regexp-js/no-empty-capturing-group": "error",
|
|
436
|
-
"regexp-js/no-empty-character-class": "error",
|
|
437
|
-
"regexp-js/no-empty-group": "error",
|
|
438
|
-
"regexp-js/no-empty-lookarounds-assertion": "error",
|
|
439
|
-
"regexp-js/no-empty-string-literal": "error",
|
|
440
|
-
"regexp-js/no-escape-backspace": "error",
|
|
441
|
-
"regexp-js/no-extra-lookaround-assertions": "error",
|
|
442
|
-
"regexp-js/no-invalid-regexp": "error",
|
|
443
|
-
"regexp-js/no-invisible-character": "error",
|
|
444
|
-
"regexp-js/no-lazy-ends": "warn",
|
|
445
|
-
"regexp-js/no-legacy-features": "error",
|
|
446
|
-
"regexp-js/no-misleading-capturing-group": "error",
|
|
447
|
-
"regexp-js/no-misleading-unicode-character": "error",
|
|
448
|
-
"regexp-js/no-missing-g-flag": "error",
|
|
449
|
-
"regexp-js/no-non-standard-flag": "error",
|
|
450
|
-
"regexp-js/no-obscure-range": "error",
|
|
451
|
-
"regexp-js/no-optional-assertion": "error",
|
|
452
|
-
"regexp-js/no-potentially-useless-backreference": "warn",
|
|
453
|
-
"regexp-js/no-super-linear-backtracking": "error",
|
|
454
|
-
"regexp-js/no-trivially-nested-assertion": "error",
|
|
455
|
-
"regexp-js/no-trivially-nested-quantifier": "error",
|
|
456
|
-
"regexp-js/no-unused-capturing-group": "error",
|
|
457
|
-
"regexp-js/no-useless-assertions": "error",
|
|
458
|
-
"regexp-js/no-useless-backreference": "error",
|
|
459
|
-
"regexp-js/no-useless-character-class": "error",
|
|
460
|
-
"regexp-js/no-useless-dollar-replacements": "error",
|
|
461
|
-
"regexp-js/no-useless-escape": "error",
|
|
462
|
-
"regexp-js/no-useless-flag": "warn",
|
|
463
|
-
"regexp-js/no-useless-lazy": "error",
|
|
464
|
-
"regexp-js/no-useless-non-capturing-group": "error",
|
|
465
|
-
"regexp-js/no-useless-quantifier": "error",
|
|
466
|
-
"regexp-js/no-useless-range": "error",
|
|
467
|
-
"regexp-js/no-useless-set-operand": "error",
|
|
468
|
-
"regexp-js/no-useless-string-literal": "error",
|
|
469
|
-
"regexp-js/no-useless-two-nums-quantifier": "error",
|
|
470
|
-
"regexp-js/no-zero-quantifier": "error",
|
|
471
|
-
"regexp-js/optimal-lookaround-quantifier": "warn",
|
|
472
|
-
"regexp-js/optimal-quantifier-concatenation": "error",
|
|
473
|
-
"regexp-js/prefer-character-class": "error",
|
|
474
|
-
"regexp-js/prefer-d": "error",
|
|
475
|
-
"regexp-js/prefer-plus-quantifier": "error",
|
|
476
|
-
"regexp-js/prefer-predefined-assertion": "error",
|
|
477
|
-
"regexp-js/prefer-question-quantifier": "error",
|
|
478
|
-
"regexp-js/prefer-range": "error",
|
|
479
|
-
"regexp-js/prefer-set-operation": "error",
|
|
480
|
-
"regexp-js/prefer-star-quantifier": "error",
|
|
481
|
-
"regexp-js/prefer-unicode-codepoint-escapes": "error",
|
|
482
|
-
"regexp-js/prefer-w": "error",
|
|
483
|
-
"regexp-js/simplify-set-operations": "error",
|
|
484
|
-
"regexp-js/sort-flags": "error",
|
|
485
|
-
"regexp-js/strict": "error",
|
|
486
|
-
"regexp-js/use-ignore-case": "error"
|
|
517
|
+
]
|
|
487
518
|
};
|
|
488
519
|
//#endregion
|
|
489
520
|
//#region src/plugins.ts
|
|
@@ -505,7 +536,7 @@ const plugins = [
|
|
|
505
536
|
//#endregion
|
|
506
537
|
//#region src/utils.ts
|
|
507
538
|
async function enableMode(configFiles, dependencies) {
|
|
508
|
-
if ((await Promise.all(configFiles.map(async (file) => access(join(cwd(), file)).then(() => true).catch(() => false)))).some(Boolean)) return true;
|
|
539
|
+
if ((await Promise.all(configFiles.map(async (file) => await access(join(cwd(), file)).then(() => true).catch(() => false)))).some(Boolean)) return true;
|
|
509
540
|
const packageJson = up("package.json", { cwd: cwd() });
|
|
510
541
|
if (typeof packageJson === "string") {
|
|
511
542
|
const json = JSON.parse(await readFile(packageJson, "utf8"));
|
|
@@ -528,7 +559,9 @@ const cloudflareSpecificGlobals = {
|
|
|
528
559
|
IdentityTransformStream: "readonly",
|
|
529
560
|
HTMLRewriter: "readonly",
|
|
530
561
|
WebSocketPair: "readonly",
|
|
531
|
-
WebSocketRequestResponsePair: "readonly"
|
|
562
|
+
WebSocketRequestResponsePair: "readonly",
|
|
563
|
+
scheduler: "readonly",
|
|
564
|
+
caches: "readonly"
|
|
532
565
|
};
|
|
533
566
|
const cloudflare = {
|
|
534
567
|
...base,
|
|
@@ -556,60 +589,67 @@ const globals = await getGlobals();
|
|
|
556
589
|
//#endregion
|
|
557
590
|
//#region src/js-plugins.ts
|
|
558
591
|
const jsPlugins = [
|
|
559
|
-
|
|
592
|
+
{
|
|
593
|
+
name: "comment-labs-js",
|
|
594
|
+
specifier: "@comment-labs/oxlint-config/plugins/labs"
|
|
595
|
+
},
|
|
560
596
|
{
|
|
561
597
|
name: "brettz9-js",
|
|
562
|
-
specifier: "@
|
|
598
|
+
specifier: "@comment-labs/oxlint-config/plugins/brettz9"
|
|
563
599
|
},
|
|
564
600
|
{
|
|
565
601
|
name: "i18next-js",
|
|
566
|
-
specifier: "
|
|
602
|
+
specifier: "@comment-labs/oxlint-config/plugins/i18next"
|
|
567
603
|
},
|
|
568
604
|
{
|
|
569
605
|
name: "import-zod-js",
|
|
570
|
-
specifier: "
|
|
606
|
+
specifier: "@comment-labs/oxlint-config/plugins/import-zod"
|
|
571
607
|
},
|
|
572
608
|
{
|
|
573
609
|
name: "playwright-js",
|
|
574
|
-
specifier: "
|
|
610
|
+
specifier: "@comment-labs/oxlint-config/plugins/playwright"
|
|
575
611
|
},
|
|
576
612
|
{
|
|
577
613
|
name: "react-hooks-js",
|
|
578
|
-
specifier: "
|
|
614
|
+
specifier: "@comment-labs/oxlint-config/plugins/react-hooks"
|
|
579
615
|
},
|
|
580
616
|
{
|
|
581
617
|
name: "react-native-js",
|
|
582
|
-
specifier: "
|
|
618
|
+
specifier: "@comment-labs/oxlint-config/plugins/react-native"
|
|
583
619
|
},
|
|
584
620
|
{
|
|
585
621
|
name: "react-refresh-js",
|
|
586
|
-
specifier: "
|
|
622
|
+
specifier: "@comment-labs/oxlint-config/plugins/react-refresh"
|
|
587
623
|
},
|
|
588
624
|
{
|
|
589
625
|
name: "security-js",
|
|
590
|
-
specifier: "
|
|
626
|
+
specifier: "@comment-labs/oxlint-config/plugins/security"
|
|
591
627
|
},
|
|
592
628
|
{
|
|
593
629
|
name: "unicorn-js",
|
|
594
|
-
specifier: "
|
|
630
|
+
specifier: "@comment-labs/oxlint-config/plugins/unicorn"
|
|
595
631
|
},
|
|
596
632
|
{
|
|
597
633
|
name: "stylistic-js",
|
|
598
|
-
specifier: "@
|
|
634
|
+
specifier: "@comment-labs/oxlint-config/plugins/stylistic"
|
|
599
635
|
},
|
|
600
636
|
{
|
|
601
637
|
name: "jsdoc-js",
|
|
602
|
-
specifier: "
|
|
638
|
+
specifier: "@comment-labs/oxlint-config/plugins/jsdoc"
|
|
603
639
|
},
|
|
604
640
|
{
|
|
605
641
|
name: "e18e-js",
|
|
606
|
-
specifier: "@
|
|
642
|
+
specifier: "@comment-labs/oxlint-config/plugins/e18e"
|
|
607
643
|
},
|
|
608
644
|
{
|
|
609
645
|
name: "regexp-js",
|
|
610
|
-
specifier: "
|
|
646
|
+
specifier: "@comment-labs/oxlint-config/plugins/regexp"
|
|
611
647
|
}
|
|
612
648
|
];
|
|
649
|
+
const i18nextOverrides = {
|
|
650
|
+
files: [await enableMode([], ["i18next"]) ? "**/*" : "___disabled"],
|
|
651
|
+
rules: { "i18next-js/no-literal-string": "warn" }
|
|
652
|
+
};
|
|
613
653
|
//#endregion
|
|
614
654
|
//#region src/overrides/playwright.ts
|
|
615
655
|
const playwrightOverrides = {
|
|
@@ -675,155 +715,29 @@ const reactNativeOverrides = {
|
|
|
675
715
|
}
|
|
676
716
|
};
|
|
677
717
|
//#endregion
|
|
678
|
-
//#region src/
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}
|
|
691
|
-
function getProperty(value, key) {
|
|
692
|
-
return Reflect.get(value, key);
|
|
693
|
-
}
|
|
694
|
-
function getParent(node, sourceCode) {
|
|
695
|
-
return sourceCode.getAncestors(node).at(-1);
|
|
696
|
-
}
|
|
697
|
-
function traverseNodes(node, sourceCode, visitor, shouldSkipChildren) {
|
|
698
|
-
visitor(node);
|
|
699
|
-
if (shouldSkipChildren?.(node) === true) return;
|
|
700
|
-
const keys = sourceCode.visitorKeys[node.type] ?? [];
|
|
701
|
-
for (const key of keys) {
|
|
702
|
-
const value = getProperty(node, key);
|
|
703
|
-
if (Array.isArray(value)) {
|
|
704
|
-
for (const child of value) if (isNode(child)) traverseNodes(child, sourceCode, visitor, shouldSkipChildren);
|
|
705
|
-
} else if (isNode(value)) traverseNodes(value, sourceCode, visitor, shouldSkipChildren);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
function isReferenceIdentifier(identifier, sourceCode) {
|
|
709
|
-
const parent = getParent(identifier, sourceCode);
|
|
710
|
-
if (!parent) return true;
|
|
711
|
-
if (parent.type.startsWith("TS")) return false;
|
|
712
|
-
if (parent.type === "Property" && parent.key === identifier) return parent.computed || parent.shorthand;
|
|
713
|
-
if (parent.type === "MemberExpression" && parent.property === identifier) return parent.computed;
|
|
714
|
-
if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === identifier && !parent.computed) return false;
|
|
715
|
-
if (parent.type === "ImportSpecifier" || parent.type === "ImportDefaultSpecifier" || parent.type === "ImportNamespaceSpecifier") return false;
|
|
716
|
-
if (parent.type === "ExportSpecifier" && parent.exported === identifier) return false;
|
|
717
|
-
if (parent.type === "LabeledStatement" && parent.label === identifier) return false;
|
|
718
|
-
return true;
|
|
719
|
-
}
|
|
720
|
-
function findVariable(node, name, sourceCode) {
|
|
721
|
-
let scope = sourceCode.getScope(node);
|
|
722
|
-
while (scope) {
|
|
723
|
-
const variable = scope.set.get(name);
|
|
724
|
-
if (variable) return variable;
|
|
725
|
-
scope = scope.upper;
|
|
726
|
-
}
|
|
727
|
-
return null;
|
|
728
|
-
}
|
|
729
|
-
function isSelfReference(identifier, variable, sourceCode) {
|
|
730
|
-
if (variable.references.some((reference) => reference.identifier === identifier)) return true;
|
|
731
|
-
let scope = sourceCode.getScope(identifier);
|
|
732
|
-
while (scope) {
|
|
733
|
-
const reference = scope.references.find((candidate) => candidate.identifier === identifier);
|
|
734
|
-
if (reference) return reference.resolved === variable;
|
|
735
|
-
scope = scope.upper;
|
|
736
|
-
}
|
|
737
|
-
scope = sourceCode.getScope(identifier);
|
|
738
|
-
while (scope) {
|
|
739
|
-
const candidate = scope.set.get(identifier.name);
|
|
740
|
-
if (candidate) return candidate === variable;
|
|
741
|
-
scope = scope.upper;
|
|
742
|
-
}
|
|
743
|
-
for (const ancestor of sourceCode.getAncestors(identifier).toReversed()) {
|
|
744
|
-
if (!isAssignmentPattern(ancestor)) continue;
|
|
745
|
-
if (isIdentifier(ancestor.left) && ancestor.left.name === variable.name && variable.defs.some((definition) => definition.name === ancestor.left)) return true;
|
|
746
|
-
}
|
|
747
|
-
return false;
|
|
748
|
-
}
|
|
749
|
-
function isUnresolvedSelfReference(identifier, name, sourceCode) {
|
|
750
|
-
if (identifier.name !== name) return false;
|
|
751
|
-
return findVariable(identifier, name, sourceCode) === null;
|
|
752
|
-
}
|
|
753
|
-
function reportSelfReferences(context, sourceCode, node, variable) {
|
|
754
|
-
traverseNodes(node, sourceCode, (child) => {
|
|
755
|
-
if (!isIdentifier(child)) return;
|
|
756
|
-
if (!isReferenceIdentifier(child, sourceCode)) return;
|
|
757
|
-
if (isSelfReference(child, variable, sourceCode)) context.report({
|
|
758
|
-
node: child,
|
|
759
|
-
messageId: "selfRef",
|
|
760
|
-
data: { name: variable.name }
|
|
761
|
-
});
|
|
762
|
-
}, isFunctionLike);
|
|
763
|
-
}
|
|
764
|
-
function reportSelfReferencesByName(context, sourceCode, node, name) {
|
|
765
|
-
traverseNodes(node, sourceCode, (child) => {
|
|
766
|
-
if (!isIdentifier(child)) return;
|
|
767
|
-
if (!isReferenceIdentifier(child, sourceCode)) return;
|
|
768
|
-
if (isUnresolvedSelfReference(child, name, sourceCode)) context.report({
|
|
769
|
-
node: child,
|
|
770
|
-
messageId: "selfRef",
|
|
771
|
-
data: { name }
|
|
772
|
-
});
|
|
773
|
-
}, isFunctionLike);
|
|
774
|
-
}
|
|
775
|
-
function reportDefaultParameterSelfReferences(context, sourceCode, node) {
|
|
776
|
-
for (const param of node.params) {
|
|
777
|
-
if (!isAssignmentPattern(param) || !isIdentifier(param.left)) continue;
|
|
778
|
-
const variable = findVariable(param.left, param.left.name, sourceCode);
|
|
779
|
-
if (!variable) continue;
|
|
780
|
-
reportSelfReferences(context, sourceCode, param.right, variable);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
const noSelfAssign = {
|
|
784
|
-
meta: {
|
|
785
|
-
type: "problem",
|
|
786
|
-
docs: { description: "Disallow self-references inside variable initializers and parameter default values" },
|
|
787
|
-
schema: [],
|
|
788
|
-
messages: { selfRef: "Variable {{name}} is referenced within its own initializer." }
|
|
789
|
-
},
|
|
790
|
-
create(context) {
|
|
791
|
-
const sourceCode = context.sourceCode;
|
|
792
|
-
return {
|
|
793
|
-
VariableDeclarator(node) {
|
|
794
|
-
if (!node.init || !isIdentifier(node.id)) return;
|
|
795
|
-
const variable = findVariable(node, node.id.name, sourceCode);
|
|
796
|
-
if (!variable) return;
|
|
797
|
-
reportSelfReferences(context, sourceCode, node.init, variable);
|
|
798
|
-
},
|
|
799
|
-
FunctionDeclaration(node) {
|
|
800
|
-
reportDefaultParameterSelfReferences(context, sourceCode, node);
|
|
801
|
-
},
|
|
802
|
-
FunctionExpression(node) {
|
|
803
|
-
reportDefaultParameterSelfReferences(context, sourceCode, node);
|
|
804
|
-
},
|
|
805
|
-
ArrowFunctionExpression(node) {
|
|
806
|
-
reportDefaultParameterSelfReferences(context, sourceCode, node);
|
|
807
|
-
},
|
|
808
|
-
PropertyDefinition(node) {
|
|
809
|
-
if (!node.value || !isIdentifier(node.key)) return;
|
|
810
|
-
reportSelfReferencesByName(context, sourceCode, node.value, node.key.name);
|
|
811
|
-
}
|
|
812
|
-
};
|
|
718
|
+
//#region src/overrides/scripts.ts
|
|
719
|
+
const scriptsOverrides = {
|
|
720
|
+
files: ["scripts/**/*.?(m)@(j|t)s"],
|
|
721
|
+
rules: { "unicorn/no-process-exit": "warn" }
|
|
722
|
+
};
|
|
723
|
+
//#endregion
|
|
724
|
+
//#region src/overrides/declarations.ts
|
|
725
|
+
const declarationsOverrides = {
|
|
726
|
+
files: ["**/*.d.ts"],
|
|
727
|
+
rules: {
|
|
728
|
+
"typescript/no-empty-interface": "off",
|
|
729
|
+
"typescript/no-empty-object-type": "off"
|
|
813
730
|
}
|
|
814
731
|
};
|
|
815
732
|
//#endregion
|
|
816
|
-
//#region src/
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
version: "1.0.0"
|
|
821
|
-
},
|
|
822
|
-
rules: { "no-self-assign": noSelfAssign }
|
|
733
|
+
//#region src/overrides/ambient.ts
|
|
734
|
+
const ambientOverrides = {
|
|
735
|
+
files: ["**/src/env.d.ts", "**/src/environment.d.ts"],
|
|
736
|
+
rules: { "no-redeclare": "off" }
|
|
823
737
|
};
|
|
824
738
|
//#endregion
|
|
825
739
|
//#region src/index.ts
|
|
826
|
-
const config =
|
|
740
|
+
const config = {
|
|
827
741
|
options: {
|
|
828
742
|
reportUnusedDisableDirectives: "warn",
|
|
829
743
|
typeAware: true,
|
|
@@ -831,14 +745,21 @@ const config = (userConfig) => defineConfig(defu({
|
|
|
831
745
|
},
|
|
832
746
|
plugins,
|
|
833
747
|
jsPlugins,
|
|
834
|
-
rules:
|
|
748
|
+
rules: {
|
|
749
|
+
...baseRules,
|
|
750
|
+
...stylisticRules
|
|
751
|
+
},
|
|
835
752
|
globals,
|
|
836
753
|
categories,
|
|
837
754
|
settings: { vitest: { typecheck: true } },
|
|
838
755
|
overrides: [
|
|
756
|
+
declarationsOverrides,
|
|
757
|
+
ambientOverrides,
|
|
758
|
+
i18nextOverrides,
|
|
839
759
|
playwrightOverrides,
|
|
840
760
|
reactOverrides,
|
|
841
|
-
reactNativeOverrides
|
|
761
|
+
reactNativeOverrides,
|
|
762
|
+
scriptsOverrides
|
|
842
763
|
],
|
|
843
764
|
ignorePatterns: [
|
|
844
765
|
"coverage/**",
|
|
@@ -848,8 +769,8 @@ const config = (userConfig) => defineConfig(defu({
|
|
|
848
769
|
"**/dist/**",
|
|
849
770
|
"**/*wasm-bindgen/**"
|
|
850
771
|
]
|
|
851
|
-
}
|
|
772
|
+
};
|
|
852
773
|
//#endregion
|
|
853
|
-
export { config
|
|
774
|
+
export { config };
|
|
854
775
|
|
|
855
776
|
//# sourceMappingURL=index.mjs.map
|