oxlint-plugin-react-doctor 0.2.0-beta.2
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 +21 -0
- package/README.md +71 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +10039 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aiden Bai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# oxlint-plugin-react-doctor
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/oxlint-plugin-react-doctor)
|
|
4
|
+
[](https://npmjs.com/package/oxlint-plugin-react-doctor)
|
|
5
|
+
|
|
6
|
+
[oxlint](https://oxc.rs/docs/guide/usage/linter) plugin for [React Doctor](https://react.doctor). Diagnoses React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues.
|
|
7
|
+
|
|
8
|
+
This package owns the rule implementations (178 rules across architecture, performance, correctness, security, accessibility, bundle-size, and framework-specific buckets). [`eslint-plugin-react-doctor`](https://npmjs.com/package/eslint-plugin-react-doctor) wraps these same rules for ESLint, and the full diagnostic CLI lives in [`react-doctor`](https://npmjs.com/package/react-doctor).
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install --save-dev oxlint oxlint-plugin-react-doctor
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add -D oxlint oxlint-plugin-react-doctor
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
yarn add -D oxlint oxlint-plugin-react-doctor
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
In `.oxlintrc.json`:
|
|
27
|
+
|
|
28
|
+
```jsonc
|
|
29
|
+
{
|
|
30
|
+
"jsPlugins": [{ "name": "react-doctor", "specifier": "oxlint-plugin-react-doctor" }],
|
|
31
|
+
"rules": {
|
|
32
|
+
"react-doctor/no-fetch-in-effect": "warn",
|
|
33
|
+
"react-doctor/no-derived-state-effect": "warn",
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Run oxlint as normal:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx oxlint .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Available rules
|
|
45
|
+
|
|
46
|
+
The full rule list lives in [`oxlint-config.ts`](https://github.com/millionco/react-doctor/blob/main/packages/react-doctor/src/oxlint-config.ts). All rules are namespaced under `react-doctor/*`.
|
|
47
|
+
|
|
48
|
+
Each rule can be set to `"error"`, `"warn"`, or `"off"`:
|
|
49
|
+
|
|
50
|
+
```jsonc
|
|
51
|
+
{
|
|
52
|
+
"rules": {
|
|
53
|
+
"react-doctor/no-cascading-set-state": "error",
|
|
54
|
+
"react-doctor/no-array-index-as-key": "warn",
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Want the CLI too?
|
|
60
|
+
|
|
61
|
+
This package only ships the oxlint plugin. To run React Doctor's full scan (with scoring, JSON reports, agent integration, etc.), use the main CLI:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npx -y react-doctor@latest .
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
See the [React Doctor README](https://github.com/millionco/react-doctor#readme) for the full feature set.
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { TSESTree } from "@typescript-eslint/types";
|
|
2
|
+
|
|
3
|
+
//#region src/plugin/utils/es-tree-node.d.ts
|
|
4
|
+
type WithLooseParent<NodeType> = NodeType extends NodeType ? Omit<NodeType, "parent"> & {
|
|
5
|
+
parent?: EsTreeNode | null;
|
|
6
|
+
} : never;
|
|
7
|
+
type EsTreeNode = WithLooseParent<TSESTree.Node>;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/plugin/utils/report-descriptor.d.ts
|
|
10
|
+
interface ReportDescriptor {
|
|
11
|
+
node: EsTreeNode;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/plugin/utils/rule-context.d.ts
|
|
16
|
+
interface RuleContext {
|
|
17
|
+
report: (descriptor: ReportDescriptor) => void;
|
|
18
|
+
getFilename?: () => string;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/plugin/utils/rule-visitors.d.ts
|
|
22
|
+
interface RuleVisitors {
|
|
23
|
+
[selector: string]: ((node: any) => void) | (() => void);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/plugin/utils/rule.d.ts
|
|
27
|
+
type RuleSeverity = "error" | "warn";
|
|
28
|
+
type RuleFramework = "global" | "nextjs" | "react-native" | "tanstack-start" | "tanstack-query";
|
|
29
|
+
interface Rule {
|
|
30
|
+
id: string;
|
|
31
|
+
severity: RuleSeverity;
|
|
32
|
+
category?: string;
|
|
33
|
+
framework?: RuleFramework;
|
|
34
|
+
requires?: ReadonlyArray<string>;
|
|
35
|
+
tags?: ReadonlyArray<string>;
|
|
36
|
+
recommendation?: string;
|
|
37
|
+
create: (context: RuleContext) => RuleVisitors;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/plugin/utils/rule-plugin.d.ts
|
|
41
|
+
interface RulePlugin {
|
|
42
|
+
meta: {
|
|
43
|
+
name: string;
|
|
44
|
+
};
|
|
45
|
+
rules: Record<string, Rule>;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/plugin/react-doctor-plugin.d.ts
|
|
49
|
+
declare const plugin: RulePlugin;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/types.d.ts
|
|
52
|
+
type OxlintRuleSeverity = RuleSeverity | "off";
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/rules-by-framework.d.ts
|
|
55
|
+
declare const GLOBAL_REACT_DOCTOR_RULES: Record<string, OxlintRuleSeverity>;
|
|
56
|
+
declare const NEXTJS_RULES: Record<string, OxlintRuleSeverity>;
|
|
57
|
+
declare const REACT_NATIVE_RULES: Record<string, OxlintRuleSeverity>;
|
|
58
|
+
declare const TANSTACK_START_RULES: Record<string, OxlintRuleSeverity>;
|
|
59
|
+
declare const TANSTACK_QUERY_RULES: Record<string, OxlintRuleSeverity>;
|
|
60
|
+
declare const ALL_REACT_DOCTOR_RULE_KEYS: ReadonlySet<string>;
|
|
61
|
+
declare const FRAMEWORK_SPECIFIC_RULE_KEYS: ReadonlySet<string>;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/plugin/constants/style.d.ts
|
|
64
|
+
declare const MOTION_LIBRARY_PACKAGES: Set<string>;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { ALL_REACT_DOCTOR_RULE_KEYS, type EsTreeNode, FRAMEWORK_SPECIFIC_RULE_KEYS, GLOBAL_REACT_DOCTOR_RULES, MOTION_LIBRARY_PACKAGES, NEXTJS_RULES, type OxlintRuleSeverity, REACT_NATIVE_RULES, type Rule, type RuleFramework, type RulePlugin, type RuleSeverity, type RuleVisitors, TANSTACK_QUERY_RULES, TANSTACK_START_RULES, plugin as default };
|
|
67
|
+
//# sourceMappingURL=index.d.ts.map
|