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

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

????Putout plugin adds ability to find and remove useless variables. Renamed to @putout/plugin-variables.

Install

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

Rules

Config

{
    "rules": {
        "remove-useless-variables/assignment": "on",
        "remove-useless-variables/rename": "on",
        "remove-useless-variables/remove": "on",
        "remove-useless-variables/destruct": "on",
        "remove-useless-variables/declaration": ["on", {
            "maxLength": 20
        }],
        "remove-useless-variables/duplicate": "on"
    }
}

assignment

Checkout in ????Putout Editor.

❌ Example of incorrect code

while (!(files = readDirectory(parentDir)).length) {}

βœ… Example of correct code

while (!readDirectory(parentDir).length) {}

rename

❌ Example of incorrect code

function hi(a) {
    const b = a;
}

βœ… Example of correct code

function hi(b) {}

destruct

❌ Example of incorrect code

function hi(c) {
    const {a, b} = c;
}

βœ… Example of correct code

function hi({a, b}) {}

remove

❌ Example of incorrect code

const child_process = require('node:child_process');

const {exec, spawn} = child_process;

βœ… Example of correct code

const {exec, spawn} = require('node:child_process');

remove

Check it out in ????Putout Editor.

❌ Example of incorrect code

const a = 5;
const b = a;

const c = 5;

d = c;

βœ… Example of correct code

const b = 5;

d = 5;

declaration

Check it out in ????Putout Editor.

❌ Example of incorrect code

function x() {
    const a = 5;
    return a;
}

const z = b.c.replace('x', 'y');

b.c = z;

βœ… Example of correct code

function x() {
    return 5;
}

b.c = b.c.replace('x', 'y');

duplicate

Check it out in ????Putout Editor.

❌ Example of incorrect code

const DestructuringErrors = function DestructuringErrors(a, b) {
    return [a, b];
};

βœ… Example of correct code

function DestructuringErrors(a, b) {
    return [a, b];
}

bc = b.c.replace('x', 'y');

License

MIT

Current Tags

  • 14.2.1                                ...           latest (4 months ago)

62 Versions

  • 14.2.1                                ...           4 months ago
  • 14.2.0                                ...           4 months ago
  • 14.1.0                                ...           5 months ago
  • 14.0.0                                ...           a year ago
  • 13.0.2                                ...           a year ago
  • 13.0.1                                ...           a year ago
  • 13.0.0                                ...           a year ago
  • 12.6.1                                ...           a year ago
  • 12.6.0                                ...           a year ago
  • 12.5.0                                ...           2 years ago
  • 12.4.2                                ...           2 years ago
  • 12.4.1                                ...           2 years ago
  • 12.4.0                                ...           2 years ago
  • 12.3.0                                ...           2 years ago
  • 12.2.0                                ...           2 years ago
  • 12.1.0                                ...           2 years ago
  • 12.0.0                                ...           2 years ago
  • 11.1.1                                ...           2 years ago
  • 11.1.0                                ...           2 years ago
  • 11.0.0                                ...           2 years ago
  • 10.0.0                                ...           3 years ago
  • 9.1.0                                ...           3 years ago
  • 9.0.0                                ...           3 years ago
  • 8.0.0                                ...           3 years ago
  • 7.3.0                                ...           4 years ago
  • 7.2.0                                ...           4 years ago
  • 7.1.0                                ...           4 years ago
  • 7.0.0                                ...           4 years ago
  • 6.3.0                                ...           4 years ago
  • 6.2.0                                ...           4 years ago
  • 6.1.0                                ...           4 years ago
  • 6.0.0                                ...           4 years ago
  • 5.1.0                                ...           4 years ago
  • 5.0.0                                ...           5 years ago
  • 4.7.0                                ...           5 years ago
  • 4.6.0                                ...           5 years ago
  • 4.5.1                                ...           5 years ago
  • 4.5.0                                ...           5 years ago
  • 4.4.1                                ...           5 years ago
  • 4.4.0                                ...           5 years ago
  • 4.3.0                                ...           6 years ago
  • 4.2.1                                ...           6 years ago
  • 4.2.0                                ...           6 years ago
  • 4.1.0                                ...           6 years ago
  • 4.0.0                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.0.0                                ...           7 years ago
  • 1.10.0                                ...           7 years ago
  • 1.9.0                                ...           7 years ago
  • 1.8.1                                ...           7 years ago
  • 1.8.0                                ...           7 years ago
  • 1.7.0                                ...           7 years ago
  • 1.6.0                                ...           7 years ago
  • 1.5.0                                ...           7 years ago
  • 1.4.1                                ...           7 years ago
  • 1.4.0                                ...           7 years ago
  • 1.3.0                                ...           7 years ago
  • 1.2.0                                ...           7 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.2                                ...           7 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 22
Dependencies (0)
None
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |