eslint-plugin-react-x 5.30.0-beta.4 → 5.30.0-beta.5
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 +12 -15
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as core from "@eslint-react/core";
|
|
|
5
5
|
import { getConstrainedTypeAtLocation, getText, merge, report } from "@eslint-react/eslint";
|
|
6
6
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
7
7
|
import { P, isMatching, match } from "ts-pattern";
|
|
8
|
-
import { isAssignmentTargetEqual, isInitializedFromReact, resolveEnclosingAssignmentTarget, resolveObjectType, resolveOrigin } from "@eslint-react/var";
|
|
8
|
+
import { isAssignmentTargetEqual, isInitializedFromReact, resolveBindingTarget, resolveEnclosingAssignmentTarget, resolveObjectType, resolveOrigin } from "@eslint-react/var";
|
|
9
9
|
import { DefinitionType, ScopeType } from "@typescript-eslint/scope-manager";
|
|
10
10
|
import { findVariable, getStaticValue } from "@typescript-eslint/utils/ast-utils";
|
|
11
11
|
import { findParentAttribute, getCreateElementPropsObject, getElementFullType, hasAttribute, isAttribute, isInsideCreateElementProps } from "@eslint-react/jsx";
|
|
@@ -130,7 +130,7 @@ const rules$6 = {
|
|
|
130
130
|
};
|
|
131
131
|
// package.json
|
|
132
132
|
var name$6 = "eslint-plugin-react-x";
|
|
133
|
-
var version = "5.30.0-beta.
|
|
133
|
+
var version = "5.30.0-beta.5";
|
|
134
134
|
// src/utils/create-rule.ts
|
|
135
135
|
function getDocsUrl(ruleName) {
|
|
136
136
|
return `https://eslint-react.xyz/docs/rules/${ruleName}`;
|
|
@@ -1727,7 +1727,7 @@ function isArrayIndexReference(context, node) {
|
|
|
1727
1727
|
if (call.arguments[callbackPosition] !== argument) return false;
|
|
1728
1728
|
const param = callback.params[indexPosition];
|
|
1729
1729
|
if (param == null) return false;
|
|
1730
|
-
return param === def.name
|
|
1730
|
+
return resolveBindingTarget(param) === def.name;
|
|
1731
1731
|
}
|
|
1732
1732
|
function getIdentifiersFromBinaryExpression(side) {
|
|
1733
1733
|
if (Check.isIdentifier(side)) return [side];
|
|
@@ -3298,7 +3298,7 @@ function create$12(context, [options]) {
|
|
|
3298
3298
|
return declarators.get(component)?.filter((d) => d.init.name === name).flatMap((d) => d.id.properties) ?? [];
|
|
3299
3299
|
}).otherwise(() => []);
|
|
3300
3300
|
for (const prop of properties) {
|
|
3301
|
-
if (prop.type !== AST_NODE_TYPES.Property || prop.value
|
|
3301
|
+
if (prop.type !== AST_NODE_TYPES.Property || !Check.isObjectPatternElementDefault(prop.value)) continue;
|
|
3302
3302
|
const { value } = prop;
|
|
3303
3303
|
const { right } = value;
|
|
3304
3304
|
const construction = resolveObjectType(context, value);
|
|
@@ -3440,7 +3440,7 @@ function collectUsedPropKeysOfParameter(context, usedPropKeys, parameter) {
|
|
|
3440
3440
|
switch (parameter.type) {
|
|
3441
3441
|
case AST_NODE_TYPES.Identifier: return collectUsedPropKeysOfIdentifier(context, usedPropKeys, parameter);
|
|
3442
3442
|
case AST_NODE_TYPES.ObjectPattern: return collectUsedPropKeysOfObjectPattern(context, usedPropKeys, parameter);
|
|
3443
|
-
case AST_NODE_TYPES.AssignmentPattern: return collectUsedPropKeysOfParameter(context, usedPropKeys, parameter
|
|
3443
|
+
case AST_NODE_TYPES.AssignmentPattern: return collectUsedPropKeysOfParameter(context, usedPropKeys, resolveBindingTarget(parameter));
|
|
3444
3444
|
default: return false;
|
|
3445
3445
|
}
|
|
3446
3446
|
}
|
|
@@ -4021,7 +4021,7 @@ function hasUseClientDirective(program) {
|
|
|
4021
4021
|
function getDestructuredPropertyName(pattern, name) {
|
|
4022
4022
|
for (const property of pattern.properties) {
|
|
4023
4023
|
if (property.type !== AST_NODE_TYPES.Property) continue;
|
|
4024
|
-
if ((property.value
|
|
4024
|
+
if (resolveBindingTarget(property.value) !== name) continue;
|
|
4025
4025
|
return Extract.getPropertyName(property, "max");
|
|
4026
4026
|
}
|
|
4027
4027
|
return null;
|
|
@@ -6401,11 +6401,8 @@ function isRefLikeName(name) {
|
|
|
6401
6401
|
return name === "ref" || name.endsWith("Ref");
|
|
6402
6402
|
}
|
|
6403
6403
|
function getParameterId(param) {
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
case AST_NODE_TYPES.AssignmentPattern: return param.left.type === AST_NODE_TYPES.Identifier ? param.left : null;
|
|
6407
|
-
default: return null;
|
|
6408
|
-
}
|
|
6404
|
+
const target = resolveBindingTarget(param);
|
|
6405
|
+
return target.type === AST_NODE_TYPES.Identifier ? target : null;
|
|
6409
6406
|
}
|
|
6410
6407
|
function getRefSourceName(node) {
|
|
6411
6408
|
switch (node.type) {
|
|
@@ -7190,7 +7187,7 @@ function isConfiguredStableHookValue(variable, configs) {
|
|
|
7190
7187
|
if (id.type !== AST_NODE_TYPES.ArrayPattern) return false;
|
|
7191
7188
|
const index = id.elements.findIndex((element) => {
|
|
7192
7189
|
if (element == null) return false;
|
|
7193
|
-
const binding = element
|
|
7190
|
+
const binding = resolveBindingTarget(element);
|
|
7194
7191
|
return variable.identifiers.some((identifier) => identifier === binding);
|
|
7195
7192
|
});
|
|
7196
7193
|
return index !== -1 && stableResult.has(index);
|
|
@@ -7354,8 +7351,8 @@ const rule = {
|
|
|
7354
7351
|
} else if (name === "useState" || name === "useReducer" || name === "useActionState") {
|
|
7355
7352
|
const isActionState = name === "useActionState";
|
|
7356
7353
|
if (id.type === "ArrayPattern" && (isActionState ? id.elements.length >= 2 : id.elements.length === 2) && isArray(resolved.identifiers)) {
|
|
7357
|
-
const firstElement = id.elements[0]
|
|
7358
|
-
const secondElement = id.elements[1]
|
|
7354
|
+
const firstElement = resolveBindingTarget(id.elements[0] ?? null);
|
|
7355
|
+
const secondElement = resolveBindingTarget(id.elements[1] ?? null);
|
|
7359
7356
|
if (resolved.identifiers.some((identifier) => identifier === secondElement)) {
|
|
7360
7357
|
if (name === "useState") {
|
|
7361
7358
|
const references = resolved.references;
|
|
@@ -7375,7 +7372,7 @@ const rule = {
|
|
|
7375
7372
|
}
|
|
7376
7373
|
} else if (name === "useTransition") {
|
|
7377
7374
|
if (id.type === "ArrayPattern" && id.elements.length === 2 && Array.isArray(resolved.identifiers)) {
|
|
7378
|
-
const secondElement = id.elements[1]
|
|
7375
|
+
const secondElement = resolveBindingTarget(id.elements[1] ?? null);
|
|
7379
7376
|
if (resolved.identifiers.some((identifier) => identifier === secondElement)) return true;
|
|
7380
7377
|
}
|
|
7381
7378
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "5.30.0-beta.
|
|
3
|
+
"version": "5.30.0-beta.5",
|
|
4
4
|
"description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@eslint-react/ast": "5.30.0-beta.
|
|
40
|
-
"@eslint-react/core": "5.30.0-beta.
|
|
41
|
-
"@eslint-react/eslint": "5.30.0-beta.
|
|
42
|
-
"@eslint-react/jsx": "5.30.0-beta.
|
|
43
|
-
"@eslint-react/shared": "5.30.0-beta.
|
|
44
|
-
"@eslint-react/var": "5.30.0-beta.
|
|
45
|
-
"@typescript-eslint/scope-manager": "^8.72.
|
|
46
|
-
"@typescript-eslint/types": "^8.72.
|
|
47
|
-
"@typescript-eslint/utils": "^8.72.
|
|
39
|
+
"@eslint-react/ast": "5.30.0-beta.5",
|
|
40
|
+
"@eslint-react/core": "5.30.0-beta.5",
|
|
41
|
+
"@eslint-react/eslint": "5.30.0-beta.5",
|
|
42
|
+
"@eslint-react/jsx": "5.30.0-beta.5",
|
|
43
|
+
"@eslint-react/shared": "5.30.0-beta.5",
|
|
44
|
+
"@eslint-react/var": "5.30.0-beta.5",
|
|
45
|
+
"@typescript-eslint/scope-manager": "^8.72.1",
|
|
46
|
+
"@typescript-eslint/types": "^8.72.1",
|
|
47
|
+
"@typescript-eslint/utils": "^8.72.1",
|
|
48
48
|
"compare-versions": "^6.1.1",
|
|
49
49
|
"string-ts": "^2.3.1",
|
|
50
50
|
"ts-api-utils": "^2.5.0",
|