Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-unused-variable is deprecated. #4046

Closed
ghost opened this issue Jul 17, 2018 · 10 comments · Fixed by #4079
Closed

no-unused-variable is deprecated. #4046

ghost opened this issue Jul 17, 2018 · 10 comments · Fixed by #4079

Comments

@ghost
Copy link

ghost commented Jul 17, 2018

Bug Report

  • TSLint version: 5.11.0
  • TypeScript version: 2.9.2
  • Running TSLint via: Node.js

TypeScript code being linted

The "tslint:all" rules give a : "no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead."

with tslint.json configuration:

{
    "extends": [
        "tslint:all"
    ],
    "defaultSeverity": "error",
    "rules": {
        "completed-docs": false,
        "prefer-for-of": false,
        "strict-type-predicates": false,
        "only-arrow-functions": [
            true,
            "allow-named-functions"
        ],
        "no-inferrable-types": [
            false,
            "ignore-params",
            "ignore-properties"
        ],
        "max-line-length": [
            false,
            170
        ],
        "align": [
            false
        ],
        "no-unnecessary-type-assertion": false,
        "prefer-switch": false
    }
}

@kachkaev
Copy link

kachkaev commented Jul 17, 2018

I'm also not sure why I'm seeing the deprecation warning given that "no-unused-variable" has been un-deprecated in #2256. 🤔

yarn tsc --version
# 2.9.2
yarn tslint --version
# 5.11.0

yarn tslint --project .
no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead.
tslint.json
{
  "extends": ["tslint:recommended", "tslint-config-prettier"],
  "rules": {
    "interface-name": [true, "never-prefix"],
    "no-console": false,
    "no-unused-variable": {"severity": "warning"},
    "object-literal-sort-keys": false
  }
}

It sometimes makes sence to use "no-unused-variable": {"severity": "warning"} rather than going for "noUnusedLocals" / "noUnusedParameters" in tsconfig.json. When you are developing something quick and dirty, you do want things to compile even when they are not ideal, yet get some gentle feedback as you edit the stuff.

@howardjing
Copy link

It looks like it was redeprecated in release 5.11.0 as per the changelog: https://github.com/palantir/tslint/blob/master/CHANGELOG.md#warning-deprecations

@johnwiseheart
Copy link
Contributor

The deprecation is intentional. Please see #3919 for details.

@realtebo
Copy link

So, now how to get rid of this warning?

"tslint": "^5.11.0",
"typescript": "^3.0.1"

> tslint --project tsconfig.json

no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead.

ans this the config json

{
  "compilerOptions": {
    "lib": ["es6"],
    "module": "commonjs",
    "noImplicitReturns": true,
    "outDir": "lib",
    "sourceMap": true,
    "target": "es6",
    "allowJs" : true
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}

I suggest to add at least a tip of what to do to fix, because in my config this rules is not present.

@kachkaev
Copy link

The warning comes from tslint.json rather than tsconfig.json. Check if you have "no-unused-variable" right in there or in any of configs declared in "extends".

@realtebo
Copy link

I removed from tslint.json and .eslintrc.json.

Warning is still here. How to 'mute' it?

This demonstrate that a warning need additional infos to be usefull to users because not every dev know where it come from. I am one of them.

@franzisk
Copy link

Just let your tsling.json like this:

{
  "rules": {
    "no-duplicate-variable": true
  },
  "rulesDirectory": [
    "node_modules/tslint-eslint-rules/dist/rules"
  ]
}

@andyfleming
Copy link

I agree with @kachkaev that having a compilation failure is very annoying during active development. Linting is specifically where I want to catch this issue.

nelsyeung pushed a commit to nelsyeung/tslint-config-airbnb-base that referenced this issue Feb 4, 2019
- "no-unused-variables" has been deprecated, see palantir/tslint#4046
  for more information.
@ghost
Copy link

ghost commented Feb 12, 2019

I want this rule so I can use --fix and fix it automatically.

@adidahiya
Copy link
Contributor

continue discussion in #4100

@palantir palantir locked as resolved and limited conversation to collaborators Feb 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants