@pobammer-ts/eslint-cease-nonsense-rules 1.5.0 → 1.5.2

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": "94d6b486c572f905054ee7538b5df44541ad1eaa",
3
- "time": "2025-12-11T01:19:08.613Z",
4
- "version": "1.5.0"
2
+ "commit": "12c06ad5566d08fbf3f48f5203aff7fdc61a801f",
3
+ "time": "2025-12-11T22:26:23.456Z",
4
+ "version": "1.5.2"
5
5
  }
@@ -2,7 +2,7 @@ import type { BanInstancesOptions } from "./rules/ban-instances";
2
2
  import type { ComplexityConfiguration } from "./rules/enforce-ianitor-check-type";
3
3
  import type { NoInstanceMethodsOptions } from "./rules/no-instance-methods-without-this";
4
4
  import type { NoShorthandOptions } from "./rules/no-shorthand-names";
5
- import type { NoUselessUseSpringOptions } from "./rules/no-useless-use-spring";
5
+ import { type NoUselessUseSpringOptions } from "./rules/no-useless-use-spring";
6
6
  import type { EffectFunctionOptions, HookConfiguration } from "./rules/require-named-effect-functions";
7
7
  import type { PairConfiguration, RequirePairedCallsOptions } from "./rules/require-paired-calls";
8
8
  import type { ReactKeysOptions } from "./rules/require-react-component-keys";
package/dist/index.js CHANGED
@@ -17705,8 +17705,35 @@ var no_shorthand_names_default = noShorthandNames;
17705
17705
  // src/rules/no-useless-use-spring.ts
17706
17706
  var import_scope_manager = __toESM(require_dist2(), 1);
17707
17707
  import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/utils";
17708
+ var DEFAULT_STATIC_GLOBAL_FACTORIES = [
17709
+ "Axes",
17710
+ "BrickColor",
17711
+ "CFrame",
17712
+ "Color3",
17713
+ "ColorSequence",
17714
+ "ColorSequenceKeypoint",
17715
+ "DateTime",
17716
+ "Faces",
17717
+ "NumberRange",
17718
+ "NumberSequence",
17719
+ "NumberSequenceKeypoint",
17720
+ "PathWaypoint",
17721
+ "PhysicalProperties",
17722
+ "Ray",
17723
+ "Rect",
17724
+ "Region3",
17725
+ "Region3int16",
17726
+ "TweenInfo",
17727
+ "UDim",
17728
+ "UDim2",
17729
+ "Vector2",
17730
+ "Vector3",
17731
+ "Vector3int16",
17732
+ "Vector3int32"
17733
+ ];
17708
17734
  var DEFAULT_OPTION_VALUES = {
17709
17735
  springHooks: ["useSpring"],
17736
+ staticGlobalFactories: DEFAULT_STATIC_GLOBAL_FACTORIES,
17710
17737
  treatEmptyDepsAsViolation: true
17711
17738
  };
17712
17739
  var STATIC_UNARY_OPERATORS = new Set(["-", "+", "!", "~", "typeof", "void", "delete"]);
@@ -17725,6 +17752,14 @@ function unwrapExpression(expression) {
17725
17752
  current = current.expression;
17726
17753
  continue;
17727
17754
  }
