eslint-plugin-react-x 1.26.3-next.6 → 1.26.3-next.8

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.d.mts CHANGED
@@ -1,12 +1,8 @@
1
1
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
2
 
3
- type MessageID$3 = "noUselessFragment" | "noUselessFragmentInBuiltIn";
4
-
5
- type MessageID$2 = "noUnstableContextValue" | "noUnstableContextValueWithFunction" | "noUnstableContextValueWithIdentifier";
6
-
7
3
  type MessageID$1 = "nestedComponent" | "nestedComponentInProps";
8
4
 
9
- type MessageID = "noMissingKey" | "noMissingKeyWithFragment";
5
+ type MessageID = "missingKey" | "unexpectedFragmentSyntax";
10
6
 
11
7
  declare const _default: {
12
8
  meta: {
@@ -53,12 +49,12 @@ declare const _default: {
53
49
  "no-unsafe-component-will-mount": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillMount", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
54
50
  "no-unsafe-component-will-receive-props": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillReceiveProps", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
55
51
  "no-unsafe-component-will-update": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillUpdate", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
56
- "no-unstable-context-value": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
52
+ "no-unstable-context-value": _typescript_eslint_utils_ts_eslint.RuleModule<"unstableContextValue", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
57
53
  "no-unstable-default-props": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnstableDefaultProps", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
58
54
  "no-unused-class-component-members": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnusedClassComponentMembers", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
59
55
  "no-unused-state": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnusedState", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
60
56
  "no-use-context": _typescript_eslint_utils_ts_eslint.RuleModule<"noUseContext", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
61
- "no-useless-fragment": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$3, [{
57
+ "no-useless-fragment": _typescript_eslint_utils_ts_eslint.RuleModule<"uselessFragment", [{
62
58
  allowExpressions: boolean;
63
59
  }], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
64
60
  "prefer-destructuring-assignment": _typescript_eslint_utils_ts_eslint.RuleModule<"preferDestructuringAssignment", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,8 @@
1
1
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
2
 
3
- type MessageID$3 = "noUselessFragment" | "noUselessFragmentInBuiltIn";
4
-
5
- type MessageID$2 = "noUnstableContextValue" | "noUnstableContextValueWithFunction" | "noUnstableContextValueWithIdentifier";
6
-
7
3
  type MessageID$1 = "nestedComponent" | "nestedComponentInProps";
8
4
 
9
- type MessageID = "noMissingKey" | "noMissingKeyWithFragment";
5
+ type MessageID = "missingKey" | "unexpectedFragmentSyntax";
10
6
 
11
7
  declare const _default: {
12
8
  meta: {
@@ -53,12 +49,12 @@ declare const _default: {
53
49
  "no-unsafe-component-will-mount": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillMount", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
54
50
  "no-unsafe-component-will-receive-props": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillReceiveProps", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
55
51
  "no-unsafe-component-will-update": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnsafeComponentWillUpdate", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
56
- "no-unstable-context-value": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$2, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
52
+ "no-unstable-context-value": _typescript_eslint_utils_ts_eslint.RuleModule<"unstableContextValue", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
57
53
  "no-unstable-default-props": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnstableDefaultProps", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
58
54
  "no-unused-class-component-members": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnusedClassComponentMembers", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
59
55
  "no-unused-state": _typescript_eslint_utils_ts_eslint.RuleModule<"noUnusedState", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
60
56
  "no-use-context": _typescript_eslint_utils_ts_eslint.RuleModule<"noUseContext", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
61
- "no-useless-fragment": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID$3, [{
57
+ "no-useless-fragment": _typescript_eslint_utils_ts_eslint.RuleModule<"uselessFragment", [{
62
58
  allowExpressions: boolean;
63
59
  }], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
64
60
  "prefer-destructuring-assignment": _typescript_eslint_utils_ts_eslint.RuleModule<"preferDestructuringAssignment", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
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.26.3-next.6";
45
+ var version = "1.26.3-next.8";
46
46
  var createRule = shared.createRuleForPlugin("x");
47
47
 
48
48
  // src/utils/get-associated-tokens.ts
@@ -1693,8 +1693,8 @@ var no_missing_key_default = createRule({
1693
1693
  [Symbol.for("rule_features")]: RULE_FEATURES29
1694
1694
  },
1695
1695
  messages: {
1696
- noMissingKey: "Missing 'key' for element when rendering list.",
1697
- noMissingKeyWithFragment: "Use fragment component instead of '<>' because it does not support `key`."
1696
+ missingKey: "Missing 'key' for element when rendering list.",
1697
+ unexpectedFragmentSyntax: "Use fragment component instead of '<>' because it does not support `key`."
1698
1698
  },
1699
1699
  schema: []
1700
1700
  },
@@ -1707,7 +1707,7 @@ var no_missing_key_default = createRule({
1707
1707
  const initialScope = context.sourceCode.getScope(node);
1708
1708
  if (!JSX7__namespace.hasAttribute("key", node.openingElement.attributes, initialScope)) {
1709
1709
  return {
1710
- messageId: "noMissingKey",
1710
+ messageId: "missingKey",
1711
1711
  node
1712
1712
  };
1713
1713
  }
@@ -1715,7 +1715,7 @@ var no_missing_key_default = createRule({
1715
1715
  }
1716
1716
  case types.AST_NODE_TYPES.JSXFragment: {
1717
1717
  return {
1718
- messageId: "noMissingKeyWithFragment",
1718
+ messageId: "unexpectedFragmentSyntax",
1719
1719
  node
1720
1720
  };
1721
1721
  }
@@ -1768,7 +1768,7 @@ var no_missing_key_default = createRule({
1768
1768
  for (const element of elements) {
1769
1769
  if (!JSX7__namespace.hasAttribute("key", element.openingElement.attributes, initialScope)) {
1770
1770
  context.report({
1771
- messageId: "noMissingKey",
1771
+ messageId: "missingKey",
1772
1772
  node: element
1773
1773
  });
1774
1774
  }
@@ -1810,7 +1810,7 @@ var no_missing_key_default = createRule({
1810
1810
  }
1811
1811
  if (node.parent.type === types.AST_NODE_TYPES.ArrayExpression) {
1812
1812
  context.report({
1813
- messageId: "noMissingKeyWithFragment",
1813
+ messageId: "unexpectedFragmentSyntax",
1814
1814
  node
1815
1815
  });
1816
1816
  }
@@ -2364,9 +2364,7 @@ var no_unstable_context_value_default = createRule({
2364
2364
  [Symbol.for("rule_features")]: RULE_FEATURES40
2365
2365
  },
2366
2366
  messages: {
2367
- noUnstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render.",
2368
- noUnstableContextValueWithFunction: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. Consider wrapping it in a useCallback hook.",
2369
- noUnstableContextValueWithIdentifier: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. Consider wrapping it in a useMemo hook."
2367
+ unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
2370
2368
  },
2371
2369
  schema: []
2372
2370
  },
@@ -2406,12 +2404,13 @@ var no_unstable_context_value_default = createRule({
2406
2404
  for (const { node: component } of components) {
2407
2405
  for (const construction of constructions.get(component) ?? []) {
2408
2406
  const { kind, node: constructionNode } = construction;
2409
- const messageId = kind.startsWith("Function") ? "noUnstableContextValueWithFunction" : "noUnstableContextValueWithIdentifier";
2407
+ const suggestion = kind.startsWith("Function") ? "Consider wrapping it in a useCallback hook." : "Consider wrapping it in a useMemo hook.";
2410
2408
  context.report({
2411
- messageId,
2409
+ messageId: "unstableContextValue",
2412
2410
  node: constructionNode,
2413
2411
  data: {
2414
- type: AST11__namespace.toReadableNodeType(constructionNode)
2412
+ type: AST11__namespace.toReadableNodeType(constructionNode),
2413
+ suggestion
2415
2414
  }
2416
2415
  });
2417
2416
  }
@@ -2950,10 +2949,24 @@ function checkAndReport(node, context, allowExpressions) {
2950
2949
  return;
2951
2950
  }
2952
2951
  if (JSX7__namespace.isBuiltInElement(node.parent)) {
2953
- context.report({ messageId: "noUselessFragmentInBuiltIn", node, fix });
2952
+ context.report({
2953
+ messageId: "uselessFragment",
2954
+ node,
2955
+ data: {
2956
+ reason: "placed inside a built-in component"
2957
+ },
2958
+ fix
2959
+ });
2954
2960
  }
2955
2961
  if (node.children.length === 0) {
2956
- context.report({ messageId: "noUselessFragment", node, fix });
2962
+ context.report({
2963
+ messageId: "uselessFragment",
2964
+ node,
2965
+ data: {
2966
+ reason: "contains less than two children"
2967
+ },
2968
+ fix
2969
+ });
2957
2970
  return;
2958
2971
  }
2959
2972
  const isChildElement = AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent);
@@ -2964,11 +2977,25 @@ function checkAndReport(node, context, allowExpressions) {
2964
2977
  }
2965
2978
  // <Foo><>hello, world</></Foo>
2966
2979
  case (!allowExpressions && isChildElement): {
2967
- context.report({ messageId: "noUselessFragment", node, fix });
2980
+ context.report({
2981
+ messageId: "uselessFragment",
2982
+ node,
2983
+ data: {
2984
+ reason: "contains less than two children"
2985
+ },
2986
+ fix
2987
+ });
2968
2988
  return;
2969
2989
  }
2970
2990
  case (!allowExpressions && !isChildElement && node.children.length === 1): {
2971
- context.report({ messageId: "noUselessFragment", node, fix });
2991
+ context.report({
2992
+ messageId: "uselessFragment",
2993
+ node,
2994
+ data: {
2995
+ reason: "contains less than two children"
2996
+ },
2997
+ fix
2998
+ });
2972
2999
  return;
2973
3000
  }
2974
3001
  }
@@ -2977,7 +3004,14 @@ function checkAndReport(node, context, allowExpressions) {
2977
3004
  switch (true) {
2978
3005
  case nonPaddingChildren.length === 0:
2979
3006
  case (nonPaddingChildren.length === 1 && firstNonPaddingChild?.type !== types.AST_NODE_TYPES.JSXExpressionContainer): {
2980
- context.report({ messageId: "noUselessFragment", node, fix });
3007
+ context.report({
3008
+ messageId: "uselessFragment",
3009
+ node,
3010
+ data: {
3011
+ reason: "contains less than two children"
3012
+ },
3013
+ fix
3014
+ });
2981
3015
  return;
2982
3016
  }
2983
3017
  }
@@ -2988,12 +3022,11 @@ var no_useless_fragment_default = createRule({
2988
3022
  type: "problem",
2989
3023
  defaultOptions: [...defaultOptions],
2990
3024
  docs: {
2991
- description: "disallow unnecessary fragments"
3025
+ description: "disallow useless fragments"
2992
3026
  },
2993
3027
  fixable: "code",
2994
3028
  messages: {
2995
- noUselessFragment: "A fragment contains less than two children is unnecessary.",
2996
- noUselessFragmentInBuiltIn: "A fragment placed inside a built-in component is unnecessary."
3029
+ uselessFragment: "A fragment {{reason}} is useless."
2997
3030
  },
2998
3031
  schema: [{
2999
3032
  type: "object",
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.26.3-next.6";
18
+ var version = "1.26.3-next.8";
19
19
  var createRule = createRuleForPlugin("x");
20
20
 
21
21
  // src/utils/get-associated-tokens.ts
@@ -1666,8 +1666,8 @@ var no_missing_key_default = createRule({
1666
1666
  [Symbol.for("rule_features")]: RULE_FEATURES29
1667
1667
  },
1668
1668
  messages: {
1669
- noMissingKey: "Missing 'key' for element when rendering list.",
1670
- noMissingKeyWithFragment: "Use fragment component instead of '<>' because it does not support `key`."
1669
+ missingKey: "Missing 'key' for element when rendering list.",
1670
+ unexpectedFragmentSyntax: "Use fragment component instead of '<>' because it does not support `key`."
1671
1671
  },
1672
1672
  schema: []
1673
1673
  },
@@ -1680,7 +1680,7 @@ var no_missing_key_default = createRule({
1680
1680
  const initialScope = context.sourceCode.getScope(node);
1681
1681
  if (!JSX7.hasAttribute("key", node.openingElement.attributes, initialScope)) {
1682
1682
  return {
1683
- messageId: "noMissingKey",
1683
+ messageId: "missingKey",
1684
1684
  node
1685
1685
  };
1686
1686
  }
@@ -1688,7 +1688,7 @@ var no_missing_key_default = createRule({
1688
1688
  }
1689
1689
  case AST_NODE_TYPES.JSXFragment: {
1690
1690
  return {
1691
- messageId: "noMissingKeyWithFragment",
1691
+ messageId: "unexpectedFragmentSyntax",
1692
1692
  node
1693
1693
  };
1694
1694
  }
@@ -1741,7 +1741,7 @@ var no_missing_key_default = createRule({
1741
1741
  for (const element of elements) {
1742
1742
  if (!JSX7.hasAttribute("key", element.openingElement.attributes, initialScope)) {
1743
1743
  context.report({
1744
- messageId: "noMissingKey",
1744
+ messageId: "missingKey",
1745
1745
  node: element
1746
1746
  });
1747
1747
  }
@@ -1783,7 +1783,7 @@ var no_missing_key_default = createRule({
1783
1783
  }
1784
1784
  if (node.parent.type === AST_NODE_TYPES.ArrayExpression) {
1785
1785
  context.report({
1786
- messageId: "noMissingKeyWithFragment",
1786
+ messageId: "unexpectedFragmentSyntax",
1787
1787
  node
1788
1788
  });
1789
1789
  }
@@ -2337,9 +2337,7 @@ var no_unstable_context_value_default = createRule({
2337
2337
  [Symbol.for("rule_features")]: RULE_FEATURES40
2338
2338
  },
2339
2339
  messages: {
2340
- noUnstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render.",
2341
- noUnstableContextValueWithFunction: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. Consider wrapping it in a useCallback hook.",
2342
- noUnstableContextValueWithIdentifier: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. Consider wrapping it in a useMemo hook."
2340
+ unstableContextValue: "A/an '{{type}}' passed as the value prop to the context provider should not be constructed. It will change on every render. {{suggestion}}"
2343
2341
  },
2344
2342
  schema: []
2345
2343
  },
@@ -2379,12 +2377,13 @@ var no_unstable_context_value_default = createRule({
2379
2377
  for (const { node: component } of components) {
2380
2378
  for (const construction of constructions.get(component) ?? []) {
2381
2379
  const { kind, node: constructionNode } = construction;
2382
- const messageId = kind.startsWith("Function") ? "noUnstableContextValueWithFunction" : "noUnstableContextValueWithIdentifier";
2380
+ const suggestion = kind.startsWith("Function") ? "Consider wrapping it in a useCallback hook." : "Consider wrapping it in a useMemo hook.";
2383
2381
  context.report({
2384
- messageId,
2382
+ messageId: "unstableContextValue",
2385
2383
  node: constructionNode,
2386
2384
  data: {
2387
- type: AST11.toReadableNodeType(constructionNode)
2385
+ type: AST11.toReadableNodeType(constructionNode),
2386
+ suggestion
2388
2387
  }
2389
2388
  });
2390
2389
  }
@@ -2923,10 +2922,24 @@ function checkAndReport(node, context, allowExpressions) {
2923
2922
  return;
2924
2923
  }
2925
2924
  if (JSX7.isBuiltInElement(node.parent)) {
2926
- context.report({ messageId: "noUselessFragmentInBuiltIn", node, fix });
2925
+ context.report({
2926
+ messageId: "uselessFragment",
2927
+ node,
2928
+ data: {
2929
+ reason: "placed inside a built-in component"
2930
+ },
2931
+ fix
2932
+ });
2927
2933
  }
2928
2934
  if (node.children.length === 0) {
2929
- context.report({ messageId: "noUselessFragment", node, fix });
2935
+ context.report({
2936
+ messageId: "uselessFragment",
2937
+ node,
2938
+ data: {
2939
+ reason: "contains less than two children"
2940
+ },
2941
+ fix
2942
+ });
2930
2943
  return;
2931
2944
  }
2932
2945
  const isChildElement = AST11.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent);
@@ -2937,11 +2950,25 @@ function checkAndReport(node, context, allowExpressions) {
2937
2950
  }
2938
2951
  // <Foo><>hello, world</></Foo>
2939
2952
  case (!allowExpressions && isChildElement): {
2940
- context.report({ messageId: "noUselessFragment", node, fix });
2953
+ context.report({
2954
+ messageId: "uselessFragment",
2955
+ node,
2956
+ data: {
2957
+ reason: "contains less than two children"
2958
+ },
2959
+ fix
2960
+ });
2941
2961
  return;
2942
2962
  }
2943
2963
  case (!allowExpressions && !isChildElement && node.children.length === 1): {
2944
- context.report({ messageId: "noUselessFragment", node, fix });
2964
+ context.report({
2965
+ messageId: "uselessFragment",
2966
+ node,
2967
+ data: {
2968
+ reason: "contains less than two children"
2969
+ },
2970
+ fix
2971
+ });
2945
2972
  return;
2946
2973
  }
2947
2974
  }
@@ -2950,7 +2977,14 @@ function checkAndReport(node, context, allowExpressions) {
2950
2977
  switch (true) {
2951
2978
  case nonPaddingChildren.length === 0:
2952
2979
  case (nonPaddingChildren.length === 1 && firstNonPaddingChild?.type !== AST_NODE_TYPES.JSXExpressionContainer): {
2953
- context.report({ messageId: "noUselessFragment", node, fix });
2980
+ context.report({
2981
+ messageId: "uselessFragment",
2982
+ node,
2983
+ data: {
2984
+ reason: "contains less than two children"
2985
+ },
2986
+ fix
2987
+ });
2954
2988
  return;
2955
2989
  }
2956
2990
  }
@@ -2961,12 +2995,11 @@ var no_useless_fragment_default = createRule({
2961
2995
  type: "problem",
2962
2996
  defaultOptions: [...defaultOptions],
2963
2997
  docs: {
2964
- description: "disallow unnecessary fragments"
2998
+ description: "disallow useless fragments"
2965
2999
  },
2966
3000
  fixable: "code",
2967
3001
  messages: {
2968
- noUselessFragment: "A fragment contains less than two children is unnecessary.",
2969
- noUselessFragmentInBuiltIn: "A fragment placed inside a built-in component is unnecessary."
3002
+ uselessFragment: "A fragment {{reason}} is useless."
2970
3003
  },
2971
3004
  schema: [{
2972
3005
  type: "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.26.3-next.6",
3
+ "version": "1.26.3-next.8",
4
4
  "description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -50,12 +50,12 @@
50
50
  "is-immutable-type": "^5.0.1",
51
51
  "string-ts": "^2.2.1",
52
52
  "ts-pattern": "^5.6.2",
53
- "@eslint-react/ast": "1.26.3-next.6",
54
- "@eslint-react/core": "1.26.3-next.6",
55
- "@eslint-react/jsx": "1.26.3-next.6",
56
- "@eslint-react/eff": "1.26.3-next.6",
57
- "@eslint-react/shared": "1.26.3-next.6",
58
- "@eslint-react/var": "1.26.3-next.6"
53
+ "@eslint-react/ast": "1.26.3-next.8",
54
+ "@eslint-react/core": "1.26.3-next.8",
55
+ "@eslint-react/eff": "1.26.3-next.8",
56
+ "@eslint-react/jsx": "1.26.3-next.8",
57
+ "@eslint-react/shared": "1.26.3-next.8",
58
+ "@eslint-react/var": "1.26.3-next.8"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/react": "^19.0.8",