eslint-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 +85 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +50 -0
- package/package.json +58 -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,85 @@
|
|
|
1
|
+
# eslint-plugin-react-doctor
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/eslint-plugin-react-doctor)
|
|
4
|
+
[](https://npmjs.com/package/eslint-plugin-react-doctor)
|
|
5
|
+
|
|
6
|
+
ESLint 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 ESLint adapter for React Doctor's rule set. The underlying rules ship in [`oxlint-plugin-react-doctor`](https://npmjs.com/package/oxlint-plugin-react-doctor) (auto-installed as a transitive dependency). The full diagnostic CLI lives in [`react-doctor`](https://npmjs.com/package/react-doctor) and pulls in this same rule set; install whichever fits your workflow.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install --save-dev eslint-plugin-react-doctor
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add -D eslint-plugin-react-doctor
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
yarn add -D eslint-plugin-react-doctor
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Flat config (ESLint v9+):
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import reactDoctor from "eslint-plugin-react-doctor";
|
|
30
|
+
|
|
31
|
+
export default [
|
|
32
|
+
reactDoctor.configs.recommended,
|
|
33
|
+
reactDoctor.configs.next,
|
|
34
|
+
reactDoctor.configs["react-native"],
|
|
35
|
+
reactDoctor.configs["tanstack-start"],
|
|
36
|
+
reactDoctor.configs["tanstack-query"],
|
|
37
|
+
];
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Pick only the configs that match your stack. `recommended` is framework-agnostic; the others layer on framework-specific rules.
|
|
41
|
+
|
|
42
|
+
## Available configs
|
|
43
|
+
|
|
44
|
+
| Config | What it adds |
|
|
45
|
+
| ---------------- | ------------------------------------------------------------- |
|
|
46
|
+
| `recommended` | Framework-agnostic React rules. Safe baseline. |
|
|
47
|
+
| `next` | Next.js specific rules (App Router, server components, etc.). |
|
|
48
|
+
| `react-native` | React Native specific rules. |
|
|
49
|
+
| `tanstack-start` | TanStack Start specific rules. |
|
|
50
|
+
| `tanstack-query` | TanStack Query specific rules. |
|
|
51
|
+
| `all` | Every rule across every framework, at recommended severity. |
|
|
52
|
+
|
|
53
|
+
## Available rules
|
|
54
|
+
|
|
55
|
+
The full rule list lives in [`oxlint-config.ts`](https://github.com/millionco/react-doctor/blob/main/packages/react-doctor/src/oxlint-config.ts). Rules are namespaced under `react-doctor/*`.
|
|
56
|
+
|
|
57
|
+
To override a rule:
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
import reactDoctor from "eslint-plugin-react-doctor";
|
|
61
|
+
|
|
62
|
+
export default [
|
|
63
|
+
reactDoctor.configs.recommended,
|
|
64
|
+
{
|
|
65
|
+
rules: {
|
|
66
|
+
"react-doctor/no-fetch-in-effect": "error",
|
|
67
|
+
"react-doctor/no-derived-state-effect": "off",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Want the CLI too?
|
|
74
|
+
|
|
75
|
+
This package only ships the ESLint plugin. To run React Doctor's full scan (with scoring, JSON reports, agent integration, etc.), use the main CLI:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npx -y react-doctor@latest .
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
See the [React Doctor README](https://github.com/millionco/react-doctor#readme) for the full feature set.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { EsTreeNode, OxlintRuleSeverity, RuleVisitors } from "oxlint-plugin-react-doctor";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
interface EslintRuleContext {
|
|
5
|
+
report: (descriptor: {
|
|
6
|
+
node: EsTreeNode;
|
|
7
|
+
message: string;
|
|
8
|
+
}) => void;
|
|
9
|
+
getFilename?: () => string;
|
|
10
|
+
}
|
|
11
|
+
interface EslintRuleMeta {
|
|
12
|
+
type: "problem" | "suggestion" | "layout";
|
|
13
|
+
docs: {
|
|
14
|
+
description: string;
|
|
15
|
+
url: string;
|
|
16
|
+
recommended: boolean;
|
|
17
|
+
};
|
|
18
|
+
schema: unknown[];
|
|
19
|
+
}
|
|
20
|
+
interface EslintRule {
|
|
21
|
+
meta: EslintRuleMeta;
|
|
22
|
+
create: (context: EslintRuleContext) => RuleVisitors;
|
|
23
|
+
}
|
|
24
|
+
interface EslintFlatConfig {
|
|
25
|
+
name: string;
|
|
26
|
+
plugins: Record<string, EslintPlugin>;
|
|
27
|
+
rules: Record<string, OxlintRuleSeverity>;
|
|
28
|
+
}
|
|
29
|
+
interface EslintPlugin {
|
|
30
|
+
meta: {
|
|
31
|
+
name: string;
|
|
32
|
+
version: string;
|
|
33
|
+
};
|
|
34
|
+
rules: Record<string, EslintRule>;
|
|
35
|
+
configs: {
|
|
36
|
+
recommended: EslintFlatConfig;
|
|
37
|
+
next: EslintFlatConfig;
|
|
38
|
+
"react-native": EslintFlatConfig;
|
|
39
|
+
"tanstack-start": EslintFlatConfig;
|
|
40
|
+
"tanstack-query": EslintFlatConfig;
|
|
41
|
+
all: EslintFlatConfig;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
declare const eslintPlugin: EslintPlugin;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { eslintPlugin as default };
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import oxlintPlugin, { GLOBAL_REACT_DOCTOR_RULES, NEXTJS_RULES, REACT_NATIVE_RULES, TANSTACK_QUERY_RULES, TANSTACK_START_RULES } from "oxlint-plugin-react-doctor";
|
|
2
|
+
//#region src/index.ts
|
|
3
|
+
const PLUGIN_NAMESPACE = "react-doctor";
|
|
4
|
+
const RULE_DOCS_BASE_URL = "https://react.doctor/rules";
|
|
5
|
+
const recommendedRuleKeys = new Set(Object.keys(GLOBAL_REACT_DOCTOR_RULES));
|
|
6
|
+
const wrapAsEslintRule = (ruleName, ruleImpl) => ({
|
|
7
|
+
meta: {
|
|
8
|
+
type: "problem",
|
|
9
|
+
docs: {
|
|
10
|
+
description: ruleName.replaceAll("-", " ").replace(/\b\w/g, (innerChar) => innerChar.toUpperCase()),
|
|
11
|
+
url: `${RULE_DOCS_BASE_URL}/${ruleName}`,
|
|
12
|
+
recommended: recommendedRuleKeys.has(`${PLUGIN_NAMESPACE}/${ruleName}`)
|
|
13
|
+
},
|
|
14
|
+
schema: []
|
|
15
|
+
},
|
|
16
|
+
create: (context) => ruleImpl.create(context)
|
|
17
|
+
});
|
|
18
|
+
const eslintShapedRules = Object.fromEntries(Object.entries(oxlintPlugin.rules).map(([ruleName, ruleImpl]) => [ruleName, wrapAsEslintRule(ruleName, ruleImpl)]));
|
|
19
|
+
const buildFlatConfig = (configName, ruleSet) => ({
|
|
20
|
+
name: `react-doctor/${configName}`,
|
|
21
|
+
plugins: {},
|
|
22
|
+
rules: { ...ruleSet }
|
|
23
|
+
});
|
|
24
|
+
const ALL_RULES_AT_RECOMMENDED_SEVERITY = {
|
|
25
|
+
...GLOBAL_REACT_DOCTOR_RULES,
|
|
26
|
+
...NEXTJS_RULES,
|
|
27
|
+
...REACT_NATIVE_RULES,
|
|
28
|
+
...TANSTACK_START_RULES,
|
|
29
|
+
...TANSTACK_QUERY_RULES
|
|
30
|
+
};
|
|
31
|
+
const eslintPlugin = {
|
|
32
|
+
meta: {
|
|
33
|
+
name: PLUGIN_NAMESPACE,
|
|
34
|
+
version: "0.2.0-beta.2"
|
|
35
|
+
},
|
|
36
|
+
rules: eslintShapedRules,
|
|
37
|
+
configs: {
|
|
38
|
+
recommended: buildFlatConfig("recommended", GLOBAL_REACT_DOCTOR_RULES),
|
|
39
|
+
next: buildFlatConfig("next", NEXTJS_RULES),
|
|
40
|
+
"react-native": buildFlatConfig("react-native", REACT_NATIVE_RULES),
|
|
41
|
+
"tanstack-start": buildFlatConfig("tanstack-start", TANSTACK_START_RULES),
|
|
42
|
+
"tanstack-query": buildFlatConfig("tanstack-query", TANSTACK_QUERY_RULES),
|
|
43
|
+
all: buildFlatConfig("all", ALL_RULES_AT_RECOMMENDED_SEVERITY)
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
for (const flatConfig of Object.values(eslintPlugin.configs)) flatConfig.plugins[PLUGIN_NAMESPACE] = eslintPlugin;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { eslintPlugin as default };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-plugin-react-doctor",
|
|
3
|
+
"version": "0.2.0-beta.2",
|
|
4
|
+
"description": "ESLint plugin for React Doctor: diagnose React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"accessibility",
|
|
7
|
+
"eslint",
|
|
8
|
+
"eslint-plugin",
|
|
9
|
+
"eslintplugin",
|
|
10
|
+
"linter",
|
|
11
|
+
"nextjs",
|
|
12
|
+
"performance",
|
|
13
|
+
"react",
|
|
14
|
+
"react-compiler",
|
|
15
|
+
"react-native",
|
|
16
|
+
"security",
|
|
17
|
+
"tanstack",
|
|
18
|
+
"typescript"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://github.com/millionco/react-doctor#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/millionco/react-doctor/issues"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "Aiden Bai",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/millionco/react-doctor.git",
|
|
29
|
+
"directory": "packages/eslint-plugin-react-doctor"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist/**/*.js",
|
|
33
|
+
"dist/**/*.d.ts"
|
|
34
|
+
],
|
|
35
|
+
"type": "module",
|
|
36
|
+
"sideEffects": false,
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"default": "./dist/index.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"oxlint-plugin-react-doctor": "0.2.0-beta.2"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^25.6.0"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=22"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"dev": "vp pack --watch",
|
|
54
|
+
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && NODE_ENV=production vp pack",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"test": "vp test run"
|
|
57
|
+
}
|
|
58
|
+
}
|