@zayne-labs/eslint-config 0.10.2 → 0.10.3

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.
@@ -207,7 +207,7 @@ var require_lib = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/eslint-
207
207
  }) });
208
208
 
209
209
  //#endregion
210
- //#region ../../node_modules/.pnpm/eslint-utils@3.0.0_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-utils/index.mjs
210
+ //#region ../../node_modules/.pnpm/eslint-utils@3.0.0_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-utils/index.mjs
211
211
  var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
212
212
  /**
213
213
  * Get the innermost scope which contains a given location.
@@ -1318,7 +1318,7 @@ function exceptDefault(name, index) {
1318
1318
  }
1319
1319
 
1320
1320
  //#endregion
1321
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/util/ast.js
1321
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/util/ast.js
1322
1322
  const traverse = (context, node, visit, visited = /* @__PURE__ */ new Set()) => {
1323
1323
  if (visited.has(node)) return;
1324
1324
  visited.add(node);
@@ -1350,13 +1350,17 @@ const getCallExpr = (ref, current = ref.identifier.parent) => {
1350
1350
  };
1351
1351
 
1352
1352
  //#endregion
1353
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/util/react.js
1353
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/util/react.js
1354
1354
  const isReactFunctionalComponent = (node) => (node.type === "FunctionDeclaration" || node.type === "VariableDeclarator" && (node.init.type === "ArrowFunctionExpression" || node.init.type === "CallExpression")) && node.id.type === "Identifier" && node.id.name[0].toUpperCase() === node.id.name[0];
1355
1355
  const isReactFunctionalHOC = (node) => node.type === "VariableDeclarator" && node.init && node.init.type === "CallExpression" && node.init.callee.type === "Identifier" && !["memo", "forwardRef"].includes(node.init.callee.name) && node.init.arguments.length > 0 && (node.init.arguments[0].type === "ArrowFunctionExpression" || node.init.arguments[0].type === "FunctionExpression") && node.id.type === "Identifier" && node.id.name[0].toUpperCase() === node.id.name[0];
1356
1356
  const isCustomHook = (node) => (node.type === "FunctionDeclaration" || node.type === "VariableDeclarator" && node.init && (node.init.type === "ArrowFunctionExpression" || node.init.type === "FunctionExpression")) && node.id.type === "Identifier" && node.id.name.startsWith("use") && node.id.name[3] === node.id.name[3].toUpperCase();
1357
1357
  const isUseState = (node) => node.type === "VariableDeclarator" && node.init && node.init.type === "CallExpression" && node.init.callee.name === "useState" && node.id.type === "ArrayPattern" && (node.id.elements.length === 1 || node.id.elements.length === 2) && node.id.elements.every((el) => {
1358
1358
  return !el || el.type === "Identifier";
1359
1359
  });
1360
+ const hasCleanup = (node) => {
1361
+ const effectFn = node.arguments[0];
1362
+ return (effectFn.type === "ArrowFunctionExpression" || effectFn.type === "FunctionExpression") && effectFn.body.type === "BlockStatement" && effectFn.body.body.some((stmt) => stmt.type === "ReturnStatement" && stmt.argument);
1363
+ };
1360
1364
  const isPropDef = (def) => {
1361
1365
  const declaringNode = def.node.type === "ArrowFunctionExpression" ? def.node.parent.type === "CallExpression" ? def.node.parent.parent : def.node.parent : def.node;
1362
1366
  return def.type === "Parameter" && (isReactFunctionalComponent(declaringNode) && !isReactFunctionalHOC(declaringNode) || isCustomHook(declaringNode));
@@ -1403,7 +1407,7 @@ const isArgsAllLiterals = (context, callExpr) => callExpr.arguments.flatMap((arg
1403
1407
  const getUpstreamReactVariables = (context, variable) => getUpstreamVariables(context, variable, (node) => !isUseState(node)).filter((variable$1) => variable$1.defs.every((def) => isPropDef(def) || def.type !== "Parameter"));
1404
1408
 
1405
1409
  //#endregion
1406
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-empty-effect.js
1410
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-empty-effect.js
1407
1411
  /**
1408
1412
  * @type {import("eslint").Rule.RuleModule}
1409
1413
  */
@@ -1424,7 +1428,7 @@ var no_empty_effect_default = {
1424
1428
  };
1425
1429
 
1426
1430
  //#endregion
1427
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-adjust-state-on-prop-change.js
1431
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-adjust-state-on-prop-change.js
1428
1432
  /**
1429
1433
  * @type {import("eslint").Rule.RuleModule}
1430
1434
  */
@@ -1454,7 +1458,7 @@ var no_adjust_state_on_prop_change_default = {
1454
1458
  };
1455
1459
 
1456
1460
  //#endregion
1457
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-reset-all-state-on-prop-change.js
1461
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-reset-all-state-on-prop-change.js
1458
1462
  /**
1459
1463
  * @type {import("eslint").Rule.RuleModule}
1460
1464
  */
@@ -1508,7 +1512,7 @@ const findContainingNode = (node) => {
1508
1512
  };
1509
1513
 
1510
1514
  //#endregion
1511
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-event-handler.js
1515
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-event-handler.js
1512
1516
  /**
1513
1517
  * @type {import("eslint").Rule.RuleModule}
1514
1518
  */
@@ -1526,6 +1530,7 @@ var no_event_handler_default = {
1526
1530
  const effectFnRefs = getEffectFnRefs(context, node);
1527
1531
  const depsRefs = getEffectDepsRefs(context, node);
1528
1532
  if (!effectFnRefs || !depsRefs) return;
1533
+ if (hasCleanup(node)) return;
1529
1534
  findDownstreamNodes(context, node, "IfStatement").filter((ifNode) => !ifNode.alternate).filter((ifNode) => getDownstreamRefs(context, ifNode.test).notEmptyEvery((ref) => isState(context, ref))).forEach((ifNode) => {
1530
1535
  context.report({
1531
1536
  node: ifNode.test,
@@ -1536,7 +1541,7 @@ var no_event_handler_default = {
1536
1541
  };
1537
1542
 
1538
1543
  //#endregion
1539
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-pass-live-state-to-parent.js
1544
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-pass-live-state-to-parent.js
1540
1545
  /**
1541
1546
  * @type {import("eslint").Rule.RuleModule}
1542
1547
  */
@@ -1565,7 +1570,7 @@ var no_pass_live_state_to_parent_default = {
1565
1570
  };
1566
1571
 
1567
1572
  //#endregion
1568
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-initialize-state.js
1573
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-initialize-state.js
1569
1574
  /**
1570
1575
  * @type {import("eslint").Rule.RuleModule}
1571
1576
  */
@@ -1594,7 +1599,7 @@ var no_initialize_state_default = {
1594
1599
  };
1595
1600
 
1596
1601
  //#endregion
1597
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-chain-state-updates.js
1602
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-chain-state-updates.js
1598
1603
  /**
1599
1604
  * @type {import("eslint").Rule.RuleModule}
1600
1605
  */
@@ -1612,6 +1617,7 @@ var no_chain_state_updates_default = {
1612
1617
  const effectFnRefs = getEffectFnRefs(context, node);
1613
1618
  const depsRefs = getEffectDepsRefs(context, node);
1614
1619
  if (!effectFnRefs || !depsRefs) return;
1620
+ if (hasCleanup(node)) return;
1615
1621
  const isAllDepsState = depsRefs.notEmptyEvery((ref) => isState(context, ref));
1616
1622
  effectFnRefs.filter((ref) => isStateSetter(context, ref)).filter((ref) => isImmediateCall(ref.identifier)).forEach((ref) => {
1617
1623
  const callExpr = getCallExpr(ref);
@@ -1624,7 +1630,7 @@ var no_chain_state_updates_default = {
1624
1630
  };
1625
1631
 
1626
1632
  //#endregion
1627
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-derived-state.js
1633
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-derived-state.js
1628
1634
  /**
1629
1635
  * @type {import('eslint').Rule.RuleModule}
1630
1636
  */
@@ -1642,6 +1648,7 @@ var no_derived_state_default = {
1642
1648
  const effectFnRefs = getEffectFnRefs(context, node);
1643
1649
  const depsRefs = getEffectDepsRefs(context, node);
1644
1650
  if (!effectFnRefs || !depsRefs) return;
1651
+ if (hasCleanup(node)) return;
1645
1652
  effectFnRefs.filter((ref) => isStateSetter(context, ref)).filter((ref) => isImmediateCall(ref.identifier)).forEach((ref) => {
1646
1653
  const callExpr = getCallExpr(ref);
1647
1654
  const useStateNode = getUseStateNode(context, ref);
@@ -1662,7 +1669,7 @@ var no_derived_state_default = {
1662
1669
  const countCalls = (ref) => ref.resolved.references.filter((ref$1) => ref$1.identifier.parent.type === "CallExpression").length;
1663
1670
 
1664
1671
  //#endregion
1665
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-pass-data-to-parent.js
1672
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-pass-data-to-parent.js
1666
1673
  /**
1667
1674
  * @type {import("eslint").Rule.RuleModule}
1668
1675
  */
@@ -1680,6 +1687,7 @@ var no_pass_data_to_parent_default = {
1680
1687
  const effectFnRefs = getEffectFnRefs(context, node);
1681
1688
  const depsRefs = getEffectDepsRefs(context, node);
1682
1689
  if (!effectFnRefs || !depsRefs) return;
1690
+ if (hasCleanup(node)) return;
1683
1691
  effectFnRefs.filter((ref) => isPropCallback(context, ref)).forEach((ref) => {
1684
1692
  const callExpr = getCallExpr(ref);
1685
1693
  if (callExpr.arguments.flatMap((arg) => getDownstreamRefs(context, arg)).notEmptyEvery((ref$1) => !isState(context, ref$1) && !isProp(context, ref$1) && !isRef(context, ref$1))) context.report({
@@ -1691,7 +1699,7 @@ var no_pass_data_to_parent_default = {
1691
1699
  };
1692
1700
 
1693
1701
  //#endregion
1694
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-manage-parent.js
1702
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/no-manage-parent.js
1695
1703
  /**
1696
1704
  * @type {import("eslint").Rule.RuleModule}
1697
1705
  */
@@ -1715,13 +1723,13 @@ var no_manage_parent_default = {
1715
1723
  };
1716
1724
 
1717
1725
  //#endregion
1718
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/util/javascript.js
1726
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/util/javascript.js
1719
1727
  Array.prototype.notEmptyEvery = function(predicate) {
1720
1728
  return this.length > 0 && this.every(predicate);
1721
1729
  };
1722
1730
 
1723
1731
  //#endregion
1724
- //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.3_eslint@9.36.0_jiti@2.5.1_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/index.js
1732
+ //#region ../../node_modules/.pnpm/eslint-plugin-react-you-might-not-need-an-effect@0.5.4_eslint@9.36.0_jiti@2.6.0_/node_modules/eslint-plugin-react-you-might-not-need-an-effect/src/index.js
1725
1733
  /**
1726
1734
  * @type {import("eslint").ESLint.Plugin}
1727
1735
  */
@@ -1766,4 +1774,4 @@ var src_default = plugin;
1766
1774
 
1767
1775
  //#endregion
1768
1776
  export { src_default as default };
1769
- //# sourceMappingURL=src-DwSufEpw.js.map
1777
+ //# sourceMappingURL=src-ZlDTU7nv.js.map