eslint-plugin-react-debug 1.24.0-beta.1 → 1.24.0-beta.18
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/dist/index.js +17 -18
- package/dist/index.mjs +18 -19
- package/package.json +13 -14
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var utils = require('@typescript-eslint/utils');
|
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
8
|
var name = "eslint-plugin-react-debug";
|
|
9
|
-
var version = "1.24.0-beta.
|
|
9
|
+
var version = "1.24.0-beta.18";
|
|
10
10
|
var createRule = shared.createRuleForPlugin("debug");
|
|
11
11
|
|
|
12
12
|
// src/rules/class-component.ts
|
|
@@ -18,7 +18,6 @@ var class_component_default = createRule({
|
|
|
18
18
|
meta: {
|
|
19
19
|
type: "problem",
|
|
20
20
|
docs: {
|
|
21
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
22
21
|
description: "report all class components, including anonymous ones",
|
|
23
22
|
[Symbol.for("rule_features")]: RULE_FEATURES
|
|
24
23
|
},
|
|
@@ -56,28 +55,35 @@ var function_component_default = createRule({
|
|
|
56
55
|
meta: {
|
|
57
56
|
type: "problem",
|
|
58
57
|
docs: {
|
|
59
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
60
58
|
description: "report all function components, including anonymous ones",
|
|
61
59
|
[Symbol.for("rule_features")]: RULE_FEATURES2
|
|
62
60
|
},
|
|
63
61
|
messages: {
|
|
64
|
-
functionComponent: "[function component] name: {{name}}, memo: {{memo}}, forwardRef: {{forwardRef}}, hookCalls: {{hookCalls}}."
|
|
62
|
+
functionComponent: "[function component] name: {{name}}, memo: {{memo}}, forwardRef: {{forwardRef}}, hookCalls: {{hookCalls}}, displayName: {{displayName}}."
|
|
65
63
|
},
|
|
66
64
|
schema: []
|
|
67
65
|
},
|
|
68
66
|
name: RULE_NAME2,
|
|
69
67
|
create(context) {
|
|
70
|
-
const { ctx, listeners } = core.useComponentCollector(
|
|
68
|
+
const { ctx, listeners } = core.useComponentCollector(
|
|
69
|
+
context,
|
|
70
|
+
core.DEFAULT_COMPONENT_HINT,
|
|
71
|
+
{
|
|
72
|
+
collectDisplayName: true,
|
|
73
|
+
collectHookCalls: true
|
|
74
|
+
}
|
|
75
|
+
);
|
|
71
76
|
return {
|
|
72
77
|
...listeners,
|
|
73
78
|
"Program:exit"(node) {
|
|
74
79
|
const components = ctx.getAllComponents(node);
|
|
75
|
-
for (const { name: name2 = "anonymous", node: node2, flag, hookCalls } of components.values()) {
|
|
80
|
+
for (const { name: name2 = "anonymous", node: node2, displayName, flag, hookCalls } of components.values()) {
|
|
76
81
|
context.report({
|
|
77
82
|
messageId: "functionComponent",
|
|
78
83
|
node: node2,
|
|
79
84
|
data: {
|
|
80
85
|
name: name2,
|
|
86
|
+
displayName: displayName != null ? context.sourceCode.getText(displayName) : "none",
|
|
81
87
|
forwardRef: (flag & core.ERFunctionComponentFlag.ForwardRef) > 0n,
|
|
82
88
|
hookCalls: hookCalls.length,
|
|
83
89
|
memo: (flag & core.ERFunctionComponentFlag.Memo) > 0n
|
|
@@ -97,7 +103,6 @@ var hook_default = createRule({
|
|
|
97
103
|
meta: {
|
|
98
104
|
type: "problem",
|
|
99
105
|
docs: {
|
|
100
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
101
106
|
description: "report all React Hooks",
|
|
102
107
|
[Symbol.for("rule_features")]: RULE_FEATURES3
|
|
103
108
|
},
|
|
@@ -136,7 +141,6 @@ var is_from_react_default = createRule({
|
|
|
136
141
|
meta: {
|
|
137
142
|
type: "problem",
|
|
138
143
|
docs: {
|
|
139
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
140
144
|
description: "report all identifiers that are initialized from React.",
|
|
141
145
|
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
142
146
|
},
|
|
@@ -147,20 +151,16 @@ var is_from_react_default = createRule({
|
|
|
147
151
|
},
|
|
148
152
|
name: RULE_NAME4,
|
|
149
153
|
create(context) {
|
|
150
|
-
const
|
|
151
|
-
importSource: "react",
|
|
152
|
-
...shared.getSettingsFromContext(context),
|
|
153
|
-
strictImportCheck: true
|
|
154
|
-
};
|
|
154
|
+
const { importSource = "react" } = shared.getSettingsFromContext(context);
|
|
155
155
|
function isFromReact(node, initialScope) {
|
|
156
156
|
const name2 = node.name;
|
|
157
157
|
switch (true) {
|
|
158
158
|
case (node.parent.type === utils.AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === utils.AST_NODE_TYPES.Identifier):
|
|
159
|
-
return core.isInitializedFromReact(node.parent.object.name,
|
|
159
|
+
return core.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
|
|
160
160
|
case (node.parent.type === utils.AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === utils.AST_NODE_TYPES.JSXIdentifier):
|
|
161
|
-
return core.isInitializedFromReact(node.parent.object.name,
|
|
161
|
+
return core.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
|
|
162
162
|
default:
|
|
163
|
-
return core.isInitializedFromReact(name2,
|
|
163
|
+
return core.isInitializedFromReact(name2, importSource, initialScope);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
function visitorFunction(node) {
|
|
@@ -177,10 +177,9 @@ var is_from_react_default = createRule({
|
|
|
177
177
|
messageId: "isFromReact",
|
|
178
178
|
node,
|
|
179
179
|
data: {
|
|
180
|
-
// eslint-disable-next-line eslint-plugin/no-unused-placeholders
|
|
181
180
|
type: node.type,
|
|
182
181
|
name: name2,
|
|
183
|
-
importSource
|
|
182
|
+
importSource
|
|
184
183
|
}
|
|
185
184
|
});
|
|
186
185
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useComponentCollectorLegacy, useComponentCollector, ERFunctionComponentFlag, useHookCollector, isInitializedFromReact } from '@eslint-react/core';
|
|
1
|
+
import { useComponentCollectorLegacy, useComponentCollector, DEFAULT_COMPONENT_HINT, ERFunctionComponentFlag, useHookCollector, isInitializedFromReact } from '@eslint-react/core';
|
|
2
2
|
import { createRuleForPlugin, getSettingsFromContext } from '@eslint-react/shared';
|
|
3
3
|
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
4
4
|
|
|
5
5
|
// package.json
|
|
6
6
|
var name = "eslint-plugin-react-debug";
|
|
7
|
-
var version = "1.24.0-beta.
|
|
7
|
+
var version = "1.24.0-beta.18";
|
|
8
8
|
var createRule = createRuleForPlugin("debug");
|
|
9
9
|
|
|
10
10
|
// src/rules/class-component.ts
|
|
@@ -16,7 +16,6 @@ var class_component_default = createRule({
|
|
|
16
16
|
meta: {
|
|
17
17
|
type: "problem",
|
|
18
18
|
docs: {
|
|
19
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
20
19
|
description: "report all class components, including anonymous ones",
|
|
21
20
|
[Symbol.for("rule_features")]: RULE_FEATURES
|
|
22
21
|
},
|
|
@@ -54,28 +53,35 @@ var function_component_default = createRule({
|
|
|
54
53
|
meta: {
|
|
55
54
|
type: "problem",
|
|
56
55
|
docs: {
|
|
57
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
58
56
|
description: "report all function components, including anonymous ones",
|
|
59
57
|
[Symbol.for("rule_features")]: RULE_FEATURES2
|
|
60
58
|
},
|
|
61
59
|
messages: {
|
|
62
|
-
functionComponent: "[function component] name: {{name}}, memo: {{memo}}, forwardRef: {{forwardRef}}, hookCalls: {{hookCalls}}."
|
|
60
|
+
functionComponent: "[function component] name: {{name}}, memo: {{memo}}, forwardRef: {{forwardRef}}, hookCalls: {{hookCalls}}, displayName: {{displayName}}."
|
|
63
61
|
},
|
|
64
62
|
schema: []
|
|
65
63
|
},
|
|
66
64
|
name: RULE_NAME2,
|
|
67
65
|
create(context) {
|
|
68
|
-
const { ctx, listeners } = useComponentCollector(
|
|
66
|
+
const { ctx, listeners } = useComponentCollector(
|
|
67
|
+
context,
|
|
68
|
+
DEFAULT_COMPONENT_HINT,
|
|
69
|
+
{
|
|
70
|
+
collectDisplayName: true,
|
|
71
|
+
collectHookCalls: true
|
|
72
|
+
}
|
|
73
|
+
);
|
|
69
74
|
return {
|
|
70
75
|
...listeners,
|
|
71
76
|
"Program:exit"(node) {
|
|
72
77
|
const components = ctx.getAllComponents(node);
|
|
73
|
-
for (const { name: name2 = "anonymous", node: node2, flag, hookCalls } of components.values()) {
|
|
78
|
+
for (const { name: name2 = "anonymous", node: node2, displayName, flag, hookCalls } of components.values()) {
|
|
74
79
|
context.report({
|
|
75
80
|
messageId: "functionComponent",
|
|
76
81
|
node: node2,
|
|
77
82
|
data: {
|
|
78
83
|
name: name2,
|
|
84
|
+
displayName: displayName != null ? context.sourceCode.getText(displayName) : "none",
|
|
79
85
|
forwardRef: (flag & ERFunctionComponentFlag.ForwardRef) > 0n,
|
|
80
86
|
hookCalls: hookCalls.length,
|
|
81
87
|
memo: (flag & ERFunctionComponentFlag.Memo) > 0n
|
|
@@ -95,7 +101,6 @@ var hook_default = createRule({
|
|
|
95
101
|
meta: {
|
|
96
102
|
type: "problem",
|
|
97
103
|
docs: {
|
|
98
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
99
104
|
description: "report all React Hooks",
|
|
100
105
|
[Symbol.for("rule_features")]: RULE_FEATURES3
|
|
101
106
|
},
|
|
@@ -134,7 +139,6 @@ var is_from_react_default = createRule({
|
|
|
134
139
|
meta: {
|
|
135
140
|
type: "problem",
|
|
136
141
|
docs: {
|
|
137
|
-
// eslint-disable-next-line eslint-plugin/require-meta-docs-description
|
|
138
142
|
description: "report all identifiers that are initialized from React.",
|
|
139
143
|
[Symbol.for("rule_features")]: RULE_FEATURES4
|
|
140
144
|
},
|
|
@@ -145,20 +149,16 @@ var is_from_react_default = createRule({
|
|
|
145
149
|
},
|
|
146
150
|
name: RULE_NAME4,
|
|
147
151
|
create(context) {
|
|
148
|
-
const
|
|
149
|
-
importSource: "react",
|
|
150
|
-
...getSettingsFromContext(context),
|
|
151
|
-
strictImportCheck: true
|
|
152
|
-
};
|
|
152
|
+
const { importSource = "react" } = getSettingsFromContext(context);
|
|
153
153
|
function isFromReact(node, initialScope) {
|
|
154
154
|
const name2 = node.name;
|
|
155
155
|
switch (true) {
|
|
156
156
|
case (node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier):
|
|
157
|
-
return isInitializedFromReact(node.parent.object.name,
|
|
157
|
+
return isInitializedFromReact(node.parent.object.name, importSource, initialScope);
|
|
158
158
|
case (node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier):
|
|
159
|
-
return isInitializedFromReact(node.parent.object.name,
|
|
159
|
+
return isInitializedFromReact(node.parent.object.name, importSource, initialScope);
|
|
160
160
|
default:
|
|
161
|
-
return isInitializedFromReact(name2,
|
|
161
|
+
return isInitializedFromReact(name2, importSource, initialScope);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
function visitorFunction(node) {
|
|
@@ -175,10 +175,9 @@ var is_from_react_default = createRule({
|
|
|
175
175
|
messageId: "isFromReact",
|
|
176
176
|
node,
|
|
177
177
|
data: {
|
|
178
|
-
// eslint-disable-next-line eslint-plugin/no-unused-placeholders
|
|
179
178
|
type: node.type,
|
|
180
179
|
name: name2,
|
|
181
|
-
importSource
|
|
180
|
+
importSource
|
|
182
181
|
}
|
|
183
182
|
});
|
|
184
183
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-debug",
|
|
3
|
-
"version": "1.24.0-beta.
|
|
3
|
+
"version": "1.24.0-beta.18",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for debugging related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -41,22 +41,21 @@
|
|
|
41
41
|
"./package.json"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
45
|
-
"@typescript-eslint/type-utils": "^8.
|
|
46
|
-
"@typescript-eslint/types": "^8.
|
|
47
|
-
"@typescript-eslint/utils": "^8.
|
|
44
|
+
"@typescript-eslint/scope-manager": "^8.20.0",
|
|
45
|
+
"@typescript-eslint/type-utils": "^8.20.0",
|
|
46
|
+
"@typescript-eslint/types": "^8.20.0",
|
|
47
|
+
"@typescript-eslint/utils": "^8.20.0",
|
|
48
48
|
"string-ts": "^2.2.0",
|
|
49
|
-
"ts-pattern": "^5.6.
|
|
50
|
-
"@eslint-react/ast": "1.24.0-beta.
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/var": "1.24.0-beta.1"
|
|
49
|
+
"ts-pattern": "^5.6.1",
|
|
50
|
+
"@eslint-react/ast": "1.24.0-beta.18",
|
|
51
|
+
"@eslint-react/core": "1.24.0-beta.18",
|
|
52
|
+
"@eslint-react/jsx": "1.24.0-beta.18",
|
|
53
|
+
"@eslint-react/eff": "1.24.0-beta.18",
|
|
54
|
+
"@eslint-react/shared": "1.24.0-beta.18",
|
|
55
|
+
"@eslint-react/var": "1.24.0-beta.18"
|
|
57
56
|
},
|
|
58
57
|
"devDependencies": {
|
|
59
|
-
"@types/react": "^19.0.
|
|
58
|
+
"@types/react": "^19.0.7",
|
|
60
59
|
"@types/react-dom": "^19.0.3",
|
|
61
60
|
"tsup": "^8.3.5",
|
|
62
61
|
"@workspace/configs": "0.0.0"
|