@pobammer-ts/eslint-cease-nonsense-rules 1.4.0 → 1.4.1

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "commit": "f4fa667fccc9bd1def0d63fcc3733e8170343d31",
3
- "time": "2025-12-02T13:23:02.709Z",
4
- "version": "1.4.0"
2
+ "commit": "f9f7350de303b20ac132d917a403f15ed30d4daf",
3
+ "time": "2025-12-04T00:47:41.402Z",
4
+ "version": "1.4.1"
5
5
  }
package/dist/index.js CHANGED
@@ -10537,6 +10537,21 @@ var IS_FUNCTION_EXPRESSION = new Set([
10537
10537
  TSESTree8.AST_NODE_TYPES.FunctionExpression,
10538
10538
  TSESTree8.AST_NODE_TYPES.ArrowFunctionExpression
10539
10539
  ]);
10540
+ var CONTROL_FLOW_TYPES = new Set([
10541
+ TSESTree8.AST_NODE_TYPES.BlockStatement,
10542
+ TSESTree8.AST_NODE_TYPES.IfStatement,
10543
+ TSESTree8.AST_NODE_TYPES.SwitchStatement,
10544
+ TSESTree8.AST_NODE_TYPES.SwitchCase,
10545
+ TSESTree8.AST_NODE_TYPES.TryStatement,
10546
+ TSESTree8.AST_NODE_TYPES.CatchClause,
10547
+ TSESTree8.AST_NODE_TYPES.WhileStatement,
10548
+ TSESTree8.AST_NODE_TYPES.DoWhileStatement,
10549
+ TSESTree8.AST_NODE_TYPES.ForStatement,
10550
+ TSESTree8.AST_NODE_TYPES.ForInStatement,
10551
+ TSESTree8.AST_NODE_TYPES.ForOfStatement,
10552
+ TSESTree8.AST_NODE_TYPES.LabeledStatement,
10553
+ TSESTree8.AST_NODE_TYPES.WithStatement
10554
+ ]);
10540
10555
  function isTopLevelReturn(node) {
10541
10556
  let parent = ascendPastWrappers(node.parent);
10542
10557
  if (!parent)
@@ -10555,7 +10570,7 @@ function isTopLevelReturn(node) {
10555
10570
  return false;
10556
10571
  if (parent.type === TSESTree8.AST_NODE_TYPES.ReturnStatement) {
10557
10572
  let currentNode = ascendPastWrappers(parent.parent);
10558
- if (currentNode?.type === TSESTree8.AST_NODE_TYPES.BlockStatement)
10573
+ while (currentNode && CONTROL_FLOW_TYPES.has(currentNode.type))
10559
10574
  currentNode = ascendPastWrappers(currentNode.parent);
10560
10575
  if (!currentNode)
10561
10576
  return false;
@@ -10614,6 +10629,25 @@ function isJSXPropValue(node) {
10614
10629
  }
10615
10630
  return parent.type === TSESTree8.AST_NODE_TYPES.JSXAttribute;
10616
10631
  }
10632
+ function isTernaryJSXChild(node) {
10633
+ let current = node.parent;
10634
+ if (!current)
10635
+ return false;
10636
+ let foundTernary = false;
10637
+ while (current && (current.type === TSESTree8.AST_NODE_TYPES.ConditionalExpression || WRAPPER_PARENT_TYPES.has(current.type))) {
10638
+ if (current.type === TSESTree8.AST_NODE_TYPES.ConditionalExpression)
10639
+ foundTernary = true;
10640
+ current = current.parent;
10641
+ }
10642
+ if (!foundTernary || !current)
10643
+ return false;
10644
+ if (current.type !== TSESTree8.AST_NODE_TYPES.JSXExpressionContainer)
10645
+ return false;
10646
+ const containerParent = current.parent;
10647
+ if (!containerParent)
10648
+ return false;
10649
+ return containerParent.type === TSESTree8.AST_NODE_TYPES.JSXElement || containerParent.type === TSESTree8.AST_NODE_TYPES.JSXFragment;
10650
+ }
10617
10651
  var docs3 = {
10618
10652
  description: "Enforce key props on all React elements except top-level returns",
10619
10653
  recommended: true
@@ -10643,6 +10677,8 @@ var requireReactComponentKeys = {
10643
10677
  return;
10644
10678
  if (isJSXPropValue(node))
10645
10679
  return;
10680
+ if (isTernaryJSXChild(node))
10681
+ return;
10646
10682
  if (node.type === TSESTree8.AST_NODE_TYPES.JSXFragment) {
10647
10683
  context.report({
10648
10684
  messageId: "missingKey",
@@ -10823,6 +10859,8 @@ function getHookName2(node) {
10823
10859
  function getMemberExpressionDepth(node) {
10824
10860
  let depth = 0;
10825
10861
  let current = node;
10862
+ if (current.type === TSESTree9.AST_NODE_TYPES.ChainExpression)
10863
+ current = current.expression;
10826
10864
  while (current.type === TSESTree9.AST_NODE_TYPES.MemberExpression) {
10827
10865
  depth += 1;
10828
10866
  current = current.object;
@@ -10831,6 +10869,8 @@ function getMemberExpressionDepth(node) {
10831
10869
  }
10832
10870
  function getRootIdentifier(node) {
10833
10871
  let current = node;
10872
+ if (current.type === TSESTree9.AST_NODE_TYPES.ChainExpression)
10873
+ current = current.expression;
10834
10874
  while (current.type === TSESTree9.AST_NODE_TYPES.MemberExpression)
10835
10875
  current = current.object;
10836
10876
  return current.type === TSESTree9.AST_NODE_TYPES.Identifier ? current : undefined;
@@ -10909,7 +10949,16 @@ function isStableValue(variable, identifierName, stableHooks) {
10909
10949
  function findTopmostMemberExpression(node) {
10910
10950
  let current = node;
10911
10951
  let { parent } = node;
10912
- while (parent?.type === TSESTree9.AST_NODE_TYPES.MemberExpression && parent.object === current) {
10952
+ while (parent) {
10953
+ if (parent.type === TSESTree9.AST_NODE_TYPES.CallExpression && parent.callee === current) {
10954
+ if (current.type === TSESTree9.AST_NODE_TYPES.MemberExpression)
10955
+ return current.object;
10956
+ break;
10957
+ }
10958
+ const isMemberParent = parent.type === TSESTree9.AST_NODE_TYPES.MemberExpression && parent.object === current;
10959
+ const isChainParent = parent.type === TSESTree9.AST_NODE_TYPES.ChainExpression;
10960
+ if (!isMemberParent && !isChainParent)
10961
+ break;
10913
10962
  current = parent;
10914
10963
  parent = parent.parent;
10915
10964
  }
@@ -11030,6 +11079,10 @@ function collectCaptures(node, sourceCode) {
11030
11079
  visit(current.property);
11031
11080
  return;
11032
11081
  }
11082
+ if (current.type === TSESTree9.AST_NODE_TYPES.ChainExpression) {
11083
+ visit(current.expression);
11084
+ return;
11085
+ }
11033
11086
  const keys2 = sourceCode.visitorKeys?.[current.type] ?? [];
11034
11087
  for (const key of keys2) {
11035
11088
  const value = current[key];
@@ -13130,4 +13183,4 @@ export {
13130
13183
  createBanInstancesOptions
13131
13184
  };
13132
13185
 
13133
- //# debugId=F981FE172662E0F564756E2164756E21
13186
+ //# debugId=8ED77B08FB4A984564756E2164756E21