eslint-plugin-react-debug 2.7.4-beta.5 → 2.7.4-beta.6
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 +9 -0
- package/dist/index.js +17 -17
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -38,6 +38,15 @@ export default defineConfig(
|
|
|
38
38
|
);
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
> [!WARNING]
|
|
42
|
+
> Debug rules report `React` patterns for code metrics, transformations, or custom tooling. These are not included in the unified plugin by default.
|
|
43
|
+
|
|
44
|
+
- [`class-component`](./debug-class-component) - Reports all class components
|
|
45
|
+
- [`function-component`](./debug-function-component) - Reports all function components
|
|
46
|
+
- [`hook`](./debug-hook) - Reports all `React` hooks
|
|
47
|
+
- [`is-from-react`](./debug-is-from-react) - Reports identifiers initialized from `React`
|
|
48
|
+
- [`jsx`](./debug-jsx) - Reports all `JSX` elements and fragments
|
|
49
|
+
|
|
41
50
|
## Rules
|
|
42
51
|
|
|
43
52
|
<https://eslint-react.xyz/docs/rules/overview#debug-rules>
|
package/dist/index.js
CHANGED
|
@@ -9,9 +9,9 @@ import { P, match } from "ts-pattern";
|
|
|
9
9
|
var __defProp = Object.defineProperty;
|
|
10
10
|
var __exportAll = (all, symbols) => {
|
|
11
11
|
let target = {};
|
|
12
|
-
for (var name
|
|
13
|
-
__defProp(target, name
|
|
14
|
-
get: all[name
|
|
12
|
+
for (var name in all) {
|
|
13
|
+
__defProp(target, name, {
|
|
14
|
+
get: all[name],
|
|
15
15
|
enumerable: true
|
|
16
16
|
});
|
|
17
17
|
}
|
|
@@ -41,7 +41,7 @@ const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
|
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region package.json
|
|
43
43
|
var name = "eslint-plugin-react-debug";
|
|
44
|
-
var version = "2.7.4-beta.
|
|
44
|
+
var version = "2.7.4-beta.6";
|
|
45
45
|
|
|
46
46
|
//#endregion
|
|
47
47
|
//#region src/utils/create-rule.ts
|
|
@@ -73,10 +73,10 @@ var class_component_default = createRule({
|
|
|
73
73
|
function create$4(context) {
|
|
74
74
|
const { ctx, visitor } = useComponentCollectorLegacy(context);
|
|
75
75
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
76
|
-
for (const { name
|
|
76
|
+
for (const { name = "anonymous", node: component } of ctx.getAllComponents(program)) context.report({
|
|
77
77
|
messageId: "classComponent",
|
|
78
78
|
node: component,
|
|
79
|
-
data: { json: stringify({ name
|
|
79
|
+
data: { json: stringify({ name }) }
|
|
80
80
|
});
|
|
81
81
|
} });
|
|
82
82
|
}
|
|
@@ -102,11 +102,11 @@ function create$3(context) {
|
|
|
102
102
|
hint: DEFAULT_COMPONENT_DETECTION_HINT
|
|
103
103
|
});
|
|
104
104
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
105
|
-
for (const { name
|
|
105
|
+
for (const { name = "anonymous", node, displayName, flag, hookCalls } of ctx.getAllComponents(program)) context.report({
|
|
106
106
|
messageId: "functionComponent",
|
|
107
107
|
node,
|
|
108
108
|
data: { json: stringify({
|
|
109
|
-
name
|
|
109
|
+
name,
|
|
110
110
|
displayName: displayName == null ? "none" : context.sourceCode.getText(displayName),
|
|
111
111
|
forwardRef: (flag & ComponentFlag.ForwardRef) > 0n,
|
|
112
112
|
hookCalls: hookCalls.length,
|
|
@@ -133,11 +133,11 @@ var hook_default = createRule({
|
|
|
133
133
|
function create$2(context) {
|
|
134
134
|
const { ctx, visitor } = useHookCollector(context);
|
|
135
135
|
return defineRuleListener(visitor, { "Program:exit"(program) {
|
|
136
|
-
for (const { name
|
|
136
|
+
for (const { name, node, hookCalls } of ctx.getAllHooks(program)) context.report({
|
|
137
137
|
messageId: "hook",
|
|
138
138
|
node,
|
|
139
139
|
data: { json: stringify({
|
|
140
|
-
name
|
|
140
|
+
name,
|
|
141
141
|
hookCalls: hookCalls.length
|
|
142
142
|
}) }
|
|
143
143
|
});
|
|
@@ -162,13 +162,13 @@ function create$1(context) {
|
|
|
162
162
|
const { importSource } = getSettingsFromContext(context);
|
|
163
163
|
function visitorFunction(node) {
|
|
164
164
|
if (node.parent.type === AST_NODE_TYPES.ImportSpecifier && node.parent.imported === node && node.parent.imported.name === node.parent.local.name) return;
|
|
165
|
-
const name
|
|
165
|
+
const name = node.name;
|
|
166
166
|
if (!isFromReact(node, context.sourceCode.getScope(node), importSource)) return;
|
|
167
167
|
context.report({
|
|
168
168
|
messageId: "isFromReact",
|
|
169
169
|
node,
|
|
170
170
|
data: { json: stringify({
|
|
171
|
-
name
|
|
171
|
+
name,
|
|
172
172
|
importSource
|
|
173
173
|
}) }
|
|
174
174
|
});
|
|
@@ -186,11 +186,11 @@ function create$1(context) {
|
|
|
186
186
|
* @returns Whether the identifier node is initialized from React
|
|
187
187
|
*/
|
|
188
188
|
function isFromReact(node, initialScope, importSource = "react") {
|
|
189
|
-
const name
|
|
189
|
+
const name = node.name;
|
|
190
190
|
switch (true) {
|
|
191
191
|
case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return isInitializedFromReact(node.parent.object.name, initialScope, importSource);
|
|
192
192
|
case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return isInitializedFromReact(node.parent.object.name, initialScope, importSource);
|
|
193
|
-
default: return isInitializedFromReact(name
|
|
193
|
+
default: return isInitializedFromReact(name, initialScope, importSource);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
@@ -215,13 +215,13 @@ function create(context) {
|
|
|
215
215
|
...jsxConfigFromContext,
|
|
216
216
|
...jsxConfigFromAnnotation
|
|
217
217
|
};
|
|
218
|
-
function getReportDescriptor(context
|
|
218
|
+
function getReportDescriptor(context) {
|
|
219
219
|
return (node) => ({
|
|
220
220
|
messageId: "jsx",
|
|
221
221
|
node,
|
|
222
222
|
data: { json: stringify({
|
|
223
|
-
kind: match(node).with({ type: AST_NODE_TYPES$1.JSXElement }, (n) => isJsxFragmentElement(context
|
|
224
|
-
type: getJsxElementType(context
|
|
223
|
+
kind: match(node).with({ type: AST_NODE_TYPES$1.JSXElement }, (n) => isJsxFragmentElement(context, n, jsxConfig) ? "fragment" : "element").with({ type: AST_NODE_TYPES$1.JSXFragment }, () => "fragment").exhaustive(),
|
|
224
|
+
type: getJsxElementType(context, node),
|
|
225
225
|
jsx: match(jsxConfig.jsx).with(JsxEmit.None, () => "none").with(JsxEmit.ReactJSX, () => "react-jsx").with(JsxEmit.ReactJSXDev, () => "react-jsx-dev").with(JsxEmit.React, () => "react").with(JsxEmit.ReactNative, () => "react-native").with(JsxEmit.Preserve, () => "preserve").otherwise(() => "unknown"),
|
|
226
226
|
jsxFactory: jsxConfig.jsxFactory,
|
|
227
227
|
jsxFragmentFactory: jsxConfig.jsxFragmentFactory,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-debug",
|
|
3
|
-
"version": "2.7.4-beta.
|
|
3
|
+
"version": "2.7.4-beta.6",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for debugging related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"@typescript-eslint/utils": "^8.53.1",
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-pattern": "^5.9.0",
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
47
|
+
"@eslint-react/core": "2.7.4-beta.6",
|
|
48
|
+
"@eslint-react/ast": "2.7.4-beta.6",
|
|
49
|
+
"@eslint-react/eff": "2.7.4-beta.6",
|
|
50
|
+
"@eslint-react/shared": "2.7.4-beta.6",
|
|
51
|
+
"@eslint-react/var": "2.7.4-beta.6"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.2.9",
|
|
55
55
|
"@types/react-dom": "^19.2.3",
|
|
56
|
-
"tsdown": "^0.20.
|
|
56
|
+
"tsdown": "^0.20.1",
|
|
57
57
|
"@local/configs": "0.0.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|