17755
+ if (current.type === AST_NODE_TYPES3.TSSatisfiesExpression) {
17756
+ current = current.expression;
17757
+ continue;
17758
+ }
17759
+ if (current.type === AST_NODE_TYPES3.TSInstantiationExpression) {
17760
+ current = current.expression;
17761
+ continue;
17762
+ }
17728
17763
  if (current.type === AST_NODE_TYPES3.ChainExpression) {
17729
17764
  current = current.expression;
17730
17765
  continue;
@@ -17764,10 +17799,10 @@ function getConstInitializer(definition) {
17764
17799
  return;
17765
17800
  return declarator.init ?? undefined;
17766
17801
  }
17767
- function isStaticIdentifier(context, identifier3, seen) {
17802
+ function isStaticIdentifier(context, identifier3, seen, options3) {
17768
17803
  const variable = findVariable(context, identifier3);
17769
17804
  if (variable === undefined)
17770
- return false;
17805
+ return options3.staticGlobalFactories.has(identifier3.name);
17771
17806
  if (!isModuleLevelScope(variable.scope))
17772
17807
  return false;
17773
17808
  if (isImport(variable))
@@ -17776,43 +17811,43 @@ function isStaticIdentifier(context, identifier3, seen) {
17776
17811
  const initializer = getConstInitializer(definition);
17777
17812
  if (initializer === undefined)
17778
17813
  continue;
17779
- if (isStaticExpression(context, initializer, seen))
17814
+ if (isStaticExpression(context, initializer, seen, options3))
17780
17815
  return true;
17781
17816
  }
17782
17817
  return false;
17783
17818
  }
17784
- function isStaticMemberProperty(property, seen) {
17819
+ function isStaticMemberProperty(property, seen, options3) {
17785
17820
  if (property.type === AST_NODE_TYPES3.PrivateIdentifier)
17786
17821
  return false;
17787
17822
  if (property.type === AST_NODE_TYPES3.Identifier)
17788
17823
  return true;
17789
- return isStaticExpressionInner(property, seen);
17824
+ return isStaticExpressionInner(property, seen, options3);
17790
17825
  }
17791
- function isStaticCallCallee(context, callee, seen) {
17826
+ function isStaticCallCallee(context, callee, seen, options3) {
17792
17827
  const unwrapped = unwrapExpression(callee);
17793
17828
  if (unwrapped.type === AST_NODE_TYPES3.Identifier)
17794
- return isStaticIdentifier(context, unwrapped, seen);
17829
+ return isStaticIdentifier(context, unwrapped, seen, options3);
17795
17830
  if (unwrapped.type === AST_NODE_TYPES3.MemberExpression) {
17796
- if (!isStaticExpression(context, unwrapped.object, seen))
17831
+ if (!isStaticExpression(context, unwrapped.object, seen, options3))
17797
17832
  return false;
17798
17833
  if (unwrapped.computed)
17799
- return isStaticMemberProperty(unwrapped.property, seen);
17834
+ return isStaticMemberProperty(unwrapped.property, seen, options3);
17800
17835
  return unwrapped.property.type === AST_NODE_TYPES3.Identifier;
17801
17836
  }
17802
17837
  return false;
17803
17838
  }
17804
- function isStaticObjectExpression(context, objectExpr, seen) {
17839
+ function isStaticObjectExpression(context, objectExpr, seen, options3) {
17805
17840
  for (const property of objectExpr.properties) {
17806
17841
  if (property.type !== AST_NODE_TYPES3.Property)
17807
17842
  return false;
17808
17843
  if (property.kind !== "init")
17809
17844
  return false;
17810
- if (property.computed && !isStaticExpressionInner(property.key, seen))
17845
+ if (property.computed && !isStaticExpressionInner(property.key, seen, options3))
17811
17846
  return false;
17812
17847
  const value = property.value;
17813
17848
  if (!isNonPatternExpression(value))
17814
17849
  return false;
17815
- if (!isStaticExpression(context, value, seen))
17850
+ if (!isStaticExpression(context, value, seen, options3))
17816
17851
  return false;
17817
17852
  }
17818
17853
  return true;
@@ -17823,10 +17858,10 @@ function isNonPatternExpression(value) {
17823
17858
  function isNonPrivateExpression(value) {
17824
17859
  return value.type !== AST_NODE_TYPES3.PrivateIdentifier;
17825
17860
  }
17826
- function isStaticObjectLikeConfig(context, expression, seen) {
17861
+ function isStaticObjectLikeConfig(context, expression, seen, options3) {
17827
17862
  const unwrapped = unwrapExpression(expression);
17828
17863
  if (unwrapped.type === AST_NODE_TYPES3.ObjectExpression)
17829
- return isStaticObjectExpression(context, unwrapped, seen);
17864
+ return isStaticObjectExpression(context, unwrapped, seen, options3);
17830
17865
  if (unwrapped.type === AST_NODE_TYPES3.Identifier) {
17831
17866
  const variable = findVariable(context, unwrapped);
17832
17867
  if (variable === undefined)
@@ -17842,27 +17877,27 @@ function isStaticObjectLikeConfig(context, expression, seen) {
17842
17877
  const normalizedInitializer = unwrapExpression(initializer);
17843
17878
  if (normalizedInitializer.type !== AST_NODE_TYPES3.ObjectExpression)
17844
17879
  continue;
17845
- if (isStaticObjectExpression(context, normalizedInitializer, seen))
17880
+ if (isStaticObjectExpression(context, normalizedInitializer, seen, options3))
17846
17881
  return true;
17847
17882
  }
17848
17883
  }
17849
17884
  return false;
17850
17885
  }
17851
- function isStaticArrayExpression(context, arrayExpr, seen) {
17886
+ function isStaticArrayExpression(context, arrayExpr, seen, options3) {
17852
17887
  for (const element of arrayExpr.elements) {
17853
17888
  if (!element)
17854
17889
  continue;
17855
17890
  if (element.type === AST_NODE_TYPES3.SpreadElement)
17856
17891
  return false;
17857
- if (!isStaticExpression(context, element, seen))
17892
+ if (!isStaticExpression(context, element, seen, options3))
17858
17893
  return false;
17859
17894
  }
17860
17895
  return true;
17861
17896
  }
17862
- function isStaticExpressionInner(node, seen) {
17863
- return isStaticExpression(undefined, node, seen);
17897
+ function isStaticExpressionInner(node, seen, options3) {
17898
+ return isStaticExpression(undefined, node, seen, options3);
17864
17899
  }
17865
- function isStaticExpression(context, expression, seen = new Set) {
17900
+ function isStaticExpression(context, expression, seen, options3) {
17866
17901
  const unwrapped = unwrapExpression(expression);
17867
17902
  if (seen.has(unwrapped))
17868
17903
  return true;
@@ -17873,37 +17908,37 @@ function isStaticExpression(context, expression, seen = new Set) {
17873
17908
  case AST_NODE_TYPES3.TemplateLiteral:
17874
17909
  return unwrapped.expressions.length === 0;
17875
17910
  case AST_NODE_TYPES3.UnaryExpression:
17876
- return STATIC_UNARY_OPERATORS.has(unwrapped.operator) && isStaticExpression(context, unwrapped.argument, seen);
17911
+ return STATIC_UNARY_OPERATORS.has(unwrapped.operator) && isStaticExpression(context, unwrapped.argument, seen, options3);
17877
17912
  case AST_NODE_TYPES3.BinaryExpression:
17878
17913
  case AST_NODE_TYPES3.LogicalExpression:
17879
17914
  if (!isNonPrivateExpression(unwrapped.left) || !isNonPrivateExpression(unwrapped.right))
17880
17915
  return false;
17881
- return isStaticExpression(context, unwrapped.left, seen) && isStaticExpression(context, unwrapped.right, seen);
17916
+ return isStaticExpression(context, unwrapped.left, seen, options3) && isStaticExpression(context, unwrapped.right, seen, options3);
17882
17917
  case AST_NODE_TYPES3.ConditionalExpression:
17883
- return isStaticExpression(context, unwrapped.test, seen) && isStaticExpression(context, unwrapped.consequent, seen) && isStaticExpression(context, unwrapped.alternate, seen);
17918
+ return isStaticExpression(context, unwrapped.test, seen, options3) && isStaticExpression(context, unwrapped.consequent, seen, options3) && isStaticExpression(context, unwrapped.alternate, seen, options3);
17884
17919
  case AST_NODE_TYPES3.ArrayExpression:
17885
- return context !== undefined && isStaticArrayExpression(context, unwrapped, seen);
17920
+ return context !== undefined && isStaticArrayExpression(context, unwrapped, seen, options3);
17886
17921
  case AST_NODE_TYPES3.ObjectExpression:
17887
- return context !== undefined && isStaticObjectExpression(context, unwrapped, seen);
17922
+ return context !== undefined && isStaticObjectExpression(context, unwrapped, seen, options3);
17888
17923
  case AST_NODE_TYPES3.Identifier:
17889
- return context !== undefined && isStaticIdentifier(context, unwrapped, seen);
17924
+ return context !== undefined && isStaticIdentifier(context, unwrapped, seen, options3);
17890
17925
  case AST_NODE_TYPES3.MemberExpression:
17891
- return isStaticExpression(context, unwrapped.object, seen) && (!unwrapped.computed || isStaticMemberProperty(unwrapped.property, seen));
17926
+ return isStaticExpression(context, unwrapped.object, seen, options3) && (!unwrapped.computed || isStaticMemberProperty(unwrapped.property, seen, options3));
17892
17927
  case AST_NODE_TYPES3.ChainExpression:
17893
- return isStaticExpression(context, unwrapped.expression, seen);
17928
+ return isStaticExpression(context, unwrapped.expression, seen, options3);
17894
17929
  case AST_NODE_TYPES3.CallExpression:
17895
- return context !== undefined && isStaticCallCallee(context, unwrapped.callee, seen) && unwrapped.arguments.every((arg) => arg.type !== AST_NODE_TYPES3.SpreadElement && isStaticExpression(context, arg, seen));
17930
+ return context !== undefined && isStaticCallCallee(context, unwrapped.callee, seen, options3) && unwrapped.arguments.every((arg) => arg.type !== AST_NODE_TYPES3.SpreadElement && isStaticExpression(context, arg, seen, options3));
17896
17931
  case AST_NODE_TYPES3.NewExpression:
17897
- return context !== undefined && isStaticCallCallee(context, unwrapped.callee, seen) && (unwrapped.arguments ?? []).every((arg) => arg.type !== AST_NODE_TYPES3.SpreadElement && isStaticExpression(context, arg, seen));
17932
+ return context !== undefined && isStaticCallCallee(context, unwrapped.callee, seen, options3) && (unwrapped.arguments ?? []).every((arg) => arg.type !== AST_NODE_TYPES3.SpreadElement && isStaticExpression(context, arg, seen, options3));
17898
17933
  case AST_NODE_TYPES3.SequenceExpression:
17899
- return unwrapped.expressions.length > 0 && unwrapped.expressions.every((expr) => isStaticExpression(context, expr, seen));
17934
+ return unwrapped.expressions.length > 0 && unwrapped.expressions.every((expr) => isStaticExpression(context, expr, seen, options3));
17900
17935
  case AST_NODE_TYPES3.AssignmentExpression:
17901
- return isStaticExpression(context, unwrapped.right, seen);
17936
+ return isStaticExpression(context, unwrapped.right, seen, options3);
17902
17937
  default:
17903
17938
  return false;
17904
17939
  }
17905
17940
  }
17906
- function classifyDependencies(context, argument, seen) {
17941
+ function classifyDependencies(context, argument, seen, options3) {
17907
17942
  if (argument === undefined)
17908
17943
  return 0 /* MissingOrOmitted */;
17909
17944
  if (argument.type === AST_NODE_TYPES3.SpreadElement)
@@ -17913,7 +17948,7 @@ function classifyDependencies(context, argument, seen) {
17913
17948
  return 3 /* DynamicOrUnknown */;
17914
17949
  if (expr.elements.length === 0)
17915
17950
  return 1 /* EmptyArray */;
17916
- if (isStaticArrayExpression(context, expr, seen))
17951
+ if (isStaticArrayExpression(context, expr, seen, options3))
17917
17952
  return 2 /* StaticArray */;
17918
17953
  return 3 /* DynamicOrUnknown */;
17919
17954
  }
@@ -17925,7 +17960,15 @@ function depsAreNonUpdating(kind, options3) {
17925
17960
  return false;
17926
17961
  }
17927
17962
  function isSpringHookCall(node, options3) {
17928
- return node.callee.type === AST_NODE_TYPES3.Identifier && options3.springHooks.has(node.callee.name);
17963
+ const { callee } = node;
17964
+ if (callee.type === AST_NODE_TYPES3.Identifier)
17965
+ return options3.springHooks.has(callee.name);
17966
+ if (callee.type === AST_NODE_TYPES3.MemberExpression && !callee.computed) {
17967
+ const { property } = callee;
17968
+ if (property.type === AST_NODE_TYPES3.Identifier)
17969
+ return options3.springHooks.has(property.name);
17970
+ }
17971
+ return false;
17929
17972
  }
17930
17973
  var noUselessUseSpring = {
17931
17974
  create(context) {
@@ -17933,7 +17976,8 @@ var noUselessUseSpring = {
17933
17976
  const normalized = {
17934
17977
  ...DEFAULT_OPTION_VALUES,
17935
17978
  ...rawOptions,
17936
- springHooks: new Set(rawOptions?.springHooks ?? DEFAULT_OPTION_VALUES.springHooks)
17979
+ springHooks: new Set(rawOptions?.springHooks ?? DEFAULT_OPTION_VALUES.springHooks),
17980
+ staticGlobalFactories: new Set(rawOptions?.staticGlobalFactories ?? DEFAULT_OPTION_VALUES.staticGlobalFactories)
17937
17981
  };
17938
17982
  return {
17939
17983
  CallExpression(node) {
@@ -17947,9 +17991,9 @@ var noUselessUseSpring = {
17947
17991
  if (configArgument.type === AST_NODE_TYPES3.SpreadElement)
17948
17992
  return;
17949
17993
  const seen = new Set;
17950
- if (!isStaticObjectLikeConfig(context, configArgument, seen))
17994
+ if (!isStaticObjectLikeConfig(context, configArgument, seen, normalized))
17951
17995
  return;
17952
- const depsKind = classifyDependencies(context, node.arguments[1], seen);
17996
+ const depsKind = classifyDependencies(context, node.arguments[1], seen, normalized);
17953
17997
  if (!depsAreNonUpdating(depsKind, normalized))
17954
17998
  return;
17955
17999
  context.report({
@@ -17976,6 +18020,12 @@ var noUselessUseSpring = {
17976
18020
  items: { type: "string" },
17977
18021
  type: "array"
17978
18022
  },
18023
+ staticGlobalFactories: {
18024
+ default: [...DEFAULT_STATIC_GLOBAL_FACTORIES],
18025
+ description: "Global factory identifiers that are treated as static constructors",
18026
+ items: { type: "string" },
18027
+ type: "array"
18028
+ },
17979
18029
  treatEmptyDepsAsViolation: {
17980
18030
  default: true,
17981
18031
  description: "Treat static config with an empty dependency array as a violation",
@@ -20199,14 +20249,15 @@ function collectCaptures(node, sourceCode) {
20199
20249
  function parseDependencies(node, sourceCode) {
20200
20250
  const dependencies4 = new Array;
20201
20251
  for (const element of node.elements) {
20202
- if (!element || element.type === TSESTree9.AST_NODE_TYPES.SpreadElement)
20252
+ if (!element)
20203
20253
  continue;
20204
- const name = nodeToDependencyString(element, sourceCode);
20205
- const depth = getMemberExpressionDepth(element);
20254
+ const actualNode = element.type === TSESTree9.AST_NODE_TYPES.SpreadElement ? element.argument : element;
20255
+ const name = nodeToDependencyString(actualNode, sourceCode);
20256
+ const depth = getMemberExpressionDepth(actualNode);
20206
20257
  dependencies4.push({
20207
20258
  depth,
20208
20259
  name,
20209
- node: element
20260
+ node: actualNode
20210
20261
  });
20211
20262
  }
20212
20263
  return dependencies4;
@@ -20939,6 +20990,7 @@ function createUseHookAtTopLevelOptions(options3 = {}) {
20939
20990
  function createNoUselessUseSpringOptions(options3 = {}) {
20940
20991
  return {
20941
20992
  springHooks: ["useSpring"],
20993
+ staticGlobalFactories: DEFAULT_STATIC_GLOBAL_FACTORIES,
20942
20994
  treatEmptyDepsAsViolation: true,
20943
20995
  ...options3
20944
20996
  };
@@ -21010,4 +21062,4 @@ export {
21010
21062
  createBanInstancesOptions
21011
21063
  };
21012
21064
 
21013
- //# debugId=5161D4E9740EB54264756E2164756E21
21065
+ //# debugId=EA151AE69FFBBA3C64756E2164756E21