@wistia/oxlint-config 0.0.1 → 0.2.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 +107 -2
- package/configs/javascript.jsonc +4 -0
- package/configs/node.jsonc +4 -0
- package/configs/playwright.jsonc +4 -0
- package/configs/react.jsonc +4 -0
- package/configs/storybook.jsonc +4 -0
- package/configs/styled-components.jsonc +4 -0
- package/configs/testing-library.jsonc +4 -0
- package/configs/typescript.jsonc +4 -0
- package/configs/vitest.jsonc +4 -0
- package/jsoncLoader.d.mts +10 -0
- package/jsoncLoader.mjs +27 -0
- package/package.json +48 -3
- package/rules/base.jsonc +636 -0
- package/rules/import.jsonc +89 -0
- package/rules/node.jsonc +133 -0
- package/rules/playwright.jsonc +195 -0
- package/rules/promise.jsonc +70 -0
- package/rules/react-a11y.jsonc +153 -0
- package/rules/react.jsonc +238 -0
- package/rules/storybook.jsonc +67 -0
- package/rules/styled-components.jsonc +153 -0
- package/rules/testing-library.jsonc +173 -0
- package/rules/typescript.jsonc +457 -0
- package/rules/vitest.jsonc +324 -0
- package/.tool-versions +0 -1
- package/.yarn/releases/yarn-4.13.0.cjs +0 -940
- package/.yarnrc.yml +0 -5
package/README.md
CHANGED
|
@@ -1,2 +1,107 @@
|
|
|
1
|
-
# oxlint-config
|
|
2
|
-
|
|
1
|
+
# @wistia/oxlint-config
|
|
2
|
+
|
|
3
|
+
Wistia's Oxlint configurations. This is a shared config package for [oxlint](https://oxc.rs/docs/guide/usage/linter), a fast TypeScript/Javascript linter.
|
|
4
|
+
|
|
5
|
+
## How to install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add -D @wistia/oxlint-config oxlint
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
Create an `.oxlintrc.json` in your project root:
|
|
14
|
+
|
|
15
|
+
**TypeScript project** (most common):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
20
|
+
"extends": ["./node_modules/@wistia/oxlint-config/configs/typescript.jsonc"]
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**JavaScript-only project:**
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
29
|
+
"extends": ["./node_modules/@wistia/oxlint-config/configs/javascript.jsonc"]
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Available configs
|
|
34
|
+
|
|
35
|
+
### Base configs
|
|
36
|
+
|
|
37
|
+
| Config | Description |
|
|
38
|
+
| -------------------------- | ---------------------------------------------------------------------- |
|
|
39
|
+
| `configs/javascript.jsonc` | Base config for any JavaScript project (base + import + promise rules) |
|
|
40
|
+
| `configs/typescript.jsonc` | TypeScript projects (includes all JavaScript rules) |
|
|
41
|
+
|
|
42
|
+
### Feature configs
|
|
43
|
+
|
|
44
|
+
| Config | Description |
|
|
45
|
+
| --------------------------------- | --------------------------------------------------------------- |
|
|
46
|
+
| `configs/react.jsonc` | React component and accessibility rules (react + jsx-a11y) |
|
|
47
|
+
| `configs/node.jsonc` | Node.js-specific rules (native + eslint-plugin-n via jsPlugins) |
|
|
48
|
+
| `configs/vitest.jsonc` | Vitest testing rules (see note below) |
|
|
49
|
+
| `configs/playwright.jsonc` | Playwright E2E testing rules (via jsPlugins) |
|
|
50
|
+
| `configs/storybook.jsonc` | Storybook story conventions (via jsPlugins) |
|
|
51
|
+
| `configs/testing-library.jsonc` | Testing Library + jest-dom rules (via jsPlugins) |
|
|
52
|
+
| `configs/styled-components.jsonc` | Styled Components accessibility rules (via jsPlugins) |
|
|
53
|
+
|
|
54
|
+
**Note on jsPlugins configs:** Some configs use oxlint's [jsPlugins](https://oxc.rs/docs/guide/usage/linter/js-plugins) feature to load ESLint plugins for rules that don't have native oxlint equivalents. These configs require the corresponding ESLint plugin to be installed as a dev dependency in the consuming project. Check each config's rule file for the required `jsPlugins` specifiers.
|
|
55
|
+
|
|
56
|
+
**Note on vitest config:** Oxlint splits vitest-related rules across two internal plugin namespaces -- `vitest/` for vitest-specific rules and `jest/` for rules that originated in eslint-plugin-jest but apply equally to vitest. The `jest/` prefix is an oxlint naming convention; it does **not** mean Jest is required or that these rules are Jest-specific.
|
|
57
|
+
|
|
58
|
+
Configs are **additive** -- start with a base (`javascript` or `typescript`), then layer on feature configs as needed:
|
|
59
|
+
|
|
60
|
+
````json
|
|
61
|
+
{
|
|
62
|
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
63
|
+
"extends": [
|
|
64
|
+
"./node_modules/@wistia/oxlint-config/configs/typescript.jsonc",
|
|
65
|
+
"./node_modules/@wistia/oxlint-config/configs/react.jsonc",
|
|
66
|
+
"./node_modules/@wistia/oxlint-config/configs/vitest.jsonc"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
## Overriding rules
|
|
71
|
+
|
|
72
|
+
Add a `rules` section to your `.oxlintrc.json` -- your rules take precedence over the shared config:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
77
|
+
"extends": [
|
|
78
|
+
"./node_modules/@wistia/oxlint-config/configs/typescript.jsonc"
|
|
79
|
+
],
|
|
80
|
+
"rules": {
|
|
81
|
+
"eslint/no-console": "off",
|
|
82
|
+
"typescript/no-explicit-any": "off"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
````
|
|
86
|
+
|
|
87
|
+
## Running oxlint
|
|
88
|
+
|
|
89
|
+
Add a script to your `package.json`:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"scripts": {
|
|
94
|
+
"lint": "oxlint ."
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Oxlint will automatically pick up `.oxlintrc.json` from your project root.
|
|
100
|
+
|
|
101
|
+
## Guidelines for adding new rules
|
|
102
|
+
|
|
103
|
+
1. Preference given for autofixable rules
|
|
104
|
+
2. Should not contradict existing rules
|
|
105
|
+
3. Person/team adding new rules handles upgrading consumers and fixing violations
|
|
106
|
+
4. Rules should always be set to `error`, never `warn` (the latter are never fixed)
|
|
107
|
+
5. Add short description of rule & link to rule definition in code comments
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load and parse a JSONC file (JSON with comments and trailing commas).
|
|
3
|
+
*
|
|
4
|
+
* Node's ESM loader doesn't support `.jsonc` imports, so this resolves the
|
|
5
|
+
* path via `require.resolve`, reads the file, and parses it with `jsonc-parser`.
|
|
6
|
+
*
|
|
7
|
+
* @param specifier - A module specifier resolvable by `require.resolve`
|
|
8
|
+
* @returns The parsed JSONC content
|
|
9
|
+
*/
|
|
10
|
+
export declare const jsoncLoader: (specifier: string) => Record<string, unknown>;
|
package/jsoncLoader.mjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { parse } from 'jsonc-parser';
|
|
4
|
+
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Load and parse a JSONC file (JSON with comments and trailing commas).
|
|
9
|
+
*
|
|
10
|
+
* Node's ESM loader doesn't support `.jsonc` imports, so this resolves the
|
|
11
|
+
* path via `require.resolve`, reads the file, and parses it with `jsonc-parser`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { jsoncLoader } from '@wistia/oxlint-config/jsoncLoader';
|
|
16
|
+
*
|
|
17
|
+
* const baseRules = jsoncLoader('@wistia/oxlint-config/rules/base.jsonc');
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param {string} specifier - A module specifier resolvable by `require.resolve`
|
|
21
|
+
* @returns {Record<string, unknown>} The parsed JSONC content
|
|
22
|
+
*/
|
|
23
|
+
export const jsoncLoader = (specifier) => {
|
|
24
|
+
const filePath = require.resolve(specifier);
|
|
25
|
+
const raw = readFileSync(filePath, 'utf8');
|
|
26
|
+
return parse(raw);
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wistia/oxlint-config",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Wistia's Oxlint configurations",
|
|
5
5
|
"packageManager": "yarn@4.13.0",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"configs",
|
|
9
|
+
"rules",
|
|
10
|
+
"jsoncLoader.mjs",
|
|
11
|
+
"jsoncLoader.d.mts"
|
|
12
|
+
],
|
|
7
13
|
"exports": {
|
|
8
|
-
"./package.json": "./package.json"
|
|
14
|
+
"./package.json": "./package.json",
|
|
15
|
+
"./configs/*": "./configs/*",
|
|
16
|
+
"./rules/*": "./rules/*",
|
|
17
|
+
".": "./configs/typescript.jsonc",
|
|
18
|
+
"./javascript": "./configs/javascript.jsonc",
|
|
19
|
+
"./typescript": "./configs/typescript.jsonc",
|
|
20
|
+
"./react": "./configs/react.jsonc",
|
|
21
|
+
"./node": "./configs/node.jsonc",
|
|
22
|
+
"./vitest": "./configs/vitest.jsonc",
|
|
23
|
+
"./jsoncLoader": {
|
|
24
|
+
"types": "./jsoncLoader.d.mts",
|
|
25
|
+
"default": "./jsoncLoader.mjs"
|
|
26
|
+
}
|
|
9
27
|
},
|
|
10
28
|
"scripts": {
|
|
11
|
-
"
|
|
29
|
+
"changeset": "changeset",
|
|
30
|
+
"format": "oxfmt .",
|
|
31
|
+
"format:ci": "oxfmt --check .",
|
|
32
|
+
"outdated": "yarn upgrade-interactive",
|
|
33
|
+
"release": "changeset publish",
|
|
34
|
+
"test": "vitest run --exclude test/validate-configs.test.mjs",
|
|
35
|
+
"validate": "vitest run test/validate-configs.test.mjs"
|
|
12
36
|
},
|
|
13
37
|
"peerDependencies": {
|
|
14
38
|
"oxlint": ">= 1.0.0"
|
|
15
39
|
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@vitest/eslint-plugin": "^1.6.14",
|
|
42
|
+
"eslint-plugin-jest-dom": "^5.5.0",
|
|
43
|
+
"eslint-plugin-n": "^17.24.0",
|
|
44
|
+
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
45
|
+
"eslint-plugin-playwright": "^2.10.1",
|
|
46
|
+
"eslint-plugin-storybook": "^10.3.4",
|
|
47
|
+
"eslint-plugin-styled-components": "^0.0.0",
|
|
48
|
+
"eslint-plugin-styled-components-a11y": "^2.2.1",
|
|
49
|
+
"eslint-plugin-testing-library": "^7.16.2",
|
|
50
|
+
"jsonc-parser": "^3.3.1"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@changesets/changelog-github": "^0.6.0",
|
|
54
|
+
"@changesets/cli": "^2.30.0",
|
|
55
|
+
"eslint": "^10.1.0",
|
|
56
|
+
"oxfmt": "^0.43.0",
|
|
57
|
+
"oxlint": "^1.58.0",
|
|
58
|
+
"storybook": "^10.3.4",
|
|
59
|
+
"vitest": "^4.1.2"
|
|
60
|
+
},
|
|
16
61
|
"engines": {
|
|
17
62
|
"node": "^20.19.0 || ^22.13.0 || >=24"
|
|
18
63
|
},
|