eslint-plugin-react-x 3.0.0-next.74 → 3.0.0-next.76

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 +201 -156
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -50,7 +50,6 @@ const conflictingRules$1 = [
50
50
  "react/jsx-key",
51
51
  "react/jsx-no-comment-textnodes",
52
52
  "react/jsx-no-constructed-context-values",
53
- "react/jsx-no-duplicate-props",
54
53
  "react/jsx-no-leaked-render",
55
54
  "react/jsx-no-script-url",
56
55
  "react/jsx-no-target-blank",
@@ -114,17 +113,17 @@ var disable_experimental_exports = /* @__PURE__ */ __exportAll({
114
113
  });
115
114
  const name$8 = "react-x/disable-experimental";
116
115
  const rules$8 = {
117
- "react-x/exhaustive-deps": "off",
118
116
  "react-x/immutability": "off",
119
117
  "react-x/jsx-key-before-spread": "off",
120
118
  "react-x/no-duplicate-key": "off",
119
+ "react-x/no-implicit-children": "off",
121
120
  "react-x/no-implicit-key": "off",
121
+ "react-x/no-implicit-ref": "off",
122
122
  "react-x/no-misused-capture-owner-stack": "off",
123
123
  "react-x/no-unnecessary-use-callback": "off",
124
124
  "react-x/no-unnecessary-use-memo": "off",
125
125
  "react-x/no-unused-props": "off",
126
126
  "react-x/refs": "off",
127
- "react-x/rules-of-hooks": "off",
128
127
  "react-x/set-state-in-render": "off",
129
128
  "react-x/unstable-rules-of-props": "off"
130
129
  };
@@ -137,7 +136,9 @@ var disable_type_checked_exports = /* @__PURE__ */ __exportAll({
137
136
  });
138
137
  const name$7 = "react-x/disable-type-checked";
139
138
  const rules$7 = {
139
+ "react-x/no-implicit-children": "off",
140
140
  "react-x/no-implicit-key": "off",
141
+ "react-x/no-implicit-ref": "off",
141
142
  "react-x/no-leaked-conditional-rendering": "off",
142
143
  "react-x/no-unused-props": "off"
143
144
  };
@@ -145,7 +146,7 @@ const rules$7 = {
145
146
  //#endregion
146
147
  //#region package.json
147
148
  var name$6 = "eslint-plugin-react-x";
148
- var version = "3.0.0-next.74";
149
+ var version = "3.0.0-next.76";
149
150
 
150
151
  //#endregion
151
152
  //#region src/utils/create-rule.ts
@@ -302,7 +303,7 @@ function getTypeVariants(types) {
302
303
 
303
304
  //#endregion
304
305
  //#region src/rules/component-hook-factories/component-hook-factories.ts
305
- const RULE_NAME$61 = "component-hook-factories";
306
+ const RULE_NAME$62 = "component-hook-factories";
306
307
  var component_hook_factories_default = createRule({
307
308
  meta: {
308
309
  type: "problem",
@@ -313,11 +314,11 @@ var component_hook_factories_default = createRule({
313
314
  },
314
315
  schema: []
315
316
  },
316
- name: RULE_NAME$61,
317
- create: create$61,
317
+ name: RULE_NAME$62,
318
+ create: create$62,
318
319
  defaultOptions: []
319
320
  });
320
- function create$61(context) {
321
+ function create$62(context) {
321
322
  const hint = core.ComponentDetectionHint.DoNotIncludeJsxWithNumberValue | core.ComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | core.ComponentDetectionHint.DoNotIncludeJsxWithNullValue | core.ComponentDetectionHint.DoNotIncludeJsxWithStringValue | core.ComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | core.ComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx | core.ComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayPattern | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedInArrayExpression | core.ComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback;
322
323
  const fCollector = core.useComponentCollector(context, { hint });
323
324
  const cCollector = core.useComponentCollectorLegacy(context);
@@ -361,7 +362,7 @@ function create$61(context) {
361
362
 
362
363
  //#endregion
363
364
  //#region src/rules/error-boundaries/error-boundaries.ts
364
- const RULE_NAME$60 = "error-boundaries";
365
+ const RULE_NAME$61 = "error-boundaries";
365
366
  var error_boundaries_default = createRule({
366
367
  meta: {
367
368
  type: "problem",
@@ -372,11 +373,11 @@ var error_boundaries_default = createRule({
372
373
  },
373
374
  schema: []
374
375
  },
375
- name: RULE_NAME$60,
376
- create: create$60,
376
+ name: RULE_NAME$61,
377
+ create: create$61,
377
378
  defaultOptions: []
378
379
  });
379
- function create$60(context) {
380
+ function create$61(context) {
380
381
  if (!context.sourceCode.text.includes("try")) return {};
381
382
  const { ctx, visitor } = core.useComponentCollector(context);
382
383
  const reported = /* @__PURE__ */ new Set();
@@ -1316,7 +1317,7 @@ function getUnknownDependenciesMessage(reactiveHookName) {
1316
1317
 
1317
1318
  //#endregion
1318
1319
  //#region src/rules/immutability/immutability.ts
1319
- const RULE_NAME$59 = "immutability";
1320
+ const RULE_NAME$60 = "immutability";
1320
1321
  /**
1321
1322
  * Array methods that mutate the array in place.
1322
1323
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
@@ -1342,11 +1343,11 @@ var immutability_default = createRule({
1342
1343
  },
1343
1344
  schema: []
1344
1345
  },
1345
- name: RULE_NAME$59,
1346
- create: create$59,
1346
+ name: RULE_NAME$60,
1347
+ create: create$60,
1347
1348
  defaultOptions: []
1348
1349
  });
1349
- function create$59(context) {
1350
+ function create$60(context) {
1350
1351
  const { additionalStateHooks } = getSettingsFromContext(context);
1351
1352
  const hCollector = core.useHookCollector(context);
1352
1353
  const cCollector = core.useComponentCollector(context);
@@ -1467,7 +1468,7 @@ function create$59(context) {
1467
1468
 
1468
1469
  //#endregion
1469
1470
  //#region src/rules/jsx-dollar/jsx-dollar.ts
1470
- const RULE_NAME$58 = "jsx-dollar";
1471
+ const RULE_NAME$59 = "jsx-dollar";
1471
1472
  var jsx_dollar_default = createRule({
1472
1473
  meta: {
1473
1474
  type: "suggestion",
@@ -1480,11 +1481,11 @@ var jsx_dollar_default = createRule({
1480
1481
  },
1481
1482
  schema: []
1482
1483
  },
1483
- name: RULE_NAME$58,
1484
- create: create$58,
1484
+ name: RULE_NAME$59,
1485
+ create: create$59,
1485
1486
  defaultOptions: []
1486
1487
  });
1487
- function create$58(context) {
1488
+ function create$59(context) {
1488
1489
  /**
1489
1490
  * Visitor function for JSXElement and JSXFragment nodes
1490
1491
  * @param node The JSXElement or JSXFragment node to be checked
@@ -1525,7 +1526,7 @@ function create$58(context) {
1525
1526
 
1526
1527
  //#endregion
1527
1528
  //#region src/rules/jsx-key-before-spread/jsx-key-before-spread.ts
1528
- const RULE_NAME$57 = "jsx-key-before-spread";
1529
+ const RULE_NAME$58 = "jsx-key-before-spread";
1529
1530
  var jsx_key_before_spread_default = createRule({
1530
1531
  meta: {
1531
1532
  type: "problem",
@@ -1533,11 +1534,11 @@ var jsx_key_before_spread_default = createRule({
1533
1534
  messages: { default: "The 'key' prop must be placed before any spread props when using the new JSX transform." },
1534
1535
  schema: []
1535
1536
  },
1536
- name: RULE_NAME$57,
1537
- create: create$57,
1537
+ name: RULE_NAME$58,
1538
+ create: create$58,
1538
1539
  defaultOptions: []
1539
1540
  });
1540
- function create$57(context) {
1541
+ function create$58(context) {
1541
1542
  const { jsx } = JsxInspector.from(context).jsxConfig;
1542
1543
  if (jsx !== JsxEmit.ReactJSX && jsx !== JsxEmit.ReactJSXDev) return {};
1543
1544
  return defineRuleListener({ JSXOpeningElement(node) {
@@ -1558,7 +1559,7 @@ function create$57(context) {
1558
1559
 
1559
1560
  //#endregion
1560
1561
  //#region src/rules/jsx-no-comment-textnodes/jsx-no-comment-textnodes.ts
1561
- const RULE_NAME$56 = "jsx-no-comment-textnodes";
1562
+ const RULE_NAME$57 = "jsx-no-comment-textnodes";
1562
1563
  var jsx_no_comment_textnodes_default = createRule({
1563
1564
  meta: {
1564
1565
  type: "problem",
@@ -1566,11 +1567,11 @@ var jsx_no_comment_textnodes_default = createRule({
1566
1567
  messages: { default: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces." },
1567
1568
  schema: []
1568
1569
  },
1569
- name: RULE_NAME$56,
1570
- create: create$56,
1570
+ name: RULE_NAME$57,
1571
+ create: create$57,
1571
1572
  defaultOptions: []
1572
1573
  });
1573
- function create$56(context) {
1574
+ function create$57(context) {
1574
1575
  function hasCommentLike(node) {
1575
1576
  if (ast.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) return false;
1576
1577
  return /^\s*\/(?:\/|\*)/mu.test(context.sourceCode.getText(node));
@@ -1589,42 +1590,9 @@ function create$56(context) {
1589
1590
  });
1590
1591
  }
1591
1592
 
1592
- //#endregion
1593
- //#region src/rules/jsx-no-duplicate-props/jsx-no-duplicate-props.ts
1594
- const RULE_NAME$55 = "jsx-no-duplicate-props";
1595
- var jsx_no_duplicate_props_default = createRule({
1596
- meta: {
1597
- type: "problem",
1598
- docs: { description: "Disallows duplicate props in JSX elements." },
1599
- messages: { default: "This JSX property is assigned multiple times." },
1600
- schema: []
1601
- },
1602
- name: RULE_NAME$55,
1603
- create: create$55,
1604
- defaultOptions: []
1605
- });
1606
- function create$55(context) {
1607
- return defineRuleListener({ JSXOpeningElement(node) {
1608
- const props = [];
1609
- for (const attr of node.attributes) {
1610
- if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) continue;
1611
- const name = attr.name.name;
1612
- if (typeof name !== "string") continue;
1613
- if (!props.includes(name)) {
1614
- props.push(name);
1615
- continue;
1616
- }
1617
- context.report({
1618
- messageId: "default",
1619
- node: attr
1620
- });
1621
- }
1622
- } });
1623
- }
1624
-
1625
1593
  //#endregion
1626
1594
  //#region src/rules/jsx-shorthand-boolean/jsx-shorthand-boolean.ts
1627
- const RULE_NAME$54 = "jsx-shorthand-boolean";
1595
+ const RULE_NAME$56 = "jsx-shorthand-boolean";
1628
1596
  const defaultOptions$4 = [1];
1629
1597
  const schema$4 = [{
1630
1598
  type: "integer",
@@ -1638,11 +1606,11 @@ var jsx_shorthand_boolean_default = createRule({
1638
1606
  messages: { default: "{{message}}" },
1639
1607
  schema: schema$4
1640
1608
  },
1641
- name: RULE_NAME$54,
1642
- create: create$54,
1609
+ name: RULE_NAME$56,
1610
+ create: create$56,
1643
1611
  defaultOptions: defaultOptions$4
1644
1612
  });
1645
- function create$54(context) {
1613
+ function create$56(context) {
1646
1614
  const policy = context.options[0] ?? defaultOptions$4[0];
1647
1615
  const jsx = JsxInspector.from(context);
1648
1616
  return defineRuleListener({ JSXAttribute(node) {
@@ -1671,7 +1639,7 @@ function create$54(context) {
1671
1639
 
1672
1640
  //#endregion
1673
1641
  //#region src/rules/jsx-shorthand-fragment/jsx-shorthand-fragment.ts
1674
- const RULE_NAME$53 = "jsx-shorthand-fragment";
1642
+ const RULE_NAME$55 = "jsx-shorthand-fragment";
1675
1643
  const defaultOptions$3 = [1];
1676
1644
  const schema$3 = [{
1677
1645
  type: "integer",
@@ -1685,11 +1653,11 @@ var jsx_shorthand_fragment_default = createRule({
1685
1653
  messages: { default: "{{message}}" },
1686
1654
  schema: schema$3
1687
1655
  },
1688
- name: RULE_NAME$53,
1689
- create: create$53,
1656
+ name: RULE_NAME$55,
1657
+ create: create$55,
1690
1658
  defaultOptions: defaultOptions$3
1691
1659
  });
1692
- function create$53(context) {
1660
+ function create$55(context) {
1693
1661
  const policy = context.options[0] ?? defaultOptions$3[0];
1694
1662
  const jsx = JsxInspector.from(context);
1695
1663
  const { jsxFragmentFactory } = jsx.jsxConfig;
@@ -1906,7 +1874,7 @@ function getOrElseUpdate(map, key, callback) {
1906
1874
 
1907
1875
  //#endregion
1908
1876
  //#region src/rules/no-access-state-in-setstate/no-access-state-in-setstate.ts
1909
- const RULE_NAME$52 = "no-access-state-in-setstate";
1877
+ const RULE_NAME$54 = "no-access-state-in-setstate";
1910
1878
  function isKeyLiteral$2(node, key) {
1911
1879
  return match(key).with({ type: AST_NODE_TYPES.Literal }, constTrue).with({
1912
1880
  type: AST_NODE_TYPES.TemplateLiteral,
@@ -1920,11 +1888,11 @@ var no_access_state_in_setstate_default = createRule({
1920
1888
  messages: { default: "Do not access 'this.state' within 'setState'. Use the update function instead." },
1921
1889
  schema: []
1922
1890
  },
1923
- name: RULE_NAME$52,
1924
- create: create$52,
1891
+ name: RULE_NAME$54,
1892
+ create: create$54,
1925
1893
  defaultOptions: []
1926
1894
  });
1927
- function create$52(context) {
1895
+ function create$54(context) {
1928
1896
  if (!context.sourceCode.text.includes("setState")) return {};
1929
1897
  const classStack = [];
1930
1898
  const methodStack = [];
@@ -1995,7 +1963,7 @@ function create$52(context) {
1995
1963
 
1996
1964
  //#endregion
1997
1965
  //#region src/rules/no-array-index-key/no-array-index-key.ts
1998
- const RULE_NAME$51 = "no-array-index-key";
1966
+ const RULE_NAME$53 = "no-array-index-key";
1999
1967
  function getIndexParamPosition(methodName) {
2000
1968
  switch (methodName) {
2001
1969
  case "every":
@@ -2040,11 +2008,11 @@ var no_array_index_key_default = createRule({
2040
2008
  messages: { default: "Do not use item index in the array as its key." },
2041
2009
  schema: []
2042
2010
  },
2043
- name: RULE_NAME$51,
2044
- create: create$51,
2011
+ name: RULE_NAME$53,
2012
+ create: create$53,
2045
2013
  defaultOptions: []
2046
2014
  });
2047
- function create$51(context) {
2015
+ function create$53(context) {
2048
2016
  const indexParamNames = [];
2049
2017
  function isArrayIndex(node) {
2050
2018
  return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name) => name != null && name === node.name);
@@ -2110,7 +2078,7 @@ function create$51(context) {
2110
2078
 
2111
2079
  //#endregion
2112
2080
  //#region src/rules/no-children-count/no-children-count.ts
2113
- const RULE_NAME$50 = "no-children-count";
2081
+ const RULE_NAME$52 = "no-children-count";
2114
2082
  var no_children_count_default = createRule({
2115
2083
  meta: {
2116
2084
  type: "suggestion",
@@ -2118,11 +2086,11 @@ var no_children_count_default = createRule({
2118
2086
  messages: { default: "Using 'Children.count' is uncommon and can lead to fragile code. Use alternatives instead." },
2119
2087
  schema: []
2120
2088
  },
2121
- name: RULE_NAME$50,
2122
- create: create$50,
2089
+ name: RULE_NAME$52,
2090
+ create: create$52,
2123
2091
  defaultOptions: []
2124
2092
  });
2125
- function create$50(context) {
2093
+ function create$52(context) {
2126
2094
  return defineRuleListener({ MemberExpression(node) {
2127
2095
  if (core.isChildrenCount(context, node)) context.report({
2128
2096
  messageId: "default",
@@ -2133,7 +2101,7 @@ function create$50(context) {
2133
2101
 
2134
2102
  //#endregion
2135
2103
  //#region src/rules/no-children-for-each/no-children-for-each.ts
2136
- const RULE_NAME$49 = "no-children-for-each";
2104
+ const RULE_NAME$51 = "no-children-for-each";
2137
2105
  var no_children_for_each_default = createRule({
2138
2106
  meta: {
2139
2107
  type: "suggestion",
@@ -2141,11 +2109,11 @@ var no_children_for_each_default = createRule({
2141
2109
  messages: { default: "Using 'Children.forEach' is uncommon and can lead to fragile code. Use alternatives instead." },
2142
2110
  schema: []
2143
2111
  },
2144
- name: RULE_NAME$49,
2145
- create: create$49,
2112
+ name: RULE_NAME$51,
2113
+ create: create$51,
2146
2114
  defaultOptions: []
2147
2115
  });
2148
- function create$49(context) {
2116
+ function create$51(context) {
2149
2117
  return defineRuleListener({ MemberExpression(node) {
2150
2118
  if (core.isChildrenForEach(context, node)) context.report({
2151
2119
  messageId: "default",
@@ -2156,7 +2124,7 @@ function create$49(context) {
2156
2124
 
2157
2125
  //#endregion
2158
2126
  //#region src/rules/no-children-map/no-children-map.ts
2159
- const RULE_NAME$48 = "no-children-map";
2127
+ const RULE_NAME$50 = "no-children-map";
2160
2128
  var no_children_map_default = createRule({
2161
2129
  meta: {
2162
2130
  type: "suggestion",
@@ -2164,11 +2132,11 @@ var no_children_map_default = createRule({
2164
2132
  messages: { default: "Using 'Children.map' is uncommon and can lead to fragile code. Use alternatives instead." },
2165
2133
  schema: []
2166
2134
  },
2167
- name: RULE_NAME$48,
2168
- create: create$48,
2135
+ name: RULE_NAME$50,
2136
+ create: create$50,
2169
2137
  defaultOptions: []
2170
2138
  });
2171
- function create$48(context) {
2139
+ function create$50(context) {
2172
2140
  return defineRuleListener({ MemberExpression(node) {
2173
2141
  if (core.isChildrenMap(context, node)) context.report({
2174
2142
  messageId: "default",
@@ -2179,7 +2147,7 @@ function create$48(context) {
2179
2147
 
2180
2148
  //#endregion
2181
2149
  //#region src/rules/no-children-only/no-children-only.ts
2182
- const RULE_NAME$47 = "no-children-only";
2150
+ const RULE_NAME$49 = "no-children-only";
2183
2151
  var no_children_only_default = createRule({
2184
2152
  meta: {
2185
2153
  type: "suggestion",
@@ -2187,11 +2155,11 @@ var no_children_only_default = createRule({
2187
2155
  messages: { default: "Using 'Children.only' is uncommon and can lead to fragile code. Use alternatives instead." },
2188
2156
  schema: []
2189
2157
  },
2190
- name: RULE_NAME$47,
2191
- create: create$47,
2158
+ name: RULE_NAME$49,
2159
+ create: create$49,
2192
2160
  defaultOptions: []
2193
2161
  });
2194
- function create$47(context) {
2162
+ function create$49(context) {
2195
2163
  return defineRuleListener({ MemberExpression(node) {
2196
2164
  if (core.isChildrenOnly(context, node)) context.report({
2197
2165
  messageId: "default",
@@ -2202,7 +2170,7 @@ function create$47(context) {
2202
2170
 
2203
2171
  //#endregion
2204
2172
  //#region src/rules/no-children-prop/no-children-prop.ts
2205
- const RULE_NAME$46 = "no-children-prop";
2173
+ const RULE_NAME$48 = "no-children-prop";
2206
2174
  var no_children_prop_default = createRule({
2207
2175
  meta: {
2208
2176
  type: "suggestion",
@@ -2210,11 +2178,11 @@ var no_children_prop_default = createRule({
2210
2178
  messages: { default: "Do not pass 'children' as props." },
2211
2179
  schema: []
2212
2180
  },
2213
- name: RULE_NAME$46,
2214
- create: create$46,
2181
+ name: RULE_NAME$48,
2182
+ create: create$48,
2215
2183
  defaultOptions: []
2216
2184
  });
2217
- function create$46(context) {
2185
+ function create$48(context) {
2218
2186
  const jsx = JsxInspector.from(context);
2219
2187
  return defineRuleListener({ JSXElement(node) {
2220
2188
  const childrenProp = jsx.findAttribute(node, "children");
@@ -2227,7 +2195,7 @@ function create$46(context) {
2227
2195
 
2228
2196
  //#endregion
2229
2197
  //#region src/rules/no-children-to-array/no-children-to-array.ts
2230
- const RULE_NAME$45 = "no-children-to-array";
2198
+ const RULE_NAME$47 = "no-children-to-array";
2231
2199
  var no_children_to_array_default = createRule({
2232
2200
  meta: {
2233
2201
  type: "suggestion",
@@ -2235,11 +2203,11 @@ var no_children_to_array_default = createRule({
2235
2203
  messages: { default: "Using 'Children.toArray' is uncommon and can lead to fragile code. Use alternatives instead." },
2236
2204
  schema: []
2237
2205
  },
2238
- name: RULE_NAME$45,
2239
- create: create$45,
2206
+ name: RULE_NAME$47,
2207
+ create: create$47,
2240
2208
  defaultOptions: []
2241
2209
  });
2242
- function create$45(context) {
2210
+ function create$47(context) {
2243
2211
  return defineRuleListener({ MemberExpression(node) {
2244
2212
  if (core.isChildrenToArray(context, node)) context.report({
2245
2213
  messageId: "default",
@@ -2250,7 +2218,7 @@ function create$45(context) {
2250
2218
 
2251
2219
  //#endregion
2252
2220
  //#region src/rules/no-class-component/no-class-component.ts
2253
- const RULE_NAME$44 = "no-class-component";
2221
+ const RULE_NAME$46 = "no-class-component";
2254
2222
  var no_class_component_default = createRule({
2255
2223
  meta: {
2256
2224
  type: "suggestion",
@@ -2258,11 +2226,11 @@ var no_class_component_default = createRule({
2258
2226
  messages: { default: "Avoid using class components. Use function components instead." },
2259
2227
  schema: []
2260
2228
  },
2261
- name: RULE_NAME$44,
2262
- create: create$44,
2229
+ name: RULE_NAME$46,
2230
+ create: create$46,
2263
2231
  defaultOptions: []
2264
2232
  });
2265
- function create$44(context) {
2233
+ function create$46(context) {
2266
2234
  if (!context.sourceCode.text.includes("Component")) return {};
2267
2235
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2268
2236
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2279,7 +2247,7 @@ function create$44(context) {
2279
2247
 
2280
2248
  //#endregion
2281
2249
  //#region src/rules/no-clone-element/no-clone-element.ts
2282
- const RULE_NAME$43 = "no-clone-element";
2250
+ const RULE_NAME$45 = "no-clone-element";
2283
2251
  var no_clone_element_default = createRule({
2284
2252
  meta: {
2285
2253
  type: "suggestion",
@@ -2287,11 +2255,11 @@ var no_clone_element_default = createRule({
2287
2255
  messages: { default: "Using 'cloneElement' is uncommon and can lead to fragile code. Use alternatives instead." },
2288
2256
  schema: []
2289
2257
  },
2290
- name: RULE_NAME$43,
2291
- create: create$43,
2258
+ name: RULE_NAME$45,
2259
+ create: create$45,
2292
2260
  defaultOptions: []
2293
2261
  });
2294
- function create$43(context) {
2262
+ function create$45(context) {
2295
2263
  return defineRuleListener({ CallExpression(node) {
2296
2264
  if (core.isCloneElementCall(context, node)) context.report({
2297
2265
  messageId: "default",
@@ -2302,7 +2270,7 @@ function create$43(context) {
2302
2270
 
2303
2271
  //#endregion
2304
2272
  //#region src/rules/no-component-will-mount/no-component-will-mount.ts
2305
- const RULE_NAME$42 = "no-component-will-mount";
2273
+ const RULE_NAME$44 = "no-component-will-mount";
2306
2274
  var no_component_will_mount_default = createRule({
2307
2275
  meta: {
2308
2276
  type: "problem",
@@ -2311,11 +2279,11 @@ var no_component_will_mount_default = createRule({
2311
2279
  messages: { default: "[Deprecated] Use 'UNSAFE_componentWillMount' instead." },
2312
2280
  schema: []
2313
2281
  },
2314
- name: RULE_NAME$42,
2315
- create: create$42,
2282
+ name: RULE_NAME$44,
2283
+ create: create$44,
2316
2284
  defaultOptions: []
2317
2285
  });
2318
- function create$42(context) {
2286
+ function create$44(context) {
2319
2287
  if (!context.sourceCode.text.includes("componentWillMount")) return {};
2320
2288
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2321
2289
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2335,7 +2303,7 @@ function create$42(context) {
2335
2303
 
2336
2304
  //#endregion
2337
2305
  //#region src/rules/no-component-will-receive-props/no-component-will-receive-props.ts
2338
- const RULE_NAME$41 = "no-component-will-receive-props";
2306
+ const RULE_NAME$43 = "no-component-will-receive-props";
2339
2307
  var no_component_will_receive_props_default = createRule({
2340
2308
  meta: {
2341
2309
  type: "problem",
@@ -2344,11 +2312,11 @@ var no_component_will_receive_props_default = createRule({
2344
2312
  messages: { default: "[Deprecated] Use 'UNSAFE_componentWillReceiveProps' instead." },
2345
2313
  schema: []
2346
2314
  },
2347
- name: RULE_NAME$41,
2348
- create: create$41,
2315
+ name: RULE_NAME$43,
2316
+ create: create$43,
2349
2317
  defaultOptions: []
2350
2318
  });
2351
- function create$41(context) {
2319
+ function create$43(context) {
2352
2320
  if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
2353
2321
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2354
2322
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2368,7 +2336,7 @@ function create$41(context) {
2368
2336
 
2369
2337
  //#endregion
2370
2338
  //#region src/rules/no-component-will-update/no-component-will-update.ts
2371
- const RULE_NAME$40 = "no-component-will-update";
2339
+ const RULE_NAME$42 = "no-component-will-update";
2372
2340
  var no_component_will_update_default = createRule({
2373
2341
  meta: {
2374
2342
  type: "problem",
@@ -2377,11 +2345,11 @@ var no_component_will_update_default = createRule({
2377
2345
  messages: { default: "[Deprecated] Use 'UNSAFE_componentWillUpdate' instead." },
2378
2346
  schema: []
2379
2347
  },
2380
- name: RULE_NAME$40,
2381
- create: create$40,
2348
+ name: RULE_NAME$42,
2349
+ create: create$42,
2382
2350
  defaultOptions: []
2383
2351
  });
2384
- function create$40(context) {
2352
+ function create$42(context) {
2385
2353
  if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
2386
2354
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
2387
2355
  return defineRuleListener(visitor, { "Program:exit"(program) {
@@ -2401,7 +2369,7 @@ function create$40(context) {
2401
2369
 
2402
2370
  //#endregion
2403
2371
  //#region src/rules/no-context-provider/no-context-provider.ts
2404
- const RULE_NAME$39 = "no-context-provider";
2372
+ const RULE_NAME$41 = "no-context-provider";
2405
2373
  var no_context_provider_default = createRule({
2406
2374
  meta: {
2407
2375
  type: "suggestion",
@@ -2414,11 +2382,11 @@ var no_context_provider_default = createRule({
2414
2382
  },
2415
2383
  schema: []
2416
2384
  },
2417
- name: RULE_NAME$39,
2418
- create: create$39,
2385
+ name: RULE_NAME$41,
2386
+ create: create$41,
2419
2387
  defaultOptions: []
2420
2388
  });
2421
- function create$39(context) {
2389
+ function create$41(context) {
2422
2390
  if (!context.sourceCode.text.includes("Provider")) return {};
2423
2391
  const { version } = getSettingsFromContext(context);
2424
2392
  if (compare(version, "19.0.0", "<")) return {};
@@ -2449,7 +2417,7 @@ function create$39(context) {
2449
2417
 
2450
2418
  //#endregion
2451
2419
  //#region src/rules/no-create-ref/no-create-ref.ts
2452
- const RULE_NAME$38 = "no-create-ref";
2420
+ const RULE_NAME$40 = "no-create-ref";
2453
2421
  var no_create_ref_default = createRule({
2454
2422
  meta: {
2455
2423
  type: "suggestion",
@@ -2457,11 +2425,11 @@ var no_create_ref_default = createRule({
2457
2425
  messages: { default: "[Deprecated] Use 'useRef' instead." },
2458
2426
  schema: []
2459
2427
  },
2460
- name: RULE_NAME$38,
2461
- create: create$38,
2428
+ name: RULE_NAME$40,
2429
+ create: create$40,
2462
2430
  defaultOptions: []
2463
2431
  });
2464
- function create$38(context) {
2432
+ function create$40(context) {
2465
2433
  return defineRuleListener({ CallExpression(node) {
2466
2434
  if (core.isCreateRefCall(context, node) && ast.findParentNode(node, core.isClassComponent) == null) context.report({
2467
2435
  messageId: "default",
@@ -2472,7 +2440,7 @@ function create$38(context) {
2472
2440
 
2473
2441
  //#endregion
2474
2442
  //#region src/rules/no-direct-mutation-state/no-direct-mutation-state.ts
2475
- const RULE_NAME$37 = "no-direct-mutation-state";
2443
+ const RULE_NAME$39 = "no-direct-mutation-state";
2476
2444
  function isConstructorFunction(node) {
2477
2445
  return ast.isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && ast.isMethodOrProperty(node.parent) && node.parent.key.type === AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
2478
2446
  }
@@ -2483,11 +2451,11 @@ var no_direct_mutation_state_default = createRule({
2483
2451
  messages: { default: "Do not mutate state directly. Use 'setState()' instead." },
2484
2452
  schema: []
2485
2453
  },
2486
- name: RULE_NAME$37,
2487
- create: create$37,
2454
+ name: RULE_NAME$39,
2455
+ create: create$39,
2488
2456
  defaultOptions: []
2489
2457
  });
2490
- function create$37(context) {
2458
+ function create$39(context) {
2491
2459
  return defineRuleListener({ AssignmentExpression(node) {
2492
2460
  if (!core.isAssignmentToThisState(node)) return;
2493
2461
  const parentClass = ast.findParentNode(node, ast.isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]));
@@ -2501,7 +2469,7 @@ function create$37(context) {
2501
2469
 
2502
2470
  //#endregion
2503
2471
  //#region src/rules/no-duplicate-key/no-duplicate-key.ts
2504
- const RULE_NAME$36 = "no-duplicate-key";
2472
+ const RULE_NAME$38 = "no-duplicate-key";
2505
2473
  var no_duplicate_key_default = createRule({
2506
2474
  meta: {
2507
2475
  type: "problem",
@@ -2509,11 +2477,11 @@ var no_duplicate_key_default = createRule({
2509
2477
  messages: { default: "The 'key' prop must be unique to its sibling elements." },
2510
2478
  schema: []
2511
2479
  },
2512
- name: RULE_NAME$36,
2513
- create: create$36,
2480
+ name: RULE_NAME$38,
2481
+ create: create$38,
2514
2482
  defaultOptions: []
2515
2483
  });
2516
- function create$36(context) {
2484
+ function create$38(context) {
2517
2485
  if (!context.sourceCode.text.includes("key=")) return {};
2518
2486
  const keyedEntries = /* @__PURE__ */ new Map();
2519
2487
  function isKeyValueEqual(a, b) {
@@ -2568,7 +2536,7 @@ function create$36(context) {
2568
2536
 
2569
2537
  //#endregion
2570
2538
  //#region src/rules/no-forward-ref/no-forward-ref.ts
2571
- const RULE_NAME$35 = "no-forward-ref";
2539
+ const RULE_NAME$37 = "no-forward-ref";
2572
2540
  var no_forward_ref_default = createRule({
2573
2541
  meta: {
2574
2542
  type: "suggestion",
@@ -2581,11 +2549,11 @@ var no_forward_ref_default = createRule({
2581
2549
  },
2582
2550
  schema: []
2583
2551
  },
2584
- name: RULE_NAME$35,
2585
- create: create$35,
2552
+ name: RULE_NAME$37,
2553
+ create: create$37,
2586
2554
  defaultOptions: []
2587
2555
  });
2588
- function create$35(context) {
2556
+ function create$37(context) {
2589
2557
  if (!context.sourceCode.text.includes("forwardRef")) return {};
2590
2558
  const { version } = getSettingsFromContext(context);
2591
2559
  if (compare(version, "19.0.0", "<")) return {};
@@ -2688,9 +2656,47 @@ function getComponentPropsFixes(context, fixer, node, typeArguments) {
2688
2656
  ].join(" ")), ...arg1 == null ? [] : [fixer.remove(arg1), fixer.removeRange([arg0.range[1], arg1.range[0]])]];
2689
2657
  }
2690
2658
 
2659
+ //#endregion
2660
+ //#region src/rules/no-implicit-children/no-implicit-children.ts
2661
+ const RULE_NAME$36 = "no-implicit-children";
2662
+ const RE_REACT_CHILDREN_TYPE = /react\.(reactnode|reactelement|reactportal)$/i;
2663
+ var no_implicit_children_default = createRule({
2664
+ meta: {
2665
+ type: "problem",
2666
+ docs: { description: "Prevents implicitly passing the 'children' prop to components." },
2667
+ messages: { default: "This spread attribute implicitly passes the 'children' prop to a component, this could lead to unexpected behavior. If you intend to pass the 'children' prop, use 'children={value}'." },
2668
+ schema: []
2669
+ },
2670
+ name: RULE_NAME$36,
2671
+ create: create$36,
2672
+ defaultOptions: []
2673
+ });
2674
+ function create$36(context) {
2675
+ const services = ESLintUtils.getParserServices(context, false);
2676
+ const checker = services.program.getTypeChecker();
2677
+ return defineRuleListener({ JSXSpreadAttribute(node) {
2678
+ for (const type of unionConstituents(getConstrainedTypeAtLocation(services, node.argument))) {
2679
+ const children = type.getProperty("children");
2680
+ if (children == null) continue;
2681
+ const fqn = getFullyQualifiedNameEx(checker, children).toLowerCase();
2682
+ if (fqn.endsWith("attributes.children") || fqn.endsWith("propswithchildren.children")) continue;
2683
+ const childrenType = checker.getTypeOfSymbol(children);
2684
+ const typeSymbol = childrenType.aliasSymbol ?? childrenType.symbol;
2685
+ if (typeSymbol != null) {
2686
+ const typeFqn = checker.getFullyQualifiedName(typeSymbol);
2687
+ if (RE_REACT_CHILDREN_TYPE.test(typeFqn) || /^JSX\.Element$/i.test(typeFqn)) continue;
2688
+ }
2689
+ context.report({
2690
+ messageId: "default",
2691
+ node
2692
+ });
2693
+ }
2694
+ } });
2695
+ }
2696
+
2691
2697
  //#endregion
2692
2698
  //#region src/rules/no-implicit-key/no-implicit-key.ts
2693
- const RULE_NAME$34 = "no-implicit-key";
2699
+ const RULE_NAME$35 = "no-implicit-key";
2694
2700
  var no_implicit_key_default = createRule({
2695
2701
  meta: {
2696
2702
  type: "problem",
@@ -2698,11 +2704,11 @@ var no_implicit_key_default = createRule({
2698
2704
  messages: { default: "This spread attribute implicitly passes the 'key' prop to a component, this could lead to unexpected behavior. If you intend to pass the 'key' prop, use 'key={value}'." },
2699
2705
  schema: []
2700
2706
  },
2701
- name: RULE_NAME$34,
2702
- create: create$34,
2707
+ name: RULE_NAME$35,
2708
+ create: create$35,
2703
2709
  defaultOptions: []
2704
2710
  });
2705
- function create$34(context) {
2711
+ function create$35(context) {
2706
2712
  const services = ESLintUtils.getParserServices(context, false);
2707
2713
  const checker = services.program.getTypeChecker();
2708
2714
  return defineRuleListener({ JSXSpreadAttribute(node) {
@@ -2710,6 +2716,47 @@ function create$34(context) {
2710
2716
  const key = type.getProperty("key");
2711
2717
  if (key == null) continue;
2712
2718
  if (getFullyQualifiedNameEx(checker, key).toLowerCase().endsWith("react.attributes.key")) continue;
2719
+ const keyType = checker.getTypeOfSymbol(key);
2720
+ if (keyType.aliasSymbol != null) {
2721
+ if (checker.getFullyQualifiedName(keyType.aliasSymbol).toLowerCase().endsWith("react.key")) continue;
2722
+ }
2723
+ context.report({
2724
+ messageId: "default",
2725
+ node
2726
+ });
2727
+ }
2728
+ } });
2729
+ }
2730
+
2731
+ //#endregion
2732
+ //#region src/rules/no-implicit-ref/no-implicit-ref.ts
2733
+ const RULE_NAME$34 = "no-implicit-ref";
2734
+ const RE_REACT_REF_TYPE = /react\.(ref|legacyref|refcallback|refobject)$/i;
2735
+ var no_implicit_ref_default = createRule({
2736
+ meta: {
2737
+ type: "problem",
2738
+ docs: { description: "Prevents implicitly passing the 'ref' prop to components." },
2739
+ messages: { default: "This spread attribute implicitly passes the 'ref' prop to a component, this could lead to unexpected behavior. If you intend to pass the 'ref' prop, use 'ref={value}'." },
2740
+ schema: []
2741
+ },
2742
+ name: RULE_NAME$34,
2743
+ create: create$34,
2744
+ defaultOptions: []
2745
+ });
2746
+ function create$34(context) {
2747
+ const services = ESLintUtils.getParserServices(context, false);
2748
+ const checker = services.program.getTypeChecker();
2749
+ return defineRuleListener({ JSXSpreadAttribute(node) {
2750
+ for (const type of unionConstituents(getConstrainedTypeAtLocation(services, node.argument))) {
2751
+ const ref = type.getProperty("ref");
2752
+ if (ref == null) continue;
2753
+ if (getFullyQualifiedNameEx(checker, ref).toLowerCase().endsWith("attributes.ref")) continue;
2754
+ const refType = checker.getTypeOfSymbol(ref);
2755
+ const typeSymbol = refType.aliasSymbol ?? refType.symbol;
2756
+ if (typeSymbol != null) {
2757
+ const typeFqn = checker.getFullyQualifiedName(typeSymbol);
2758
+ if (RE_REACT_REF_TYPE.test(typeFqn)) continue;
2759
+ }
2713
2760
  context.report({
2714
2761
  messageId: "default",
2715
2762
  node
@@ -4347,8 +4394,8 @@ var purity_default = createRule({
4347
4394
  function create$7(context) {
4348
4395
  const hCollector = core.useHookCollector(context);
4349
4396
  const cCollector = core.useComponentCollector(context);
4350
- const cExprs = [];
4351
- const nExprs = [];
4397
+ const cEntries = [];
4398
+ const nEntries = [];
4352
4399
  return defineRuleListener(hCollector.visitor, cCollector.visitor, {
4353
4400
  CallExpression(node) {
4354
4401
  const expr = ast.getUnderlyingExpression(node.callee);
@@ -4357,7 +4404,7 @@ function create$7(context) {
4357
4404
  if (!IMPURE_FUNCS.get("globalThis")?.has(expr.name)) return;
4358
4405
  const func = ast.findParentNode(node, ast.isFunction);
4359
4406
  if (func == null) return;
4360
- cExprs.push({
4407
+ cEntries.push({
4361
4408
  func,
4362
4409
  node
4363
4410
  });
@@ -4369,7 +4416,7 @@ function create$7(context) {
4369
4416
  if (!IMPURE_FUNCS.get(objectName)?.has(propertyName)) return;
4370
4417
  const func = ast.findParentNode(node, ast.isFunction);
4371
4418
  if (func == null) return;
4372
- cExprs.push({
4419
+ cEntries.push({
4373
4420
  func,
4374
4421
  node
4375
4422
  });
@@ -4383,7 +4430,7 @@ function create$7(context) {
4383
4430
  if (!IMPURE_CTORS.has(expr.name)) return;
4384
4431
  const func = ast.findParentNode(node, ast.isFunction);
4385
4432
  if (func == null) return;
4386
- nExprs.push({
4433
+ nEntries.push({
4387
4434
  func,
4388
4435
  node
4389
4436
  });
@@ -4392,7 +4439,7 @@ function create$7(context) {
4392
4439
  const comps = cCollector.ctx.getAllComponents(node);
4393
4440
  const hooks = hCollector.ctx.getAllHooks(node);
4394
4441
  const funcs = [...comps, ...hooks];
4395
- for (const { func, node } of [...cExprs, ...nExprs]) {
4442
+ for (const { func, node } of [...cEntries, ...nEntries]) {
4396
4443
  if (!funcs.some((f) => f.node === func)) continue;
4397
4444
  context.report({
4398
4445
  data: { name: context.sourceCode.getText(node) },
@@ -7355,7 +7402,6 @@ const plugin = {
7355
7402
  "jsx-dollar": jsx_dollar_default,
7356
7403
  "jsx-key-before-spread": jsx_key_before_spread_default,
7357
7404
  "jsx-no-comment-textnodes": jsx_no_comment_textnodes_default,
7358
- "jsx-no-duplicate-props": jsx_no_duplicate_props_default,
7359
7405
  "jsx-shorthand-boolean": jsx_shorthand_boolean_default,
7360
7406
  "jsx-shorthand-fragment": jsx_shorthand_fragment_default,
7361
7407
  "no-access-state-in-setstate": no_access_state_in_setstate_default,
@@ -7376,7 +7422,9 @@ const plugin = {
7376
7422
  "no-direct-mutation-state": no_direct_mutation_state_default,
7377
7423
  "no-duplicate-key": no_duplicate_key_default,
7378
7424
  "no-forward-ref": no_forward_ref_default,
7425
+ "no-implicit-children": no_implicit_children_default,
7379
7426
  "no-implicit-key": no_implicit_key_default,
7427
+ "no-implicit-ref": no_implicit_ref_default,
7380
7428
  "no-leaked-conditional-rendering": no_leaked_conditional_rendering_default,
7381
7429
  "no-missing-component-display-name": no_missing_component_display_name_default,
7382
7430
  "no-missing-context-display-name": no_missing_context_display_name_default,
@@ -7430,7 +7478,6 @@ const rules$6 = {
7430
7478
  "react-x/exhaustive-deps": "warn",
7431
7479
  "react-x/jsx-key-before-spread": "warn",
7432
7480
  "react-x/jsx-no-comment-textnodes": "warn",
7433
- "react-x/jsx-no-duplicate-props": "warn",
7434
7481
  "react-x/no-access-state-in-setstate": "error",
7435
7482
  "react-x/no-array-index-key": "warn",
7436
7483
  "react-x/no-children-count": "warn",
@@ -7475,7 +7522,7 @@ const settings$5 = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
7475
7522
  /**
7476
7523
  * Disables rules that are already handled by TypeScript
7477
7524
  */
7478
- const rules$5 = { "react-x/jsx-no-duplicate-props": "off" };
7525
+ const rules$5 = {};
7479
7526
 
7480
7527
  //#endregion
7481
7528
  //#region src/configs/recommended-typescript.ts
@@ -7504,7 +7551,6 @@ var recommended_type_checked_exports = /* @__PURE__ */ __exportAll({
7504
7551
  const name$3 = "react-x/recommended-type-checked";
7505
7552
  const rules$3 = {
7506
7553
  ...rules$4,
7507
- "react-x/no-implicit-key": "error",
7508
7554
  "react-x/no-leaked-conditional-rendering": "error"
7509
7555
  };
7510
7556
  const plugins$3 = { ...plugins$4 };
@@ -7562,7 +7608,6 @@ var strict_type_checked_exports = /* @__PURE__ */ __exportAll({
7562
7608
  const name = "react-x/strict-type-checked";
7563
7609
  const rules = {
7564
7610
  ...rules$1,
7565
- "react-x/no-implicit-key": "error",
7566
7611
  "react-x/no-leaked-conditional-rendering": "error",
7567
7612
  "react-x/no-unused-props": "warn"
7568
7613
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "3.0.0-next.74",
3
+ "version": "3.0.0-next.76",
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",
@@ -45,11 +45,11 @@
45
45
  "string-ts": "^2.3.1",
46
46
  "ts-api-utils": "^2.4.0",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/shared": "3.0.0-next.74",
49
- "@eslint-react/var": "3.0.0-next.74",
48
+ "@eslint-react/ast": "3.0.0-next.76",
49
+ "@eslint-react/core": "3.0.0-next.76",
50
+ "@eslint-react/shared": "3.0.0-next.76",
50
51
  "@local/eff": "3.0.0-beta.72",
51
- "@eslint-react/ast": "3.0.0-next.74",
52
- "@eslint-react/core": "3.0.0-next.74"
52
+ "@eslint-react/var": "3.0.0-next.76"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",