@wistia/oxlint-config 0.3.2 → 0.3.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 +1 -0
- package/configs/typescript.mjs +1 -0
- package/package.json +2 -1
- package/rules/base.mjs +63 -0
- package/rules/import.mjs +84 -0
- package/rules/vitest.mjs +4 -7
package/configs/javascript.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { promiseRules } from '../rules/promise.mjs';
|
|
|
5
5
|
|
|
6
6
|
export default defineConfig({
|
|
7
7
|
plugins: [...baseRules.plugins, ...importRules.plugins, ...promiseRules.plugins],
|
|
8
|
+
jsPlugins: [...(importRules.jsPlugins || [])],
|
|
8
9
|
rules: {
|
|
9
10
|
...baseRules.rules,
|
|
10
11
|
...importRules.rules,
|
package/configs/typescript.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wistia/oxlint-config",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Wistia's Oxlint configurations",
|
|
5
5
|
"packageManager": "yarn@4.13.0",
|
|
6
6
|
"type": "module",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@vitest/eslint-plugin": "^1.6.14",
|
|
41
|
+
"eslint-plugin-import-x": "^4.16.2",
|
|
41
42
|
"eslint-plugin-jest-dom": "^5.5.0",
|
|
42
43
|
"eslint-plugin-n": "^17.24.0",
|
|
43
44
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
package/rules/base.mjs
CHANGED
|
@@ -221,10 +221,22 @@ export const baseRules = {
|
|
|
221
221
|
// https://eslint.org/docs/rules/accessor-pairs
|
|
222
222
|
'eslint/accessor-pairs': 'error',
|
|
223
223
|
|
|
224
|
+
// Require braces around arrow function bodies
|
|
225
|
+
// https://eslint.org/docs/rules/arrow-body-style
|
|
226
|
+
'eslint/arrow-body-style': 'off',
|
|
227
|
+
|
|
224
228
|
// Enforce the use of variables within the scope they are defined
|
|
225
229
|
// https://eslint.org/docs/rules/block-scoped-var
|
|
226
230
|
'eslint/block-scoped-var': 'error',
|
|
227
231
|
|
|
232
|
+
// Enforce that class methods utilize this
|
|
233
|
+
// https://eslint.org/docs/rules/class-methods-use-this
|
|
234
|
+
'eslint/class-methods-use-this': 'error',
|
|
235
|
+
|
|
236
|
+
// Require default cases in switch statements
|
|
237
|
+
// https://eslint.org/docs/rules/default-case
|
|
238
|
+
'eslint/default-case': ['error', { commentPattern: '^no default$' }],
|
|
239
|
+
|
|
228
240
|
// Enforce default clauses in switch statements to be last
|
|
229
241
|
// https://eslint.org/docs/rules/default-case-last
|
|
230
242
|
'eslint/default-case-last': 'error',
|
|
@@ -241,6 +253,18 @@ export const baseRules = {
|
|
|
241
253
|
// https://eslint.org/docs/rules/guard-for-in
|
|
242
254
|
'eslint/guard-for-in': 'error',
|
|
243
255
|
|
|
256
|
+
// Require or disallow named function expressions
|
|
257
|
+
// https://eslint.org/docs/rules/func-names
|
|
258
|
+
'eslint/func-names': ['error', 'always'],
|
|
259
|
+
|
|
260
|
+
// Enforce the consistent use of either function declarations or expressions
|
|
261
|
+
// https://eslint.org/docs/rules/func-style
|
|
262
|
+
'eslint/func-style': ['error', 'expression'],
|
|
263
|
+
|
|
264
|
+
// Enforce grouped accessor pairs in object literals and classes
|
|
265
|
+
// https://eslint.org/docs/rules/grouped-accessor-pairs
|
|
266
|
+
'eslint/grouped-accessor-pairs': 'error',
|
|
267
|
+
|
|
244
268
|
// Enforce minimum and maximum identifier lengths
|
|
245
269
|
// https://eslint.org/docs/rules/id-length
|
|
246
270
|
'eslint/id-length': [
|
|
@@ -255,6 +279,18 @@ export const baseRules = {
|
|
|
255
279
|
// https://eslint.org/docs/rules/max-classes-per-file
|
|
256
280
|
'eslint/max-classes-per-file': ['error', 1],
|
|
257
281
|
|
|
282
|
+
// Require constructor names to begin with a capital letter
|
|
283
|
+
// https://eslint.org/docs/rules/new-cap
|
|
284
|
+
'eslint/new-cap': [
|
|
285
|
+
'error',
|
|
286
|
+
{
|
|
287
|
+
newIsCap: true,
|
|
288
|
+
newIsCapExceptions: [],
|
|
289
|
+
capIsNew: false,
|
|
290
|
+
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
|
|
291
|
+
},
|
|
292
|
+
],
|
|
293
|
+
|
|
258
294
|
// Disallow the use of alert, confirm, and prompt
|
|
259
295
|
// https://eslint.org/docs/rules/no-alert
|
|
260
296
|
'eslint/no-alert': 'error',
|
|
@@ -355,6 +391,17 @@ export const baseRules = {
|
|
|
355
391
|
// https://eslint.org/docs/rules/no-loop-func
|
|
356
392
|
'eslint/no-loop-func': 'error',
|
|
357
393
|
|
|
394
|
+
// Disallow magic numbers
|
|
395
|
+
// https://eslint.org/docs/rules/no-magic-numbers
|
|
396
|
+
'eslint/no-magic-numbers': [
|
|
397
|
+
'error',
|
|
398
|
+
{
|
|
399
|
+
ignore: [-1, 0, 1, 2, 3, 4, 5, 100, 1024, 1000, 10000],
|
|
400
|
+
ignoreArrayIndexes: true,
|
|
401
|
+
ignoreDefaultValues: true,
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
|
|
358
405
|
// Disallow use of chained assignment expressions
|
|
359
406
|
// https://eslint.org/docs/rules/no-multi-assign
|
|
360
407
|
'eslint/no-multi-assign': 'error',
|
|
@@ -425,6 +472,10 @@ export const baseRules = {
|
|
|
425
472
|
// https://eslint.org/docs/rules/no-regex-spaces
|
|
426
473
|
'eslint/no-regex-spaces': 'error',
|
|
427
474
|
|
|
475
|
+
// Disallow specified modules when loaded by import
|
|
476
|
+
// https://eslint.org/docs/rules/no-restricted-imports
|
|
477
|
+
'eslint/no-restricted-imports': 'off',
|
|
478
|
+
|
|
428
479
|
// Disallow assignment operators in return statements
|
|
429
480
|
// https://eslint.org/docs/rules/no-return-assign
|
|
430
481
|
'eslint/no-return-assign': ['error', 'always'],
|
|
@@ -502,6 +553,10 @@ export const baseRules = {
|
|
|
502
553
|
// https://eslint.org/docs/rules/no-with
|
|
503
554
|
'eslint/no-with': 'error',
|
|
504
555
|
|
|
556
|
+
// Require or disallow assignment operator shorthand where possible
|
|
557
|
+
// https://eslint.org/docs/rules/operator-assignment
|
|
558
|
+
'eslint/operator-assignment': ['error', 'always'],
|
|
559
|
+
|
|
505
560
|
// Require const declarations for variables that are never reassigned after declared
|
|
506
561
|
// https://eslint.org/docs/rules/prefer-const
|
|
507
562
|
'eslint/prefer-const': ['error', { destructuring: 'any', ignoreReadBeforeAssign: true }],
|
|
@@ -569,6 +624,14 @@ export const baseRules = {
|
|
|
569
624
|
// https://eslint.org/docs/rules/symbol-description
|
|
570
625
|
'eslint/symbol-description': 'error',
|
|
571
626
|
|
|
627
|
+
// Require or disallow Unicode byte order mark (BOM)
|
|
628
|
+
// https://eslint.org/docs/rules/unicode-bom
|
|
629
|
+
'eslint/unicode-bom': ['error', 'never'],
|
|
630
|
+
|
|
631
|
+
// Require var declarations be placed at the top of their containing scope
|
|
632
|
+
// https://eslint.org/docs/rules/vars-on-top
|
|
633
|
+
'eslint/vars-on-top': 'error',
|
|
634
|
+
|
|
572
635
|
// Require or disallow "Yoda" conditions
|
|
573
636
|
// https://eslint.org/docs/rules/yoda
|
|
574
637
|
'eslint/yoda': 'error',
|
package/rules/import.mjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
// Native oxlint import rules + eslint-plugin-import-x via jsPlugins for rules
|
|
2
|
+
// without native equivalents.
|
|
1
3
|
export const importRules = {
|
|
2
4
|
plugins: ['import'],
|
|
5
|
+
jsPlugins: [{ name: 'import-x-js', specifier: 'eslint-plugin-import-x' }],
|
|
3
6
|
rules: {
|
|
4
7
|
// Ensure named imports coupled with named exports
|
|
5
8
|
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/named.md
|
|
@@ -83,5 +86,86 @@ export const importRules = {
|
|
|
83
86
|
// Forbid Webpack loader syntax in imports
|
|
84
87
|
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-webpack-loader-syntax.md
|
|
85
88
|
'import/no-webpack-loader-syntax': 'error',
|
|
89
|
+
|
|
90
|
+
// -- Rules via jsPlugins (eslint-plugin-import-x) --
|
|
91
|
+
// These rules have no native oxlint equivalent.
|
|
92
|
+
|
|
93
|
+
// Ensure imports point to files/modules that can be resolved
|
|
94
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-unresolved.md
|
|
95
|
+
'import-x-js/no-unresolved': ['error', { caseSensitive: true }],
|
|
96
|
+
|
|
97
|
+
// Disallow invalid exports, e.g. multiple defaults
|
|
98
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/export.md
|
|
99
|
+
'import-x-js/export': 'error',
|
|
100
|
+
|
|
101
|
+
// Forbid the use of extraneous packages
|
|
102
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-extraneous-dependencies.md
|
|
103
|
+
'import-x-js/no-extraneous-dependencies': [
|
|
104
|
+
'error',
|
|
105
|
+
{
|
|
106
|
+
devDependencies: [
|
|
107
|
+
'**/*{.,_}{test,vitest,spec}.{js,jsx,ts,tsx}',
|
|
108
|
+
'**/vite.config.{ts,js,cjs,mjs,mts}',
|
|
109
|
+
'**/vitest.config.{ts,js,cjs,mjs,mts}',
|
|
110
|
+
'**/jest.config.{js,cjs,mjs,mts}',
|
|
111
|
+
'**/jest.setup.{js,cjs,mjs,mts}',
|
|
112
|
+
'**/eslint.config.{js,cjs,mjs,mts}',
|
|
113
|
+
'**/.eslintrc.{js,cjs}',
|
|
114
|
+
'**/.stylelintrc.{cjs,js,json,yaml,yml}',
|
|
115
|
+
'**/stylelint.config.{cjs,mjs,mts,js}',
|
|
116
|
+
'**/esbuild.config.{js,cjs,mjs,mts}',
|
|
117
|
+
'**/tsup.config.{js,cjs,mjs,mts}',
|
|
118
|
+
'**/webpack.config.{js,cjs,mjs,mts}',
|
|
119
|
+
'**/webpack.config.*.{js,cjs,mjs,mts}',
|
|
120
|
+
'**/rollup.config.{js,cjs,mjs,mts}',
|
|
121
|
+
'**/rollup.config.*.{js,cjs,mjs,mts}',
|
|
122
|
+
],
|
|
123
|
+
optionalDependencies: false,
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
|
|
127
|
+
// Reports if a default export is renamed during import
|
|
128
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-rename-default.md
|
|
129
|
+
'import-x-js/no-rename-default': 'error',
|
|
130
|
+
|
|
131
|
+
// Ensure consistent use of file extension within the import path
|
|
132
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/extensions.md
|
|
133
|
+
'import-x-js/extensions': [
|
|
134
|
+
'error',
|
|
135
|
+
'ignorePackages',
|
|
136
|
+
{
|
|
137
|
+
js: 'never',
|
|
138
|
+
mjs: 'never',
|
|
139
|
+
jsx: 'never',
|
|
140
|
+
ts: 'never',
|
|
141
|
+
tsx: 'never',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
|
|
145
|
+
// Ensure absolute imports are above relative imports
|
|
146
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/order.md
|
|
147
|
+
'import-x-js/order': [
|
|
148
|
+
'error',
|
|
149
|
+
{
|
|
150
|
+
groups: [['builtin', 'external', 'internal'], 'index', ['parent', 'sibling']],
|
|
151
|
+
'newlines-between': 'never',
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
|
|
155
|
+
// Require a newline after the last import/require in a group
|
|
156
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/newline-after-import.md
|
|
157
|
+
'import-x-js/newline-after-import': 'error',
|
|
158
|
+
|
|
159
|
+
// Ensures that there are no useless path segments
|
|
160
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-useless-path-segments.md
|
|
161
|
+
'import-x-js/no-useless-path-segments': ['error', { commonjs: true }],
|
|
162
|
+
|
|
163
|
+
// Reports the use of import declarations with CommonJS exports
|
|
164
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-import-module-exports.md
|
|
165
|
+
'import-x-js/no-import-module-exports': ['error', { exceptions: [] }],
|
|
166
|
+
|
|
167
|
+
// Use this rule to prevent importing packages through relative paths
|
|
168
|
+
// https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-relative-packages.md
|
|
169
|
+
'import-x-js/no-relative-packages': 'error',
|
|
86
170
|
},
|
|
87
171
|
};
|
package/rules/vitest.mjs
CHANGED
|
@@ -36,6 +36,10 @@ export const vitestRules = {
|
|
|
36
36
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-import-node-test.md
|
|
37
37
|
'vitest/no-import-node-test': 'error',
|
|
38
38
|
|
|
39
|
+
// Disallow conditional tests
|
|
40
|
+
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md
|
|
41
|
+
'vitest/no-conditional-in-test': 'error',
|
|
42
|
+
|
|
39
43
|
// Prefer toHaveBeenCalledOnce() over toHaveBeenCalledTimes(1)
|
|
40
44
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/prefer-called-once.md
|
|
41
45
|
// decision: conflicts with prefer-called-times (jest plugin), which is enabled
|
|
@@ -115,13 +119,6 @@ export const vitestRules = {
|
|
|
115
119
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-expect.md
|
|
116
120
|
'jest/no-conditional-expect': 'error',
|
|
117
121
|
|
|
118
|
-
// Disallow conditional tests
|
|
119
|
-
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-conditional-in-test.md
|
|
120
|
-
// decision: disabled in oxlint — the native jest/ prefix doesn't match existing
|
|
121
|
-
// `eslint-disable vitest/no-conditional-in-test` comments, and the jsPlugin vitest-js/
|
|
122
|
-
// alias has the same problem. Eslint still enforces this rule.
|
|
123
|
-
'jest/no-conditional-in-test': 'off',
|
|
124
|
-
|
|
125
122
|
// Disallow disabled tests
|
|
126
123
|
// https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/no-disabled-tests.md
|
|
127
124
|
// decision: it is often useful to be allowed to add a .skip
|