eslint-plugin-react-x 3.0.0-next.12 → 3.0.0-next.13
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 +9 -9
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ESLintUtils } from "@typescript-eslint/utils";
|
|
|
5
5
|
import { P, isMatching, match } from "ts-pattern";
|
|
6
6
|
import ts from "typescript";
|
|
7
7
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
8
|
-
import { findEnclosingAssignmentTarget, findVariable, getChildScopes, getObjectType,
|
|
8
|
+
import { findEnclosingAssignmentTarget, findVariable, getChildScopes, getObjectType, getVariableInitializer, isAssignmentTargetEqual } from "@eslint-react/var";
|
|
9
9
|
import { DefinitionType } from "@typescript-eslint/scope-manager";
|
|
10
10
|
import { constFalse, constTrue, constVoid, flow, getOrElseUpdate, identity, not, unit } from "@eslint-react/eff";
|
|
11
11
|
import { compare } from "compare-versions";
|
|
@@ -68,7 +68,7 @@ const rules$7 = {
|
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region package.json
|
|
70
70
|
var name$6 = "eslint-plugin-react-x";
|
|
71
|
-
var version = "3.0.0-next.
|
|
71
|
+
var version = "3.0.0-next.13";
|
|
72
72
|
|
|
73
73
|
//#endregion
|
|
74
74
|
//#region src/utils/create-rule.ts
|
|
@@ -2499,7 +2499,7 @@ function create$23(context) {
|
|
|
2499
2499
|
const [arg0, arg1] = init.arguments;
|
|
2500
2500
|
if (arg0 == null || arg1 == null) return;
|
|
2501
2501
|
if (!match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
2502
|
-
const variableNode =
|
|
2502
|
+
const variableNode = getVariableInitializer(findVariable(n.name, scope), 0);
|
|
2503
2503
|
if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
|
|
2504
2504
|
return variableNode.elements.length === 0;
|
|
2505
2505
|
}).otherwise(() => false)) {
|
|
@@ -2510,7 +2510,7 @@ function create$23(context) {
|
|
|
2510
2510
|
if (n.body.type === AST_NODE_TYPES.ArrowFunctionExpression) return n.body;
|
|
2511
2511
|
return n;
|
|
2512
2512
|
}).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
2513
|
-
const variableNode =
|
|
2513
|
+
const variableNode = getVariableInitializer(findVariable(n.name, scope), 0);
|
|
2514
2514
|
if (variableNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
|
|
2515
2515
|
return variableNode;
|
|
2516
2516
|
}).otherwise(() => null);
|
|
@@ -2580,7 +2580,7 @@ function create$22(context) {
|
|
|
2580
2580
|
return;
|
|
2581
2581
|
}
|
|
2582
2582
|
if (!match(arg1).with({ type: AST_NODE_TYPES.ArrayExpression }, (n) => n.elements.length === 0).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
2583
|
-
const variableNode =
|
|
2583
|
+
const variableNode = getVariableInitializer(findVariable(n.name, scope), 0);
|
|
2584
2584
|
if (variableNode?.type !== AST_NODE_TYPES.ArrayExpression) return false;
|
|
2585
2585
|
return variableNode.elements.length === 0;
|
|
2586
2586
|
}).otherwise(() => false)) {
|
|
@@ -2591,7 +2591,7 @@ function create$22(context) {
|
|
|
2591
2591
|
if (n.body.type === AST_NODE_TYPES.ArrowFunctionExpression) return n.body;
|
|
2592
2592
|
return n;
|
|
2593
2593
|
}).with({ type: AST_NODE_TYPES.FunctionExpression }, identity).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
|
|
2594
|
-
const variableNode =
|
|
2594
|
+
const variableNode = getVariableInitializer(findVariable(n.name, scope), 0);
|
|
2595
2595
|
if (variableNode?.type !== AST_NODE_TYPES.ArrowFunctionExpression && variableNode?.type !== AST_NODE_TYPES.FunctionExpression) return null;
|
|
2596
2596
|
return variableNode;
|
|
2597
2597
|
}).otherwise(() => null);
|
|
@@ -4180,7 +4180,7 @@ function create$2(context) {
|
|
|
4180
4180
|
}
|
|
4181
4181
|
}
|
|
4182
4182
|
function isIdFromUseStateCall(topLevelId, at) {
|
|
4183
|
-
const variableNode =
|
|
4183
|
+
const variableNode = getVariableInitializer(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
|
|
4184
4184
|
if (variableNode == null) return false;
|
|
4185
4185
|
if (variableNode.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
4186
4186
|
if (!isUseStateCall(variableNode)) return false;
|
|
@@ -4276,7 +4276,7 @@ function create$2(context) {
|
|
|
4276
4276
|
},
|
|
4277
4277
|
"Program:exit"() {
|
|
4278
4278
|
const getSetStateCalls = (id, initialScope) => {
|
|
4279
|
-
const node =
|
|
4279
|
+
const node = getVariableInitializer(findVariable(id, initialScope), 0);
|
|
4280
4280
|
switch (node?.type) {
|
|
4281
4281
|
case AST_NODE_TYPES.ArrowFunctionExpression:
|
|
4282
4282
|
case AST_NODE_TYPES.FunctionDeclaration:
|
|
@@ -4348,7 +4348,7 @@ function create$1(context) {
|
|
|
4348
4348
|
return core.isUseStateLikeCall(node, additionalStateHooks);
|
|
4349
4349
|
}
|
|
4350
4350
|
function isIdFromUseStateCall(topLevelId, at) {
|
|
4351
|
-
const variableNode =
|
|
4351
|
+
const variableNode = getVariableInitializer(findVariable(topLevelId, context.sourceCode.getScope(topLevelId)), 0);
|
|
4352
4352
|
if (variableNode == null) return false;
|
|
4353
4353
|
if (variableNode.type !== AST_NODE_TYPES.CallExpression) return false;
|
|
4354
4354
|
if (!isUseStateCall(variableNode)) return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.13",
|
|
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",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"is-immutable-type": "^5.0.1",
|
|
46
46
|
"ts-api-utils": "^2.4.0",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/eff": "3.0.0-next.
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
52
|
-
"@eslint-react/
|
|
48
|
+
"@eslint-react/ast": "3.0.0-next.13",
|
|
49
|
+
"@eslint-react/eff": "3.0.0-next.13",
|
|
50
|
+
"@eslint-react/shared": "3.0.0-next.13",
|
|
51
|
+
"@eslint-react/var": "3.0.0-next.13",
|
|
52
|
+
"@eslint-react/core": "3.0.0-next.13"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/react": "^19.2.14",
|