eslint-plugin-react-x 1.24.0-next.9 → 1.24.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 CHANGED
@@ -42,7 +42,7 @@ var ts__default = /*#__PURE__*/_interopDefault(ts);
42
42
 
43
43
  // package.json
44
44
  var name = "eslint-plugin-react-x";
45
- var version = "1.24.0-next.9";
45
+ var version = "1.24.0";
46
46
  var createRule = shared.createRuleForPlugin("x");
47
47
 
48
48
  // src/rules/avoid-shorthand-boolean.ts
@@ -301,7 +301,7 @@ function isReactChildrenMethod(name2) {
301
301
  return reactChildrenMethod.some((method) => method === name2);
302
302
  }
303
303
  function isUsingReactChildren(node, context) {
304
- const settings = shared.unsafeDecodeSettings(context.settings);
304
+ const { importSource = "react" } = shared.unsafeDecodeSettings(context.settings);
305
305
  const { callee } = node;
306
306
  if (!("property" in callee) || !("object" in callee) || !("name" in callee.property)) {
307
307
  return false;
@@ -314,7 +314,7 @@ function isUsingReactChildren(node, context) {
314
314
  return true;
315
315
  }
316
316
  if (callee.object.type === types.AST_NODE_TYPES.MemberExpression && "name" in callee.object.object) {
317
- return core.isInitializedFromReact(callee.object.object.name, initialScope, settings.importSource);
317
+ return core.isInitializedFromReact(callee.object.object.name, importSource, initialScope);
318
318
  }
319
319
  return false;
320
320
  }
@@ -610,10 +610,10 @@ var no_children_prop_default = createRule({
610
610
  create(context) {
611
611
  return {
612
612
  JSXElement(node) {
613
- const attribute = JSX7__namespace.getAttributeNode(
613
+ const attribute = JSX7__namespace.getAttribute(
614
614
  "children",
615
- context.sourceCode.getScope(node),
616
- node.openingElement.attributes
615
+ node.openingElement.attributes,
616
+ context.sourceCode.getScope(node)
617
617
  );
618
618
  if (attribute != null) {
619
619
  context.report({
@@ -691,7 +691,6 @@ var no_class_component_default = createRule({
691
691
  messageId: "noClassComponent",
692
692
  node: component,
693
693
  data: {
694
- // eslint-disable-next-line eslint-plugin/no-unused-placeholders
695
694
  name: name2
696
695
  }
697
696
  });
@@ -1012,7 +1011,7 @@ var no_context_provider_default = createRule({
1012
1011
  }
1013
1012
  return {
1014
1013
  JSXElement(node) {
1015
- const elementName = JSX7__namespace.getElementName(node.openingElement);
1014
+ const elementName = JSX7__namespace.getElementName(node);
1016
1015
  if (!elementName.endsWith(".Provider")) {
1017
1016
  return;
1018
1017
  }
@@ -1438,7 +1437,7 @@ var no_implicit_key_default = createRule({
1438
1437
  return {
1439
1438
  JSXOpeningElement(node) {
1440
1439
  const initialScope = context.sourceCode.getScope(node);
1441
- const keyPropFound = JSX7__namespace.getAttributeNode("key", initialScope, node.attributes);
1440
+ const keyPropFound = JSX7__namespace.getAttribute("key", node.attributes, initialScope);
1442
1441
  const keyPropOnElement = node.attributes.some(
1443
1442
  (n) => n.type === types.AST_NODE_TYPES.JSXAttribute && n.name.type === types.AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
1444
1443
  );
@@ -1583,7 +1582,7 @@ var no_leaked_conditional_rendering_default = createRule({
1583
1582
  return getReportDescriptor(right);
1584
1583
  }
1585
1584
  const initialScope = context.sourceCode.getScope(left);
1586
- const isLeftNan = left.type === types.AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR__namespace.toResolved({ kind: "lazy", node: left, initialScope }).value === "NaN";
1585
+ const isLeftNan = left.type === types.AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR__namespace.toStaticValue({ kind: "lazy", node: left, initialScope }).value === "NaN";
1587
1586
  if (isLeftNan) {
1588
1587
  return {
1589
1588
  messageId: "noLeakedConditionalRendering",
@@ -1702,7 +1701,7 @@ var no_missing_key_default = createRule({
1702
1701
  switch (node.type) {
1703
1702
  case types.AST_NODE_TYPES.JSXElement: {
1704
1703
  const initialScope = context.sourceCode.getScope(node);
1705
- if (!JSX7__namespace.hasAttribute("key", initialScope, node.openingElement.attributes)) {
1704
+ if (!JSX7__namespace.hasAttribute("key", node.openingElement.attributes, initialScope)) {
1706
1705
  return {
1707
1706
  messageId: "noMissingKey",
1708
1707
  node
@@ -1763,7 +1762,7 @@ var no_missing_key_default = createRule({
1763
1762
  }
1764
1763
  const initialScope = context.sourceCode.getScope(node);
1765
1764
  for (const element of elements) {
1766
- if (!JSX7__namespace.hasAttribute("key", initialScope, element.openingElement.attributes)) {
1765
+ if (!JSX7__namespace.hasAttribute("key", element.openingElement.attributes, initialScope)) {
1767
1766
  context.report({
1768
1767
  messageId: "noMissingKey",
1769
1768
  node: element
@@ -1865,7 +1864,7 @@ var no_nested_components_default = createRule({
1865
1864
  continue;
1866
1865
  }
1867
1866
  const isInsideProperty = component.parent.type === types.AST_NODE_TYPES.Property;
1868
- const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || JSX7__namespace.findParentAttributeNode(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer) != null;
1867
+ const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || JSX7__namespace.findParentAttribute(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer) != null;
1869
1868
  if (isInsideJSXPropValue) {
1870
1869
  if (!core.isDeclaredInRenderPropLoose(component)) {
1871
1870
  context.report({
@@ -2893,9 +2892,7 @@ var no_useless_fragment_default = createRule({
2893
2892
  const { allowExpressions = true } = option;
2894
2893
  return {
2895
2894
  JSXElement(node) {
2896
- if (JSX7__namespace.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
2897
- return;
2898
- }
2895
+ if (!JSX7__namespace.isFragmentElement(node)) return;
2899
2896
  checkAndReport(node, context, allowExpressions);
2900
2897
  },
2901
2898
  JSXFragment(node) {
@@ -3007,7 +3004,7 @@ var prefer_react_namespace_import_default = createRule({
3007
3004
  },
3008
3005
  name: RULE_NAME46,
3009
3006
  create(context) {
3010
- const importSource = shared.getSettingsFromContext(context).importSource ?? "react";
3007
+ const { importSource } = shared.getSettingsFromContext(context);
3011
3008
  return {
3012
3009
  [`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
3013
3010
  const hasOtherSpecifiers = node.parent.specifiers.length > 1;
@@ -3153,9 +3150,7 @@ var prefer_shorthand_fragment_default = createRule({
3153
3150
  create(context) {
3154
3151
  return {
3155
3152
  JSXElement(node) {
3156
- if (JSX7__namespace.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
3157
- return;
3158
- }
3153
+ if (!JSX7__namespace.isFragmentElement(node)) return;
3159
3154
  const hasAttributes = node.openingElement.attributes.length > 0;
3160
3155
  if (hasAttributes) {
3161
3156
  return;
@@ -3169,9 +3164,7 @@ var prefer_shorthand_fragment_default = createRule({
3169
3164
  return [];
3170
3165
  }
3171
3166
  return [
3172
- // eslint-disable-next-line eslint-plugin/prefer-replace-text
3173
3167
  fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
3174
- // eslint-disable-next-line eslint-plugin/prefer-replace-text
3175
3168
  fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
3176
3169
  ];
3177
3170
  }
@@ -3187,7 +3180,6 @@ var use_jsx_vars_default = createRule({
3187
3180
  meta: {
3188
3181
  type: "problem",
3189
3182
  docs: {
3190
- // eslint-disable-next-line eslint-plugin/require-meta-docs-description
3191
3183
  description: "helpes `eslint/no-unused-vars` to correctly mark JSX variables as used.",
3192
3184
  [Symbol.for("rule_features")]: RULE_FEATURES49
3193
3185
  },
package/dist/index.mjs CHANGED
@@ -15,7 +15,7 @@ import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReado
15
15
 
16
16
  // package.json
17
17
  var name = "eslint-plugin-react-x";
18
- var version = "1.24.0-next.9";
18
+ var version = "1.24.0";
19
19
  var createRule = createRuleForPlugin("x");
20
20
 
21
21
  // src/rules/avoid-shorthand-boolean.ts
@@ -274,7 +274,7 @@ function isReactChildrenMethod(name2) {
274
274
  return reactChildrenMethod.some((method) => method === name2);
275
275
  }
276
276
  function isUsingReactChildren(node, context) {
277
- const settings = unsafeDecodeSettings(context.settings);
277
+ const { importSource = "react" } = unsafeDecodeSettings(context.settings);
278
278
  const { callee } = node;
279
279
  if (!("property" in callee) || !("object" in callee) || !("name" in callee.property)) {
280
280
  return false;
@@ -287,7 +287,7 @@ function isUsingReactChildren(node, context) {
287
287
  return true;
288
288
  }
289
289
  if (callee.object.type === AST_NODE_TYPES.MemberExpression && "name" in callee.object.object) {
290
- return isInitializedFromReact(callee.object.object.name, initialScope, settings.importSource);
290
+ return isInitializedFromReact(callee.object.object.name, importSource, initialScope);
291
291
  }
292
292
  return false;
293
293
  }
@@ -583,10 +583,10 @@ var no_children_prop_default = createRule({
583
583
  create(context) {
584
584
  return {
585
585
  JSXElement(node) {
586
- const attribute = JSX7.getAttributeNode(
586
+ const attribute = JSX7.getAttribute(
587
587
  "children",
588
- context.sourceCode.getScope(node),
589
- node.openingElement.attributes
588
+ node.openingElement.attributes,
589
+ context.sourceCode.getScope(node)
590
590
  );
591
591
  if (attribute != null) {
592
592
  context.report({
@@ -664,7 +664,6 @@ var no_class_component_default = createRule({
664
664
  messageId: "noClassComponent",
665
665
  node: component,
666
666
  data: {
667
- // eslint-disable-next-line eslint-plugin/no-unused-placeholders
668
667
  name: name2
669
668
  }
670
669
  });
@@ -985,7 +984,7 @@ var no_context_provider_default = createRule({
985
984
  }
986
985
  return {
987
986
  JSXElement(node) {
988
- const elementName = JSX7.getElementName(node.openingElement);
987
+ const elementName = JSX7.getElementName(node);
989
988
  if (!elementName.endsWith(".Provider")) {
990
989
  return;
991
990
  }
@@ -1411,7 +1410,7 @@ var no_implicit_key_default = createRule({
1411
1410
  return {
1412
1411
  JSXOpeningElement(node) {
1413
1412
  const initialScope = context.sourceCode.getScope(node);
1414
- const keyPropFound = JSX7.getAttributeNode("key", initialScope, node.attributes);
1413
+ const keyPropFound = JSX7.getAttribute("key", node.attributes, initialScope);
1415
1414
  const keyPropOnElement = node.attributes.some(
1416
1415
  (n) => n.type === AST_NODE_TYPES.JSXAttribute && n.name.type === AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
1417
1416
  );
@@ -1556,7 +1555,7 @@ var no_leaked_conditional_rendering_default = createRule({
1556
1555
  return getReportDescriptor(right);
1557
1556
  }
1558
1557
  const initialScope = context.sourceCode.getScope(left);
1559
- const isLeftNan = left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR.toResolved({ kind: "lazy", node: left, initialScope }).value === "NaN";
1558
+ const isLeftNan = left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR.toStaticValue({ kind: "lazy", node: left, initialScope }).value === "NaN";
1560
1559
  if (isLeftNan) {
1561
1560
  return {
1562
1561
  messageId: "noLeakedConditionalRendering",
@@ -1675,7 +1674,7 @@ var no_missing_key_default = createRule({
1675
1674
  switch (node.type) {
1676
1675
  case AST_NODE_TYPES.JSXElement: {
1677
1676
  const initialScope = context.sourceCode.getScope(node);
1678
- if (!JSX7.hasAttribute("key", initialScope, node.openingElement.attributes)) {
1677
+ if (!JSX7.hasAttribute("key", node.openingElement.attributes, initialScope)) {
1679
1678
  return {
1680
1679
  messageId: "noMissingKey",
1681
1680
  node
@@ -1736,7 +1735,7 @@ var no_missing_key_default = createRule({
1736
1735
  }
1737
1736
  const initialScope = context.sourceCode.getScope(node);
1738
1737
  for (const element of elements) {
1739
- if (!JSX7.hasAttribute("key", initialScope, element.openingElement.attributes)) {
1738
+ if (!JSX7.hasAttribute("key", element.openingElement.attributes, initialScope)) {
1740
1739
  context.report({
1741
1740
  messageId: "noMissingKey",
1742
1741
  node: element
@@ -1838,7 +1837,7 @@ var no_nested_components_default = createRule({
1838
1837
  continue;
1839
1838
  }
1840
1839
  const isInsideProperty = component.parent.type === AST_NODE_TYPES.Property;
1841
- const isInsideJSXPropValue = component.parent.type === AST_NODE_TYPES.JSXAttribute || JSX7.findParentAttributeNode(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer) != null;
1840
+ const isInsideJSXPropValue = component.parent.type === AST_NODE_TYPES.JSXAttribute || JSX7.findParentAttribute(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer) != null;
1842
1841
  if (isInsideJSXPropValue) {
1843
1842
  if (!isDeclaredInRenderPropLoose(component)) {
1844
1843
  context.report({
@@ -2866,9 +2865,7 @@ var no_useless_fragment_default = createRule({
2866
2865
  const { allowExpressions = true } = option;
2867
2866
  return {
2868
2867
  JSXElement(node) {
2869
- if (JSX7.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
2870
- return;
2871
- }
2868
+ if (!JSX7.isFragmentElement(node)) return;
2872
2869
  checkAndReport(node, context, allowExpressions);
2873
2870
  },
2874
2871
  JSXFragment(node) {
@@ -2980,7 +2977,7 @@ var prefer_react_namespace_import_default = createRule({
2980
2977
  },
2981
2978
  name: RULE_NAME46,
2982
2979
  create(context) {
2983
- const importSource = getSettingsFromContext(context).importSource ?? "react";
2980
+ const { importSource } = getSettingsFromContext(context);
2984
2981
  return {
2985
2982
  [`ImportDeclaration[source.value="${importSource}"] ImportDefaultSpecifier`](node) {
2986
2983
  const hasOtherSpecifiers = node.parent.specifiers.length > 1;
@@ -3126,9 +3123,7 @@ var prefer_shorthand_fragment_default = createRule({
3126
3123
  create(context) {
3127
3124
  return {
3128
3125
  JSXElement(node) {
3129
- if (JSX7.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
3130
- return;
3131
- }
3126
+ if (!JSX7.isFragmentElement(node)) return;
3132
3127
  const hasAttributes = node.openingElement.attributes.length > 0;
3133
3128
  if (hasAttributes) {
3134
3129
  return;
@@ -3142,9 +3137,7 @@ var prefer_shorthand_fragment_default = createRule({
3142
3137
  return [];
3143
3138
  }
3144
3139
  return [
3145
- // eslint-disable-next-line eslint-plugin/prefer-replace-text
3146
3140
  fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
3147
- // eslint-disable-next-line eslint-plugin/prefer-replace-text
3148
3141
  fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
3149
3142
  ];
3150
3143
  }
@@ -3160,7 +3153,6 @@ var use_jsx_vars_default = createRule({
3160
3153
  meta: {
3161
3154
  type: "problem",
3162
3155
  docs: {
3163
- // eslint-disable-next-line eslint-plugin/require-meta-docs-description
3164
3156
  description: "helpes `eslint/no-unused-vars` to correctly mark JSX variables as used.",
3165
3157
  [Symbol.for("rule_features")]: RULE_FEATURES49
3166
3158
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.24.0-next.9",
3
+ "version": "1.24.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",
@@ -47,13 +47,13 @@
47
47
  "compare-versions": "^6.1.1",
48
48
  "is-immutable-type": "^5.0.1",
49
49
  "string-ts": "^2.2.0",
50
- "ts-pattern": "^5.6.0",
51
- "@eslint-react/ast": "1.24.0-next.9",
52
- "@eslint-react/core": "1.24.0-next.9",
53
- "@eslint-react/eff": "1.24.0-next.9",
54
- "@eslint-react/shared": "1.24.0-next.9",
55
- "@eslint-react/jsx": "1.24.0-next.9",
56
- "@eslint-react/var": "1.24.0-next.9"
50
+ "ts-pattern": "^5.6.1",
51
+ "@eslint-react/core": "1.24.0",
52
+ "@eslint-react/eff": "1.24.0",
53
+ "@eslint-react/jsx": "1.24.0",
54
+ "@eslint-react/var": "1.24.0",
55
+ "@eslint-react/ast": "1.24.0",
56
+ "@eslint-react/shared": "1.24.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/react": "^19.0.7",