oxlint-config-react-hooks-js 0.0.1 → 1.0.1
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/LICENSE +20 -0
- package/README.md +147 -28
- package/configs/oxlint-config.d.ts +3 -0
- package/configs/recommended-latest.json +26 -0
- package/configs/recommended.json +25 -0
- package/package.json +64 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License Copyright (c) 2026 y.takahashi
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge,
|
|
4
|
+
to any person obtaining a copy of this software and associated documentation
|
|
5
|
+
files (the "Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
7
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
|
8
|
+
Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above
|
|
11
|
+
copyright notice and this permission notice (including the next paragraph) shall
|
|
12
|
+
be included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE
|
|
15
|
+
IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
16
|
+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
17
|
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
18
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
19
|
+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,45 +1,164 @@
|
|
|
1
1
|
# oxlint-config-react-hooks-js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Oxlint config presets for [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks) as a JS plugin. Provides React Compiler lint rules that are not available in oxlint's native React plugin.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Why
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Oxlint's built-in `react` plugin covers `rules-of-hooks` and `exhaustive-deps` natively, but the React Compiler rules (introduced in eslint-plugin-react-hooks v7) have no native oxlint equivalent. This package bridges the gap by configuring `eslint-plugin-react-hooks` as an oxlint JS plugin with the correct alias and rule settings.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Rules that oxlint already implements natively are automatically excluded using [@oxlint/migrate](https://www.npmjs.com/package/@oxlint/migrate).
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
11
|
+
> [!WARNING]
|
|
12
|
+
> This package runs `eslint-plugin-react-hooks` as an oxlint JS plugin, which is significantly slower than oxlint's native Rust-based rules. Expect a noticeable performance hit compared to a native-only setup.
|
|
15
13
|
|
|
16
|
-
##
|
|
14
|
+
## Presets
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
<!-- PRESETS START -->
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
| Preset | Rules | Source |
|
|
19
|
+
| ------------------------- | ----- | ----------------------------------------------------- |
|
|
20
|
+
| `recommended.json` | 15 | `recommended` from `eslint-plugin-react-hooks` |
|
|
21
|
+
| `recommended-latest.json` | 16 | `recommended-latest` from `eslint-plugin-react-hooks` |
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
<!-- PRESETS END -->
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
25
|
+
### Rules
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
<details>
|
|
28
|
+
<summary>Rule breakdown per preset and opt-in rules</summary>
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
30
|
+
<!-- RULES START -->
|
|
36
31
|
|
|
37
|
-
|
|
32
|
+
#### `recommended`
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
34
|
+
Enabled via JS plugin (15 rules, prefixed with `react-hooks-js/`):
|
|
42
35
|
|
|
43
|
-
|
|
36
|
+
- `component-hook-factories`
|
|
37
|
+
- `config`
|
|
38
|
+
- `error-boundaries`
|
|
39
|
+
- `gating`
|
|
40
|
+
- `globals`
|
|
41
|
+
- `immutability`
|
|
42
|
+
- `incompatible-library`
|
|
43
|
+
- `preserve-manual-memoization`
|
|
44
|
+
- `purity`
|
|
45
|
+
- `refs`
|
|
46
|
+
- `set-state-in-effect`
|
|
47
|
+
- `set-state-in-render`
|
|
48
|
+
- `static-components`
|
|
49
|
+
- `unsupported-syntax`
|
|
50
|
+
- `use-memo`
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
Excluded because oxlint covers them natively (2 rules):
|
|
53
|
+
|
|
54
|
+
- `exhaustive-deps`
|
|
55
|
+
- `rules-of-hooks`
|
|
56
|
+
|
|
57
|
+
#### `recommended-latest`
|
|
58
|
+
|
|
59
|
+
Enabled via JS plugin (16 rules, prefixed with `react-hooks-js/`):
|
|
60
|
+
|
|
61
|
+
- `component-hook-factories`
|
|
62
|
+
- `config`
|
|
63
|
+
- `error-boundaries`
|
|
64
|
+
- `gating`
|
|
65
|
+
- `globals`
|
|
66
|
+
- `immutability`
|
|
67
|
+
- `incompatible-library`
|
|
68
|
+
- `preserve-manual-memoization`
|
|
69
|
+
- `purity`
|
|
70
|
+
- `refs`
|
|
71
|
+
- `set-state-in-effect`
|
|
72
|
+
- `set-state-in-render`
|
|
73
|
+
- `static-components`
|
|
74
|
+
- `unsupported-syntax`
|
|
75
|
+
- `use-memo`
|
|
76
|
+
- `void-use-memo`
|
|
77
|
+
|
|
78
|
+
Excluded because oxlint covers them natively (2 rules):
|
|
79
|
+
|
|
80
|
+
- `exhaustive-deps`
|
|
81
|
+
- `rules-of-hooks`
|
|
82
|
+
|
|
83
|
+
#### Opt-in rules (not in any preset)
|
|
84
|
+
|
|
85
|
+
Rules shipped by `eslint-plugin-react-hooks` that no preset enables (11 rules). Add them manually under `rules` with the `react-hooks-js/` prefix (see [Overriding rules](#overriding-rules)):
|
|
86
|
+
|
|
87
|
+
- `automatic-effect-dependencies`
|
|
88
|
+
- `capitalized-calls`
|
|
89
|
+
- `fbt`
|
|
90
|
+
- `fire`
|
|
91
|
+
- `hooks`
|
|
92
|
+
- `invariant`
|
|
93
|
+
- `memoized-effect-dependencies`
|
|
94
|
+
- `no-deriving-state-in-effects`
|
|
95
|
+
- `rule-suppression`
|
|
96
|
+
- `syntax`
|
|
97
|
+
- `todo`
|
|
98
|
+
|
|
99
|
+
<!-- RULES END -->
|
|
100
|
+
|
|
101
|
+
</details>
|
|
102
|
+
|
|
103
|
+
## Installation
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
pnpm add -D oxlint-config-react-hooks-js eslint-plugin-react-hooks
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`eslint-plugin-react-hooks` is a peer dependency and must be installed in your project.
|
|
110
|
+
|
|
111
|
+
## Usage
|
|
112
|
+
|
|
113
|
+
### JSON config (`.oxlintrc.json`)
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
118
|
+
"extends": ["./node_modules/oxlint-config-react-hooks-js/configs/recommended-latest.json"]
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### TypeScript config (`oxlint.config.ts`)
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { defineConfig } from "oxlint";
|
|
126
|
+
import reactCompiler from "oxlint-config-react-hooks-js/configs/recommended-latest.json" with { type: "json" };
|
|
127
|
+
|
|
128
|
+
export default defineConfig({
|
|
129
|
+
extends: [reactCompiler],
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
The JSON import is typed as `OxlintConfig` via the bundled type declaration file exposed through the `types` subpath condition.
|
|
134
|
+
|
|
135
|
+
### Overriding rules
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { defineConfig } from "oxlint";
|
|
139
|
+
import reactCompiler from "oxlint-config-react-hooks-js/configs/recommended-latest.json" with { type: "json" };
|
|
140
|
+
|
|
141
|
+
export default defineConfig({
|
|
142
|
+
extends: [reactCompiler],
|
|
143
|
+
rules: {
|
|
144
|
+
"react-hooks-js/incompatible-library": "off",
|
|
145
|
+
// Add rules not in the preset
|
|
146
|
+
"react-hooks-js/todo": "error",
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## How it works
|
|
152
|
+
|
|
153
|
+
The `scripts/generate.ts` script:
|
|
154
|
+
|
|
155
|
+
1. Reads the `recommended` and `recommended-latest` configs from `eslint-plugin-react-hooks`
|
|
156
|
+
2. Passes them through `@oxlint/migrate` to identify rules that oxlint implements natively
|
|
157
|
+
3. Excludes native rules and prefixes the remaining rules with the `react-hooks-js` alias
|
|
158
|
+
4. Outputs JSON preset files to `configs/`
|
|
159
|
+
|
|
160
|
+
The `react-hooks-js` alias is required because `react-hooks` is a reserved plugin name in oxlint (covered by the native `react` plugin).
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
MIT
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsPlugins": [
|
|
3
|
+
{
|
|
4
|
+
"name": "react-hooks-js",
|
|
5
|
+
"specifier": "eslint-plugin-react-hooks"
|
|
6
|
+
}
|
|
7
|
+
],
|
|
8
|
+
"rules": {
|
|
9
|
+
"react-hooks-js/static-components": "error",
|
|
10
|
+
"react-hooks-js/use-memo": "error",
|
|
11
|
+
"react-hooks-js/void-use-memo": "error",
|
|
12
|
+
"react-hooks-js/component-hook-factories": "error",
|
|
13
|
+
"react-hooks-js/preserve-manual-memoization": "error",
|
|
14
|
+
"react-hooks-js/incompatible-library": "warn",
|
|
15
|
+
"react-hooks-js/immutability": "error",
|
|
16
|
+
"react-hooks-js/globals": "error",
|
|
17
|
+
"react-hooks-js/refs": "error",
|
|
18
|
+
"react-hooks-js/set-state-in-effect": "error",
|
|
19
|
+
"react-hooks-js/error-boundaries": "error",
|
|
20
|
+
"react-hooks-js/purity": "error",
|
|
21
|
+
"react-hooks-js/set-state-in-render": "error",
|
|
22
|
+
"react-hooks-js/unsupported-syntax": "warn",
|
|
23
|
+
"react-hooks-js/config": "error",
|
|
24
|
+
"react-hooks-js/gating": "error"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsPlugins": [
|
|
3
|
+
{
|
|
4
|
+
"name": "react-hooks-js",
|
|
5
|
+
"specifier": "eslint-plugin-react-hooks"
|
|
6
|
+
}
|
|
7
|
+
],
|
|
8
|
+
"rules": {
|
|
9
|
+
"react-hooks-js/static-components": "error",
|
|
10
|
+
"react-hooks-js/use-memo": "error",
|
|
11
|
+
"react-hooks-js/component-hook-factories": "error",
|
|
12
|
+
"react-hooks-js/preserve-manual-memoization": "error",
|
|
13
|
+
"react-hooks-js/incompatible-library": "warn",
|
|
14
|
+
"react-hooks-js/immutability": "error",
|
|
15
|
+
"react-hooks-js/globals": "error",
|
|
16
|
+
"react-hooks-js/refs": "error",
|
|
17
|
+
"react-hooks-js/set-state-in-effect": "error",
|
|
18
|
+
"react-hooks-js/error-boundaries": "error",
|
|
19
|
+
"react-hooks-js/purity": "error",
|
|
20
|
+
"react-hooks-js/set-state-in-render": "error",
|
|
21
|
+
"react-hooks-js/unsupported-syntax": "warn",
|
|
22
|
+
"react-hooks-js/config": "error",
|
|
23
|
+
"react-hooks-js/gating": "error"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,66 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"name": "oxlint-config-react-hooks-js",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Oxlint config presets for eslint-plugin-react-hooks JS plugin (React Compiler rules)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"lint",
|
|
7
|
+
"oxlint",
|
|
8
|
+
"react",
|
|
9
|
+
"react-compiler",
|
|
10
|
+
"react-hooks"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/eai04191/oxlint-config-react-hooks-js#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/eai04191/oxlint-config-react-hooks-js/issues"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "y.takahashi <eai@mizle.net> (https://github.com/eai04191)",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/eai04191/oxlint-config-react-hooks-js.git"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"configs"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
"./configs/*.json": {
|
|
28
|
+
"types": "./configs/oxlint-config.d.ts",
|
|
29
|
+
"default": "./configs/*.json"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"directory": "dist"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"generate": "node scripts/generate.ts",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"lint": "oxlint",
|
|
39
|
+
"format": "oxfmt",
|
|
40
|
+
"format:check": "oxfmt --check",
|
|
41
|
+
"test": "node --test",
|
|
42
|
+
"check": "run-s generate format check:parallel",
|
|
43
|
+
"check:parallel": "run-p typecheck lint format:check test",
|
|
44
|
+
"prepack": "run-s generate format && node scripts/prepack.ts"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@oxlint/migrate": "1.59.0",
|
|
48
|
+
"@tsconfig/strictest": "2.0.8",
|
|
49
|
+
"@types/node": "25.6.0",
|
|
50
|
+
"eslint-plugin-react-hooks": "7.0.1",
|
|
51
|
+
"npm-run-all2": "8.0.4",
|
|
52
|
+
"oxfmt": "0.44.0",
|
|
53
|
+
"oxlint": "1.59.0",
|
|
54
|
+
"oxlint-config-presets": "0.1.6",
|
|
55
|
+
"oxlint-tsgolint": "0.20.0",
|
|
56
|
+
"semantic-release": "25.0.3",
|
|
57
|
+
"typescript": "6.0.2"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"eslint-plugin-react-hooks": ">=7.0.0"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=24"
|
|
64
|
+
},
|
|
65
|
+
"packageManager": "pnpm@10.33.0"
|
|
10
66
|
}
|