8000 Bug: no-useless-constructor rule doesn't work properly with NestJS DI · Issue #5201 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Bug: no-useless-constructor rule doesn't work properly with NestJS DI #5201

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

Closed
4 tasks done
dkrylovdotcom opened this issue Jun 17, 2022 · 3 comments · Fixed by #5450
Closed
4 tasks done

Bug: no-useless-constructor rule doesn't work properly with NestJS DI #5201

dkrylovdotcom opened this issue Jun 17, 2022 · 3 comments · Fixed by #5450
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement New feature or request package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@dkrylovdotcom
Copy link
dkrylovdotcom commented Jun 17, 2022

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

Greetings, colleagues!

I faced with a problem of useless constructor with a rule: @typescript-eslint/no-useless-constructor

But in my case, it's false positive, coz here I use NestJS DI capabilities to pass necessary parameters in the constructor.
Yep, I understood, that is eslint thinkings that my super(repository) call is useless, but it's not true.

Any ideas? Is it a bug or I misunderstood something?

Reproduction Repository Link

https://github.com/dkrylovdotcom/nestjs-di-eslint-problem

Repro Steps

  1. clone the repo
  2. npm run lint

Versions

package version
@typescript-eslint/eslint-plugin 5.28.0
@typescript-eslint/parser 5.28.0
TypeScript 4.7.3
ESLint 8.17.0
node 16.15.0
@dkrylovdotcom dkrylovdotcom added bug Something isn't working triage Waiting for team members to take a look labels Jun 17, 2022
@bradzacher
Copy link
Member
bradzacher commented Jun 17, 2022

Nope - this rule just doesn't have support for treating directives on parameters as a marker for a useful constructor.
Haopy to accept a PR.


Side note - you needn't create such a large repo to reproduce this! Just one file with a constructor with a param with a decorator would have been more than enough to illustrate the problem!

@bradzacher bradzacher added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin accepting prs Go ahead, send a pull request that resolves this issue enhancement New feature or request and removed bug Something isn't working triage Waiting for team members to take a look labels Jun 17, 2022
@dkrylovdotcom
Copy link
Author

Thank you for the answer, Brad! Everything is clear.

Sorry, but there is no time for PR currently 😞

@armano2
Copy link
Collaborator
armano2 commented Jun 19, 2022

minimal reproduction case Playground

class Test extends Object {
  constructor(@Bar foo: string) {
    super(foo);
  }
}

yeonjuan added a commit to yeonjuan/typescript-eslint that referenced this issue Aug 15, 2022
JoshuaKGoldberg added a commit to yeonjuan/typescript-eslint that referenced this issue Aug 16, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue enhancement New feature or request package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0