eslint-plugin-react-x 1.22.2-next.5 → 1.22.2-next.6

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.22.2-next.5";
45
+ var version = "1.22.2-next.6";
46
46
  var createRule = shared.createRuleForPlugin("x");
47
47
 
48
48
  // src/rules/avoid-shorthand-boolean.ts
@@ -1123,7 +1123,7 @@ var no_duplicate_key_default = createRule({
1123
1123
  },
1124
1124
  name: RULE_NAME24,
1125
1125
  create(context) {
1126
- const isWithinChildrenToArrayRef = eff.MutRef.make(false);
1126
+ const state = { isWithinChildrenToArray: false };
1127
1127
  function isKeyEqual(a, b) {
1128
1128
  return VAR__namespace.isNodeValueEqual(a, b, [context.sourceCode.getScope(a), context.sourceCode.getScope(b)]);
1129
1129
  }
@@ -1177,7 +1177,7 @@ var no_duplicate_key_default = createRule({
1177
1177
  const seen = /* @__PURE__ */ new WeakSet();
1178
1178
  return {
1179
1179
  "ArrayExpression, JSXElement > JSXElement"(node) {
1180
- if (eff.MutRef.get(isWithinChildrenToArrayRef)) return;
1180
+ if (state.isWithinChildrenToArray) return;
1181
1181
  const elements = tsPattern.match(node).with({ type: types.AST_NODE_TYPES.ArrayExpression }, ({ elements: elements2 }) => elements2).with({ type: types.AST_NODE_TYPES.JSXElement }, ({ parent }) => "children" in parent ? parent.children : []).otherwise(() => []).filter(AST11__namespace.is(types.AST_NODE_TYPES.JSXElement)).filter((element) => !seen.has(element));
1182
1182
  const keys = elements.reduce(
1183
1183
  (acc, element) => {
@@ -1208,7 +1208,8 @@ var no_duplicate_key_default = createRule({
1208
1208
  }
1209
1209
  },
1210
1210
  CallExpression(node) {
1211
- if (core.isChildrenToArrayCall(node, context)) eff.MutRef.set(isWithinChildrenToArrayRef, true);
1211
+ state.isWithinChildrenToArray ||= core.isChildrenToArrayCall(node, context);
1212
+ if (state.isWithinChildrenToArray) return;
1212
1213
  const isMapCall = AST11__namespace.isMapCallLoose(node);
1213
1214
  const isArrayFromCall = tsPattern.isMatching({
1214
1215
  type: types.AST_NODE_TYPES.CallExpression,
@@ -1220,7 +1221,6 @@ var no_duplicate_key_default = createRule({
1220
1221
  }
1221
1222
  }, node);
1222
1223
  if (!isMapCall && !isArrayFromCall) return;
1223
- if (eff.MutRef.get(isWithinChildrenToArrayRef)) return;
1224
1224
  const fn = node.arguments[isMapCall ? 0 : 1];
1225
1225
  if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression])(fn)) return;
1226
1226
  if (fn.body.type === types.AST_NODE_TYPES.BlockStatement) {
@@ -1232,7 +1232,8 @@ var no_duplicate_key_default = createRule({
1232
1232
  eff.O.map(checkExpression(fn.body), context.report);
1233
1233
  },
1234
1234
  "CallExpression:exit"(node) {
1235
- if (core.isChildrenToArrayCall(node, context)) eff.MutRef.set(isWithinChildrenToArrayRef, false);
1235
+ if (!core.isChildrenToArrayCall(node, context)) return;
1236
+ state.isWithinChildrenToArray = false;
1236
1237
  }
1237
1238
  };
1238
1239
  },
@@ -1595,7 +1596,7 @@ var no_missing_key_default = createRule({
1595
1596
  },
1596
1597
  name: RULE_NAME29,
1597
1598
  create(context) {
1598
- const isWithinChildrenToArrayRef = eff.MutRef.make(false);
1599
+ const state = { isWithinChildrenToArray: false };
1599
1600
  function checkIteratorElement(node) {
1600
1601
  switch (node.type) {
1601
1602
  case types.AST_NODE_TYPES.JSXElement: {
@@ -1644,7 +1645,7 @@ var no_missing_key_default = createRule({
1644
1645
  }
1645
1646
  return {
1646
1647
  ArrayExpression(node) {
1647
- if (eff.MutRef.get(isWithinChildrenToArrayRef)) return;
1648
+ if (state.isWithinChildrenToArray) return;
1648
1649
  const elements = node.elements.filter(AST11__namespace.is(types.AST_NODE_TYPES.JSXElement));
1649
1650
  if (elements.length === 0) return;
1650
1651
  const initialScope = context.sourceCode.getScope(node);
@@ -1658,7 +1659,8 @@ var no_missing_key_default = createRule({
1658
1659
  }
1659
1660
  },
1660
1661
  CallExpression(node) {
1661
- if (core.isChildrenToArrayCall(node, context)) eff.MutRef.set(isWithinChildrenToArrayRef, true);
1662
+ state.isWithinChildrenToArray ||= core.isChildrenToArrayCall(node, context);
1663
+ if (state.isWithinChildrenToArray) return;
1662
1664
  const isMapCall = AST11__namespace.isMapCallLoose(node);
1663
1665
  const isArrayFromCall = tsPattern.isMatching({
1664
1666
  type: types.AST_NODE_TYPES.CallExpression,
@@ -1670,7 +1672,6 @@ var no_missing_key_default = createRule({
1670
1672
  }
1671
1673
  }, node);
1672
1674
  if (!isMapCall && !isArrayFromCall) return;
1673
- if (eff.MutRef.get(isWithinChildrenToArrayRef)) return;
1674
1675
  const fn = node.arguments[isMapCall ? 0 : 1];
1675
1676
  if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression])(fn)) return;
1676
1677
  if (fn.body.type === types.AST_NODE_TYPES.BlockStatement) {
@@ -1682,10 +1683,11 @@ var no_missing_key_default = createRule({
1682
1683
  eff.O.map(checkExpression(fn.body), context.report);
1683
1684
  },
1684
1685
  "CallExpression:exit"(node) {
1685
- if (core.isChildrenToArrayCall(node, context)) eff.MutRef.set(isWithinChildrenToArrayRef, false);
1686
+ if (!core.isChildrenToArrayCall(node, context)) return;
1687
+ state.isWithinChildrenToArray = false;
1686
1688
  },
1687
1689
  JSXFragment(node) {
1688
- if (eff.MutRef.get(isWithinChildrenToArrayRef)) return;
1690
+ if (state.isWithinChildrenToArray) return;
1689
1691
  if (node.parent.type === types.AST_NODE_TYPES.ArrayExpression) {
1690
1692
  context.report({
1691
1693
  messageId: "noMissingKeyWithFragment",
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { F, O, isString, MutRef, isNullable } from '@eslint-react/eff';
1
+ import { F, O, isString, isNullable } from '@eslint-react/eff';
2
2
  import * as JSX8 from '@eslint-react/jsx';
3
3
  import { createRuleForPlugin, normalizeSettings, decodeSettings, unsafeReadSettings } from '@eslint-react/shared';
4
4
  import * as AST11 from '@eslint-react/ast';
@@ -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.22.2-next.5";
18
+ var version = "1.22.2-next.6";
19
19
  var createRule = createRuleForPlugin("x");
20
20
 
21
21
  // src/rules/avoid-shorthand-boolean.ts
@@ -1096,7 +1096,7 @@ var no_duplicate_key_default = createRule({
1096
1096
  },
1097
1097
  name: RULE_NAME24,
1098
1098
  create(context) {
1099
- const isWithinChildrenToArrayRef = MutRef.make(false);
1099
+ const state = { isWithinChildrenToArray: false };
1100
1100
  function isKeyEqual(a, b) {
1101
1101
  return VAR.isNodeValueEqual(a, b, [context.sourceCode.getScope(a), context.sourceCode.getScope(b)]);
1102
1102
  }
@@ -1150,7 +1150,7 @@ var no_duplicate_key_default = createRule({
1150
1150
  const seen = /* @__PURE__ */ new WeakSet();
1151
1151
  return {
1152
1152
  "ArrayExpression, JSXElement > JSXElement"(node) {
1153
- if (MutRef.get(isWithinChildrenToArrayRef)) return;
1153
+ if (state.isWithinChildrenToArray) return;
1154
1154
  const elements = match(node).with({ type: AST_NODE_TYPES.ArrayExpression }, ({ elements: elements2 }) => elements2).with({ type: AST_NODE_TYPES.JSXElement }, ({ parent }) => "children" in parent ? parent.children : []).otherwise(() => []).filter(AST11.is(AST_NODE_TYPES.JSXElement)).filter((element) => !seen.has(element));
1155
1155
  const keys = elements.reduce(
1156
1156
  (acc, element) => {
@@ -1181,7 +1181,8 @@ var no_duplicate_key_default = createRule({
1181
1181
  }
1182
1182
  },
1183
1183
  CallExpression(node) {
1184
- if (isChildrenToArrayCall(node, context)) MutRef.set(isWithinChildrenToArrayRef, true);
1184
+ state.isWithinChildrenToArray ||= isChildrenToArrayCall(node, context);
1185
+ if (state.isWithinChildrenToArray) return;
1185
1186
  const isMapCall = AST11.isMapCallLoose(node);
1186
1187
  const isArrayFromCall = isMatching({
1187
1188
  type: AST_NODE_TYPES.CallExpression,
@@ -1193,7 +1194,6 @@ var no_duplicate_key_default = createRule({
1193
1194
  }
1194
1195
  }, node);
1195
1196
  if (!isMapCall && !isArrayFromCall) return;
1196
- if (MutRef.get(isWithinChildrenToArrayRef)) return;
1197
1197
  const fn = node.arguments[isMapCall ? 0 : 1];
1198
1198
  if (!AST11.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(fn)) return;
1199
1199
  if (fn.body.type === AST_NODE_TYPES.BlockStatement) {
@@ -1205,7 +1205,8 @@ var no_duplicate_key_default = createRule({
1205
1205
  O.map(checkExpression(fn.body), context.report);
1206
1206
  },
1207
1207
  "CallExpression:exit"(node) {
1208
- if (isChildrenToArrayCall(node, context)) MutRef.set(isWithinChildrenToArrayRef, false);
1208
+ if (!isChildrenToArrayCall(node, context)) return;
1209
+ state.isWithinChildrenToArray = false;
1209
1210
  }
1210
1211
  };
1211
1212
  },
@@ -1568,7 +1569,7 @@ var no_missing_key_default = createRule({
1568
1569
  },
1569
1570
  name: RULE_NAME29,
1570
1571
  create(context) {
1571
- const isWithinChildrenToArrayRef = MutRef.make(false);
1572
+ const state = { isWithinChildrenToArray: false };
1572
1573
  function checkIteratorElement(node) {
1573
1574
  switch (node.type) {
1574
1575
  case AST_NODE_TYPES.JSXElement: {
@@ -1617,7 +1618,7 @@ var no_missing_key_default = createRule({
1617
1618
  }
1618
1619
  return {
1619
1620
  ArrayExpression(node) {
1620
- if (MutRef.get(isWithinChildrenToArrayRef)) return;
1621
+ if (state.isWithinChildrenToArray) return;
1621
1622
  const elements = node.elements.filter(AST11.is(AST_NODE_TYPES.JSXElement));
1622
1623
  if (elements.length === 0) return;
1623
1624
  const initialScope = context.sourceCode.getScope(node);
@@ -1631,7 +1632,8 @@ var no_missing_key_default = createRule({
1631
1632
  }
1632
1633
  },
1633
1634
  CallExpression(node) {
1634
- if (isChildrenToArrayCall(node, context)) MutRef.set(isWithinChildrenToArrayRef, true);
1635
+ state.isWithinChildrenToArray ||= isChildrenToArrayCall(node, context);
1636
+ if (state.isWithinChildrenToArray) return;
1635
1637
  const isMapCall = AST11.isMapCallLoose(node);
1636
1638
  const isArrayFromCall = isMatching({
1637
1639
  type: AST_NODE_TYPES.CallExpression,
@@ -1643,7 +1645,6 @@ var no_missing_key_default = createRule({
1643
1645
  }
1644
1646
  }, node);
1645
1647
  if (!isMapCall && !isArrayFromCall) return;
1646
- if (MutRef.get(isWithinChildrenToArrayRef)) return;
1647
1648
  const fn = node.arguments[isMapCall ? 0 : 1];
1648
1649
  if (!AST11.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(fn)) return;
1649
1650
  if (fn.body.type === AST_NODE_TYPES.BlockStatement) {
@@ -1655,10 +1656,11 @@ var no_missing_key_default = createRule({
1655
1656
  O.map(checkExpression(fn.body), context.report);
1656
1657
  },
1657
1658
  "CallExpression:exit"(node) {
1658
- if (isChildrenToArrayCall(node, context)) MutRef.set(isWithinChildrenToArrayRef, false);
1659
+ if (!isChildrenToArrayCall(node, context)) return;
1660
+ state.isWithinChildrenToArray = false;
1659
1661
  },
1660
1662
  JSXFragment(node) {
1661
- if (MutRef.get(isWithinChildrenToArrayRef)) return;
1663
+ if (state.isWithinChildrenToArray) return;
1662
1664
  if (node.parent.type === AST_NODE_TYPES.ArrayExpression) {
1663
1665
  context.report({
1664
1666
  messageId: "noMissingKeyWithFragment",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "1.22.2-next.5",
3
+ "version": "1.22.2-next.6",
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",
@@ -49,13 +49,13 @@
49
49
  "string-ts": "^2.2.0",
50
50
  "ts-api-utils": "^2.0.0",
51
51
  "ts-pattern": "^5.6.0",
52
- "@eslint-react/ast": "1.22.2-next.5",
53
- "@eslint-react/eff": "1.22.2-next.5",
54
- "@eslint-react/jsx": "1.22.2-next.5",
55
- "@eslint-react/core": "1.22.2-next.5",
56
- "@eslint-react/shared": "1.22.2-next.5",
57
- "@eslint-react/types": "1.22.2-next.5",
58
- "@eslint-react/var": "1.22.2-next.5"
52
+ "@eslint-react/ast": "1.22.2-next.6",
53
+ "@eslint-react/core": "1.22.2-next.6",
54
+ "@eslint-react/eff": "1.22.2-next.6",
55
+ "@eslint-react/jsx": "1.22.2-next.6",
56
+ "@eslint-react/shared": "1.22.2-next.6",
57
+ "@eslint-react/types": "1.22.2-next.6",
58
+ "@eslint-react/var": "1.22.2-next.6"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/react": "^19.0.2",