@putout/plugin-remove-unused-variables
🐊Putout plugin adds ability to find and remove unused variables
Last updated 2 years ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @putout/plugin-remove-unused-variables 
SYNC missed versions from official npm registry.

@putout/plugin-remove-unused-variables NPM version

A variable is a container for a value, like a number we might use in a sum, or a string that we might use as part of a sentence.

(c) MDN

🐊Putout plugin adds ability to find and remove the variables that are declared, but:

  • not passed as argument to a function;
  • not used as operand in expression;

That is unused variables. Most likely it is a leftovers due to incomplete transforming of the code. Such variables take up space and gives no value so they must be removed.

☝️Remember, when you writing a transform you can skip all parts related to removing unused variables and just reuse current plugin it will make your code simpler and less error prone.

☝️No, you cannot just look at referenced and constant fields to determine if you can remove variable and here is why one of the biggest plugins exists.

Install

npm i @putout/plugin-remove-unused-variables -D

Rule

Rule remove-unused-variables is enabled by default, to disable add to .putout.json:

{
    "rules": {
        "remove-unused-variables": "off"
    }
}

❌ Example of incorrect code

const a = 'hello';
const b = 'world';

console.log(a);

✅ Example of correct code

const a = 'hello';
console.log(a);

Comparison

Linter Rule Fix
🐊 Putout remove-unused-variables
ESLint no-unused-vars

License

MIT

Current Tags

  • 9.2.0                                ...           latest (4 months ago)

109 Versions

  • 9.2.0                                ...           4 months ago
  • 9.1.0                                ...           5 months ago
  • 9.0.0                                ...           8 months ago
  • 8.1.0                                ...           a year ago
  • 8.0.0                                ...           a year ago
  • 7.0.0                                ...           a year ago
  • 6.0.2                                ...           a year ago
  • 6.0.1                                ...           a year ago
  • 6.0.0                                ...           a year ago
  • 5.4.0                                ...           2 years ago
  • 5.3.0                                ...           2 years ago
  • 5.2.0                                ...           2 years ago
  • 5.1.0                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.2.0                                ...           2 years ago
  • 4.1.0                                ...           2 years ago
  • 4.0.0                                ...           3 years ago
  • 3.8.1                                ...           3 years ago
  • 3.8.0                                ...           3 years ago
  • 3.7.0                                ...           3 years ago
  • 3.6.1                                ...           3 years ago
  • 3.6.0                                ...           3 years ago
  • 3.5.3                                ...           3 years ago
  • 3.5.1                                ...           3 years ago
  • 3.5.0                                ...           3 years ago
  • 3.4.0                                ...           3 years ago
  • 3.3.0                                ...           3 years ago
  • 3.2.0                                ...           3 years ago
  • 3.1.0                                ...           4 years ago
  • 3.0.0                                ...           4 years ago
  • 2.6.1                                ...           4 years ago
  • 2.6.0                                ...           4 years ago
  • 2.5.0                                ...           4 years ago
  • 2.4.0                                ...           4 years ago
  • 2.3.0                                ...           5 years ago
  • 2.2.0                                ...           5 years ago
  • 2.1.0                                ...           5 years ago
  • 2.0.1                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 1.57.0                                ...           5 years ago
  • 1.56.0                                ...           5 years ago
  • 1.55.0                                ...           5 years ago
  • 1.54.0                                ...           5 years ago
  • 1.53.0                                ...           5 years ago
  • 1.52.0                                ...           5 years ago
  • 1.51.1                                ...           5 years ago
  • 1.51.0                                ...           5 years ago
  • 1.50.0                                ...           5 years ago
  • 1.49.0                                ...           5 years ago
  • 1.48.0                                ...           5 years ago
  • 1.47.0                                ...           5 years ago
  • 1.46.0                                ...           5 years ago
  • 1.45.0                                ...           5 years ago
  • 1.44.0                                ...           5 years ago
  • 1.43.0                                ...           5 years ago
  • 1.42.0                                ...           5 years ago
  • 1.41.0                                ...           5 years ago
  • 1.40.0                                ...           5 years ago
  • 1.39.0                                ...           5 years ago
  • 1.38.0                                ...           5 years ago
  • 1.37.1                                ...           5 years ago
  • 1.37.0                                ...           5 years ago
  • 1.36.0                                ...           5 years ago
  • 1.35.1                                ...           5 years ago
  • 1.35.0                                ...           5 years ago
  • 1.34.0                                ...           5 years ago
  • 1.33.0                                ...           5 years ago
  • 1.32.0                                ...           5 years ago
  • 1.31.0                                ...           5 years ago
  • 1.30.1                                ...           5 years ago
  • 1.30.0                                ...           5 years ago
  • 1.29.0                                ...           5 years ago
  • 1.28.0                                ...           6 years ago
  • 1.27.1                                ...           6 years ago
  • 1.27.0                                ...           6 years ago
  • 1.26.1                                ...           6 years ago
  • 1.26.0                                ...           6 years ago
  • 1.25.1                                ...           6 years ago
  • 1.25.0                                ...           6 years ago
  • 1.24.0                                ...           6 years ago
  • 1.23.0                                ...           6 years ago
  • 1.22.0                                ...           6 years ago
  • 1.21.0                                ...           6 years ago
  • 1.20.0                                ...           6 years ago
  • 1.19.0                                ...           6 years ago
  • 1.18.0                                ...           6 years ago
  • 1.17.0                                ...           6 years ago
  • 1.16.0                                ...           6 years ago
  • 1.15.1                                ...           6 years ago
  • 1.15.0                                ...           6 years ago
  • 1.14.0                                ...           6 years ago
  • 1.13.0                                ...           6 years ago
  • 1.12.1                                ...           6 years ago
  • 1.12.0                                ...           6 years ago
  • 1.11.0                                ...           6 years ago
  • 1.10.0                                ...           6 years ago
  • 1.9.0                                ...           6 years ago
  • 1.8.0                                ...           6 years ago
  • 1.7.0                                ...           6 years ago
  • 1.6.0                                ...           6 years ago
  • 1.5.1                                ...           6 years ago
  • 1.5.0                                ...           6 years ago
  • 1.4.0                                ...           6 years ago
  • 1.3.1                                ...           6 years ago
  • 1.3.0                                ...           6 years ago
  • 1.2.0                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (10)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE