@wistia/oxlint-config 0.4.2 → 0.4.3
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/configs/javascript.mjs +2 -0
- package/configs/typescript.mjs +2 -0
- package/index.d.mts +1 -0
- package/index.mjs +1 -0
- package/package.json +1 -1
- package/rules/base.mjs +1 -6
- package/rules/import.mjs +1 -2
- package/rules/node.mjs +1 -3
- package/rules/react.mjs +1 -6
- package/rules/testing-library.mjs +0 -4
- package/rules/typescript.mjs +5 -3
- package/rules/unicorn.mjs +56 -0
- package/rules/vitest.mjs +10 -4
package/configs/javascript.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { baseRules } from '../rules/base.mjs';
|
|
|
3
3
|
import { importRules } from '../rules/import.mjs';
|
|
4
4
|
import { promiseRules } from '../rules/promise.mjs';
|
|
5
5
|
import { barrelFilesRules } from '../rules/barrel-files.mjs';
|
|
6
|
+
import { unicornRules } from '../rules/unicorn.mjs';
|
|
6
7
|
|
|
7
8
|
export default defineConfig({
|
|
8
9
|
plugins: [...baseRules.plugins, ...importRules.plugins, ...promiseRules.plugins],
|
|
@@ -12,5 +13,6 @@ export default defineConfig({
|
|
|
12
13
|
...importRules.rules,
|
|
13
14
|
...promiseRules.rules,
|
|
14
15
|
...barrelFilesRules.rules,
|
|
16
|
+
...unicornRules.rules,
|
|
15
17
|
},
|
|
16
18
|
});
|
package/configs/typescript.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { importRules } from '../rules/import.mjs';
|
|
|
4
4
|
import { promiseRules } from '../rules/promise.mjs';
|
|
5
5
|
import { typescriptRules } from '../rules/typescript.mjs';
|
|
6
6
|
import { barrelFilesRules } from '../rules/barrel-files.mjs';
|
|
7
|
+
import { unicornRules } from '../rules/unicorn.mjs';
|
|
7
8
|
|
|
8
9
|
export default defineConfig({
|
|
9
10
|
options: {
|
|
@@ -23,5 +24,6 @@ export default defineConfig({
|
|
|
23
24
|
...promiseRules.rules,
|
|
24
25
|
...typescriptRules.rules,
|
|
25
26
|
...barrelFilesRules.rules,
|
|
27
|
+
...unicornRules.rules,
|
|
26
28
|
},
|
|
27
29
|
});
|
package/index.d.mts
CHANGED
|
@@ -14,6 +14,7 @@ export declare const typescriptRules: RuleFile;
|
|
|
14
14
|
export declare const reactRules: RuleFile;
|
|
15
15
|
export declare const reactA11yRules: RuleFile;
|
|
16
16
|
export declare const nodeRules: RuleFile;
|
|
17
|
+
export declare const unicornRules: RuleFile;
|
|
17
18
|
export declare const vitestRules: RuleFile;
|
|
18
19
|
export declare const playwrightRules: RuleFile;
|
|
19
20
|
export declare const storybookRules: RuleFile;
|
package/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ export { typescriptRules } from './rules/typescript.mjs';
|
|
|
6
6
|
export { reactRules } from './rules/react.mjs';
|
|
7
7
|
export { reactA11yRules } from './rules/react-a11y.mjs';
|
|
8
8
|
export { nodeRules } from './rules/node.mjs';
|
|
9
|
+
export { unicornRules } from './rules/unicorn.mjs';
|
|
9
10
|
export { vitestRules } from './rules/vitest.mjs';
|
|
10
11
|
export { playwrightRules } from './rules/playwright.mjs';
|
|
11
12
|
export { storybookRules } from './rules/storybook.mjs';
|
package/package.json
CHANGED
package/rules/base.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export const baseRules = {
|
|
2
2
|
plugins: ['eslint', 'oxc'],
|
|
3
3
|
rules: {
|
|
4
|
-
// -- Possible Problems (Correctness) --
|
|
5
|
-
|
|
6
4
|
// Enforce return statements in callbacks of array methods
|
|
7
5
|
// https://eslint.org/docs/rules/array-callback-return
|
|
8
6
|
'eslint/array-callback-return': ['error', { allowImplicit: true }],
|
|
@@ -215,8 +213,6 @@ export const baseRules = {
|
|
|
215
213
|
// https://eslint.org/docs/rules/valid-typeof
|
|
216
214
|
'eslint/valid-typeof': ['error', { requireStringLiterals: true }],
|
|
217
215
|
|
|
218
|
-
// -- Suggestions --
|
|
219
|
-
|
|
220
216
|
// Enforce getter and setter pairs in objects and classes
|
|
221
217
|
// https://eslint.org/docs/rules/accessor-pairs
|
|
222
218
|
'eslint/accessor-pairs': 'error',
|
|
@@ -636,8 +632,7 @@ export const baseRules = {
|
|
|
636
632
|
// https://eslint.org/docs/rules/yoda
|
|
637
633
|
'eslint/yoda': 'error',
|
|
638
634
|
|
|
639
|
-
//
|
|
640
|
-
// These are bug-catchers that oxlint can detect natively.
|
|
635
|
+
//oxc rules - these are bug-catchers that oxlint can detect natively.
|
|
641
636
|
|
|
642
637
|
// Disallow calling array methods on arguments (it's array-like, not an array)
|
|
643
638
|
// https://oxc.rs/docs/guide/usage/linter/rules/oxc/bad-array-method-on-arguments.html
|
package/rules/import.mjs
CHANGED
|
@@ -87,8 +87,7 @@ export const importRules = {
|
|
|
87
87
|
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-webpack-loader-syntax.md
|
|
88
88
|
'import/no-webpack-loader-syntax': 'error',
|
|
89
89
|
|
|
90
|
-
//
|
|
91
|
-
// These rules have no native oxlint equivalent.
|
|
90
|
+
//rules via jsPlugins (eslint-plugin-import-x)
|
|
92
91
|
|
|
93
92
|
// Ensure imports point to files/modules that can be resolved
|
|
94
93
|
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md
|
package/rules/node.mjs
CHANGED
|
@@ -4,8 +4,6 @@ export const nodeRules = {
|
|
|
4
4
|
plugins: ['node'],
|
|
5
5
|
jsPlugins: [{ name: 'n', specifier: 'eslint-plugin-n' }],
|
|
6
6
|
rules: {
|
|
7
|
-
// -- Native oxlint node rules --
|
|
8
|
-
|
|
9
7
|
// Require error handling in callbacks
|
|
10
8
|
// https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/handle-callback-err.md
|
|
11
9
|
'node/handle-callback-err': 'error',
|
|
@@ -22,7 +20,7 @@ export const nodeRules = {
|
|
|
22
20
|
// https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-path-concat.md
|
|
23
21
|
'node/no-path-concat': 'error',
|
|
24
22
|
|
|
25
|
-
//
|
|
23
|
+
//eslint-plugin-n rules via jsPlugins
|
|
26
24
|
|
|
27
25
|
// Disallow deprecated APIs
|
|
28
26
|
// https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-deprecated-api.md
|
package/rules/react.mjs
CHANGED
|
@@ -4,8 +4,6 @@ export const reactRules = {
|
|
|
4
4
|
plugins: ['react'],
|
|
5
5
|
jsPlugins: [{ name: '@eslint-react', specifier: '@eslint-react/eslint-plugin' }],
|
|
6
6
|
rules: {
|
|
7
|
-
// -- React Core --
|
|
8
|
-
|
|
9
7
|
// Enforce that button elements have an explicit type attribute
|
|
10
8
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
|
|
11
9
|
'react/button-has-type': 'error',
|
|
@@ -236,10 +234,7 @@ export const reactRules = {
|
|
|
236
234
|
// decision: stylistic choice best left for formatter
|
|
237
235
|
'react/jsx-handler-names': 'off',
|
|
238
236
|
|
|
239
|
-
//
|
|
240
|
-
// These rules have no native oxlint equivalent.
|
|
241
|
-
|
|
242
|
-
// --- Core React rules ---
|
|
237
|
+
//rules via jsPlugins (@eslint-react/eslint-plugin)
|
|
243
238
|
|
|
244
239
|
// Validates higher order functions defining nested components or hooks
|
|
245
240
|
// https://eslint-react.xyz/docs/rules/component-hook-factories
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
export const testingLibraryRules = {
|
|
3
3
|
jsPlugins: ['eslint-plugin-testing-library', 'eslint-plugin-jest-dom'],
|
|
4
4
|
rules: {
|
|
5
|
-
// -- testing-library rules --
|
|
6
|
-
|
|
7
5
|
// Enforce async events to be awaited
|
|
8
6
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/await-async-events.md
|
|
9
7
|
'eslint-plugin-testing-library/await-async-events': 'error',
|
|
@@ -122,8 +120,6 @@ export const testingLibraryRules = {
|
|
|
122
120
|
// https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/render-result-naming-convention.md
|
|
123
121
|
'eslint-plugin-testing-library/render-result-naming-convention': 'error',
|
|
124
122
|
|
|
125
|
-
// -- jest-dom rules --
|
|
126
|
-
|
|
127
123
|
// Prefer toBeChecked over checking attributes
|
|
128
124
|
// https://github.com/testing-library/eslint-plugin-jest-dom/blob/main/docs/rules/prefer-checked.md
|
|
129
125
|
'eslint-plugin-jest-dom/prefer-checked': 'error',
|
package/rules/typescript.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const typescriptRules = {
|
|
2
2
|
plugins: ['typescript'],
|
|
3
3
|
rules: {
|
|
4
|
-
//
|
|
4
|
+
//Disable base eslint rules superseded by typescript equivalents --
|
|
5
5
|
'eslint/class-methods-use-this': 'off',
|
|
6
6
|
'eslint/default-param-last': 'off',
|
|
7
7
|
'eslint/init-declarations': 'off',
|
|
@@ -44,8 +44,6 @@ export const typescriptRules = {
|
|
|
44
44
|
},
|
|
45
45
|
],
|
|
46
46
|
|
|
47
|
-
// -- TypeScript rules --
|
|
48
|
-
|
|
49
47
|
// Require that function overload signatures be consecutive
|
|
50
48
|
// https://typescript-eslint.io/rules/adjacent-overload-signatures
|
|
51
49
|
'typescript/adjacent-overload-signatures': 'error',
|
|
@@ -314,6 +312,10 @@ export const typescriptRules = {
|
|
|
314
312
|
// https://typescript-eslint.io/rules/no-unsafe-unary-minus
|
|
315
313
|
'typescript/no-unsafe-unary-minus': 'error',
|
|
316
314
|
|
|
315
|
+
// Disallow useless default assignments in parameter destructuring
|
|
316
|
+
// https://typescript-eslint.io/rules/no-useless-default-assignment
|
|
317
|
+
'typescript/no-useless-default-assignment': 'error',
|
|
318
|
+
|
|
317
319
|
// Disallow empty exports that don't change anything in a module file
|
|
318
320
|
// https://typescript-eslint.io/rules/no-useless-empty-export
|
|
319
321
|
'typescript/no-useless-empty-export': 'error',
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const unicornRules = {
|
|
2
|
+
plugins: [],
|
|
3
|
+
rules: {
|
|
4
|
+
// Disallow using await in Promise.all/race/etc. array arguments
|
|
5
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.html
|
|
6
|
+
'unicorn/no-await-in-promise-methods': 'error',
|
|
7
|
+
|
|
8
|
+
// Disallow empty files
|
|
9
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-empty-file.html
|
|
10
|
+
'unicorn/no-empty-file': 'error',
|
|
11
|
+
|
|
12
|
+
// Disallow invalid options in fetch() calls
|
|
13
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-invalid-fetch-options.html
|
|
14
|
+
'unicorn/no-invalid-fetch-options': 'error',
|
|
15
|
+
|
|
16
|
+
// Disallow invalid removeEventListener arguments
|
|
17
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-invalid-remove-event-listener.html
|
|
18
|
+
'unicorn/no-invalid-remove-event-listener': 'error',
|
|
19
|
+
|
|
20
|
+
// Disallow new Array() (use Array.from or [...] instead)
|
|
21
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-new-array.html
|
|
22
|
+
'unicorn/no-new-array': 'error',
|
|
23
|
+
|
|
24
|
+
// Disallow passing single-element arrays to Promise.all/race/etc.
|
|
25
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-single-promise-in-promise-methods.html
|
|
26
|
+
'unicorn/no-single-promise-in-promise-methods': 'error',
|
|
27
|
+
|
|
28
|
+
// Disallow thenable objects (confuses await/Promise behavior)
|
|
29
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-thenable.html
|
|
30
|
+
'unicorn/no-thenable': 'error',
|
|
31
|
+
|
|
32
|
+
// Disallow unnecessary await on non-Promise values
|
|
33
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-unnecessary-await.html
|
|
34
|
+
'unicorn/no-unnecessary-await': 'error',
|
|
35
|
+
|
|
36
|
+
// Disallow useless fallback in spread (e.g. ...obj || {})
|
|
37
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-fallback-in-spread.html
|
|
38
|
+
'unicorn/no-useless-fallback-in-spread': 'error',
|
|
39
|
+
|
|
40
|
+
// Disallow useless length checks before array operations
|
|
41
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-length-check.html
|
|
42
|
+
'unicorn/no-useless-length-check': 'error',
|
|
43
|
+
|
|
44
|
+
// Disallow useless spread operators
|
|
45
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-spread.html
|
|
46
|
+
'unicorn/no-useless-spread': 'error',
|
|
47
|
+
|
|
48
|
+
// Prefer Set#size over converting to array and checking length
|
|
49
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-set-size.html
|
|
50
|
+
'unicorn/prefer-set-size': 'error',
|
|
51
|
+
|
|
52
|
+
// Prefer String#startsWith/endsWith over regex or slice comparisons
|
|
53
|
+
// https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-string-starts-ends-with.html
|
|
54
|
+
'unicorn/prefer-string-starts-ends-with': 'error',
|
|
55
|
+
},
|
|
56
|
+
};
|
package/rules/vitest.mjs
CHANGED
|
@@ -10,8 +10,6 @@ export const vitestRules = {
|
|
|
10
10
|
'eslint-plugin-no-only-tests',
|
|
11
11
|
],
|
|
12
12
|
rules: {
|
|
13
|
-
// -- vitest-specific rules (no Jest equivalent) --
|
|
14
|
-
|
|
15
13
|
// Require .test test file pattern
|
|
16
14
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-filename.md
|
|
17
15
|
'vitest/consistent-test-filename': 'error',
|
|
@@ -84,11 +82,19 @@ export const vitestRules = {
|
|
|
84
82
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-mock-type-parameters.md
|
|
85
83
|
'vitest/require-mock-type-parameters': 'error',
|
|
86
84
|
|
|
85
|
+
// Require awaited expect.poll() calls
|
|
86
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-awaited-expect-poll.md
|
|
87
|
+
'vitest/require-awaited-expect-poll': 'error',
|
|
88
|
+
|
|
87
89
|
// Require local Test Context for concurrent snapshot tests
|
|
88
90
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/require-local-test-context-for-concurrent-snapshots.md
|
|
89
91
|
'vitest/require-local-test-context-for-concurrent-snapshots': 'error',
|
|
90
92
|
|
|
91
|
-
//
|
|
93
|
+
// Warn on test.todo() usage
|
|
94
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/warn-todo.md
|
|
95
|
+
'vitest/warn-todo': 'error',
|
|
96
|
+
|
|
97
|
+
//oxlint uses the "jest/" prefix for these unfortunately
|
|
92
98
|
|
|
93
99
|
// Prefer test or it but not both
|
|
94
100
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/consistent-test-it.md
|
|
@@ -274,7 +280,7 @@ export const vitestRules = {
|
|
|
274
280
|
// decision: `allowArguments` avoids conflict with `prefer-describe-function-title` rule, which is enabled
|
|
275
281
|
'jest/valid-title': ['error', { allowArguments: true }],
|
|
276
282
|
|
|
277
|
-
//
|
|
283
|
+
//rules via jsPlugins (@vitest/eslint-plugin + no-only-tests)
|
|
278
284
|
|
|
279
285
|
// Disallow .only tests
|
|
280
286
|
// https://github.com/levibuzolic/eslint-plugin-no-only-tests
|