eslint / typescript-eslint-parser

An ESLint custom parser which leverages TypeScript ESTree to allow for ESLint to lint TypeScript source code.
Other
915 stars 92 forks source link

Parameter properties trigger `no-useless-constructor` #546

Closed o-nix closed 5 years ago

o-nix commented 5 years ago

What version of TypeScript are you using?

3.1.6

What version of typescript-eslint-parser are you using?

5.8.0 + standardjs config.

What code were you trying to parse?

constructor (private readonly appService: AppService) { }

What did you expect to happen?

Should be valid code.

What happened?

It currently triggers no-useless-constructor.

https://www.typescriptlang.org/docs/handbook/classes.html#parameter-properties

Parameter properties are declared by prefixing a constructor parameter with an accessibility modifier or readonly, or both. Using private for a parameter property declares and initializes a private member; likewise, the same is done for public, protected, and readonly.

So this shouldn't be invalid.

mysticatea commented 5 years ago

Thank you for this report.

That syntax doesn't exist in JavaScript, so the no-useless-constructor rule, one of ESLint core rule that verifies JavaScript, cannot realize the syntax. Please open issue on eslint-plugin-typescript to request a rule to check it for TypeScript.

....Hm, https://github.com/nzakas/eslint-plugin-typescript/issues/101 looks like the one.

o-nix commented 5 years ago

Oh, thank you for clarification!