eslint-plugin-react-debug 5.2.5-next.1 → 5.3.0-beta.0
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 +45 -39
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region package.json
|
|
29
29
|
var name$1 = "eslint-plugin-react-debug";
|
|
30
|
-
var version = "5.
|
|
30
|
+
var version = "5.3.0-beta.0";
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/utils/create-rule.ts
|
|
@@ -104,6 +104,24 @@ function create$3(context) {
|
|
|
104
104
|
} });
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/rules/is-from-react/lib.ts
|
|
109
|
+
/**
|
|
110
|
+
* Check if an identifier node is initialized from React
|
|
111
|
+
* @param node The identifier node to check
|
|
112
|
+
* @param initialScope Initial scope to search for the identifier
|
|
113
|
+
* @param importSource The import source to check against
|
|
114
|
+
* @returns Whether the identifier node is initialized from React
|
|
115
|
+
*/
|
|
116
|
+
function isFromReact(node, initialScope, importSource = "react") {
|
|
117
|
+
const name = node.name;
|
|
118
|
+
switch (true) {
|
|
119
|
+
case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return core.isAPIFromReact(node.parent.object.name, initialScope, importSource);
|
|
120
|
+
case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return core.isAPIFromReact(node.parent.object.name, initialScope, importSource);
|
|
121
|
+
default: return core.isAPIFromReact(name, initialScope, importSource);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
107
125
|
//#endregion
|
|
108
126
|
//#region src/rules/is-from-react/is-from-react.ts
|
|
109
127
|
const RULE_NAME$2 = "is-from-react";
|
|
@@ -138,20 +156,35 @@ function create$2(context) {
|
|
|
138
156
|
JSXIdentifier: visitorFunction
|
|
139
157
|
});
|
|
140
158
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
* @param importSource The import source to check against
|
|
146
|
-
* @returns Whether the identifier node is initialized from React
|
|
147
|
-
*/
|
|
148
|
-
function isFromReact(node, initialScope, importSource = "react") {
|
|
159
|
+
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/rules/is-from-ref/lib.ts
|
|
162
|
+
function getRefInitNode(context, node, initialScope) {
|
|
149
163
|
const name = node.name;
|
|
150
164
|
switch (true) {
|
|
151
|
-
case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return
|
|
152
|
-
case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return
|
|
153
|
-
default: return
|
|
165
|
+
case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return getRefInit(context, node.parent.object.name, initialScope);
|
|
166
|
+
case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return getRefInit(context, node.parent.object.name, initialScope);
|
|
167
|
+
default: return getRefInit(context, name, initialScope);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get the init expression of a ref variable
|
|
172
|
+
* @param context The rule context
|
|
173
|
+
* @param name The variable name
|
|
174
|
+
* @param initialScope The initial scope
|
|
175
|
+
* @returns The init expression node if the variable is derived from a ref, or null otherwise
|
|
176
|
+
*/
|
|
177
|
+
function getRefInit(context, name, initialScope) {
|
|
178
|
+
for (const { node } of findVariable(initialScope, name)?.defs ?? []) {
|
|
179
|
+
if (node.type !== AST_NODE_TYPES.VariableDeclarator) continue;
|
|
180
|
+
const init = node.init;
|
|
181
|
+
if (init == null) continue;
|
|
182
|
+
switch (true) {
|
|
183
|
+
case init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier && (init.object.name === "ref" || init.object.name.endsWith("Ref")): return init;
|
|
184
|
+
case init.type === AST_NODE_TYPES.CallExpression && isUseRefCall(context, init): return init;
|
|
185
|
+
}
|
|
154
186
|
}
|
|
187
|
+
return null;
|
|
155
188
|
}
|
|
156
189
|
|
|
157
190
|
//#endregion
|
|
@@ -188,33 +221,6 @@ function create$1(context) {
|
|
|
188
221
|
JSXIdentifier: visitorFunction
|
|
189
222
|
});
|
|
190
223
|
}
|
|
191
|
-
function getRefInitNode(context, node, initialScope) {
|
|
192
|
-
const name = node.name;
|
|
193
|
-
switch (true) {
|
|
194
|
-
case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return getRefInit(context, node.parent.object.name, initialScope);
|
|
195
|
-
case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return getRefInit(context, node.parent.object.name, initialScope);
|
|
196
|
-
default: return getRefInit(context, name, initialScope);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Get the init expression of a ref variable
|
|
201
|
-
* @param context The rule context
|
|
202
|
-
* @param name The variable name
|
|
203
|
-
* @param initialScope The initial scope
|
|
204
|
-
* @returns The init expression node if the variable is derived from a ref, or null otherwise
|
|
205
|
-
*/
|
|
206
|
-
function getRefInit(context, name, initialScope) {
|
|
207
|
-
for (const { node } of findVariable(initialScope, name)?.defs ?? []) {
|
|
208
|
-
if (node.type !== AST_NODE_TYPES.VariableDeclarator) continue;
|
|
209
|
-
const init = node.init;
|
|
210
|
-
if (init == null) continue;
|
|
211
|
-
switch (true) {
|
|
212
|
-
case init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier && (init.object.name === "ref" || init.object.name.endsWith("Ref")): return init;
|
|
213
|
-
case init.type === AST_NODE_TYPES.CallExpression && isUseRefCall(context, init): return init;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
224
|
|
|
219
225
|
//#endregion
|
|
220
226
|
//#region ../../.pkgs/eff/dist/index.js
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-debug",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0-beta.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for debugging related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,23 +43,23 @@
|
|
|
43
43
|
"@typescript-eslint/types": "^8.58.2",
|
|
44
44
|
"@typescript-eslint/utils": "^8.58.2",
|
|
45
45
|
"ts-pattern": "^5.9.0",
|
|
46
|
-
"@eslint-react/ast": "5.
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
46
|
+
"@eslint-react/ast": "5.3.0-beta.0",
|
|
47
|
+
"@eslint-react/eslint": "5.3.0-beta.0",
|
|
48
|
+
"@eslint-react/jsx": "5.3.0-beta.0",
|
|
49
|
+
"@eslint-react/var": "5.3.0-beta.0",
|
|
50
|
+
"@eslint-react/shared": "5.3.0-beta.0",
|
|
51
|
+
"@eslint-react/core": "5.3.0-beta.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.2.14",
|
|
55
55
|
"@types/react-dom": "^19.2.3",
|
|
56
|
-
"eslint": "^10.2.
|
|
56
|
+
"eslint": "^10.2.1",
|
|
57
57
|
"tsdown": "^0.21.9",
|
|
58
|
-
"@local/
|
|
59
|
-
"@local/
|
|
58
|
+
"@local/configs": "0.0.0",
|
|
59
|
+
"@local/eff": "3.0.0-beta.72"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"eslint": "^10.2.
|
|
62
|
+
"eslint": "^10.2.1",
|
|
63
63
|
"typescript": "*"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|