eslint-plugin-react-x 2.0.0-beta.49 → 2.0.0-beta.53
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 +13 -13
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -115,7 +115,7 @@ const settings = { ...settings$1 };
|
|
|
115
115
|
//#endregion
|
|
116
116
|
//#region package.json
|
|
117
117
|
var name = "eslint-plugin-react-x";
|
|
118
|
-
var version = "2.0.0-beta.
|
|
118
|
+
var version = "2.0.0-beta.53";
|
|
119
119
|
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/utils/create-rule.ts
|
|
@@ -1154,7 +1154,7 @@ function create$44(context) {
|
|
|
1154
1154
|
if (property.type !== AST_NODE_TYPES.Identifier || property.name !== "defaultProps") return;
|
|
1155
1155
|
if (!ER.isComponentNameLoose(object.name)) return;
|
|
1156
1156
|
const variable = VAR.findVariable(object.name, context.sourceCode.getScope(node));
|
|
1157
|
-
const variableNode = VAR.
|
|
1157
|
+
const variableNode = VAR.getVariableDefinitionNode(variable, 0);
|
|
1158
1158
|
if (variableNode == null) return;
|
|
1159
1159
|
if (!AST.isFunction(variableNode)) return;
|
|
1160
1160
|
context.report({
|
|
@@ -1246,7 +1246,7 @@ function create$42(context) {
|
|
|
1246
1246
|
if (!AST.isFunction(iter)) return;
|
|
1247
1247
|
const arg0 = call?.arguments[0];
|
|
1248
1248
|
if (call == null || arg0 == null) return;
|
|
1249
|
-
if (AST.
|
|
1249
|
+
if (AST.getUnderlyingExpression(arg0) !== iter) return;
|
|
1250
1250
|
keyedEntries.set(call, {
|
|
1251
1251
|
hasDuplicate: node.value?.type === AST_NODE_TYPES.Literal,
|
|
1252
1252
|
keys: [node],
|
|
@@ -1938,7 +1938,7 @@ function isInsideJSXAttributeValue(node) {
|
|
|
1938
1938
|
* @returns `true` if node is inside class component's render block, `false` if not
|
|
1939
1939
|
*/
|
|
1940
1940
|
function isInsideRenderMethod(node) {
|
|
1941
|
-
return AST.findParentNode(node, (n) => ER.
|
|
1941
|
+
return AST.findParentNode(node, (n) => ER.isRenderMethodLike(n) && ER.isClassComponent(n.parent.parent)) != null;
|
|
1942
1942
|
}
|
|
1943
1943
|
/**
|
|
1944
1944
|
* Determines whether inside `createElement`'s props.
|
|
@@ -2032,7 +2032,7 @@ function create$31(context) {
|
|
|
2032
2032
|
if (property.type !== AST_NODE_TYPES.Identifier || property.name !== "propTypes") return;
|
|
2033
2033
|
if (!ER.isComponentNameLoose(object.name)) return;
|
|
2034
2034
|
const variable = VAR.findVariable(object.name, context.sourceCode.getScope(node));
|
|
2035
|
-
const variableNode = VAR.
|
|
2035
|
+
const variableNode = VAR.getVariableDefinitionNode(variable, 0);
|
|
2036
2036
|
if (variableNode != null && (AST.isFunction(variableNode) || ER.isClassComponent(variableNode))) context.report({
|
|
2037
2037
|
messageId: "noPropTypes",
|
|
2038
2038
|
node: property
|
|
@@ -2287,7 +2287,7 @@ function create$25(context) {
|
|
|
2287
2287
|
function isMapCallback(node) {
|
|
2288
2288
|
if (node.parent == null) return false;
|
|
2289
2289
|
if (!AST.isArrayMapCall(node.parent)) return false;
|
|
2290
|
-
return AST.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(AST.
|
|
2290
|
+
return AST.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(AST.getUnderlyingExpression(node));
|
|
2291
2291
|
}
|
|
2292
2292
|
|
|
2293
2293
|
//#endregion
|
|
@@ -2323,7 +2323,7 @@ function create$24(context) {
|
|
|
2323
2323
|
if (arg0 == null || arg1 == null) return;
|
|
2324
2324
|
const hasEmptyDeps = match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
2325
2325
|
const variable = VAR.findVariable(n.name, initialScope);
|
|
2326
|
-
const variableNode = VAR.
|
|
2326
|
+
const variableNode = VAR.getVariableDefinitionNode(variable, 0);
|
|
2327
2327
|
if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
|
|
2328
2328
|
return variableNode.elements.length === 0;
|
|
2329
2329
|
}).otherwise(() => false);
|
|
@@ -2333,13 +2333,13 @@ function create$24(context) {
|
|
|
2333
2333
|
return n;
|
|
2334
2334
|
}).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
2335
2335
|
const variable = VAR.findVariable(n.name, initialScope);
|
|
2336
|
-
const variableNode = VAR.
|
|
2336
|
+
const variableNode = VAR.getVariableDefinitionNode(variable, 0);
|
|
2337
2337
|
if (variableNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
|
|
2338
2338
|
return variableNode;
|
|
2339
2339
|
}).otherwise(() => null);
|
|
2340
2340
|
if (arg0Node == null) return;
|
|
2341
2341
|
const arg0NodeScope = context.sourceCode.getScope(arg0Node);
|
|
2342
|
-
const arg0NodeReferences = VAR.
|
|
2342
|
+
const arg0NodeReferences = VAR.getChildScopes(arg0NodeScope).flatMap((x) => x.references);
|
|
2343
2343
|
const isReferencedToComponentScope = arg0NodeReferences.some((x) => x.resolved?.scope.block === component);
|
|
2344
2344
|
if (!isReferencedToComponentScope) context.report({
|
|
2345
2345
|
messageId: "noUnnecessaryUseCallback",
|
|
@@ -2383,7 +2383,7 @@ function create$23(context) {
|
|
|
2383
2383
|
if (hasCallInArg0) return;
|
|
2384
2384
|
const hasEmptyDeps = match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
2385
2385
|
const variable = VAR.findVariable(n.name, initialScope);
|
|
2386
|
-
const variableNode = VAR.
|
|
2386
|
+
const variableNode = VAR.getVariableDefinitionNode(variable, 0);
|
|
2387
2387
|
if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
|
|
2388
2388
|
return variableNode.elements.length === 0;
|
|
2389
2389
|
}).otherwise(() => false);
|
|
@@ -2393,13 +2393,13 @@ function create$23(context) {
|
|
|
2393
2393
|
return n;
|
|
2394
2394
|
}).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
2395
2395
|
const variable = VAR.findVariable(n.name, initialScope);
|
|
2396
|
-
const variableNode = VAR.
|
|
2396
|
+
const variableNode = VAR.getVariableDefinitionNode(variable, 0);
|
|
2397
2397
|
if (variableNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
|
|
2398
2398
|
return variableNode;
|
|
2399
2399
|
}).otherwise(() => null);
|
|
2400
2400
|
if (arg0Node == null) return;
|
|
2401
2401
|
const arg0NodeScope = context.sourceCode.getScope(arg0Node);
|
|
2402
|
-
const arg0NodeReferences = VAR.
|
|
2402
|
+
const arg0NodeReferences = VAR.getChildScopes(arg0NodeScope).flatMap((x) => x.references);
|
|
2403
2403
|
const isReferencedToComponentScope = arg0NodeReferences.some((x) => x.resolved?.scope.block === component);
|
|
2404
2404
|
if (!isReferencedToComponentScope) context.report({
|
|
2405
2405
|
messageId: "noUnnecessaryUseMemo",
|
|
@@ -2438,7 +2438,7 @@ function create$22(context) {
|
|
|
2438
2438
|
const allHooks = ctx.getAllHooks(program);
|
|
2439
2439
|
for (const { id, name: name$4, node, hookCalls } of allHooks.values()) {
|
|
2440
2440
|
if (hookCalls.length > 0) continue;
|
|
2441
|
-
if (AST.
|
|
2441
|
+
if (AST.isFunctionEmpty(node)) continue;
|
|
2442
2442
|
if (WELL_KNOWN_HOOKS.includes(name$4)) continue;
|
|
2443
2443
|
if (containsUseComments(context, node)) continue;
|
|
2444
2444
|
if (AST.findParentNode(node, ContextDetection.isViMockCallback) != null) continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.53",
|
|
4
4
|
"description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
"is-immutable-type": "^5.0.1",
|
|
43
43
|
"string-ts": "^2.2.1",
|
|
44
44
|
"ts-pattern": "^5.8.0",
|
|
45
|
-
"@eslint-react/ast": "2.0.0-beta.
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/var": "2.0.0-beta.
|
|
45
|
+
"@eslint-react/ast": "2.0.0-beta.53",
|
|
46
|
+
"@eslint-react/core": "2.0.0-beta.53",
|
|
47
|
+
"@eslint-react/eff": "2.0.0-beta.53",
|
|
48
|
+
"@eslint-react/kit": "2.0.0-beta.53",
|
|
49
|
+
"@eslint-react/shared": "2.0.0-beta.53",
|
|
50
|
+
"@eslint-react/var": "2.0.0-beta.53"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/react": "^19.1.
|
|
53
|
+
"@types/react": "^19.1.12",
|
|
54
54
|
"@types/react-dom": "^19.1.8",
|
|
55
55
|
"ts-api-utils": "^2.1.0",
|
|
56
56
|
"tsdown": "^0.14.2",
|