eslint-plugin-react-x 5.6.7-beta.0 → 5.7.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 +40 -4
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -120,6 +120,7 @@ const rules$7 = {
|
|
|
120
120
|
"react-x/no-implicit-ref": "off",
|
|
121
121
|
"react-x/no-misused-capture-owner-stack": "off",
|
|
122
122
|
"react-x/no-unused-props": "off",
|
|
123
|
+
"react-x/no-unused-state": "off",
|
|
123
124
|
"react-x/refs": "off",
|
|
124
125
|
"react-x/set-state-in-render": "off"
|
|
125
126
|
};
|
|
@@ -142,7 +143,7 @@ const rules$6 = {
|
|
|
142
143
|
//#endregion
|
|
143
144
|
//#region package.json
|
|
144
145
|
var name$6 = "eslint-plugin-react-x";
|
|
145
|
-
var version = "5.
|
|
146
|
+
var version = "5.7.0";
|
|
146
147
|
|
|
147
148
|
//#endregion
|
|
148
149
|
//#region src/utils/create-rule.ts
|
|
@@ -3688,15 +3689,49 @@ var no_unused_state_default = createRule({
|
|
|
3688
3689
|
meta: {
|
|
3689
3690
|
type: "problem",
|
|
3690
3691
|
docs: { description: "Warns about state variables that are defined but never used, or only used in effects." },
|
|
3691
|
-
messages: { default: "State variable '{{name}}' is
|
|
3692
|
+
messages: { default: "State variable '{{name}}' is defined but never used, or only used in effects." },
|
|
3692
3693
|
schema: []
|
|
3693
3694
|
},
|
|
3694
3695
|
name: RULE_NAME$9,
|
|
3695
3696
|
create: create$9,
|
|
3696
3697
|
defaultOptions: []
|
|
3697
3698
|
});
|
|
3698
|
-
function create$9(
|
|
3699
|
-
|
|
3699
|
+
function create$9(context) {
|
|
3700
|
+
const { additionalEffectHooks, additionalStateHooks } = getSettingsFromContext(context);
|
|
3701
|
+
const stateEntries = [];
|
|
3702
|
+
return {
|
|
3703
|
+
CallExpression(node) {
|
|
3704
|
+
if (!core.isUseStateLikeCall(node, additionalStateHooks)) return;
|
|
3705
|
+
const { parent } = node;
|
|
3706
|
+
if (parent?.type !== AST_NODE_TYPES.VariableDeclarator || parent.id.type !== AST_NODE_TYPES.ArrayPattern) return;
|
|
3707
|
+
const [stateEl] = parent.id.elements;
|
|
3708
|
+
if (stateEl?.type !== AST_NODE_TYPES.Identifier) return;
|
|
3709
|
+
stateEntries.push({
|
|
3710
|
+
name: stateEl.name,
|
|
3711
|
+
node: stateEl
|
|
3712
|
+
});
|
|
3713
|
+
},
|
|
3714
|
+
"Program:exit"() {
|
|
3715
|
+
for (const { name, node } of stateEntries) {
|
|
3716
|
+
const variable = findVariable(context.sourceCode.getScope(node), name);
|
|
3717
|
+
if (variable == null) continue;
|
|
3718
|
+
let hasNonEffectRead = false;
|
|
3719
|
+
for (const ref of variable.references) {
|
|
3720
|
+
if (ref.isWrite()) continue;
|
|
3721
|
+
if (ref.identifier === node) continue;
|
|
3722
|
+
if (Traverse.findParent(ref.identifier, (n) => core.isUseEffectLikeCall(n, additionalEffectHooks)) == null) {
|
|
3723
|
+
hasNonEffectRead = true;
|
|
3724
|
+
break;
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
if (!hasNonEffectRead) context.report({
|
|
3728
|
+
data: { name },
|
|
3729
|
+
messageId: "default",
|
|
3730
|
+
node
|
|
3731
|
+
});
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
};
|
|
3700
3735
|
}
|
|
3701
3736
|
|
|
3702
3737
|
//#endregion
|
|
@@ -7694,6 +7729,7 @@ const rules$5 = {
|
|
|
7694
7729
|
"react-x/no-unsafe-component-will-receive-props": "warn",
|
|
7695
7730
|
"react-x/no-unsafe-component-will-update": "warn",
|
|
7696
7731
|
"react-x/no-unused-class-component-members": "warn",
|
|
7732
|
+
"react-x/no-unused-state": "warn",
|
|
7697
7733
|
"react-x/no-use-context": "warn",
|
|
7698
7734
|
"react-x/purity": "warn",
|
|
7699
7735
|
"react-x/rules-of-hooks": "error",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.0",
|
|
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,26 +45,26 @@
|
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-api-utils": "^2.5.0",
|
|
47
47
|
"ts-pattern": "^5.9.0",
|
|
48
|
-
"@eslint-react/ast": "5.
|
|
49
|
-
"@eslint-react/core": "5.
|
|
50
|
-
"@eslint-react/eslint": "5.
|
|
51
|
-
"@eslint-react/jsx": "5.
|
|
52
|
-
"@eslint-react/shared": "5.
|
|
53
|
-
"@eslint-react/var": "5.
|
|
48
|
+
"@eslint-react/ast": "5.7.0",
|
|
49
|
+
"@eslint-react/core": "5.7.0",
|
|
50
|
+
"@eslint-react/eslint": "5.7.0",
|
|
51
|
+
"@eslint-react/jsx": "5.7.0",
|
|
52
|
+
"@eslint-react/shared": "5.7.0",
|
|
53
|
+
"@eslint-react/var": "5.7.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/react": "^19.2.14",
|
|
57
57
|
"@types/react-dom": "^19.2.3",
|
|
58
58
|
"dedent": "^1.7.2",
|
|
59
|
-
"eslint": "^10.
|
|
59
|
+
"eslint": "^10.3.0",
|
|
60
60
|
"react": "^19.2.5",
|
|
61
61
|
"react-dom": "^19.2.5",
|
|
62
62
|
"tsdown": "^0.21.10",
|
|
63
63
|
"tsl": "^1.0.30",
|
|
64
64
|
"tsl-dx": "^0.12.1",
|
|
65
65
|
"typescript": "^6.0.3",
|
|
66
|
-
"@local/
|
|
67
|
-
"@local/
|
|
66
|
+
"@local/eff": "3.0.0-beta.72",
|
|
67
|
+
"@local/configs": "0.0.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"eslint": "^10.2.1",
|