Create-react-app: no-useless-constructor eslint rule with typescript false positive

Created on 23 Apr 2019  路  3Comments  路  Source: facebook/create-react-app

v3.0.0

There seems to be cases where eslint rule "no-useless-constructor" will give false positives when used with typescript

e.g.

  constructor(private readonly x: number) {}

That constructor is not really useless since it will assign the given parameter to this.x, so maybe consider dropping that rule for now for typescript?

typescript

Most helpful comment

Ignore me @xaviergonz, hard to debug from phone 馃槢.

It looks like there's already a typescript-eslint equivalent: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/rules/no-useless-constructor.ts.

I'll fix this up and it will be part of our next release. Thanks for reporting!

All 3 comments

Yeah this seems like a bug. Do you mind opening an issue in the typescript-eslint repo and linking back here so we can track?

Sorry just realized that the rule you linked is the ESLint rule right (sorry on phone). May be worth posting in typescript-eslint anyways as they may need their own version of the rule.

Ignore me @xaviergonz, hard to debug from phone 馃槢.

It looks like there's already a typescript-eslint equivalent: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/rules/no-useless-constructor.ts.

I'll fix this up and it will be part of our next release. Thanks for reporting!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrice727 picture adrice727  路  3Comments

alleroux picture alleroux  路  3Comments

alleroux picture alleroux  路  3Comments

ap13p picture ap13p  路  3Comments

dualcnhq picture dualcnhq  路  3Comments