Skip to content

@typescript-eslint/no-useless-constructor won't turn off. #873

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
gpresland opened this issue Aug 16, 2019 · 3 comments
Closed

@typescript-eslint/no-useless-constructor won't turn off. #873

gpresland opened this issue Aug 16, 2019 · 3 comments
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin working as intended Issues that are closed as they are working as intended

Comments

@gpresland
Copy link

gpresland commented Aug 16, 2019

What code were you trying to parse?

  constructor() {
    super();
  }

with .eslintrc.js

  rules: {
    "no-useless-constructor": "off",
    "@typescript-eslint/no-useless-constructor": false
  }

and tslint.json

  "jsRules": {
    "no-useless-constructor": "off",
    "@typescript-eslint/no-useless-constructor": false
  },
  "rules": {
    "no-useless-constructor": "off",
    "@typescript-eslint/no-useless-constructor": false
  },

along with every value combinations off "off", false, and 0.

Documentation followed at:

https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md

What did you expect to happen?

Expect to receive no warnings for useless constructors.

What actually happened?

Compiled with warnings.

Line 31:  Useless constructor  @typescript-eslint/no-useless-constructor

Versions

package version
@typescript-eslint/eslint-plugin-tslint 1.6.0
@typescript-eslint/parser 1.6.0
TypeScript 3.5.2
ESLint 5.16.0
node 10.16.0
npm 6.9.0
@gpresland gpresland added package: eslint-plugin-tslint Issues related to @typescript-eslint/eslint-plugin-tslint triage Waiting for team members to take a look labels Aug 16, 2019
@bradzacher
Copy link
Member

bradzacher commented Aug 16, 2019

Could you post your eslint config as well?

Chances are you're using a config set which uses overrides to apply the rule to typescript files only. Considering you're on eslint 5, you'd then need to aslo disable the rule in an overrides block. (This has been fixed in eslint6).

I also notice you're using v1.6 of our tooling, why are you on such an old version? You should upgrade as you're missing a large number of bug fixes and performance improvements.

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin and removed package: eslint-plugin-tslint Issues related to @typescript-eslint/eslint-plugin-tslint triage Waiting for team members to take a look labels Aug 16, 2019
@gpresland
Copy link
Author

gpresland commented Aug 16, 2019

@bradzacher

This was all created roughly a month ago with create-react-app and Storybook. The version of 1.6.0 in the tooling is what I see for the version value in the package.json under node_modules@typescript-eslint that create-react-app installed. I didn't install these modules manually, create-react-app installed them automatically.

A fresh test of create-react-app appears to install version 1.13.0.

Looking through the files after your input, I am not sure why I have an .eslintrc file as all files are TypeScript and am using TSLint. I've deleted my .eslintrc file and removed tslint-config-airbnb and the problem continues to persists.

Here is the .eslintrc anyways though as requested:

module.exports = {
  env: {
    browser: true,
    es6: true,
  },
  extends: [
    "airbnb",
  ],
  globals: {
    Atomics: "readonly",
    SharedArrayBuffer: "readonly",
  },
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: "module",
  },
  plugins: [
    "react",
  ],
  rules: {
    "comma-dangle": 0,
    "global-require": 0,
    "import/no-unresolved": 0,
    "react/jsx-filename-extension": 0,
    "no-useless-constructor": 0,
    "@typescript-eslint/no-useless-constructor": 0
  }
};

Current tslint.json file

{
  "defaultSeverity": "error",
  "extends": [
    "tslint-react"
  ],
  "jsRules": {},
  "rules": {
    "jsx-boolean-value": false,
    "jsx-no-multiline-js": false,
    "no-empty": false,
    "no-empty-interface": false,
    "no-useless-constructor": false,
    "@typescript-eslint/no-useless-constructor": false
  },
  "rulesDirectory": []
}

@bradzacher bradzacher added working as intended Issues that are closed as they are working as intended and removed awaiting response Issues waiting for a reply from the OP or another party labels Aug 16, 2019
@bradzacher
Copy link
Member

bradzacher commented Aug 16, 2019

create-react-app provides config by default.
Even if you provide it none, or you provide it your own, it still forces you to use its config as well.

This is the config: https://github.com/facebook/create-react-app/blob/master/packages/eslint-config-react-app/index.js

Note that, as expected, it uses an overrides block to apply the rule to typescript files only.

You will have to use a similar overrides block in your config because you're using eslint v5.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin working as intended Issues that are closed as they are working as intended
Projects
None yet
Development

No branches or pull requests

2 participants