-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[no-useless-constructor] / [no-empty-function] with mixed JS & TS codebase #48
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
Comments
I'm curious what the proper solution is here. Should these rules be implemented in this plugin to support TypeScript's constructor syntax, since class Foo {
private name: string
constructor(name: string) {
this.name = name
}
} I'd like to help out, but I'm not sure I understand what the next steps should be. |
Yes the eslint rule should be forked into this plugin and fixed to understand TypeScript just like https://github.com/nzakas/eslint-plugin-typescript/blob/master/docs/rules/no-unused-vars.md |
Cool, thanks for that info, @corbinu! |
Really glad your helping out! |
no-useless-constructor
/ no-empty-function
with mixed JS & TS codebase
Please try out 1.2.0 and see if it helps - it's possible that no-empty-function is not yet taken care of, but if that's the case please open a dedicate issue. Many thanks! |
this issue is still valid for
is still going to error |
The new Unfortunately the new rule won't help in mixed JS & TS codebases, as per the issue title. I was hoping that the (I'm guessing that this simply isn't possible, and that once an error has been flagged by a rule, there's no way for that error to be 'unflagged'?) A similar issue exists with a number of other I appreciate that mixed JS & TS codebases may not be the primary use case for most, but having to disable the older rules means developers working in mixed codebases (or are still in the process of migrating from JS to TS) have to choose which language they want these rules to apply to, and not both. |
@scottohara can you give me example of issue with |
// no-useless-constructor.js
class Foo {
constructor() {}
} // no-useless-constructor.ts
class Foo {
constructor(private name: string) {}
}
The expectation here is that the constructor in the With both rules enabled, we get 3 errors:
|
we are not able to augment how eslint rules are working, you should use only |
So I believe closing this was correct, and that a new focused issue should be created for |
i didn't see any issues for |
Spawned off into #426 so it's clearly tracked |
(This issue was originally raised in eslint/typescript-eslint-parser#418; and it was suggested that it would be more appropriately logged here, as it is not something that the parser can handle)
What version of TypeScript are you using?
2.6.2
What version of
typescript-eslint-parser
are you using?9.0.0
What code were you trying to parse?
What did you expect to happen?
No errors/warnings about empty constructor.
What happened?
For now, I have turned off these two rules in my
.ts
projects; but for projects that mix*.ts
and*.js
code, it would be nice to be able to have these rules enabled to catch any useless constructors/empty functions in*.js
code without it also warning about valid*.ts
constructors.The text was updated successfully, but these errors were encountered: