Skip to content

[no-unsafe-return] option to allow returning any if the function explicitly declares returning any #3482

@JoshuaKGoldberg

Description

@JoshuaKGoldberg
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/no-unsafe-return": "error"
  }
}
function returnsAnyIntentionally(input: string): any {
  return JSON.parse(input);
}

Practically, see removeLocationDataAndSourceTypeFromProgramNode internally. https://github.com/typescript-eslint/typescript-eslint/blob/9524424a4bce09dafb7eb0d6c322f07f2a0003da/packages/typescript-estree/tests/ast-alignment/utils.ts

Expected Result

Suppose you have a function that intentionally has a : any return type declared and returns something that is any.

Can we add an option to the rule like allowExplicitAny that prevents a rule complaint if the function has that : any?

Actual Result

This rule still gives a complaint on that, even though the any is intentional.

Versions

package version
@typescript-eslint/eslint-plugin 4.26.0
@typescript-eslint/parser 4.26.0
TypeScript 4.3.2
ESLint 7.27.0
node 12.16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy