eslint-plugin-react-x 5.30.0-beta.19 → 5.30.0-beta.20
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 +19 -23
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -129,7 +129,7 @@ const rules$6 = {
|
|
|
129
129
|
};
|
|
130
130
|
// package.json
|
|
131
131
|
var name$6 = "eslint-plugin-react-x";
|
|
132
|
-
var version = "5.30.0-beta.
|
|
132
|
+
var version = "5.30.0-beta.20";
|
|
133
133
|
// src/utils/create-rule.ts
|
|
134
134
|
function getDocsUrl(ruleName) {
|
|
135
135
|
return `https://eslint-react.xyz/docs/rules/${ruleName}`;
|
|
@@ -2710,24 +2710,13 @@ function create$25(context) {
|
|
|
2710
2710
|
}
|
|
2711
2711
|
};
|
|
2712
2712
|
}
|
|
2713
|
-
// src/
|
|
2714
|
-
const
|
|
2713
|
+
// src/rules/no-missing-key/no-missing-key.ts
|
|
2714
|
+
const RULE_NAME$24 = "no-missing-key";
|
|
2715
|
+
const ITERATOR_CALLBACK_POSITIONS = /* @__PURE__ */ new Map([
|
|
2715
2716
|
["flatMap", 0],
|
|
2716
2717
|
["from", 1],
|
|
2717
2718
|
["map", 0]
|
|
2718
2719
|
]);
|
|
2719
|
-
function getIteratorCallback(node) {
|
|
2720
|
-
const callee = Extract.unwrap(node.callee);
|
|
2721
|
-
if (callee.type !== AST_NODE_TYPES.MemberExpression) return null;
|
|
2722
|
-
if (!Check.isIdentifier(callee.property)) return null;
|
|
2723
|
-
const position = KNOWN_CALLBACK_POSITIONS.get(callee.property.name);
|
|
2724
|
-
if (position == null) return null;
|
|
2725
|
-
const argument = node.arguments[position];
|
|
2726
|
-
if (argument == null) return null;
|
|
2727
|
-
const callback = Extract.unwrap(argument);
|
|
2728
|
-
if (!Check.isFunction(callback)) return null;
|
|
2729
|
-
return callback;
|
|
2730
|
-
}
|
|
2731
2720
|
var no_missing_key_default = createRule({
|
|
2732
2721
|
meta: {
|
|
2733
2722
|
type: "problem",
|
|
@@ -2738,7 +2727,7 @@ var no_missing_key_default = createRule({
|
|
|
2738
2727
|
},
|
|
2739
2728
|
schema: []
|
|
2740
2729
|
},
|
|
2741
|
-
name:
|
|
2730
|
+
name: RULE_NAME$24,
|
|
2742
2731
|
create: create$24
|
|
2743
2732
|
});
|
|
2744
2733
|
function create$24(context) {
|
|
@@ -2779,13 +2768,20 @@ function create$24(context) {
|
|
|
2779
2768
|
}
|
|
2780
2769
|
},
|
|
2781
2770
|
CallExpression(node) {
|
|
2771
|
+
const call = node;
|
|
2782
2772
|
if (core.isChildrenToArrayCall(context, node)) {
|
|
2783
2773
|
childrenToArrayDepth += 1;
|
|
2784
2774
|
return;
|
|
2785
2775
|
}
|
|
2786
2776
|
if (childrenToArrayDepth > 0) return;
|
|
2787
|
-
const
|
|
2788
|
-
if (
|
|
2777
|
+
const callee = Extract.unwrap(call.callee);
|
|
2778
|
+
if (callee.type !== AST_NODE_TYPES.MemberExpression || !Check.isIdentifier(callee.property)) return;
|
|
2779
|
+
const position = ITERATOR_CALLBACK_POSITIONS.get(callee.property.name);
|
|
2780
|
+
if (position == null) return;
|
|
2781
|
+
const argument = call.arguments[position];
|
|
2782
|
+
if (argument == null) return;
|
|
2783
|
+
const callback = Extract.unwrap(argument);
|
|
2784
|
+
if (!Check.isFunction(callback)) return;
|
|
2789
2785
|
for (const desc of visitIteratorCallback(callback)) context.report(desc);
|
|
2790
2786
|
},
|
|
2791
2787
|
"CallExpression:exit"(node) {
|
|
@@ -6677,6 +6673,9 @@ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
|
|
|
6677
6673
|
if (survivingCandidates.length > 0) return survivingCandidates.some((c) => c.previous != null && isInitializedFromRef(c.previous, refParams, seen) || isRefValue(c.value, refParams, seen, "initializer"));
|
|
6678
6674
|
return variable.defs.some((d) => d.type === DefinitionType.Parameter && (refParams?.has(d.name) === true || d.name.type === AST_NODE_TYPES.Identifier && isRefLikeName(d.name.name)));
|
|
6679
6675
|
}
|
|
6676
|
+
function isInitializedFromParameter(id) {
|
|
6677
|
+
return findVariable(context.sourceCode.getScope(id), id)?.defs.some((d) => d.type === DefinitionType.Parameter) ?? false;
|
|
6678
|
+
}
|
|
6680
6679
|
function isRefValue(node, refParams, seen, mode) {
|
|
6681
6680
|
const expression = Extract.unwrap(node);
|
|
6682
6681
|
if (isUseRefCall(expression)) return true;
|
|
@@ -6685,7 +6684,7 @@ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
|
|
|
6685
6684
|
case AST_NODE_TYPES.MemberExpression: {
|
|
6686
6685
|
const property = Extract.unwrap(expression.property);
|
|
6687
6686
|
const object = Extract.unwrap(expression.object);
|
|
6688
|
-
if (!expression.computed && Check.isIdentifier(property, "current") && object.type === AST_NODE_TYPES.Identifier &&
|
|
6687
|
+
if (!expression.computed && Check.isIdentifier(property, "current") && object.type === AST_NODE_TYPES.Identifier && isInitializedFromParameter(object)) return true;
|
|
6689
6688
|
if (mode === "initializer") {
|
|
6690
6689
|
let current = expression;
|
|
6691
6690
|
while (current.type === AST_NODE_TYPES.MemberExpression) {
|
|
@@ -6694,7 +6693,7 @@ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
|
|
|
6694
6693
|
if (!current.computed && Check.isIdentifier(currentProperty, "current")) {
|
|
6695
6694
|
const sourceName = getRefSourceName(currentObject);
|
|
6696
6695
|
if (sourceName != null && isRefLikeName(sourceName)) return true;
|
|
6697
|
-
if (currentObject.type === AST_NODE_TYPES.Identifier &&
|
|
6696
|
+
if (currentObject.type === AST_NODE_TYPES.Identifier && isInitializedFromParameter(currentObject)) return true;
|
|
6698
6697
|
}
|
|
6699
6698
|
current = currentObject;
|
|
6700
6699
|
}
|
|
@@ -6795,9 +6794,6 @@ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
|
|
|
6795
6794
|
}
|
|
6796
6795
|
return false;
|
|
6797
6796
|
}
|
|
6798
|
-
function isParameterId(id) {
|
|
6799
|
-
return findVariable(context.sourceCode.getScope(id), id)?.defs.some((d) => d.type === DefinitionType.Parameter) ?? false;
|
|
6800
|
-
}
|
|
6801
6797
|
return {
|
|
6802
6798
|
getRefDerivedParams,
|
|
6803
6799
|
getSetterName,
|
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.20",
|
|
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,12 +36,12 @@
|
|
|
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.
|
|
39
|
+
"@eslint-react/ast": "5.30.0-beta.20",
|
|
40
|
+
"@eslint-react/core": "5.30.0-beta.20",
|
|
41
|
+
"@eslint-react/eslint": "5.30.0-beta.20",
|
|
42
|
+
"@eslint-react/jsx": "5.30.0-beta.20",
|
|
43
|
+
"@eslint-react/shared": "5.30.0-beta.20",
|
|
44
|
+
"@eslint-react/var": "5.30.0-beta.20",
|
|
45
45
|
"@typescript-eslint/scope-manager": "^8.72.1",
|
|
46
46
|
"@typescript-eslint/types": "^8.72.1",
|
|
47
47
|
"@typescript-eslint/utils": "^8.72.1",
|