eslint-plugin-react-x 5.30.0-rc.1 → 5.30.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 +173 -61
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -16,14 +16,14 @@ import "typescript";
|
|
|
16
16
|
import { delimiterCase, snakeCase, toLowerCase } from "string-ts";
|
|
17
17
|
// \0rolldown/runtime.js
|
|
18
18
|
var __defProp = Object.defineProperty;
|
|
19
|
-
var __exportAll = (all,
|
|
20
|
-
let target = {};
|
|
19
|
+
var __exportAll = (all, flags) => {
|
|
20
|
+
let target = Object.setPrototypeOf({}, null);
|
|
21
21
|
for (var name in all) __defProp(target, name, {
|
|
22
22
|
get: all[name],
|
|
23
23
|
enumerable: true
|
|
24
24
|
});
|
|
25
|
-
if (!
|
|
26
|
-
return target;
|
|
25
|
+
if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
26
|
+
return flags & 2 ? target : Object.preventExtensions(target);
|
|
27
27
|
};
|
|
28
28
|
// src/configs/disable-conflict-eslint-plugin-react.ts
|
|
29
29
|
var disable_conflict_eslint_plugin_react_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -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
|
|
133
|
+
var version = "5.30.0";
|
|
134
134
|
// src/utils/create-rule.ts
|
|
135
135
|
function getDocsUrl(ruleName) {
|
|
136
136
|
return `https://eslint-react.xyz/docs/rules/${ruleName}`;
|
|
@@ -1290,7 +1290,8 @@ const KNOWN_MUTATING_HOOKS = /* @__PURE__ */ new Set([
|
|
|
1290
1290
|
"useHistory",
|
|
1291
1291
|
"useNavigate",
|
|
1292
1292
|
"useNavigation",
|
|
1293
|
-
"useRouter"
|
|
1293
|
+
"useRouter",
|
|
1294
|
+
"useWorld"
|
|
1294
1295
|
]);
|
|
1295
1296
|
function isNodeWithin(node, ancestor) {
|
|
1296
1297
|
let current = node;
|
|
@@ -2362,6 +2363,16 @@ function isKeyValueEqual(a, b) {
|
|
|
2362
2363
|
if (aValue == null || bValue == null) return false;
|
|
2363
2364
|
return Compare.isEqual(aValue, bValue);
|
|
2364
2365
|
}
|
|
2366
|
+
function isRepeatingStaticKey(key) {
|
|
2367
|
+
const { value } = key;
|
|
2368
|
+
if (value == null) return true;
|
|
2369
|
+
if (value.type === AST_NODE_TYPES.Literal) return true;
|
|
2370
|
+
if (value.type !== AST_NODE_TYPES.JSXExpressionContainer) return false;
|
|
2371
|
+
const expr = Extract.unwrap(value.expression);
|
|
2372
|
+
if (expr.type === AST_NODE_TYPES.Literal) return expr.value != null;
|
|
2373
|
+
if (expr.type === AST_NODE_TYPES.TemplateLiteral) return expr.expressions.length === 0;
|
|
2374
|
+
return false;
|
|
2375
|
+
}
|
|
2365
2376
|
var no_duplicate_key_default = createRule({
|
|
2366
2377
|
meta: {
|
|
2367
2378
|
type: "problem",
|
|
@@ -2398,7 +2409,7 @@ function create$32(context) {
|
|
|
2398
2409
|
}
|
|
2399
2410
|
function recordMapCallbackKey(call, key) {
|
|
2400
2411
|
getGroup(call).keys.push({
|
|
2401
|
-
duplicate: key
|
|
2412
|
+
duplicate: isRepeatingStaticKey(key),
|
|
2402
2413
|
node: key
|
|
2403
2414
|
});
|
|
2404
2415
|
}
|
|
@@ -6462,15 +6473,14 @@ function last(array) {
|
|
|
6462
6473
|
return array[array.length - 1];
|
|
6463
6474
|
}
|
|
6464
6475
|
// src/rules/set-state-in-effect/collect.ts
|
|
6465
|
-
function createFactCollector$3(
|
|
6476
|
+
function createFactCollector$3(additionalHooks) {
|
|
6477
|
+
const [stateHooks, effectHooks] = additionalHooks;
|
|
6466
6478
|
const facts = {
|
|
6467
6479
|
calls: [],
|
|
6468
6480
|
effectRoots: [],
|
|
6469
6481
|
jsxRefExprs: []
|
|
6470
6482
|
};
|
|
6471
6483
|
const functionEntries = [];
|
|
6472
|
-
const isUseStateCall = (node) => node.type === AST_NODE_TYPES.CallExpression && core.isUseStateLikeCall(node, additionalStateHooks);
|
|
6473
|
-
const isUseEffectCall = (node) => node.type === AST_NODE_TYPES.CallExpression && core.isUseEffectLikeCall(node, additionalEffectHooks);
|
|
6474
6484
|
return {
|
|
6475
6485
|
facts,
|
|
6476
6486
|
visitor: {
|
|
@@ -6486,8 +6496,8 @@ function createFactCollector$3(additionalStateHooks, additionalEffectHooks) {
|
|
|
6486
6496
|
facts.jsxRefExprs.push(node.value.expression);
|
|
6487
6497
|
},
|
|
6488
6498
|
CallExpression(node) {
|
|
6489
|
-
if (
|
|
6490
|
-
if (
|
|
6499
|
+
if (core.isUseStateLikeCall(node, stateHooks)) return;
|
|
6500
|
+
if (core.isUseEffectLikeCall(node, effectHooks)) {
|
|
6491
6501
|
const setup = node.arguments.at(0);
|
|
6492
6502
|
if (setup != null) facts.effectRoots.push({
|
|
6493
6503
|
node,
|
|
@@ -6893,7 +6903,7 @@ function createSetStateResolver$1(context, facts = EMPTY_FACTS) {
|
|
|
6893
6903
|
};
|
|
6894
6904
|
}
|
|
6895
6905
|
// src/rules/set-state-in-effect/effects.ts
|
|
6896
|
-
function inferViolations$
|
|
6906
|
+
function inferViolations$3(context, facts) {
|
|
6897
6907
|
if (facts.effectRoots.length === 0) return [];
|
|
6898
6908
|
const resolver = createSetStateResolver$1(context, facts);
|
|
6899
6909
|
const callsByFunction = /* @__PURE__ */ new Map();
|
|
@@ -6970,41 +6980,17 @@ var set_state_in_effect_default = createRule({
|
|
|
6970
6980
|
function create$5(context) {
|
|
6971
6981
|
if (!/use\w*Effect/u.test(context.sourceCode.text)) return {};
|
|
6972
6982
|
const { additionalEffectHooks, additionalStateHooks } = getSettingsFromContext(context);
|
|
6973
|
-
const { facts, visitor } = createFactCollector$3(additionalStateHooks, additionalEffectHooks);
|
|
6983
|
+
const { facts, visitor } = createFactCollector$3([additionalStateHooks, additionalEffectHooks]);
|
|
6974
6984
|
return merge(visitor, { "Program:exit"() {
|
|
6975
|
-
for (const violation of inferViolations$
|
|
6985
|
+
for (const violation of inferViolations$3(context, facts)) context.report({
|
|
6976
6986
|
data: { name: violation.name },
|
|
6977
6987
|
messageId: "default",
|
|
6978
6988
|
node: violation.node
|
|
6979
6989
|
});
|
|
6980
6990
|
} });
|
|
6981
6991
|
}
|
|
6982
|
-
// src/rules/set-state-in-render/helpers.ts
|
|
6983
|
-
const isComponentOrHookName = or(core.isFunctionComponentName, core.isHookName);
|
|
6984
|
-
function isComponentOrHookLikeFunction(context, node) {
|
|
6985
|
-
const id = core.getFunctionId(node);
|
|
6986
|
-
if (id == null) return core.isFunctionComponentWrapperCallback(context, node);
|
|
6987
|
-
if (Check.isIdentifier(id)) return isComponentOrHookName(id.name);
|
|
6988
|
-
if (id.type === AST_NODE_TYPES.MemberExpression && Check.isIdentifier(id.property)) return isComponentOrHookName(id.property.name);
|
|
6989
|
-
return false;
|
|
6990
|
-
}
|
|
6991
|
-
function isInsideConditional(node, stopAt) {
|
|
6992
|
-
let current = node.parent;
|
|
6993
|
-
while (current != null && current !== stopAt) {
|
|
6994
|
-
switch (current.type) {
|
|
6995
|
-
case AST_NODE_TYPES.IfStatement:
|
|
6996
|
-
case AST_NODE_TYPES.ConditionalExpression:
|
|
6997
|
-
case AST_NODE_TYPES.LogicalExpression:
|
|
6998
|
-
case AST_NODE_TYPES.SwitchStatement:
|
|
6999
|
-
case AST_NODE_TYPES.SwitchCase: return true;
|
|
7000
|
-
}
|
|
7001
|
-
current = current.parent;
|
|
7002
|
-
}
|
|
7003
|
-
return false;
|
|
7004
|
-
}
|
|
7005
6992
|
// src/rules/set-state-in-render/collect.ts
|
|
7006
|
-
function createFactCollector$2(
|
|
7007
|
-
const { additionalStateHooks } = getSettingsFromContext(context);
|
|
6993
|
+
function createFactCollector$2(additionalStateHooks, isComponentOrHookLike) {
|
|
7008
6994
|
const facts = {
|
|
7009
6995
|
calls: [],
|
|
7010
6996
|
earlyReturns: []
|
|
@@ -7015,7 +7001,7 @@ function createFactCollector$2(context) {
|
|
|
7015
7001
|
return node.type === AST_NODE_TYPES.CallExpression && core.isUseStateLikeCall(node, additionalStateHooks);
|
|
7016
7002
|
}
|
|
7017
7003
|
function getFunctionKind(node) {
|
|
7018
|
-
if (
|
|
7004
|
+
if (isComponentOrHookLike(node)) return "component";
|
|
7019
7005
|
const parent = Traverse.findParent(node, not(Check.isTypeExpression)) ?? node.parent;
|
|
7020
7006
|
if (parent.type === AST_NODE_TYPES.CallExpression && parent.callee !== node) return "callback";
|
|
7021
7007
|
return "other";
|
|
@@ -7068,6 +7054,29 @@ function createFactCollector$2(context) {
|
|
|
7068
7054
|
}
|
|
7069
7055
|
};
|
|
7070
7056
|
}
|
|
7057
|
+
// src/rules/set-state-in-render/helpers.ts
|
|
7058
|
+
const isComponentOrHookName = or(core.isFunctionComponentName, core.isHookName);
|
|
7059
|
+
function isComponentOrHookLikeFunction(context, node) {
|
|
7060
|
+
const id = core.getFunctionId(node);
|
|
7061
|
+
if (id == null) return core.isFunctionComponentWrapperCallback(context, node);
|
|
7062
|
+
if (Check.isIdentifier(id)) return isComponentOrHookName(id.name);
|
|
7063
|
+
if (id.type === AST_NODE_TYPES.MemberExpression && Check.isIdentifier(id.property)) return isComponentOrHookName(id.property.name);
|
|
7064
|
+
return false;
|
|
7065
|
+
}
|
|
7066
|
+
function isInsideConditional(node, stopAt) {
|
|
7067
|
+
let current = node.parent;
|
|
7068
|
+
while (current != null && current !== stopAt) {
|
|
7069
|
+
switch (current.type) {
|
|
7070
|
+
case AST_NODE_TYPES.IfStatement:
|
|
7071
|
+
case AST_NODE_TYPES.ConditionalExpression:
|
|
7072
|
+
case AST_NODE_TYPES.LogicalExpression:
|
|
7073
|
+
case AST_NODE_TYPES.SwitchStatement:
|
|
7074
|
+
case AST_NODE_TYPES.SwitchCase: return true;
|
|
7075
|
+
}
|
|
7076
|
+
current = current.parent;
|
|
7077
|
+
}
|
|
7078
|
+
return false;
|
|
7079
|
+
}
|
|
7071
7080
|
// src/rules/set-state-in-render/origins.ts
|
|
7072
7081
|
function createSetStateResolver(context) {
|
|
7073
7082
|
const { additionalStateHooks } = getSettingsFromContext(context);
|
|
@@ -7092,7 +7101,7 @@ function createSetStateResolver(context) {
|
|
|
7092
7101
|
};
|
|
7093
7102
|
}
|
|
7094
7103
|
// src/rules/set-state-in-render/effects.ts
|
|
7095
|
-
function inferViolations$
|
|
7104
|
+
function inferViolations$2(context, facts) {
|
|
7096
7105
|
const resolver = createSetStateResolver(context);
|
|
7097
7106
|
const earlyReturnPositions = /* @__PURE__ */ new Map();
|
|
7098
7107
|
for (const { componentFunction, node } of facts.earlyReturns) getOrInsertComputed(earlyReturnPositions, componentFunction, () => []).push(node.range[0]);
|
|
@@ -7121,9 +7130,10 @@ var set_state_in_render_default = createRule({
|
|
|
7121
7130
|
create: create$4
|
|
7122
7131
|
});
|
|
7123
7132
|
function create$4(context) {
|
|
7124
|
-
const {
|
|
7133
|
+
const { additionalStateHooks } = getSettingsFromContext(context);
|
|
7134
|
+
const { facts, visitor } = createFactCollector$2(additionalStateHooks, (node) => isComponentOrHookLikeFunction(context, node));
|
|
7125
7135
|
return merge(visitor, { "Program:exit"() {
|
|
7126
|
-
for (const violation of inferViolations$
|
|
7136
|
+
for (const violation of inferViolations$2(context, facts)) context.report({
|
|
7127
7137
|
data: { name: violation.name },
|
|
7128
7138
|
messageId: "default",
|
|
7129
7139
|
node: violation.node
|
|
@@ -7136,12 +7146,28 @@ function createFactCollector$1() {
|
|
|
7136
7146
|
return {
|
|
7137
7147
|
facts,
|
|
7138
7148
|
visitor: { JSXOpeningElement(node) {
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
if (
|
|
7149
|
+
const tag = node.name;
|
|
7150
|
+
if (tag.type === AST_NODE_TYPES.JSXNamespacedName) return;
|
|
7151
|
+
if (tag.type === AST_NODE_TYPES.JSXIdentifier) {
|
|
7152
|
+
if (!core.isFunctionComponentName(tag.name)) return;
|
|
7153
|
+
facts.componentUsages.push({
|
|
7154
|
+
name: tag.name,
|
|
7155
|
+
path: [],
|
|
7156
|
+
node: tag
|
|
7157
|
+
});
|
|
7158
|
+
return;
|
|
7159
|
+
}
|
|
7160
|
+
const path = [];
|
|
7161
|
+
let root = tag;
|
|
7162
|
+
while (root.type === AST_NODE_TYPES.JSXMemberExpression) {
|
|
7163
|
+
path.unshift(root.property.name);
|
|
7164
|
+
root = root.object;
|
|
7165
|
+
}
|
|
7166
|
+
if (root.type !== AST_NODE_TYPES.JSXIdentifier) return;
|
|
7142
7167
|
facts.componentUsages.push({
|
|
7143
|
-
name,
|
|
7144
|
-
|
|
7168
|
+
name: root.name,
|
|
7169
|
+
path,
|
|
7170
|
+
node: tag
|
|
7145
7171
|
});
|
|
7146
7172
|
} }
|
|
7147
7173
|
};
|
|
@@ -7168,6 +7194,42 @@ function getMemoizedValueExpressions(context, call) {
|
|
|
7168
7194
|
if (!Check.isFunction(callback) || callback.async || callback.generator) return null;
|
|
7169
7195
|
return Collect.getReturnExpressions(callback);
|
|
7170
7196
|
}
|
|
7197
|
+
function resolveValueAtPath(context, node, path, isInsideRender, seen) {
|
|
7198
|
+
const expr = Extract.unwrap(node);
|
|
7199
|
+
if (path.length === 0) return expr;
|
|
7200
|
+
switch (expr.type) {
|
|
7201
|
+
case AST_NODE_TYPES.ObjectExpression: {
|
|
7202
|
+
const [head, ...rest] = path;
|
|
7203
|
+
for (const property of expr.properties) {
|
|
7204
|
+
if (property.type !== AST_NODE_TYPES.Property || property.computed) continue;
|
|
7205
|
+
if ((property.key.type === AST_NODE_TYPES.Identifier ? property.key.name : isString(property.key.value) ? property.key.value : null) !== head) continue;
|
|
7206
|
+
const { value } = property;
|
|
7207
|
+
if (value.type === AST_NODE_TYPES.ArrayPattern) continue;
|
|
7208
|
+
if (value.type === AST_NODE_TYPES.ObjectPattern) continue;
|
|
7209
|
+
if (value.type === AST_NODE_TYPES.AssignmentPattern) continue;
|
|
7210
|
+
if (value.type === AST_NODE_TYPES.TSEmptyBodyFunctionExpression) continue;
|
|
7211
|
+
return resolveValueAtPath(context, value, rest, isInsideRender, seen);
|
|
7212
|
+
}
|
|
7213
|
+
return null;
|
|
7214
|
+
}
|
|
7215
|
+
case AST_NODE_TYPES.Identifier: {
|
|
7216
|
+
const variable = findVariable(context.sourceCode.getScope(expr), expr.name);
|
|
7217
|
+
if (variable == null || seen.has(variable)) return null;
|
|
7218
|
+
seen.add(variable);
|
|
7219
|
+
for (const def of variable.defs) {
|
|
7220
|
+
if (!isInsideRender(def.node)) continue;
|
|
7221
|
+
if (def.node.type !== AST_NODE_TYPES.VariableDeclarator || def.node.init == null) continue;
|
|
7222
|
+
const value = resolveValueAtPath(context, def.node.init, path, isInsideRender, seen);
|
|
7223
|
+
if (value != null) return value;
|
|
7224
|
+
}
|
|
7225
|
+
return null;
|
|
7226
|
+
}
|
|
7227
|
+
case AST_NODE_TYPES.MemberExpression:
|
|
7228
|
+
if (expr.computed || expr.property.type !== AST_NODE_TYPES.Identifier) return null;
|
|
7229
|
+
return resolveValueAtPath(context, expr.object, [expr.property.name, ...path], isInsideRender, seen);
|
|
7230
|
+
default: return null;
|
|
7231
|
+
}
|
|
7232
|
+
}
|
|
7171
7233
|
function findDynamicCreationSite(context, node, isInsideRender, seen) {
|
|
7172
7234
|
const expr = Extract.unwrap(node);
|
|
7173
7235
|
if (expr.type === AST_NODE_TYPES.CallExpression) {
|
|
@@ -7188,6 +7250,11 @@ function findDynamicCreationSite(context, node, isInsideRender, seen) {
|
|
|
7188
7250
|
const last = expr.expressions.at(-1);
|
|
7189
7251
|
return last == null ? null : findDynamicCreationSite(context, last, isInsideRender, seen);
|
|
7190
7252
|
}
|
|
7253
|
+
case AST_NODE_TYPES.MemberExpression: {
|
|
7254
|
+
if (expr.computed || expr.property.type !== AST_NODE_TYPES.Identifier) return null;
|
|
7255
|
+
const value = resolveValueAtPath(context, expr.object, [expr.property.name], isInsideRender, seen);
|
|
7256
|
+
return value == null ? null : findDynamicCreationSite(context, value, isInsideRender, seen);
|
|
7257
|
+
}
|
|
7191
7258
|
case AST_NODE_TYPES.Identifier:
|
|
7192
7259
|
case AST_NODE_TYPES.JSXIdentifier: {
|
|
7193
7260
|
const variable = findVariable(context.sourceCode.getScope(expr), expr.name);
|
|
@@ -7197,13 +7264,28 @@ function findDynamicCreationSite(context, node, isInsideRender, seen) {
|
|
|
7197
7264
|
default: return null;
|
|
7198
7265
|
}
|
|
7199
7266
|
}
|
|
7200
|
-
function
|
|
7267
|
+
function getReassignmentValues(variable) {
|
|
7268
|
+
const values = [];
|
|
7201
7269
|
for (const ref of variable.references) {
|
|
7202
7270
|
if (!ref.isWrite()) continue;
|
|
7203
7271
|
const { identifier } = ref;
|
|
7204
7272
|
if (identifier.parent.type !== AST_NODE_TYPES.AssignmentExpression) continue;
|
|
7205
7273
|
if (identifier.parent.left !== identifier) continue;
|
|
7206
|
-
|
|
7274
|
+
values.push(identifier.parent.right);
|
|
7275
|
+
}
|
|
7276
|
+
return values;
|
|
7277
|
+
}
|
|
7278
|
+
function findReassignmentCreationSite(context, variable, isInsideRender, seen) {
|
|
7279
|
+
for (const value of getReassignmentValues(variable)) {
|
|
7280
|
+
const source = findDynamicCreationSite(context, value, isInsideRender, seen);
|
|
7281
|
+
if (source != null) return source;
|
|
7282
|
+
}
|
|
7283
|
+
return null;
|
|
7284
|
+
}
|
|
7285
|
+
function findMemberReassignmentCreationSite(context, variable, path, isInsideRender, seen) {
|
|
7286
|
+
for (const value of getReassignmentValues(variable)) {
|
|
7287
|
+
const selected = resolveValueAtPath(context, value, path, isInsideRender, seen);
|
|
7288
|
+
const source = selected == null ? null : findDynamicCreationSite(context, selected, isInsideRender, seen);
|
|
7207
7289
|
if (source != null) return source;
|
|
7208
7290
|
}
|
|
7209
7291
|
return null;
|
|
@@ -7240,22 +7322,52 @@ function resolveDynamicComponentOrigin(context, variable, isInsideRender, seen =
|
|
|
7240
7322
|
isDynamic: false
|
|
7241
7323
|
};
|
|
7242
7324
|
}
|
|
7325
|
+
function resolveDynamicMemberOrigin(context, variable, path, isInsideRender, seen = /* @__PURE__ */ new Set()) {
|
|
7326
|
+
if (path.length === 0) return resolveDynamicComponentOrigin(context, variable, isInsideRender, seen);
|
|
7327
|
+
if (seen.has(variable)) return {
|
|
7328
|
+
creationNode: null,
|
|
7329
|
+
isDynamic: false
|
|
7330
|
+
};
|
|
7331
|
+
seen.add(variable);
|
|
7332
|
+
for (const def of variable.defs) {
|
|
7333
|
+
const defNode = def.node;
|
|
7334
|
+
if (!isInsideRender(defNode)) continue;
|
|
7335
|
+
if (defNode.type !== AST_NODE_TYPES.VariableDeclarator) continue;
|
|
7336
|
+
if (defNode.init != null) {
|
|
7337
|
+
const selected = resolveValueAtPath(context, defNode.init, path, isInsideRender, seen);
|
|
7338
|
+
const initSource = selected == null ? null : findDynamicCreationSite(context, selected, isInsideRender, seen);
|
|
7339
|
+
if (initSource != null) return {
|
|
7340
|
+
creationNode: initSource,
|
|
7341
|
+
isDynamic: true
|
|
7342
|
+
};
|
|
7343
|
+
}
|
|
7344
|
+
const reassignmentSource = findMemberReassignmentCreationSite(context, variable, path, isInsideRender, seen);
|
|
7345
|
+
if (reassignmentSource != null) return {
|
|
7346
|
+
creationNode: reassignmentSource,
|
|
7347
|
+
isDynamic: true
|
|
7348
|
+
};
|
|
7349
|
+
}
|
|
7350
|
+
return {
|
|
7351
|
+
creationNode: null,
|
|
7352
|
+
isDynamic: false
|
|
7353
|
+
};
|
|
7354
|
+
}
|
|
7243
7355
|
// src/rules/static-components/effects.ts
|
|
7244
|
-
function
|
|
7245
|
-
const
|
|
7356
|
+
function inferViolations$1(context, componentUsages, isInsideRender) {
|
|
7357
|
+
const violations = [];
|
|
7246
7358
|
for (const usage of componentUsages) {
|
|
7247
7359
|
const variable = findVariable(context.sourceCode.getScope(usage.node), usage.name);
|
|
7248
7360
|
if (variable == null) continue;
|
|
7249
7361
|
if (!variable.defs.some((def) => isInsideRender(def.node))) continue;
|
|
7250
|
-
const { creationNode, isDynamic } = resolveDynamicComponentOrigin(context, variable, isInsideRender);
|
|
7362
|
+
const { creationNode, isDynamic } = usage.path.length === 0 ? resolveDynamicComponentOrigin(context, variable, isInsideRender) : resolveDynamicMemberOrigin(context, variable, usage.path, isInsideRender);
|
|
7251
7363
|
if (!isDynamic) continue;
|
|
7252
|
-
|
|
7364
|
+
violations.push({
|
|
7253
7365
|
name: usage.name,
|
|
7254
7366
|
creationNode,
|
|
7255
7367
|
node: usage.node
|
|
7256
7368
|
});
|
|
7257
7369
|
}
|
|
7258
|
-
return
|
|
7370
|
+
return violations;
|
|
7259
7371
|
}
|
|
7260
7372
|
var static_components_default = createRule({
|
|
7261
7373
|
meta: {
|
|
@@ -7278,16 +7390,16 @@ function create$3(context) {
|
|
|
7278
7390
|
return merge(fc.visitor, cc.visitor, visitor, { "Program:exit"(program) {
|
|
7279
7391
|
const isInsideRender = createRenderBoundaryChecker([...fc.api.getAllComponents(program), ...cc.api.getAllComponents(program)].map((component) => component.node));
|
|
7280
7392
|
const reportedCreations = /* @__PURE__ */ new Set();
|
|
7281
|
-
for (const
|
|
7393
|
+
for (const violation of inferViolations$1(context, facts.componentUsages, isInsideRender)) {
|
|
7282
7394
|
context.report({
|
|
7283
7395
|
messageId: "default",
|
|
7284
|
-
node:
|
|
7396
|
+
node: violation.node
|
|
7285
7397
|
});
|
|
7286
|
-
if (reportedCreations.has(
|
|
7287
|
-
reportedCreations.add(
|
|
7398
|
+
if (reportedCreations.has(violation.creationNode)) continue;
|
|
7399
|
+
reportedCreations.add(violation.creationNode);
|
|
7288
7400
|
context.report({
|
|
7289
7401
|
messageId: "created-here",
|
|
7290
|
-
node:
|
|
7402
|
+
node: violation.creationNode
|
|
7291
7403
|
});
|
|
7292
7404
|
}
|
|
7293
7405
|
} });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "5.30.0
|
|
3
|
+
"version": "5.30.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",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@eslint-react/ast": "5.30.0
|
|
40
|
-
"@eslint-react/core": "5.30.0
|
|
41
|
-
"@eslint-react/eslint": "5.30.0
|
|
42
|
-
"@eslint-react/jsx": "5.30.0
|
|
43
|
-
"@eslint-react/shared": "5.30.0
|
|
44
|
-
"@eslint-react/var": "5.30.0
|
|
39
|
+
"@eslint-react/ast": "5.30.0",
|
|
40
|
+
"@eslint-react/core": "5.30.0",
|
|
41
|
+
"@eslint-react/eslint": "5.30.0",
|
|
42
|
+
"@eslint-react/jsx": "5.30.0",
|
|
43
|
+
"@eslint-react/shared": "5.30.0",
|
|
44
|
+
"@eslint-react/var": "5.30.0",
|
|
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",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"eslint": "^10.14.0",
|
|
64
64
|
"react": "^19.3.1",
|
|
65
65
|
"react-dom": "^19.3.1",
|
|
66
|
-
"tsdown": "^0.23.
|
|
66
|
+
"tsdown": "^0.23.7",
|
|
67
67
|
"tsl": "^1.0.30",
|
|
68
68
|
"tsl-dx": "^0.15.2",
|
|
69
69
|
"typescript": "6.0.3"
|