@putout/plugin-remove-useless-variables

12.4.1ย โ€ขย Publicย โ€ขย Published

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

๐ŸŠPutout plugin adds ability to find and remove useless variables.

Install

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

Rules

  • โœ… [declaration][#declaration];
  • โœ… [destruct][#destruct];
  • โœ… [duplicate][#duplicate];
  • โœ… [remove][#remove];
  • โœ… [rename][#rename];

Config

{
    "rules": {
        "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"
    }
}

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;
}

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
12.4.12,116latest

Version History

VersionDownloads (Last 7 Days)Published
12.4.12,116
12.4.0113
12.3.01
12.2.01
12.1.04
12.0.0205
11.1.11,548
11.1.01
11.0.03
10.0.0788
9.1.0702
9.0.02
8.0.0235
7.3.0745
7.2.01
7.1.017
7.0.01
6.3.0354
6.2.01
6.1.01
6.0.068
5.1.063
5.0.01
4.7.06,062
4.6.02
4.5.11
4.5.01
4.4.11
4.4.01
4.3.06
4.2.11
4.2.01
4.1.01
4.0.01
3.0.01
2.0.07
1.10.03
1.9.01
1.8.11
1.8.01
1.7.01
1.6.01
1.5.01
1.4.11
1.4.01
1.3.01
1.2.01
1.1.01
1.0.21
1.0.11
1.0.01

Package Sidebar

Install

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

Weekly Downloads

13,074

Version

12.4.1

License

MIT

Unpacked Size

14.1 kB

Total Files

9

Last publish

Collaborators

  • coderaiser