eslint-plugin-react-x 2.0.5 → 2.0.6-next.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.
Files changed (2) hide show
  1. package/dist/index.js +50 -51
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -115,7 +115,7 @@ const settings = { ...settings$1 };
115
115
  //#endregion
116
116
  //#region package.json
117
117
  var name = "eslint-plugin-react-x";
118
- var version = "2.0.5";
118
+ var version = "2.0.6-next.0";
119
119
 
120
120
  //#endregion
121
121
  //#region src/utils/create-rule.ts
@@ -256,8 +256,7 @@ var jsx_no_comment_textnodes_default = createRule({
256
256
  function create$60(context) {
257
257
  function hasCommentLike(node) {
258
258
  if (AST.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) return false;
259
- const rawValue = context.sourceCode.getText(node);
260
- return /^\s*\/(?:\/|\*)/mu.test(rawValue);
259
+ return /^\s*\/(?:\/|\*)/mu.test(context.sourceCode.getText(node));
261
260
  }
262
261
  const visitorFunction = (node) => {
263
262
  if (!AST.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent)) return;
@@ -593,37 +592,37 @@ var no_access_state_in_setstate_default = createRule({
593
592
  });
594
593
  function create$52(context) {
595
594
  if (!context.sourceCode.text.includes("setState")) return {};
596
- const classEntries = [];
597
- const methodEntries = [];
598
- const setStateEntries = [];
595
+ const classStack = [];
596
+ const methodStack = [];
597
+ const setStateStack = [];
599
598
  return {
600
599
  CallExpression(node) {
601
600
  if (!isThisSetState(node)) return;
602
- setStateEntries.push([node, false]);
601
+ setStateStack.push([node, false]);
603
602
  },
604
603
  "CallExpression:exit"(node) {
605
604
  if (!isThisSetState(node)) return;
606
- setStateEntries.pop();
605
+ setStateStack.pop();
607
606
  },
608
607
  ClassDeclaration(node) {
609
- classEntries.push([node, isClassComponent(node)]);
608
+ classStack.push([node, isClassComponent(node)]);
610
609
  },
611
610
  "ClassDeclaration:exit"() {
612
- classEntries.pop();
611
+ classStack.pop();
613
612
  },
614
613
  ClassExpression(node) {
615
- classEntries.push([node, isClassComponent(node)]);
614
+ classStack.push([node, isClassComponent(node)]);
616
615
  },
617
616
  "ClassExpression:exit"() {
618
- classEntries.pop();
617
+ classStack.pop();
619
618
  },
620
619
  MemberExpression(node) {
621
620
  if (!AST.isThisExpression(node.object)) return;
622
- const [currClass, isComponent = false] = classEntries.at(-1) ?? [];
621
+ const [currClass, isComponent = false] = classStack.at(-1) ?? [];
623
622
  if (currClass == null || !isComponent) return;
624
- const [currMethod, isStatic = false] = methodEntries.at(-1) ?? [];
623
+ const [currMethod, isStatic = false] = methodStack.at(-1) ?? [];
625
624
  if (currMethod == null || isStatic) return;
626
- const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
625
+ const [setState, hasThisState = false] = setStateStack.at(-1) ?? [];
627
626
  if (setState == null || hasThisState) return;
628
627
  if (AST.getPropertyName(node.property) !== "state") return;
629
628
  context.report({
@@ -632,23 +631,23 @@ function create$52(context) {
632
631
  });
633
632
  },
634
633
  MethodDefinition(node) {
635
- methodEntries.push([node, node.static]);
634
+ methodStack.push([node, node.static]);
636
635
  },
637
636
  "MethodDefinition:exit"() {
638
- methodEntries.pop();
637
+ methodStack.pop();
639
638
  },
640
639
  PropertyDefinition(node) {
641
- methodEntries.push([node, node.static]);
640
+ methodStack.push([node, node.static]);
642
641
  },
643
642
  "PropertyDefinition:exit"() {
644
- methodEntries.pop();
643
+ methodStack.pop();
645
644
  },
646
645
  VariableDeclarator(node) {
647
- const [currClass, isComponent = false] = classEntries.at(-1) ?? [];
646
+ const [currClass, isComponent = false] = classStack.at(-1) ?? [];
648
647
  if (currClass == null || !isComponent) return;
649
- const [currMethod, isStatic = false] = methodEntries.at(-1) ?? [];
648
+ const [currMethod, isStatic = false] = methodStack.at(-1) ?? [];
650
649
  if (currMethod == null || isStatic) return;
651
- const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
650
+ const [setState, hasThisState = false] = setStateStack.at(-1) ?? [];
652
651
  if (setState == null || hasThisState) return;
653
652
  if (node.init == null || !AST.isThisExpression(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
654
653
  if (!node.id.properties.some((prop) => prop.type === AST_NODE_TYPES.Property && isKeyLiteral$2(prop, prop.key) && AST.getPropertyName(prop.key) === "state")) return;
@@ -2781,18 +2780,18 @@ var no_unused_class_component_members_default = createRule({
2781
2780
  defaultOptions: []
2782
2781
  });
2783
2782
  function create$9(context) {
2784
- const classEntries = [];
2785
- const methodEntries = [];
2783
+ const classStack = [];
2784
+ const methodStack = [];
2786
2785
  const propertyDefs = /* @__PURE__ */ new WeakMap();
2787
2786
  const propertyUsages = /* @__PURE__ */ new WeakMap();
2788
2787
  function classEnter(node) {
2789
- classEntries.push(node);
2788
+ classStack.push(node);
2790
2789
  if (!isClassComponent(node)) return;
2791
2790
  propertyDefs.set(node, /* @__PURE__ */ new Set());
2792
2791
  propertyUsages.set(node, /* @__PURE__ */ new Set());
2793
2792
  }
2794
2793
  function classExit() {
2795
- const currentClass = classEntries.pop();
2794
+ const currentClass = classStack.pop();
2796
2795
  if (currentClass == null || !isClassComponent(currentClass)) return;
2797
2796
  const className = AST.getClassId(currentClass)?.name;
2798
2797
  const defs = propertyDefs.get(currentClass);
@@ -2813,14 +2812,14 @@ function create$9(context) {
2813
2812
  }
2814
2813
  }
2815
2814
  function methodEnter(node) {
2816
- methodEntries.push(node);
2817
- const currentClass = classEntries.at(-1);
2815
+ methodStack.push(node);
2816
+ const currentClass = classStack.at(-1);
2818
2817
  if (currentClass == null || !isClassComponent(currentClass)) return;
2819
2818
  if (node.static) return;
2820
2819
  if (isKeyLiteral$1(node, node.key)) propertyDefs.get(currentClass)?.add(node.key);
2821
2820
  }
2822
2821
  function methodExit() {
2823
- methodEntries.pop();
2822
+ methodStack.pop();
2824
2823
  }
2825
2824
  return {
2826
2825
  ClassDeclaration: classEnter,
@@ -2828,8 +2827,8 @@ function create$9(context) {
2828
2827
  ClassExpression: classEnter,
2829
2828
  "ClassExpression:exit": classExit,
2830
2829
  MemberExpression(node) {
2831
- const currentClass = classEntries.at(-1);
2832
- const currentMethod = methodEntries.at(-1);
2830
+ const currentClass = classStack.at(-1);
2831
+ const currentMethod = methodStack.at(-1);
2833
2832
  if (currentClass == null || currentMethod == null) return;
2834
2833
  if (!isClassComponent(currentClass) || currentMethod.static) return;
2835
2834
  if (!AST.isThisExpression(node.object) || !isKeyLiteral$1(node, node.property)) return;
@@ -2845,8 +2844,8 @@ function create$9(context) {
2845
2844
  PropertyDefinition: methodEnter,
2846
2845
  "PropertyDefinition:exit": methodExit,
2847
2846
  VariableDeclarator(node) {
2848
- const currentClass = classEntries.at(-1);
2849
- const currentMethod = methodEntries.at(-1);
2847
+ const currentClass = classStack.at(-1);
2848
+ const currentMethod = methodStack.at(-1);
2850
2849
  if (currentClass == null || currentMethod == null) return;
2851
2850
  if (!isClassComponent(currentClass) || currentMethod.static) return;
2852
2851
  if (node.init != null && AST.isThisExpression(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern) {
@@ -3002,15 +3001,15 @@ var no_unused_state_default = createRule({
3002
3001
  defaultOptions: []
3003
3002
  });
3004
3003
  function create$7(context) {
3005
- const classEntries = [];
3006
- const methodEntries = [];
3007
- const constructorEntries = [];
3004
+ const classStack = [];
3005
+ const methodStack = [];
3006
+ const constructorStack = [];
3008
3007
  const stateDefs = /* @__PURE__ */ new WeakMap();
3009
3008
  function classEnter(node) {
3010
- classEntries.push(node);
3009
+ classStack.push(node);
3011
3010
  }
3012
3011
  function classExit() {
3013
- const currentClass = classEntries.pop();
3012
+ const currentClass = classStack.pop();
3014
3013
  if (currentClass == null || !isClassComponent(currentClass)) return;
3015
3014
  const className = AST.getClassId(currentClass)?.name;
3016
3015
  const { node: defNode, isUsed = false } = stateDefs.get(currentClass) ?? {};
@@ -3022,8 +3021,8 @@ function create$7(context) {
3022
3021
  });
3023
3022
  }
3024
3023
  function methodEnter(node) {
3025
- methodEntries.push(node);
3026
- const currentClass = classEntries.at(-1);
3024
+ methodStack.push(node);
3025
+ const currentClass = classStack.at(-1);
3027
3026
  if (currentClass == null || !isClassComponent(currentClass)) return;
3028
3027
  if (node.static) {
3029
3028
  if (isGetDerivedStateFromProps(node) && isMatching({ params: [P.nonNullable, ...P.array()] })(node.value)) {
@@ -3041,20 +3040,20 @@ function create$7(context) {
3041
3040
  });
3042
3041
  }
3043
3042
  function methodExit() {
3044
- methodEntries.pop();
3043
+ methodStack.pop();
3045
3044
  }
3046
3045
  function constructorEnter(node) {
3047
- constructorEntries.push(node);
3046
+ constructorStack.push(node);
3048
3047
  }
3049
3048
  function constructorExit() {
3050
- constructorEntries.pop();
3049
+ constructorStack.pop();
3051
3050
  }
3052
3051
  return {
3053
3052
  AssignmentExpression(node) {
3054
3053
  if (!isAssignmentToThisState(node)) return;
3055
- const currentClass = classEntries.at(-1);
3054
+ const currentClass = classStack.at(-1);
3056
3055
  if (currentClass == null || !isClassComponent(currentClass)) return;
3057
- const currentConstructor = constructorEntries.at(-1);
3056
+ const currentConstructor = constructorStack.at(-1);
3058
3057
  if (currentConstructor == null || !currentClass.body.body.includes(currentConstructor)) return;
3059
3058
  const isUsed = stateDefs.get(currentClass)?.isUsed ?? false;
3060
3059
  stateDefs.set(currentClass, {
@@ -3069,11 +3068,11 @@ function create$7(context) {
3069
3068
  MemberExpression(node) {
3070
3069
  if (!AST.isThisExpression(node.object)) return;
3071
3070
  if (AST.getPropertyName(node.property) !== "state") return;
3072
- const currentClass = classEntries.at(-1);
3071
+ const currentClass = classStack.at(-1);
3073
3072
  if (currentClass == null || !isClassComponent(currentClass)) return;
3074
- const currentMethod = methodEntries.at(-1);
3073
+ const currentMethod = methodStack.at(-1);
3075
3074
  if (currentMethod == null || currentMethod.static) return;
3076
- if (currentMethod === constructorEntries.at(-1)) return;
3075
+ if (currentMethod === constructorStack.at(-1)) return;
3077
3076
  if (!currentClass.body.body.includes(currentMethod)) return;
3078
3077
  const defNode = stateDefs.get(currentClass)?.node;
3079
3078
  stateDefs.set(currentClass, {
@@ -3088,11 +3087,11 @@ function create$7(context) {
3088
3087
  PropertyDefinition: methodEnter,
3089
3088
  "PropertyDefinition:exit": methodExit,
3090
3089
  VariableDeclarator(node) {
3091
- const currentClass = classEntries.at(-1);
3090
+ const currentClass = classStack.at(-1);
3092
3091
  if (currentClass == null || !isClassComponent(currentClass)) return;
3093
- const currentMethod = methodEntries.at(-1);
3092
+ const currentMethod = methodStack.at(-1);
3094
3093
  if (currentMethod == null || currentMethod.static) return;
3095
- if (currentMethod === constructorEntries.at(-1)) return;
3094
+ if (currentMethod === constructorStack.at(-1)) return;
3096
3095
  if (!currentClass.body.body.includes(currentMethod)) return;
3097
3096
  if (node.init == null || !AST.isThisExpression(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
3098
3097
  if (!node.id.properties.some((prop) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "2.0.5",
3
+ "version": "2.0.6-next.0",
4
4
  "description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -43,12 +43,12 @@
43
43
  "string-ts": "^2.2.1",
44
44
  "ts-api-utils": "^2.1.0",
45
45
  "ts-pattern": "^5.8.0",
46
- "@eslint-react/ast": "2.0.5",
47
- "@eslint-react/core": "2.0.5",
48
- "@eslint-react/shared": "2.0.5",
49
- "@eslint-react/kit": "2.0.5",
50
- "@eslint-react/var": "2.0.5",
51
- "@eslint-react/eff": "2.0.5"
46
+ "@eslint-react/ast": "2.0.6-next.0",
47
+ "@eslint-react/eff": "2.0.6-next.0",
48
+ "@eslint-react/var": "2.0.6-next.0",
49
+ "@eslint-react/core": "2.0.6-next.0",
50
+ "@eslint-react/kit": "2.0.6-next.0",
51
+ "@eslint-react/shared": "2.0.6-next.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/react": "^19.2.0",