Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S2814 might not be needed in TypeScript #3580

Closed
gabriel-vivas-sonarsource opened this issue Nov 23, 2022 · 1 comment · Fixed by #3635
Closed

S2814 might not be needed in TypeScript #3580

gabriel-vivas-sonarsource opened this issue Nov 23, 2022 · 1 comment · Fixed by #3635
Assignees
Milestone

Comments

@gabriel-vivas-sonarsource
Copy link

gabriel-vivas-sonarsource commented Nov 23, 2022

Label Description
Rule S2814 "Variables and functions should not be redeclared"
Subject FP on TypeScript type and function with same name
Community https://community.sonarsource.com/t/typescript-file-produces-a-false-positive-already-defined-when-types-and-variable-share-same-name/76080

Explanation

type and function have different name spaces in TypeScript, so we should not raise an issue for this case.
Notice that this also applies to variables, namespace, interface, and perhaps more.

See many FP in Peach (internal):

Suggestion

The TypeScript compiler will already check for reused names and output an error.
So this rule does not make much sense in TypeScript, as compared to JavaScript.

Regardless of potential fixes to the FP, we should consider removing this rule for TypeScript.
Or at least remove it from the "Sonar Way" profile for TypeScript.

@saberduck
Copy link
Contributor

We need programmatically deprecate the rule in TypeScriptRulesDefinition and JavaScriptProfilesDefinition because metadata is shared for both JS and TS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants