@comment-labs/oxlint-config 1.0.0-beta.2 → 1.0.0-beta.21
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 +189 -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,33 @@ 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",
|
|
117
|
+
"vitest/no-hooks": "off",
|
|
102
118
|
"jsdoc/require-param-type": "off",
|
|
103
119
|
"jsdoc/require-returns": "off",
|
|
104
120
|
"jsdoc/require-param": "off",
|
|
@@ -106,7 +122,21 @@ const baseRules = {
|
|
|
106
122
|
"unicorn/switch-case-braces": ["warn", "avoid"],
|
|
107
123
|
"unicorn/no-array-method-this-argument": "warn",
|
|
108
124
|
"unicorn/no-await-expression-member": "warn",
|
|
109
|
-
"
|
|
125
|
+
"unicorn/no-invalid-fetch-options": "off",
|
|
126
|
+
"unicorn/import-style": ["warn", {
|
|
127
|
+
extendDefaultStyles: false,
|
|
128
|
+
styles: {
|
|
129
|
+
"path": {
|
|
130
|
+
named: true,
|
|
131
|
+
default: false
|
|
132
|
+
},
|
|
133
|
+
"util": {
|
|
134
|
+
named: true,
|
|
135
|
+
default: false
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}],
|
|
139
|
+
"unicorn/max-nested-calls": ["warn", { max: 5 }],
|
|
110
140
|
"comment-labs-js/no-self-assign": "error",
|
|
111
141
|
"brettz9-js/arrow-parens": "off",
|
|
112
142
|
"brettz9-js/block-scoped-var": "off",
|
|
@@ -116,7 +146,6 @@ const baseRules = {
|
|
|
116
146
|
"brettz9-js/no-use-ignored-vars": "warn",
|
|
117
147
|
"brettz9-js/no-useless-rest-spread": "warn",
|
|
118
148
|
"brettz9-js/prefer-for-of": "off",
|
|
119
|
-
"i18next-js/no-literal-string": "warn",
|
|
120
149
|
"import-zod-js/prefer-zod-namespace": "warn",
|
|
121
150
|
"security-js/detect-unsafe-regex": "error",
|
|
122
151
|
"security-js/detect-non-literal-regexp": "error",
|
|
@@ -142,6 +171,106 @@ const baseRules = {
|
|
|
142
171
|
"unicorn-js/prefer-switch": "warn",
|
|
143
172
|
"unicorn-js/switch-case-break-position": "warn",
|
|
144
173
|
"unicorn-js/prefer-single-call": "warn",
|
|
174
|
+
"jsdoc-js/check-alignment": "warn",
|
|
175
|
+
"jsdoc-js/check-indentation": "warn",
|
|
176
|
+
"jsdoc-js/check-line-alignment": "warn",
|
|
177
|
+
"jsdoc-js/check-param-names": "warn",
|
|
178
|
+
"jsdoc-js/check-types": "warn",
|
|
179
|
+
"jsdoc-js/check-values": "warn",
|
|
180
|
+
"jsdoc-js/multiline-blocks": "warn",
|
|
181
|
+
"jsdoc-js/no-multi-asterisks": "warn",
|
|
182
|
+
"jsdoc-js/no-undefined-types": "warn",
|
|
183
|
+
"jsdoc-js/require-returns-check": "warn",
|
|
184
|
+
"jsdoc-js/require-yields-check": "warn",
|
|
185
|
+
"jsdoc-js/tag-lines": "warn",
|
|
186
|
+
"jsdoc-js/valid-types": "warn",
|
|
187
|
+
"e18e-js/prefer-array-at": "error",
|
|
188
|
+
"e18e-js/prefer-array-fill": "error",
|
|
189
|
+
"e18e-js/prefer-includes": "error",
|
|
190
|
+
"e18e-js/prefer-array-to-reversed": "error",
|
|
191
|
+
"e18e-js/prefer-array-to-sorted": "error",
|
|
192
|
+
"e18e-js/prefer-array-to-spliced": "error",
|
|
193
|
+
"e18e-js/prefer-nullish-coalescing": "error",
|
|
194
|
+
"e18e-js/prefer-object-has-own": "error",
|
|
195
|
+
"e18e-js/prefer-spread-syntax": "error",
|
|
196
|
+
"e18e-js/prefer-url-canparse": "error",
|
|
197
|
+
"e18e-js/ban-dependencies": "error",
|
|
198
|
+
"e18e-js/prefer-array-from-map": "error",
|
|
199
|
+
"e18e-js/prefer-timer-args": "error",
|
|
200
|
+
"e18e-js/prefer-date-now": "error",
|
|
201
|
+
"e18e-js/prefer-regex-test": "error",
|
|
202
|
+
"e18e-js/prefer-array-some": "error",
|
|
203
|
+
"e18e-js/prefer-static-regex": "error",
|
|
204
|
+
"no-control-regex": "error",
|
|
205
|
+
"no-misleading-character-class": "error",
|
|
206
|
+
"no-regex-spaces": "error",
|
|
207
|
+
"no-invalid-regexp": "off",
|
|
208
|
+
"no-useless-backreference": "off",
|
|
209
|
+
"no-empty-character-class": "off",
|
|
210
|
+
"regexp-js/confusing-quantifier": "warn",
|
|
211
|
+
"regexp-js/control-character-escape": "error",
|
|
212
|
+
"regexp-js/match-any": "error",
|
|
213
|
+
"regexp-js/negation": "error",
|
|
214
|
+
"regexp-js/no-contradiction-with-assertion": "error",
|
|
215
|
+
"regexp-js/no-dupe-characters-character-class": "error",
|
|
216
|
+
"regexp-js/no-dupe-disjunctions": "error",
|
|
217
|
+
"regexp-js/no-empty-alternative": "warn",
|
|
218
|
+
"regexp-js/no-empty-capturing-group": "error",
|
|
219
|
+
"regexp-js/no-empty-character-class": "error",
|
|
220
|
+
"regexp-js/no-empty-group": "error",
|
|
221
|
+
"regexp-js/no-empty-lookarounds-assertion": "error",
|
|
222
|
+
"regexp-js/no-empty-string-literal": "error",
|
|
223
|
+
"regexp-js/no-escape-backspace": "error",
|
|
224
|
+
"regexp-js/no-extra-lookaround-assertions": "error",
|
|
225
|
+
"regexp-js/no-invalid-regexp": "error",
|
|
226
|
+
"regexp-js/no-invisible-character": "error",
|
|
227
|
+
"regexp-js/no-lazy-ends": "warn",
|
|
228
|
+
"regexp-js/no-legacy-features": "error",
|
|
229
|
+
"regexp-js/no-misleading-capturing-group": "error",
|
|
230
|
+
"regexp-js/no-misleading-unicode-character": "error",
|
|
231
|
+
"regexp-js/no-missing-g-flag": "error",
|
|
232
|
+
"regexp-js/no-non-standard-flag": "error",
|
|
233
|
+
"regexp-js/no-obscure-range": "error",
|
|
234
|
+
"regexp-js/no-optional-assertion": "error",
|
|
235
|
+
"regexp-js/no-potentially-useless-backreference": "warn",
|
|
236
|
+
"regexp-js/no-super-linear-backtracking": "error",
|
|
237
|
+
"regexp-js/no-trivially-nested-assertion": "error",
|
|
238
|
+
"regexp-js/no-trivially-nested-quantifier": "error",
|
|
239
|
+
"regexp-js/no-unused-capturing-group": "error",
|
|
240
|
+
"regexp-js/no-useless-assertions": "error",
|
|
241
|
+
"regexp-js/no-useless-backreference": "error",
|
|
242
|
+
"regexp-js/no-useless-character-class": "error",
|
|
243
|
+
"regexp-js/no-useless-dollar-replacements": "error",
|
|
244
|
+
"regexp-js/no-useless-escape": "error",
|
|
245
|
+
"regexp-js/no-useless-flag": "warn",
|
|
246
|
+
"regexp-js/no-useless-lazy": "error",
|
|
247
|
+
"regexp-js/no-useless-non-capturing-group": "error",
|
|
248
|
+
"regexp-js/no-useless-quantifier": "error",
|
|
249
|
+
"regexp-js/no-useless-range": "error",
|
|
250
|
+
"regexp-js/no-useless-set-operand": "error",
|
|
251
|
+
"regexp-js/no-useless-string-literal": "error",
|
|
252
|
+
"regexp-js/no-useless-two-nums-quantifier": "error",
|
|
253
|
+
"regexp-js/no-zero-quantifier": "error",
|
|
254
|
+
"regexp-js/optimal-lookaround-quantifier": "warn",
|
|
255
|
+
"regexp-js/optimal-quantifier-concatenation": "error",
|
|
256
|
+
"regexp-js/prefer-character-class": "error",
|
|
257
|
+
"regexp-js/prefer-d": "error",
|
|
258
|
+
"regexp-js/prefer-plus-quantifier": "error",
|
|
259
|
+
"regexp-js/prefer-predefined-assertion": "error",
|
|
260
|
+
"regexp-js/prefer-question-quantifier": "error",
|
|
261
|
+
"regexp-js/prefer-range": "error",
|
|
262
|
+
"regexp-js/prefer-set-operation": "error",
|
|
263
|
+
"regexp-js/prefer-star-quantifier": "error",
|
|
264
|
+
"regexp-js/prefer-unicode-codepoint-escapes": "error",
|
|
265
|
+
"regexp-js/prefer-w": "error",
|
|
266
|
+
"regexp-js/simplify-set-operations": "error",
|
|
267
|
+
"regexp-js/sort-flags": "error",
|
|
268
|
+
"regexp-js/strict": "error",
|
|
269
|
+
"regexp-js/use-ignore-case": "error"
|
|
270
|
+
};
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region src/stylistic-rules.ts
|
|
273
|
+
const stylisticRules = {
|
|
145
274
|
"stylistic-js/type-generic-spacing": "warn",
|
|
146
275
|
"stylistic-js/type-named-tuple-spacing": "warn",
|
|
147
276
|
"stylistic-js/function-call-spacing": ["warn", "never"],
|
|
@@ -386,104 +515,7 @@ const baseRules = {
|
|
|
386
515
|
prev: "multiline-block-like",
|
|
387
516
|
next: "*"
|
|
388
517
|
}
|
|
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"
|
|
518
|
+
]
|
|
487
519
|
};
|
|
488
520
|
//#endregion
|
|
489
521
|
//#region src/plugins.ts
|
|
@@ -505,7 +537,7 @@ const plugins = [
|
|
|
505
537
|
//#endregion
|
|
506
538
|
//#region src/utils.ts
|
|
507
539
|
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;
|
|
540
|
+
if ((await Promise.all(configFiles.map(async (file) => await access(join(cwd(), file)).then(() => true).catch(() => false)))).some(Boolean)) return true;
|
|
509
541
|
const packageJson = up("package.json", { cwd: cwd() });
|
|
510
542
|
if (typeof packageJson === "string") {
|
|
511
543
|
const json = JSON.parse(await readFile(packageJson, "utf8"));
|
|
@@ -528,7 +560,9 @@ const cloudflareSpecificGlobals = {
|
|
|
528
560
|
IdentityTransformStream: "readonly",
|
|
529
561
|
HTMLRewriter: "readonly",
|
|
530
562
|
WebSocketPair: "readonly",
|
|
531
|
-
WebSocketRequestResponsePair: "readonly"
|
|
563
|
+
WebSocketRequestResponsePair: "readonly",
|
|
564
|
+
scheduler: "readonly",
|
|
565
|
+
caches: "readonly"
|
|
532
566
|
};
|
|
533
567
|
const cloudflare = {
|
|
534
568
|
...base,
|
|
@@ -556,60 +590,67 @@ const globals = await getGlobals();
|
|
|
556
590
|
//#endregion
|
|
557
591
|
//#region src/js-plugins.ts
|
|
558
592
|
const jsPlugins = [
|
|
559
|
-
|
|
593
|
+
{
|
|
594
|
+
name: "comment-labs-js",
|
|
595
|
+
specifier: "@comment-labs/oxlint-config/plugins/labs"
|
|
596
|
+
},
|
|
560
597
|
{
|
|
561
598
|
name: "brettz9-js",
|
|
562
|
-
specifier: "@
|
|
599
|
+
specifier: "@comment-labs/oxlint-config/plugins/brettz9"
|
|
563
600
|
},
|
|
564
601
|
{
|
|
565
602
|
name: "i18next-js",
|
|
566
|
-
specifier: "
|
|
603
|
+
specifier: "@comment-labs/oxlint-config/plugins/i18next"
|
|
567
604
|
},
|
|
568
605
|
{
|
|
569
606
|
name: "import-zod-js",
|
|
570
|
-
specifier: "
|
|
607
|
+
specifier: "@comment-labs/oxlint-config/plugins/import-zod"
|
|
571
608
|
},
|
|
572
609
|
{
|
|
573
610
|
name: "playwright-js",
|
|
574
|
-
specifier: "
|
|
611
|
+
specifier: "@comment-labs/oxlint-config/plugins/playwright"
|
|
575
612
|
},
|
|
576
613
|
{
|
|
577
614
|
name: "react-hooks-js",
|
|
578
|
-
specifier: "
|
|
615
|
+
specifier: "@comment-labs/oxlint-config/plugins/react-hooks"
|
|
579
616
|
},
|
|
580
617
|
{
|
|
581
618
|
name: "react-native-js",
|
|
582
|
-
specifier: "
|
|
619
|
+
specifier: "@comment-labs/oxlint-config/plugins/react-native"
|
|
583
620
|
},
|
|
584
621
|
{
|
|
585
622
|
name: "react-refresh-js",
|
|
586
|
-
specifier: "
|
|
623
|
+
specifier: "@comment-labs/oxlint-config/plugins/react-refresh"
|
|
587
624
|
},
|
|
588
625
|
{
|
|
589
626
|
name: "security-js",
|
|
590
|
-
specifier: "
|
|
627
|
+
specifier: "@comment-labs/oxlint-config/plugins/security"
|
|
591
628
|
},
|
|
592
629
|
{
|
|
593
630
|
name: "unicorn-js",
|
|
594
|
-
specifier: "
|
|
631
|
+
specifier: "@comment-labs/oxlint-config/plugins/unicorn"
|
|
595
632
|
},
|
|
596
633
|
{
|
|
597
634
|
name: "stylistic-js",
|
|
598
|
-
specifier: "@
|
|
635
|
+
specifier: "@comment-labs/oxlint-config/plugins/stylistic"
|
|
599
636
|
},
|
|
600
637
|
{
|
|
601
638
|
name: "jsdoc-js",
|
|
602
|
-
specifier: "
|
|
639
|
+
specifier: "@comment-labs/oxlint-config/plugins/jsdoc"
|
|
603
640
|
},
|
|
604
641
|
{
|
|
605
642
|
name: "e18e-js",
|
|
606
|
-
specifier: "@
|
|
643
|
+
specifier: "@comment-labs/oxlint-config/plugins/e18e"
|
|
607
644
|
},
|
|
608
645
|
{
|
|
609
646
|
name: "regexp-js",
|
|
610
|
-
specifier: "
|
|
647
|
+
specifier: "@comment-labs/oxlint-config/plugins/regexp"
|
|
611
648
|
}
|
|
612
649
|
];
|
|
650
|
+
const i18nextOverrides = {
|
|
651
|
+
files: [await enableMode([], ["i18next"]) ? "**/*" : "___disabled"],
|
|
652
|
+
rules: { "i18next-js/no-literal-string": "warn" }
|
|
653
|
+
};
|
|
613
654
|
//#endregion
|
|
614
655
|
//#region src/overrides/playwright.ts
|
|
615
656
|
const playwrightOverrides = {
|
|
@@ -675,155 +716,29 @@ const reactNativeOverrides = {
|
|
|
675
716
|
}
|
|
676
717
|
};
|
|
677
718
|
//#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
|
-
};
|
|
719
|
+
//#region src/overrides/scripts.ts
|
|
720
|
+
const scriptsOverrides = {
|
|
721
|
+
files: ["scripts/**/*.?(m)@(j|t)s"],
|
|
722
|
+
rules: { "unicorn/no-process-exit": "warn" }
|
|
723
|
+
};
|
|
724
|
+
//#endregion
|
|
725
|
+
//#region src/overrides/declarations.ts
|
|
726
|
+
const declarationsOverrides = {
|
|
727
|
+
files: ["**/*.d.ts"],
|
|
728
|
+
rules: {
|
|
729
|
+
"typescript/no-empty-interface": "off",
|
|
730
|
+
"typescript/no-empty-object-type": "off"
|
|
813
731
|
}
|
|
814
732
|
};
|
|
815
733
|
//#endregion
|
|
816
|
-
//#region src/
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
version: "1.0.0"
|
|
821
|
-
},
|
|
822
|
-
rules: { "no-self-assign": noSelfAssign }
|
|
734
|
+
//#region src/overrides/ambient.ts
|
|
735
|
+
const ambientOverrides = {
|
|
736
|
+
files: ["**/src/env.d.ts", "**/src/environment.d.ts"],
|
|
737
|
+
rules: { "no-redeclare": "off" }
|
|
823
738
|
};
|
|
824
739
|
//#endregion
|
|
825
740
|
//#region src/index.ts
|
|
826
|
-
const config =
|
|
741
|
+
const config = {
|
|
827
742
|
options: {
|
|
828
743
|
reportUnusedDisableDirectives: "warn",
|
|
829
744
|
typeAware: true,
|
|
@@ -831,14 +746,21 @@ const config = (userConfig) => defineConfig(defu({
|
|
|
831
746
|
},
|
|
832
747
|
plugins,
|
|
833
748
|
jsPlugins,
|
|
834
|
-
rules:
|
|
749
|
+
rules: {
|
|
750
|
+
...baseRules,
|
|
751
|
+
...stylisticRules
|
|
752
|
+
},
|
|
835
753
|
globals,
|
|
836
754
|
categories,
|
|
837
755
|
settings: { vitest: { typecheck: true } },
|
|
838
756
|
overrides: [
|
|
757
|
+
declarationsOverrides,
|
|
758
|
+
ambientOverrides,
|
|
759
|
+
i18nextOverrides,
|
|
839
760
|
playwrightOverrides,
|
|
840
761
|
reactOverrides,
|
|
841
|
-
reactNativeOverrides
|
|
762
|
+
reactNativeOverrides,
|
|
763
|
+
scriptsOverrides
|
|
842
764
|
],
|
|
843
765
|
ignorePatterns: [
|
|
844
766
|
"coverage/**",
|
|
@@ -848,8 +770,8 @@ const config = (userConfig) => defineConfig(defu({
|
|
|
848
770
|
"**/dist/**",
|
|
849
771
|
"**/*wasm-bindgen/**"
|
|
850
772
|
]
|
|
851
|
-
}
|
|
773
|
+
};
|
|
852
774
|
//#endregion
|
|
853
|
-
export { config
|
|
775
|
+
export { config };
|
|
854
776
|
|
|
855
777
|
//# sourceMappingURL=index.mjs.map
|