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

What is right way to disable eslint rules? #456

Closed bondom closed 6 years ago

bondom commented 6 years ago

What version of TypeScript are you using? 2.7.1

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

What code were you trying to parse?

// eslint-disable
const a = 3;

What did you expect to happen? I expect to see clear code without warning

What happened? I see warning: [ts] 'a' is declared but its value is never read.

But If I replace // eslint-disable with @ts-ignore everything works fine.

Is there way to disable rules with eslint-disable but not ts-ignore?

mightyiam commented 6 years ago

This? https://eslint.org/docs/2.13.1/user-guide/configuring#disabling-rules-with-inline-comments

bondom commented 6 years ago

@mightyiam Sorry, but this doesn't work

j-f1 commented 6 years ago

I think the error you’re encountering is a TypeScript error, and you have to use // @ts-ignore to silence it.

mightyiam commented 6 years ago

I recognize this line format: [ts] 'a' is declared but its value is never read. from VS Code. It seems like a TypeScript error, indeed. Otherwise, it would say [eslint]..., or so.

bondom commented 6 years ago

@j-f1 @mightyiam If this is TypeScript error, it should be controlled by compiler options intsconfig.json, right? There is my tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": "./",
    "module": "esnext",
    "target": "es5",
    "lib": ["es6", "dom"],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    "rootDir": "src",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "allowUnusedLabels": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", ".tmp", "dist", "preprod"]
}

Also when I run tsc --noEmit --p ./tsconfig.json I get no errors.

So I think it is not related to tsconfig.json

When I deleted "no-unused-vars": "warn", from my .eslintrc file, project was successfully compiled, but vscode still shows this warning

mightyiam commented 6 years ago

noUnusedLocals: false is it. Yet, if you're getting this error in your editor, it probably means that your editor is not reading the tsconfig.json or so.

bondom commented 6 years ago

@mightyiam Yes! You are right! My TSLint extension was turned off

bondom commented 6 years ago

Thanks to all!