@putout/plugin-remove-useless-variables

11.1.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/await": "on",
        "remove-useless-variables/declaration": "on",
        "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;
}

โœ… 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];
}

License

MIT

Package Sidebar

Install

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

Weekly Downloads

18,769

Version

11.1.1

License

MIT

Unpacked Size

12.6 kB

Total Files

9

Last publish

Collaborators

  • coderaiser