Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

no-useless-constructor / no-empty-function with mixed JS & TS codebase #418

Closed
scottohara opened this issue Dec 19, 2017 · 3 comments
Closed
Labels

Comments

@scottohara
Copy link

(As discussed in #77 (comment))

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?

export default class Foo {
  constructor(private name: string) {}

  get greeting() : string {
    return `Hello ${this.name}`;
  }
}

What did you expect to happen?
No errors/warnings about empty constructor.

What happened?

  2:2   error  Useless constructor           no-useless-constructor
  2:36  error  Unexpected empty constructor  no-empty-function

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.

@j-f1
Copy link
Contributor

j-f1 commented Dec 19, 2017

This would probably have to be fixed by forking those rules into eslint-plugin-typescript and silencing​ warnings where they’re not appropriate.

@JamesHenry
Copy link
Member

Yes, @j-f1 is correct! This will definitely have to be addressed via a new rule, because it is entirely TypeScript-specific.

@scottohara Please can you open an issue on https://github.com/nzakas/eslint-plugin-typescript?

@scottohara
Copy link
Author

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

No branches or pull requests

3 participants