eslint-plugin-absolute 0.11.0-beta.1 → 0.11.0-beta.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.
Files changed (2) hide show
  1. package/dist/index.js +22 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3653,6 +3653,20 @@ var noRedundantTypeAnnotation = createRule({
3653
3653
  return {};
3654
3654
  }
3655
3655
  const stringify = (type) => tsChecker.typeToString(type, undefined, ts2.TypeFormatFlags.NoTruncation | ts2.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope);
3656
+ const referencesTypeParam = (typeNode, name) => {
3657
+ let found = false;
3658
+ const visit = (node) => {
3659
+ if (found)
3660
+ return;
3661
+ if (ts2.isTypeReferenceNode(node) && ts2.isIdentifier(node.typeName) && node.typeName.text === name) {
3662
+ found = true;
3663
+ return;
3664
+ }
3665
+ ts2.forEachChild(node, visit);
3666
+ };
3667
+ visit(typeNode);
3668
+ return found;
3669
+ };
3656
3670
  const leansOnContextualInference = (initNode) => {
3657
3671
  const callLike = ts2.isCallExpression(initNode) || ts2.isNewExpression(initNode) ? initNode : null;
3658
3672
  if (!callLike)
@@ -3660,6 +3674,14 @@ var noRedundantTypeAnnotation = createRule({
3660
3674
  if (callLike.typeArguments && callLike.typeArguments.length > 0) {
3661
3675
  return false;
3662
3676
  }
3677
+ const resolved = tsChecker.getResolvedSignature(callLike);
3678
+ const declaration = resolved?.declaration;
3679
+ if (declaration && !ts2.isJSDocSignature(declaration)) {
3680
+ const typeParams = declaration.typeParameters;
3681
+ if (!typeParams || typeParams.length === 0)
3682
+ return false;
3683
+ return typeParams.some((typeParam) => !declaration.parameters.some((parameter) => parameter.type !== undefined && referencesTypeParam(parameter.type, typeParam.name.text)));
3684
+ }
3663
3685
  const calleeType = tsChecker.getTypeAtLocation(callLike.expression);
3664
3686
  const signatures = ts2.isNewExpression(callLike) ? calleeType.getConstructSignatures() : calleeType.getCallSignatures();
3665
3687
  return signatures.some((signature) => (signature.getTypeParameters()?.length ?? 0) > 0);
package/package.json CHANGED
@@ -40,5 +40,5 @@
40
40
  "typecheck": "bun run tsc --noEmit"
41
41
  },
42
42
  "type": "module",
43
- "version": "0.11.0-beta.1"
43
+ "version": "0.11.0-beta.2"
44
44
  }