eslint-plugin-react-x 5.21.0 → 5.21.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 +16 -33
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -144,7 +144,7 @@ const rules$6 = {
|
|
|
144
144
|
//#endregion
|
|
145
145
|
//#region package.json
|
|
146
146
|
var name$6 = "eslint-plugin-react-x";
|
|
147
|
-
var version = "5.21.
|
|
147
|
+
var version = "5.21.1";
|
|
148
148
|
|
|
149
149
|
//#endregion
|
|
150
150
|
//#region src/utils/create-rule.ts
|
|
@@ -1807,7 +1807,7 @@ function create$47(context) {
|
|
|
1807
1807
|
if (!context.sourceCode.text.includes("setState")) return {};
|
|
1808
1808
|
return { MemberExpression(node) {
|
|
1809
1809
|
if (!core.isAPI("this.state")(context, node)) return;
|
|
1810
|
-
const fact = Traverse.findParent(Traverse.findParent(node, (n) => Check.is(AST_NODE_TYPES.CallExpression)(n) && core.isThisSetStateCall(n)),
|
|
1810
|
+
const fact = Traverse.findParent(Traverse.findParent(node, (n) => Check.is(AST_NODE_TYPES.CallExpression)(n) && core.isThisSetStateCall(n)), Check.isClass);
|
|
1811
1811
|
if (fact == null || !core.isClassComponent(fact)) return;
|
|
1812
1812
|
context.report({
|
|
1813
1813
|
messageId: "default",
|
|
@@ -4230,28 +4230,19 @@ var no_unused_class_component_members_default = createRule({
|
|
|
4230
4230
|
defaultOptions: []
|
|
4231
4231
|
});
|
|
4232
4232
|
function create$11(context) {
|
|
4233
|
-
const classStack = [];
|
|
4234
|
-
const methodStack = [];
|
|
4235
4233
|
const propertyDefs = /* @__PURE__ */ new WeakMap();
|
|
4236
4234
|
const propertyUsages = /* @__PURE__ */ new WeakMap();
|
|
4237
|
-
function
|
|
4238
|
-
classStack.push(node);
|
|
4235
|
+
function classExit(node) {
|
|
4239
4236
|
if (!core.isClassComponent(node)) return;
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
}
|
|
4243
|
-
function classExit() {
|
|
4244
|
-
const currentClass = classStack.pop();
|
|
4245
|
-
if (currentClass == null || !core.isClassComponent(currentClass)) return;
|
|
4246
|
-
const id = core.getClassId(currentClass);
|
|
4247
|
-
const defs = propertyDefs.get(currentClass);
|
|
4248
|
-
const usages = propertyUsages.get(currentClass);
|
|
4237
|
+
const id = core.getClassId(node);
|
|
4238
|
+
const defs = propertyDefs.get(node);
|
|
4249
4239
|
if (defs == null) return;
|
|
4240
|
+
const usages = propertyUsages.get(node);
|
|
4250
4241
|
for (const def of defs) {
|
|
4251
4242
|
const methodName = def.name;
|
|
4252
4243
|
if (usages?.has(methodName) ?? false) continue;
|
|
4253
4244
|
if (LIFECYCLE_METHODS.has(methodName)) {
|
|
4254
|
-
if (methodName === "shouldComponentUpdate" && core.isPureComponent(
|
|
4245
|
+
if (methodName === "shouldComponentUpdate" && core.isPureComponent(node)) {} else continue;
|
|
4255
4246
|
}
|
|
4256
4247
|
context.report({
|
|
4257
4248
|
data: {
|
|
@@ -4264,43 +4255,35 @@ function create$11(context) {
|
|
|
4264
4255
|
}
|
|
4265
4256
|
}
|
|
4266
4257
|
function methodEnter(node) {
|
|
4267
|
-
|
|
4268
|
-
const currentClass = classStack.at(-1);
|
|
4258
|
+
const currentClass = Traverse.findParent(node, Check.isClass);
|
|
4269
4259
|
if (currentClass == null || !core.isClassComponent(currentClass)) return;
|
|
4270
4260
|
if (node.static) return;
|
|
4271
|
-
if (!node.computed && node.key.type === AST_NODE_TYPES.Identifier) propertyDefs
|
|
4272
|
-
}
|
|
4273
|
-
function methodExit() {
|
|
4274
|
-
methodStack.pop();
|
|
4261
|
+
if (!node.computed && node.key.type === AST_NODE_TYPES.Identifier) getOrInsertComputed(propertyDefs, currentClass, () => /* @__PURE__ */ new Set()).add(node.key);
|
|
4275
4262
|
}
|
|
4276
4263
|
return {
|
|
4277
|
-
ClassDeclaration: classEnter,
|
|
4278
4264
|
"ClassDeclaration:exit": classExit,
|
|
4279
|
-
ClassExpression: classEnter,
|
|
4280
4265
|
"ClassExpression:exit": classExit,
|
|
4281
4266
|
MemberExpression(node) {
|
|
4282
|
-
const currentClass =
|
|
4283
|
-
const currentMethod =
|
|
4267
|
+
const currentClass = Traverse.findParent(node, Check.isClass);
|
|
4268
|
+
const currentMethod = Traverse.findParent(node, Check.isPropertyOrMethod);
|
|
4284
4269
|
if (currentClass == null || currentMethod == null) return;
|
|
4285
4270
|
if (!core.isClassComponent(currentClass) || currentMethod.static) return;
|
|
4286
4271
|
if (node.object.type !== AST_NODE_TYPES.ThisExpression || node.computed || node.property.type !== AST_NODE_TYPES.Identifier) return;
|
|
4287
4272
|
if (node.parent.type === AST_NODE_TYPES.AssignmentExpression && node.parent.left === node) {
|
|
4288
|
-
propertyDefs
|
|
4273
|
+
getOrInsertComputed(propertyDefs, currentClass, () => /* @__PURE__ */ new Set()).add(node.property);
|
|
4289
4274
|
return;
|
|
4290
4275
|
}
|
|
4291
|
-
propertyUsages
|
|
4276
|
+
getOrInsertComputed(propertyUsages, currentClass, () => /* @__PURE__ */ new Set()).add(node.property.name);
|
|
4292
4277
|
},
|
|
4293
4278
|
MethodDefinition: methodEnter,
|
|
4294
|
-
"MethodDefinition:exit": methodExit,
|
|
4295
4279
|
PropertyDefinition: methodEnter,
|
|
4296
|
-
"PropertyDefinition:exit": methodExit,
|
|
4297
4280
|
VariableDeclarator(node) {
|
|
4298
|
-
const currentClass =
|
|
4299
|
-
const currentMethod =
|
|
4281
|
+
const currentClass = Traverse.findParent(node, Check.isClass);
|
|
4282
|
+
const currentMethod = Traverse.findParent(node, Check.isPropertyOrMethod);
|
|
4300
4283
|
if (currentClass == null || currentMethod == null) return;
|
|
4301
4284
|
if (!core.isClassComponent(currentClass) || currentMethod.static) return;
|
|
4302
4285
|
if (node.init != null && node.init.type === AST_NODE_TYPES.ThisExpression && node.id.type === AST_NODE_TYPES.ObjectPattern) {
|
|
4303
|
-
for (const prop of node.id.properties) if (prop.type === AST_NODE_TYPES.Property && !prop.computed && prop.key.type === AST_NODE_TYPES.Identifier) propertyUsages
|
|
4286
|
+
for (const prop of node.id.properties) if (prop.type === AST_NODE_TYPES.Property && !prop.computed && prop.key.type === AST_NODE_TYPES.Identifier) getOrInsertComputed(propertyUsages, currentClass, () => /* @__PURE__ */ new Set()).add(prop.key.name);
|
|
4304
4287
|
}
|
|
4305
4288
|
}
|
|
4306
4289
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "5.21.
|
|
3
|
+
"version": "5.21.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.21.
|
|
40
|
-
"@eslint-react/core": "5.21.
|
|
41
|
-
"@eslint-react/eslint": "5.21.
|
|
42
|
-
"@eslint-react/jsx": "5.21.
|
|
43
|
-
"@eslint-react/shared": "5.21.
|
|
44
|
-
"@eslint-react/var": "5.21.
|
|
39
|
+
"@eslint-react/ast": "5.21.1",
|
|
40
|
+
"@eslint-react/core": "5.21.1",
|
|
41
|
+
"@eslint-react/eslint": "5.21.1",
|
|
42
|
+
"@eslint-react/jsx": "5.21.1",
|
|
43
|
+
"@eslint-react/shared": "5.21.1",
|
|
44
|
+
"@eslint-react/var": "5.21.1",
|
|
45
45
|
"@typescript-eslint/scope-manager": "^8.70.1",
|
|
46
46
|
"@typescript-eslint/types": "^8.70.1",
|
|
47
47
|
"@typescript-eslint/typescript-estree": "^8.70.1",
|