@wistia/oxlint-config 0.3.5 → 0.4.0
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 +67 -71
- package/configs/typescript.mjs +4 -0
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -23,11 +23,10 @@ Create an `oxlint.config.ts` in your project root:
|
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
25
|
import { defineConfig } from 'oxlint';
|
|
26
|
-
import {
|
|
26
|
+
import { typescriptConfig, reactConfig } from '@wistia/oxlint-config';
|
|
27
27
|
|
|
28
28
|
export default defineConfig({
|
|
29
|
-
|
|
30
|
-
rules: typescriptRules.rules,
|
|
29
|
+
extends: [typescriptConfig, reactConfig],
|
|
31
30
|
});
|
|
32
31
|
```
|
|
33
32
|
|
|
@@ -35,106 +34,102 @@ export default defineConfig({
|
|
|
35
34
|
|
|
36
35
|
```ts
|
|
37
36
|
import { defineConfig } from 'oxlint';
|
|
38
|
-
import {
|
|
37
|
+
import { javascriptConfig } from '@wistia/oxlint-config';
|
|
39
38
|
|
|
40
39
|
export default defineConfig({
|
|
41
|
-
|
|
42
|
-
rules: {
|
|
43
|
-
...baseRules.rules,
|
|
44
|
-
...importRules.rules,
|
|
45
|
-
...promiseRules.rules,
|
|
46
|
-
},
|
|
40
|
+
extends: [javascriptConfig],
|
|
47
41
|
});
|
|
48
42
|
```
|
|
49
43
|
|
|
50
|
-
## Available
|
|
51
|
-
|
|
52
|
-
### Base rules
|
|
53
|
-
|
|
54
|
-
| Export | Description |
|
|
55
|
-
| ----------------- | ------------------------------------------------------------------------ |
|
|
56
|
-
| `baseRules` | Core ESLint rules (correctness + suggestions) |
|
|
57
|
-
| `importRules` | Import/export validation (native + eslint-plugin-import-x via jsPlugins) |
|
|
58
|
-
| `promiseRules` | Promise handling rules |
|
|
59
|
-
| `typescriptRules` | TypeScript-specific rules (disables superseded base rules) |
|
|
44
|
+
## Available configs
|
|
60
45
|
|
|
61
|
-
###
|
|
46
|
+
### Base configs
|
|
62
47
|
|
|
63
|
-
| Export
|
|
64
|
-
|
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `nodeRules` | Node.js rules (native + eslint-plugin-n via jsPlugins) |
|
|
68
|
-
| `vitestRules` | Vitest testing rules (see note below) |
|
|
69
|
-
| `playwrightRules` | Playwright E2E testing rules (via jsPlugins) |
|
|
70
|
-
| `storybookRules` | Storybook story conventions (via jsPlugins) |
|
|
71
|
-
| `testingLibraryRules` | Testing Library + jest-dom rules (via jsPlugins) |
|
|
72
|
-
| `styledComponentsRules` | Styled Components accessibility rules (via jsPlugins) |
|
|
73
|
-
| `filenamesRules` | Filename convention rules (via jsPlugins) |
|
|
74
|
-
| `barrelFilesRules` | Barrel file rules (via jsPlugins) |
|
|
48
|
+
| Export | Description |
|
|
49
|
+
| ------------------ | ----------------------------------------------------------------------------- |
|
|
50
|
+
| `javascriptConfig` | Base config for any JS project (base + import + promise + barrel-files rules) |
|
|
51
|
+
| `typescriptConfig` | TypeScript projects (includes all JavaScript rules + TypeScript rules) |
|
|
75
52
|
|
|
76
|
-
|
|
53
|
+
### Feature configs
|
|
77
54
|
|
|
78
|
-
|
|
55
|
+
Feature configs wrap their rules in `overrides` with default file patterns, so they scope correctly when extended at the top level.
|
|
79
56
|
|
|
80
|
-
|
|
57
|
+
| Export | Default file patterns | Description |
|
|
58
|
+
| ------------------------ | ----------------------------------------- | ------------------------------------- |
|
|
59
|
+
| `reactConfig` | all files (global) | React component + accessibility rules |
|
|
60
|
+
| `styledComponentsConfig` | all files (global) | Styled Components accessibility rules |
|
|
61
|
+
| `vitestConfig` | `**/*.{test,spec,vitest}.{ts,tsx,js,jsx}` | Vitest testing rules |
|
|
62
|
+
| `testingLibraryConfig` | `**/*.{test,spec,vitest}.{ts,tsx,js,jsx}` | Testing Library + jest-dom rules |
|
|
63
|
+
| `storybookConfig` | `**/*.stories.{ts,tsx,js,jsx}` | Storybook story conventions |
|
|
64
|
+
| `nodeConfig` | `**/*.{mts,mjs,cjs}` | Node.js-specific rules |
|
|
65
|
+
| `playwrightConfig` | `**/*.spec.{ts,tsx,js}`, `**/e2e/**/*.ts` | Playwright E2E testing rules |
|
|
81
66
|
|
|
82
|
-
|
|
67
|
+
**Composing configs:**
|
|
83
68
|
|
|
84
69
|
```ts
|
|
85
70
|
import { defineConfig } from 'oxlint';
|
|
86
71
|
import {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
72
|
+
typescriptConfig,
|
|
73
|
+
reactConfig,
|
|
74
|
+
styledComponentsConfig,
|
|
75
|
+
vitestConfig,
|
|
76
|
+
testingLibraryConfig,
|
|
77
|
+
storybookConfig,
|
|
78
|
+
nodeConfig,
|
|
93
79
|
} from '@wistia/oxlint-config';
|
|
94
80
|
|
|
95
81
|
export default defineConfig({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
82
|
+
extends: [
|
|
83
|
+
typescriptConfig,
|
|
84
|
+
reactConfig,
|
|
85
|
+
styledComponentsConfig,
|
|
86
|
+
vitestConfig,
|
|
87
|
+
testingLibraryConfig,
|
|
88
|
+
storybookConfig,
|
|
89
|
+
nodeConfig,
|
|
102
90
|
],
|
|
103
|
-
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Overriding rules
|
|
95
|
+
|
|
96
|
+
Add a `rules` section — your rules take precedence over the shared configs:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
export default defineConfig({
|
|
100
|
+
extends: [typescriptConfig, reactConfig],
|
|
104
101
|
rules: {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
...typescriptRules.rules,
|
|
108
|
-
...reactRules.rules,
|
|
109
|
-
...reactA11yRules.rules,
|
|
102
|
+
'typescript/no-explicit-any': 'off',
|
|
103
|
+
'react/no-clone-element': 'off',
|
|
110
104
|
},
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
File-specific overrides use `overrides`. Note that `extends` is not supported inside `overrides` — use rule imports for those:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { defineConfig } from 'oxlint';
|
|
112
|
+
import { typescriptConfig, vitestRules } from '@wistia/oxlint-config';
|
|
113
|
+
|
|
114
|
+
export default defineConfig({
|
|
115
|
+
extends: [typescriptConfig],
|
|
111
116
|
overrides: [
|
|
112
117
|
{
|
|
113
|
-
files: ['**/*.test.ts', '**/*.
|
|
118
|
+
files: ['**/*.test.ts', '**/*.vitest.ts'],
|
|
114
119
|
plugins: vitestRules.plugins,
|
|
115
120
|
jsPlugins: vitestRules.jsPlugins,
|
|
116
|
-
rules:
|
|
121
|
+
rules: {
|
|
122
|
+
...vitestRules.rules,
|
|
123
|
+
// project-specific overrides
|
|
124
|
+
'jest/expect-expect': ['error', { assertFunctionNames: ['expect', 'expectValid'] }],
|
|
125
|
+
},
|
|
117
126
|
},
|
|
118
127
|
],
|
|
119
128
|
});
|
|
120
129
|
```
|
|
121
130
|
|
|
122
|
-
## Overriding rules
|
|
123
|
-
|
|
124
|
-
Add overrides after the spread -- your rules take precedence:
|
|
125
|
-
|
|
126
|
-
```ts
|
|
127
|
-
rules: {
|
|
128
|
-
...typescriptRules.rules,
|
|
129
|
-
// override
|
|
130
|
-
'typescript/no-explicit-any': 'off',
|
|
131
|
-
},
|
|
132
|
-
```
|
|
133
|
-
|
|
134
131
|
## Running oxlint
|
|
135
132
|
|
|
136
|
-
Add a script to your `package.json`:
|
|
137
|
-
|
|
138
133
|
```json
|
|
139
134
|
{
|
|
140
135
|
"scripts": {
|
|
@@ -150,6 +145,7 @@ Add a script to your `package.json`:
|
|
|
150
145
|
3. Person/team adding new rules handles upgrading consumers and fixing violations
|
|
151
146
|
4. Rules should always be set to `error`, never `warn`
|
|
152
147
|
5. Add short description of rule and link to rule documentation in code comments
|
|
148
|
+
6. Never delete a rule — set it to `off` with a comment explaining why
|
|
153
149
|
|
|
154
150
|
## ESLint parity
|
|
155
151
|
|
package/configs/typescript.mjs
CHANGED
|
@@ -6,6 +6,10 @@ import { typescriptRules } from '../rules/typescript.mjs';
|
|
|
6
6
|
import { barrelFilesRules } from '../rules/barrel-files.mjs';
|
|
7
7
|
|
|
8
8
|
export default defineConfig({
|
|
9
|
+
options: {
|
|
10
|
+
typeAware: true,
|
|
11
|
+
typeCheck: true,
|
|
12
|
+
},
|
|
9
13
|
plugins: [
|
|
10
14
|
...baseRules.plugins,
|
|
11
15
|
...importRules.plugins,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wistia/oxlint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Wistia's Oxlint configurations",
|
|
5
5
|
"packageManager": "yarn@4.13.0",
|
|
6
6
|
"type": "module",
|
|
@@ -34,29 +34,31 @@
|
|
|
34
34
|
"validate": "vitest run test/validate-configs.test.mjs"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"oxlint": ">= 1.0.0"
|
|
37
|
+
"oxlint": ">= 1.0.0",
|
|
38
|
+
"oxlint-tsgolint": ">= 1.0.0"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
41
|
+
"@vitest/eslint-plugin": "^1.6.16",
|
|
41
42
|
"eslint-plugin-barrel-files": "^3.0.1",
|
|
42
43
|
"eslint-plugin-import-x": "^4.16.2",
|
|
43
44
|
"eslint-plugin-jest-dom": "^5.5.0",
|
|
44
45
|
"eslint-plugin-n": "^17.24.0",
|
|
45
46
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
46
|
-
"eslint-plugin-playwright": "^2.10.
|
|
47
|
-
"eslint-plugin-storybook": "^10.3.
|
|
47
|
+
"eslint-plugin-playwright": "^2.10.2",
|
|
48
|
+
"eslint-plugin-storybook": "^10.3.5",
|
|
48
49
|
"eslint-plugin-styled-components": "^0.0.0",
|
|
49
50
|
"eslint-plugin-styled-components-a11y": "^2.2.1",
|
|
50
51
|
"eslint-plugin-testing-library": "^7.16.2"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@changesets/changelog-github": "^0.6.0",
|
|
54
|
-
"@changesets/cli": "^2.
|
|
55
|
-
"eslint": "^10.2.
|
|
56
|
-
"oxfmt": "^0.
|
|
57
|
-
"oxlint": "^1.
|
|
58
|
-
"
|
|
59
|
-
"
|
|
55
|
+
"@changesets/cli": "^2.31.0",
|
|
56
|
+
"eslint": "^10.2.1",
|
|
57
|
+
"oxfmt": "^0.46.0",
|
|
58
|
+
"oxlint": "^1.61.0",
|
|
59
|
+
"oxlint-tsgolint": "^0.21.1",
|
|
60
|
+
"storybook": "^10.3.5",
|
|
61
|
+
"vitest": "^4.1.5"
|
|
60
62
|
},
|
|
61
63
|
"engines": {
|
|
62
64
|
"node": "^20.19.0 || ^22.13.0 || >=24 || >=26"
|