eslint-plugin-react-x 5.26.8 → 5.27.1
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 +28 -35
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -135,7 +135,7 @@ const rules$6 = {
|
|
|
135
135
|
//#endregion
|
|
136
136
|
//#region package.json
|
|
137
137
|
var name$6 = "eslint-plugin-react-x";
|
|
138
|
-
var version = "5.
|
|
138
|
+
var version = "5.27.1";
|
|
139
139
|
//#endregion
|
|
140
140
|
//#region src/utils/create-rule.ts
|
|
141
141
|
function getDocsUrl(ruleName) {
|
|
@@ -1547,9 +1547,10 @@ function inferMutableFunctions(context, mutations) {
|
|
|
1547
1547
|
const origin = mutation.kind === "binding" ? variable : resolveVariableOrigin(context, variable);
|
|
1548
1548
|
if (isGlobalOrModuleVariable(origin)) continue;
|
|
1549
1549
|
const declaration = origin.identifiers.at(0) ?? null;
|
|
1550
|
+
const declarationFn = declaration == null ? null : Traverse.findParent(declaration, Check.isFunction);
|
|
1550
1551
|
let current = mutation.enclosingFunction;
|
|
1551
1552
|
while (current != null) {
|
|
1552
|
-
if (
|
|
1553
|
+
if (declarationFn === current) break;
|
|
1553
1554
|
if (!mutableFunctions.has(current)) mutableFunctions.set(current, {
|
|
1554
1555
|
name: origin.name,
|
|
1555
1556
|
node: mutation.node
|
|
@@ -2005,7 +2006,7 @@ cast(absurd);
|
|
|
2005
2006
|
function not(predicate) {
|
|
2006
2007
|
return (data) => !predicate(data);
|
|
2007
2008
|
}
|
|
2008
|
-
dual(2, (a, b) => (data) => a(data) && b(data));
|
|
2009
|
+
const and = dual(2, (a, b) => (data) => a(data) && b(data));
|
|
2009
2010
|
const or = dual(2, (a, b) => (data) => a(data) || b(data));
|
|
2010
2011
|
dual(2, (a, b) => (data) => a(data) !== b(data));
|
|
2011
2012
|
dual(2, (a, b) => (data) => a(data) === b(data));
|
|
@@ -2322,10 +2323,11 @@ function create$32(context) {
|
|
|
2322
2323
|
if (callee.type !== AST_NODE_TYPES.MemberExpression) return false;
|
|
2323
2324
|
return Check.isIdentifier(callee.property, "map");
|
|
2324
2325
|
});
|
|
2326
|
+
if (call == null) return;
|
|
2325
2327
|
const iter = Traverse.findParent(jsxElement, Check.isFunction, (n) => n === call);
|
|
2326
|
-
if (
|
|
2327
|
-
const arg0 = call
|
|
2328
|
-
if (
|
|
2328
|
+
if (iter == null) return;
|
|
2329
|
+
const arg0 = call.arguments[0];
|
|
2330
|
+
if (arg0 == null) return;
|
|
2329
2331
|
if (Extract.unwrap(arg0) !== iter) return;
|
|
2330
2332
|
keyedEntries.set(call, {
|
|
2331
2333
|
hasDuplicate: node.value?.type === AST_NODE_TYPES.Literal,
|
|
@@ -3023,12 +3025,12 @@ function create$20(context) {
|
|
|
3023
3025
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
3024
3026
|
return { CallExpression(node) {
|
|
3025
3027
|
if (!core.isThisSetStateCall(node)) return;
|
|
3026
|
-
const
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
const
|
|
3031
|
-
if (
|
|
3028
|
+
const component = Traverse.findParent(node, core.isClassComponent);
|
|
3029
|
+
if (component == null) return;
|
|
3030
|
+
const method = Traverse.findParent(node, core.isComponentDidMount, (n) => n === component);
|
|
3031
|
+
if (method == null) return;
|
|
3032
|
+
const lifecycleFunction = method.value == null ? null : Extract.unwrap(method.value);
|
|
3033
|
+
if (method.parent === component.body && lifecycleFunction != null && lifecycleFunction === Traverse.findParent(node, Check.isFunctionOrClass)) context.report({
|
|
3032
3034
|
messageId: "default",
|
|
3033
3035
|
node
|
|
3034
3036
|
});
|
|
@@ -3048,12 +3050,12 @@ function create$19(context) {
|
|
|
3048
3050
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
3049
3051
|
return { CallExpression(node) {
|
|
3050
3052
|
if (!core.isThisSetStateCall(node)) return;
|
|
3051
|
-
const
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
const
|
|
3056
|
-
if (
|
|
3053
|
+
const component = Traverse.findParent(node, core.isClassComponent);
|
|
3054
|
+
if (component == null) return;
|
|
3055
|
+
const method = Traverse.findParent(node, core.isComponentDidUpdate, (n) => n === component);
|
|
3056
|
+
if (method == null) return;
|
|
3057
|
+
const lifecycleFunction = method.value == null ? null : Extract.unwrap(method.value);
|
|
3058
|
+
if (method.parent === component.body && lifecycleFunction != null && lifecycleFunction === Traverse.findParent(node, Check.isFunctionOrClass)) context.report({
|
|
3057
3059
|
messageId: "default",
|
|
3058
3060
|
node
|
|
3059
3061
|
});
|
|
@@ -3073,12 +3075,12 @@ function create$18(context) {
|
|
|
3073
3075
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
3074
3076
|
return { CallExpression(node) {
|
|
3075
3077
|
if (!core.isThisSetStateCall(node)) return;
|
|
3076
|
-
const
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
const
|
|
3081
|
-
if (
|
|
3078
|
+
const component = Traverse.findParent(node, core.isClassComponent);
|
|
3079
|
+
if (component == null) return;
|
|
3080
|
+
const method = Traverse.findParent(node, core.isComponentWillUpdate, (n) => n === component);
|
|
3081
|
+
if (method == null) return;
|
|
3082
|
+
const lifecycleFunction = method.value == null ? null : Extract.unwrap(method.value);
|
|
3083
|
+
if (method.parent === component.body && lifecycleFunction != null && lifecycleFunction === Traverse.findParent(node, Check.isFunctionOrClass)) context.report({
|
|
3082
3084
|
messageId: "default",
|
|
3083
3085
|
node
|
|
3084
3086
|
});
|
|
@@ -6589,20 +6591,11 @@ function isInitializedFromRef(context, id, refParams, seen = /* @__PURE__ */ new
|
|
|
6589
6591
|
const writeExpr = reference.writeExpr == null ? null : Extract.unwrap(reference.writeExpr);
|
|
6590
6592
|
if (writeExpr == null) continue;
|
|
6591
6593
|
if (writeExpr.range[1] > id.range[0]) continue;
|
|
6592
|
-
|
|
6593
|
-
if (writeFn != null && !isSelfOrAncestorFunction(writeFn, id)) continue;
|
|
6594
|
+
if (Traverse.findParent(writeExpr, and(Check.isFunction, (n) => !Traverse.hasParent(id, (m) => m === n))) != null) continue;
|
|
6594
6595
|
if (isExpressionFromRef(context, writeExpr, refParams, seen)) return true;
|
|
6595
6596
|
}
|
|
6596
6597
|
return false;
|
|
6597
6598
|
}
|
|
6598
|
-
function isSelfOrAncestorFunction(fn, node) {
|
|
6599
|
-
let current = Traverse.findParent(node, Check.isFunction);
|
|
6600
|
-
while (current != null) {
|
|
6601
|
-
if (current === fn) return true;
|
|
6602
|
-
current = Traverse.findParent(current, Check.isFunction);
|
|
6603
|
-
}
|
|
6604
|
-
return false;
|
|
6605
|
-
}
|
|
6606
6599
|
function isExpressionFromRef(context, init, refParams, seen) {
|
|
6607
6600
|
const { additionalRefHooks } = getSettingsFromContext(context);
|
|
6608
6601
|
switch (true) {
|
|
@@ -7041,7 +7034,7 @@ const KNOWN_DYNAMIC_EXPRESSION_TYPES = /* @__PURE__ */ new Set([
|
|
|
7041
7034
|
]);
|
|
7042
7035
|
function createRenderBoundaryChecker(componentNodes) {
|
|
7043
7036
|
const components = new Set(componentNodes);
|
|
7044
|
-
return (node) => Traverse.hasParent(node, (n) =>
|
|
7037
|
+
return (node) => Traverse.hasParent(node, (n) => Check.isFunctionOrClass(n) && components.has(n));
|
|
7045
7038
|
}
|
|
7046
7039
|
//#endregion
|
|
7047
7040
|
//#region src/rules/static-components/origins.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.27.1",
|
|
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.
|
|
40
|
-
"@eslint-react/core": "5.
|
|
41
|
-
"@eslint-react/eslint": "5.
|
|
42
|
-
"@eslint-react/jsx": "5.
|
|
43
|
-
"@eslint-react/shared": "5.
|
|
44
|
-
"@eslint-react/var": "5.
|
|
39
|
+
"@eslint-react/ast": "5.27.1",
|
|
40
|
+
"@eslint-react/core": "5.27.1",
|
|
41
|
+
"@eslint-react/eslint": "5.27.1",
|
|
42
|
+
"@eslint-react/jsx": "5.27.1",
|
|
43
|
+
"@eslint-react/shared": "5.27.1",
|
|
44
|
+
"@eslint-react/var": "5.27.1",
|
|
45
45
|
"@typescript-eslint/scope-manager": "^8.71.2",
|
|
46
46
|
"@typescript-eslint/types": "^8.71.2",
|
|
47
47
|
"@typescript-eslint/typescript-estree": "^8.71.2",
|