eslint-plugin-react-x 2.0.5 → 2.0.6-beta.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.
Files changed (2) hide show
  1. package/dist/index.js +69 -51
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -37,6 +37,10 @@ const name$3 = "react-x/recommended";
37
37
  const rules$2 = {
38
38
  "react-x/jsx-no-comment-textnodes": "warn",
39
39
  "react-x/jsx-no-duplicate-props": "warn",
40
+ "react-x/jsx-no-iife": "off",
41
+ "react-x/jsx-no-undef": "off",
42
+ "react-x/jsx-shorthand-boolean": "off",
43
+ "react-x/jsx-shorthand-fragment": "off",
40
44
  "react-x/jsx-uses-react": "warn",
41
45
  "react-x/jsx-uses-vars": "warn",
42
46
  "react-x/no-access-state-in-setstate": "error",
@@ -45,7 +49,9 @@ const rules$2 = {
45
49
  "react-x/no-children-for-each": "warn",
46
50
  "react-x/no-children-map": "warn",
47
51
  "react-x/no-children-only": "warn",
52
+ "react-x/no-children-prop": "off",
48
53
  "react-x/no-children-to-array": "warn",
54
+ "react-x/no-class-component": "off",
49
55
  "react-x/no-clone-element": "warn",
50
56
  "react-x/no-component-will-mount": "error",
51
57
  "react-x/no-component-will-receive-props": "error",
@@ -55,9 +61,14 @@ const rules$2 = {
55
61
  "react-x/no-default-props": "error",
56
62
  "react-x/no-direct-mutation-state": "error",
57
63
  "react-x/no-duplicate-key": "error",
64
+ "react-x/no-forbidden-props": "off",
58
65
  "react-x/no-forward-ref": "warn",
59
66
  "react-x/no-implicit-key": "warn",
67
+ "react-x/no-leaked-conditional-rendering": "off",
68
+ "react-x/no-missing-component-display-name": "off",
69
+ "react-x/no-missing-context-display-name": "off",
60
70
  "react-x/no-missing-key": "error",
71
+ "react-x/no-misused-capture-owner-stack": "off",
61
72
  "react-x/no-nested-component-definitions": "error",
62
73
  "react-x/no-nested-lazy-component-declarations": "error",
63
74
  "react-x/no-prop-types": "error",
@@ -66,6 +77,9 @@ const rules$2 = {
66
77
  "react-x/no-set-state-in-component-did-update": "warn",
67
78
  "react-x/no-set-state-in-component-will-update": "warn",
68
79
  "react-x/no-string-refs": "error",
80
+ "react-x/no-unnecessary-key": "off",
81
+ "react-x/no-unnecessary-use-callback": "off",
82
+ "react-x/no-unnecessary-use-memo": "off",
69
83
  "react-x/no-unnecessary-use-prefix": "warn",
70
84
  "react-x/no-unsafe-component-will-mount": "warn",
71
85
  "react-x/no-unsafe-component-will-receive-props": "warn",
@@ -73,9 +87,14 @@ const rules$2 = {
73
87
  "react-x/no-unstable-context-value": "warn",
74
88
  "react-x/no-unstable-default-props": "warn",
75
89
  "react-x/no-unused-class-component-members": "warn",
90
+ "react-x/no-unused-props": "off",
76
91
  "react-x/no-unused-state": "warn",
77
92
  "react-x/no-use-context": "warn",
78
93
  "react-x/no-useless-forward-ref": "warn",
94
+ "react-x/no-useless-fragment": "off",
95
+ "react-x/prefer-destructuring-assignment": "off",
96
+ "react-x/prefer-namespace-import": "off",
97
+ "react-x/prefer-read-only-props": "off",
79
98
  "react-x/prefer-use-state-lazy-initialization": "warn"
80
99
  };
81
100
  const settings$2 = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
@@ -115,7 +134,7 @@ const settings = { ...settings$1 };
115
134
  //#endregion
116
135
  //#region package.json
117
136
  var name = "eslint-plugin-react-x";
118
- var version = "2.0.5";
137
+ var version = "2.0.6-beta.1";
119
138
 
120
139
  //#endregion
121
140
  //#region src/utils/create-rule.ts
@@ -256,8 +275,7 @@ var jsx_no_comment_textnodes_default = createRule({
256
275
  function create$60(context) {
257
276
  function hasCommentLike(node) {
258
277
  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);
278
+ return /^\s*\/(?:\/|\*)/mu.test(context.sourceCode.getText(node));
261
279
  }
262
280
  const visitorFunction = (node) => {
263
281
  if (!AST.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent)) return;
@@ -593,37 +611,37 @@ var no_access_state_in_setstate_default = createRule({
593
611
  });
594
612
  function create$52(context) {
595
613
  if (!context.sourceCode.text.includes("setState")) return {};
596
- const classEntries = [];
597
- const methodEntries = [];
598
- const setStateEntries = [];
614
+ const classStack = [];
615
+ const methodStack = [];
616
+ const setStateStack = [];
599
617
  return {
600
618
  CallExpression(node) {
601
619
  if (!isThisSetState(node)) return;
602
- setStateEntries.push([node, false]);
620
+ setStateStack.push([node, false]);
603
621
  },
604
622
  "CallExpression:exit"(node) {
605
623
  if (!isThisSetState(node)) return;
606
- setStateEntries.pop();
624
+ setStateStack.pop();
607
625
  },
608
626
  ClassDeclaration(node) {
609
- classEntries.push([node, isClassComponent(node)]);
627
+ classStack.push([node, isClassComponent(node)]);
610
628
  },
611
629
  "ClassDeclaration:exit"() {
612
- classEntries.pop();
630
+ classStack.pop();
613
631
  },
614
632
  ClassExpression(node) {
615
- classEntries.push([node, isClassComponent(node)]);
633
+ classStack.push([node, isClassComponent(node)]);
616
634
  },
617
635
  "ClassExpression:exit"() {
618
- classEntries.pop();
636
+ classStack.pop();
619
637
  },
620
638
  MemberExpression(node) {
621
639
  if (!AST.isThisExpression(node.object)) return;
622
- const [currClass, isComponent = false] = classEntries.at(-1) ?? [];
640
+ const [currClass, isComponent = false] = classStack.at(-1) ?? [];
623
641
  if (currClass == null || !isComponent) return;
624
- const [currMethod, isStatic = false] = methodEntries.at(-1) ?? [];
642
+ const [currMethod, isStatic = false] = methodStack.at(-1) ?? [];
625
643
  if (currMethod == null || isStatic) return;
626
- const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
644
+ const [setState, hasThisState = false] = setStateStack.at(-1) ?? [];
627
645
  if (setState == null || hasThisState) return;
628
646
  if (AST.getPropertyName(node.property) !== "state") return;
629
647
  context.report({
@@ -632,23 +650,23 @@ function create$52(context) {
632
650
  });
633
651
  },
634
652
  MethodDefinition(node) {
635
- methodEntries.push([node, node.static]);
653
+ methodStack.push([node, node.static]);
636
654
  },
637
655
  "MethodDefinition:exit"() {
638
- methodEntries.pop();
656
+ methodStack.pop();
639
657
  },
640
658
  PropertyDefinition(node) {
641
- methodEntries.push([node, node.static]);
659
+ methodStack.push([node, node.static]);
642
660
  },
643
661
  "PropertyDefinition:exit"() {
644
- methodEntries.pop();
662
+ methodStack.pop();
645
663
  },
646
664
  VariableDeclarator(node) {
647
- const [currClass, isComponent = false] = classEntries.at(-1) ?? [];
665
+ const [currClass, isComponent = false] = classStack.at(-1) ?? [];
648
666
  if (currClass == null || !isComponent) return;
649
- const [currMethod, isStatic = false] = methodEntries.at(-1) ?? [];
667
+ const [currMethod, isStatic = false] = methodStack.at(-1) ?? [];
650
668
  if (currMethod == null || isStatic) return;
651
- const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
669
+ const [setState, hasThisState = false] = setStateStack.at(-1) ?? [];
652
670
  if (setState == null || hasThisState) return;
653
671
  if (node.init == null || !AST.isThisExpression(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
654
672
  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 +2799,18 @@ var no_unused_class_component_members_default = createRule({
2781
2799
  defaultOptions: []
2782
2800
  });
2783
2801
  function create$9(context) {
2784
- const classEntries = [];
2785
- const methodEntries = [];
2802
+ const classStack = [];
2803
+ const methodStack = [];
2786
2804
  const propertyDefs = /* @__PURE__ */ new WeakMap();
2787
2805
  const propertyUsages = /* @__PURE__ */ new WeakMap();
2788
2806
  function classEnter(node) {
2789
- classEntries.push(node);
2807
+ classStack.push(node);
2790
2808
  if (!isClassComponent(node)) return;
2791
2809
  propertyDefs.set(node, /* @__PURE__ */ new Set());
2792
2810
  propertyUsages.set(node, /* @__PURE__ */ new Set());
2793
2811
  }
2794
2812
  function classExit() {
2795
- const currentClass = classEntries.pop();
2813
+ const currentClass = classStack.pop();
2796
2814
  if (currentClass == null || !isClassComponent(currentClass)) return;
2797
2815
  const className = AST.getClassId(currentClass)?.name;
2798
2816
  const defs = propertyDefs.get(currentClass);
@@ -2813,14 +2831,14 @@ function create$9(context) {
2813
2831
  }
2814
2832
  }
2815
2833
  function methodEnter(node) {
2816
- methodEntries.push(node);
2817
- const currentClass = classEntries.at(-1);
2834
+ methodStack.push(node);
2835
+ const currentClass = classStack.at(-1);
2818
2836
  if (currentClass == null || !isClassComponent(currentClass)) return;
2819
2837
  if (node.static) return;
2820
2838
  if (isKeyLiteral$1(node, node.key)) propertyDefs.get(currentClass)?.add(node.key);
2821
2839
  }
2822
2840
  function methodExit() {
2823
- methodEntries.pop();
2841
+ methodStack.pop();
2824
2842
  }
2825
2843
  return {
2826
2844
  ClassDeclaration: classEnter,
@@ -2828,8 +2846,8 @@ function create$9(context) {
2828
2846
  ClassExpression: classEnter,
2829
2847
  "ClassExpression:exit": classExit,
2830
2848
  MemberExpression(node) {
2831
- const currentClass = classEntries.at(-1);
2832
- const currentMethod = methodEntries.at(-1);
2849
+ const currentClass = classStack.at(-1);
2850
+ const currentMethod = methodStack.at(-1);
2833
2851
  if (currentClass == null || currentMethod == null) return;
2834
2852
  if (!isClassComponent(currentClass) || currentMethod.static) return;
2835
2853
  if (!AST.isThisExpression(node.object) || !isKeyLiteral$1(node, node.property)) return;
@@ -2845,8 +2863,8 @@ function create$9(context) {
2845
2863
  PropertyDefinition: methodEnter,
2846
2864
  "PropertyDefinition:exit": methodExit,
2847
2865
  VariableDeclarator(node) {
2848
- const currentClass = classEntries.at(-1);
2849
- const currentMethod = methodEntries.at(-1);
2866
+ const currentClass = classStack.at(-1);
2867
+ const currentMethod = methodStack.at(-1);
2850
2868
  if (currentClass == null || currentMethod == null) return;
2851
2869
  if (!isClassComponent(currentClass) || currentMethod.static) return;
2852
2870
  if (node.init != null && AST.isThisExpression(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern) {
@@ -3002,15 +3020,15 @@ var no_unused_state_default = createRule({
3002
3020
  defaultOptions: []
3003
3021
  });
3004
3022
  function create$7(context) {
3005
- const classEntries = [];
3006
- const methodEntries = [];
3007
- const constructorEntries = [];
3023
+ const classStack = [];
3024
+ const methodStack = [];
3025
+ const constructorStack = [];
3008
3026
  const stateDefs = /* @__PURE__ */ new WeakMap();
3009
3027
  function classEnter(node) {
3010
- classEntries.push(node);
3028
+ classStack.push(node);
3011
3029
  }
3012
3030
  function classExit() {
3013
- const currentClass = classEntries.pop();
3031
+ const currentClass = classStack.pop();
3014
3032
  if (currentClass == null || !isClassComponent(currentClass)) return;
3015
3033
  const className = AST.getClassId(currentClass)?.name;
3016
3034
  const { node: defNode, isUsed = false } = stateDefs.get(currentClass) ?? {};
@@ -3022,8 +3040,8 @@ function create$7(context) {
3022
3040
  });
3023
3041
  }
3024
3042
  function methodEnter(node) {
3025
- methodEntries.push(node);
3026
- const currentClass = classEntries.at(-1);
3043
+ methodStack.push(node);
3044
+ const currentClass = classStack.at(-1);
3027
3045
  if (currentClass == null || !isClassComponent(currentClass)) return;
3028
3046
  if (node.static) {
3029
3047
  if (isGetDerivedStateFromProps(node) && isMatching({ params: [P.nonNullable, ...P.array()] })(node.value)) {
@@ -3041,20 +3059,20 @@ function create$7(context) {
3041
3059
  });
3042
3060
  }
3043
3061
  function methodExit() {
3044
- methodEntries.pop();
3062
+ methodStack.pop();
3045
3063
  }
3046
3064
  function constructorEnter(node) {
3047
- constructorEntries.push(node);
3065
+ constructorStack.push(node);
3048
3066
  }
3049
3067
  function constructorExit() {
3050
- constructorEntries.pop();
3068
+ constructorStack.pop();
3051
3069
  }
3052
3070
  return {
3053
3071
  AssignmentExpression(node) {
3054
3072
  if (!isAssignmentToThisState(node)) return;
3055
- const currentClass = classEntries.at(-1);
3073
+ const currentClass = classStack.at(-1);
3056
3074
  if (currentClass == null || !isClassComponent(currentClass)) return;
3057
- const currentConstructor = constructorEntries.at(-1);
3075
+ const currentConstructor = constructorStack.at(-1);
3058
3076
  if (currentConstructor == null || !currentClass.body.body.includes(currentConstructor)) return;
3059
3077
  const isUsed = stateDefs.get(currentClass)?.isUsed ?? false;
3060
3078
  stateDefs.set(currentClass, {
@@ -3069,11 +3087,11 @@ function create$7(context) {
3069
3087
  MemberExpression(node) {
3070
3088
  if (!AST.isThisExpression(node.object)) return;
3071
3089
  if (AST.getPropertyName(node.property) !== "state") return;
3072
- const currentClass = classEntries.at(-1);
3090
+ const currentClass = classStack.at(-1);
3073
3091
  if (currentClass == null || !isClassComponent(currentClass)) return;
3074
- const currentMethod = methodEntries.at(-1);
3092
+ const currentMethod = methodStack.at(-1);
3075
3093
  if (currentMethod == null || currentMethod.static) return;
3076
- if (currentMethod === constructorEntries.at(-1)) return;
3094
+ if (currentMethod === constructorStack.at(-1)) return;
3077
3095
  if (!currentClass.body.body.includes(currentMethod)) return;
3078
3096
  const defNode = stateDefs.get(currentClass)?.node;
3079
3097
  stateDefs.set(currentClass, {
@@ -3088,11 +3106,11 @@ function create$7(context) {
3088
3106
  PropertyDefinition: methodEnter,
3089
3107
  "PropertyDefinition:exit": methodExit,
3090
3108
  VariableDeclarator(node) {
3091
- const currentClass = classEntries.at(-1);
3109
+ const currentClass = classStack.at(-1);
3092
3110
  if (currentClass == null || !isClassComponent(currentClass)) return;
3093
- const currentMethod = methodEntries.at(-1);
3111
+ const currentMethod = methodStack.at(-1);
3094
3112
  if (currentMethod == null || currentMethod.static) return;
3095
- if (currentMethod === constructorEntries.at(-1)) return;
3113
+ if (currentMethod === constructorStack.at(-1)) return;
3096
3114
  if (!currentClass.body.body.includes(currentMethod)) return;
3097
3115
  if (node.init == null || !AST.isThisExpression(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
3098
3116
  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-beta.1",
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-beta.1",
47
+ "@eslint-react/core": "2.0.6-beta.1",
48
+ "@eslint-react/eff": "2.0.6-beta.1",
49
+ "@eslint-react/kit": "2.0.6-beta.1",
50
+ "@eslint-react/shared": "2.0.6-beta.1",
51
+ "@eslint-react/var": "2.0.6-beta.1"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/react": "^19.2.0",