putout
the pluggable code transformer
Last updated a day ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install putout 
SYNC missed versions from official npm registry.

Putout NPM version Dependency Status Build Status Coverage Status

Putout is a tool for identifying, reporting and fixing patterns found in JavaScript/JSX/Typescript/Flow code. It can:

  • find and remove unused variables;
  • find and remove unused private fields;
  • find and remove unused expressions;
  • find and remove useless variables;
  • find and remove useless Array.from;
  • find and remove useless spread;
  • find and remove useless arguments;
  • find and remove useless escape;
  • find and remove useless async;
  • find and remove useless await;
  • find and remove useless typeof;
  • find and remove debugger statement;
  • find and remove nested blocks;
  • find and remove process.exit call;
  • find and remove console.log calls;
  • find and remove empty block statements;
  • find and remove empty patterns;
  • find and remove strict mode directive from esm;
  • find and remove constant conditions;
  • find and remove boolean from logical expressions;
  • find and remove double negations;
  • find and remove unreachable code;
  • find and remove duplicate keys;
  • find and replace test.only to test calls;
  • find and replace test.skip to test calls;
  • find and split variable declarations;
  • find and split nested destructuring;
  • find and simplify ternary;
  • if absent strict mode directive in commonjs add it;
  • convert esm to commonjs (disabled);
  • convert commonjs to esm (disabled);
  • convert template with one expression to string;
  • convert equal to strict equal;
  • convert indexOf to includes;
  • apply destructuring;
  • apply top-level await (disabled, stage 3);
  • convert throw statement into expression (disabled, stage 2);
  • apply shorthand properties;
  • apply optional chaining (disabled stage4);
  • apply nullish coalescing (disabled stage4);
  • merge destructuring properties;
  • merge duplicate imports;
  • merge if statements;
  • convert Math.pow to exponentiation operator;
  • convert anonymous to arrow function;
  • convert for to for-of;
  • convert forEach to for-of;
  • convert for-in to for-of;
  • convert apply to spread;
  • convert arguments to rest;
  • convert Object.assign to merge spread;
  • convert binary expression to boolean;
  • convert top-level return into process.exit();
  • convert spread to Array.from;
  • extract sequence expressions;
  • extract object properties;
  • add return await;
  • remove useless Promise.resolve;
  • convert Promise.reject to throw;

Why?

The main difference of putout is saving code transformation results directly into source code in a day-to-day baisis.

Install

npm i putout -g

Usage

Usage: putout [options] [path]
Options:
  -h, --help              display this help and exit
  -v, --version           output version information and exit
  -f, --format            use a specific output format - default: dump
  -s, --staged            add staged files when in git repository
  --fix                   apply found fixes of errors to code
  --fix-count             count of fixes rounds (defaults to 10)
  --rulesdir              use additional rules from directory
  --enable                enable rule by name in .putout.json
  --disable               disable rule by name in .putout.json
  --enable-all            enable all rules in .putout.json
  --disable-all           disable all rules in .putout.json
  --ext                   specify JavaScript file extensions
  --jsx                   enable jsx (default)
  --flow                  enable flow
  --cache                 enable .putoutcache to speed up processing
  --update-cache          enable .putoutcache to speed up processing from scratch
  --remove-cache          remove .putoutcache
  --no-jsx                disable jsx
  --no-flow               disable flow (default)

To find erros:

putout lib test

To fix errors:

putout lib test --fix

Environment variables

Putout supports next environment variables:

  • PUTOUT_FILES - files that should be processed by putout, divided by ",";
PUTOUT_FILES=lib,test putout --fix

Configuration

To configure create .putout.json file and override any of default options.

Match

When you need to match paths to rules you can use match section for this purpose in .putout.json:

{
    "match": {
        "server": {
            "remove-process-exit": true
        }
    }
}

Ignore

When you need to ignore some routes no metter what, you can use ignore section in .putout.json:

{
    "ignore": [
        "test/fixture"
    ]
}

Plugins

Putout supports plugins, there is two types: with prefix official @putout/plugin- and user plugins with prefix putout-plugin-. To use your plugin create plugin as npm package with keywords putout, putout-plugin and add it to .putout.json.

For example if you need to remove-something create putout plugin with name putout-plugin-remove-something and it to package.json:

{
    "plugins": [
        "remove-something"
    ]
}

Codemods

putout supports codemodes in the similar to plugins way, just create a directory ~/.putout and put your plugins there. Here is example: convert-tape-to-supertape and this is example of work.

API

putout(source, options)

const putout = require('putout');

const source = `
const t = 'hello';
const m = t + '!';
console.log(t);
`;

const result = putout(source, {
    plugins: [
        'remove-unused-variables',
    ]
});
// returns
`
const t = 'hello';
console.log(t);
`

License

MIT

Current Tags

  • 8.13.1                                ...           latest (a day ago)

405 Versions

  • 8.13.1                                ...           a day ago
  • 8.13.0                                ...           2 days ago
  • 8.12.0                                ...           3 days ago
  • 8.11.1                                ...           5 days ago
  • 8.11.0                                ...           5 days ago
  • 8.10.1                                ...           6 days ago
  • 8.10.0                                ...           7 days ago
  • 8.9.0                                ...           9 days ago
  • 8.8.0                                ...           14 days ago
  • 8.7.0                                ...           15 days ago
  • 8.6.0                                ...           17 days ago
  • 8.5.2                                ...           17 days ago
  • 8.5.1                                ...           18 days ago
  • 8.5.0                                ...           18 days ago
  • 8.4.1                                ...           19 days ago
  • 8.4.0                                ...           20 days ago
  • 8.3.0                                ...           a month ago
  • 8.2.0                                ...           a month ago
  • 8.1.1                                ...           a month ago
  • 8.1.0                                ...           a month ago
  • 8.0.4                                ...           a month ago
  • 8.0.3                                ...           a month ago
  • 8.0.2                                ...           a month ago
  • 8.0.1                                ...           a month ago
  • 8.0.0                                ...           a month ago
  • 7.24.0                                ...           a month ago
  • 7.23.0                                ...           2 months ago
  • 7.22.0                                ...           2 months ago
  • 7.21.0                                ...           2 months ago
  • 7.20.4                                ...           2 months ago
  • 7.20.3                                ...           2 months ago
  • 7.20.2                                ...           2 months ago
  • 7.20.1                                ...           2 months ago
  • 7.20.0                                ...           3 months ago
  • 7.19.1                                ...           3 months ago
  • 7.19.0                                ...           3 months ago
  • 7.18.2                                ...           3 months ago
  • 7.18.1                                ...           3 months ago
  • 7.18.0                                ...           3 months ago
  • 7.17.0                                ...           3 months ago
  • 7.16.2                                ...           3 months ago
  • 7.16.1                                ...           3 months ago
  • 7.16.0                                ...           3 months ago
  • 7.15.0                                ...           3 months ago
  • 7.14.2                                ...           3 months ago
  • 7.14.1                                ...           3 months ago
  • 7.14.0                                ...           3 months ago
  • 7.13.4                                ...           3 months ago
  • 7.13.3                                ...           3 months ago
  • 7.13.2                                ...           3 months ago
  • 7.13.1                                ...           4 months ago
  • 7.13.0                                ...           4 months ago
  • 7.12.2                                ...           4 months ago
  • 7.12.1                                ...           4 months ago
  • 7.12.0                                ...           4 months ago
  • 7.11.1                                ...           4 months ago
  • 7.11.0                                ...           4 months ago
  • 7.10.2                                ...           4 months ago
  • 7.10.1                                ...           4 months ago
  • 7.10.0                                ...           4 months ago
  • 7.9.1                                ...           4 months ago
  • 7.9.0                                ...           4 months ago
  • 7.8.0                                ...           4 months ago
  • 7.7.1                                ...           4 months ago
  • 7.7.0                                ...           4 months ago
  • 7.6.2                                ...           5 months ago
  • 7.6.1                                ...           5 months ago
  • 7.6.0                                ...           5 months ago
  • 7.5.0                                ...           5 months ago
  • 7.4.4                                ...           5 months ago
  • 7.4.3                                ...           5 months ago
  • 7.4.2                                ...           5 months ago
  • 7.4.1                                ...           5 months ago
  • 7.4.0                                ...           5 months ago
  • 7.3.4                                ...           5 months ago
  • 7.3.3                                ...           6 months ago
  • 7.3.2                                ...           6 months ago
  • 7.3.1                                ...           6 months ago
  • 7.3.0                                ...           6 months ago
  • 7.2.2                                ...           6 months ago
  • 7.2.1                                ...           6 months ago
  • 7.2.0                                ...           6 months ago
  • 7.1.0                                ...           7 months ago
  • 7.0.6                                ...           7 months ago
  • 7.0.5                                ...           7 months ago
  • 7.0.4                                ...           7 months ago
  • 7.0.3                                ...           7 months ago
  • 7.0.2                                ...           7 months ago
  • 7.0.1                                ...           7 months ago
  • 7.0.0                                ...           7 months ago
  • 6.22.0                                ...           7 months ago
  • 6.21.0                                ...           7 months ago
  • 6.20.0                                ...           7 months ago
  • 6.19.0                                ...           7 months ago
  • 6.18.0                                ...           7 months ago
  • 6.17.0                                ...           7 months ago
  • 6.16.1                                ...           7 months ago
  • 6.16.0                                ...           7 months ago
  • 6.15.1                                ...           8 months ago
  • 6.15.0                                ...           8 months ago
  • 6.14.1                                ...           8 months ago
  • 6.14.0                                ...           8 months ago
  • 6.13.0                                ...           8 months ago
  • 6.12.1                                ...           8 months ago
  • 6.12.0                                ...           8 months ago
  • 6.11.0                                ...           8 months ago
  • 6.10.2                                ...           8 months ago
  • 6.10.1                                ...           8 months ago
  • 6.10.0                                ...           8 months ago
  • 6.9.1                                ...           8 months ago
  • 6.9.0                                ...           8 months ago
  • 6.8.0                                ...           8 months ago
  • 6.7.1                                ...           8 months ago
  • 6.7.0                                ...           8 months ago
  • 6.6.1                                ...           8 months ago
  • 6.6.0                                ...           8 months ago
  • 6.5.1                                ...           8 months ago
  • 6.5.0                                ...           8 months ago
  • 6.4.0                                ...           8 months ago
  • 6.3.1                                ...           8 months ago
  • 6.3.0                                ...           8 months ago
  • 6.2.0                                ...           8 months ago
  • 6.1.0                                ...           9 months ago
  • 6.0.0                                ...           9 months ago
  • 5.28.2                                ...           9 months ago
  • 5.28.1                                ...           9 months ago
  • 5.28.0                                ...           9 months ago
  • 5.27.0                                ...           9 months ago
  • 5.26.0                                ...           9 months ago
  • 5.25.0                                ...           9 months ago
  • 5.24.0                                ...           9 months ago
  • 5.23.0                                ...           9 months ago
  • 5.22.1                                ...           9 months ago
  • 5.22.0                                ...           9 months ago
  • 5.21.0                                ...           9 months ago
  • 5.20.0                                ...           9 months ago
  • 5.19.0                                ...           9 months ago
  • 5.18.2                                ...           9 months ago
  • 5.18.1                                ...           9 months ago
  • 5.18.0                                ...           9 months ago
  • 5.17.0                                ...           9 months ago
  • 5.16.0                                ...           9 months ago
  • 5.15.1                                ...           9 months ago
  • 5.15.0                                ...           9 months ago
  • 5.14.1                                ...           9 months ago
  • 5.14.0                                ...           9 months ago
  • 5.13.3                                ...           9 months ago
  • 5.13.2                                ...           9 months ago
  • 5.13.1                                ...           9 months ago
  • 5.13.0                                ...           9 months ago
  • 5.12.1                                ...           9 months ago
  • 5.12.0                                ...           9 months ago
  • 5.11.2                                ...           9 months ago
  • 5.11.1                                ...           9 months ago
  • 5.11.0                                ...           9 months ago
  • 5.10.4                                ...           9 months ago
  • 5.10.3                                ...           9 months ago
  • 5.10.2                                ...           9 months ago
  • 5.10.1                                ...           9 months ago
  • 5.10.0                                ...           9 months ago
  • 5.9.0                                ...           9 months ago
  • 5.8.0                                ...           9 months ago
  • 5.7.1                                ...           10 months ago
  • 5.7.0                                ...           10 months ago
  • 5.6.0                                ...           10 months ago
  • 5.5.0                                ...           10 months ago
  • 5.4.0                                ...           10 months ago
  • 5.3.6                                ...           10 months ago
  • 5.3.5                                ...           10 months ago
  • 5.3.4                                ...           10 months ago
  • 5.3.3                                ...           10 months ago
  • 5.3.2                                ...           10 months ago
  • 5.3.1                                ...           10 months ago
  • 5.3.0                                ...           10 months ago
  • 5.2.1                                ...           10 months ago
  • 5.2.0                                ...           10 months ago
  • 5.1.0                                ...           10 months ago
  • 5.0.1                                ...           10 months ago
  • 5.0.0                                ...           10 months ago
  • 4.72.1                                ...           10 months ago
  • 4.72.0                                ...           10 months ago
  • 4.71.0                                ...           10 months ago
  • 4.70.0                                ...           10 months ago
  • 4.69.1                                ...           10 months ago
  • 4.69.0                                ...           10 months ago
  • 4.68.2                                ...           10 months ago
  • 4.68.1                                ...           10 months ago
  • 4.68.0                                ...           10 months ago
  • 4.67.0                                ...           10 months ago
  • 4.66.0                                ...           10 months ago
  • 4.65.2                                ...           10 months ago
  • 4.65.1                                ...           10 months ago
  • 4.65.0                                ...           10 months ago
  • 4.64.0                                ...           10 months ago
  • 4.63.2                                ...           10 months ago
  • 4.63.1                                ...           10 months ago
  • 4.63.0                                ...           10 months ago
  • 4.62.0                                ...           10 months ago
  • 4.61.0                                ...           10 months ago
  • 4.60.0                                ...           10 months ago
  • 4.59.2                                ...           10 months ago
  • 4.59.1                                ...           10 months ago
  • 4.59.0                                ...           10 months ago
  • 4.58.1                                ...           10 months ago
  • 4.58.0                                ...           10 months ago
  • 4.57.0                                ...           10 months ago
  • 4.56.0                                ...           10 months ago
  • 4.55.0                                ...           10 months ago
  • 4.54.0                                ...           a year ago
  • 4.53.0                                ...           a year ago
  • 4.52.3                                ...           a year ago
  • 4.52.2                                ...           a year ago
  • 4.52.1                                ...           a year ago
  • 4.52.0                                ...           a year ago
  • 4.51.0                                ...           a year ago
  • 4.50.0                                ...           a year ago
  • 4.49.0                                ...           a year ago
  • 4.48.2                                ...           a year ago
  • 4.48.1                                ...           a year ago
  • 4.48.0                                ...           a year ago
  • 4.47.0                                ...           a year ago
  • 4.46.2                                ...           a year ago
  • 4.46.1                                ...           a year ago
  • 4.46.0                                ...           a year ago
  • 4.45.0                                ...           a year ago
  • 4.44.0                                ...           a year ago
  • 4.43.0                                ...           a year ago
  • 4.42.0                                ...           a year ago
  • 4.41.0                                ...           a year ago
  • 4.40.0                                ...           a year ago
  • 4.39.0                                ...           a year ago
  • 4.38.0                                ...           a year ago
  • 4.37.1                                ...           a year ago
  • 4.37.0                                ...           a year ago
  • 4.36.1                                ...           a year ago
  • 4.36.0                                ...           a year ago
  • 4.35.0                                ...           a year ago
  • 4.34.0                                ...           a year ago
  • 4.33.0                                ...           a year ago
  • 4.32.3                                ...           a year ago
  • 4.32.2                                ...           a year ago
  • 4.32.1                                ...           a year ago
  • 4.32.0                                ...           a year ago
  • 4.31.0                                ...           a year ago
  • 4.30.0                                ...           a year ago
  • 4.29.0                                ...           a year ago
  • 4.28.2                                ...           a year ago
  • 4.28.1                                ...           a year ago
  • 4.28.0                                ...           a year ago
  • 4.27.1                                ...           a year ago
  • 4.27.0                                ...           a year ago
  • 4.26.0                                ...           a year ago
  • 4.25.0                                ...           a year ago
  • 4.24.1                                ...           a year ago
  • 4.24.0                                ...           a year ago
  • 4.23.5                                ...           a year ago
  • 4.23.4                                ...           a year ago
  • 4.23.3                                ...           a year ago
  • 4.23.2                                ...           a year ago
  • 4.23.1                                ...           a year ago
  • 4.23.0                                ...           a year ago
  • 4.22.0                                ...           a year ago
  • 4.21.0                                ...           a year ago
  • 4.20.0                                ...           a year ago
  • 4.19.0                                ...           a year ago
  • 4.18.1                                ...           a year ago
  • 4.18.0                                ...           a year ago
  • 4.17.0                                ...           a year ago
  • 4.16.2                                ...           a year ago
  • 4.16.1                                ...           a year ago
  • 4.16.0                                ...           a year ago
  • 4.15.1                                ...           a year ago
  • 4.15.0                                ...           a year ago
  • 4.14.0                                ...           a year ago
  • 4.13.0                                ...           a year ago
  • 4.12.0                                ...           a year ago
  • 4.11.2                                ...           a year ago
  • 4.11.1                                ...           a year ago
  • 4.11.0                                ...           a year ago
  • 4.10.0                                ...           a year ago
  • 4.9.0                                ...           a year ago
  • 4.8.1                                ...           a year ago
  • 4.8.0                                ...           a year ago
  • 4.7.1                                ...           a year ago
  • 4.7.0                                ...           a year ago
  • 4.6.0                                ...           a year ago
  • 4.5.0                                ...           a year ago
  • 4.4.1                                ...           a year ago
  • 4.4.0                                ...           a year ago
  • 4.3.2                                ...           a year ago
  • 4.3.1                                ...           a year ago
  • 4.3.0                                ...           a year ago
  • 4.2.2                                ...           a year ago
  • 4.2.1                                ...           a year ago
  • 4.2.0                                ...           a year ago
  • 4.1.2                                ...           a year ago
  • 4.1.1                                ...           a year ago
  • 4.1.0                                ...           a year ago
  • 4.0.3                                ...           a year ago
  • 4.0.2                                ...           a year ago
  • 4.0.1                                ...           a year ago
  • 4.0.0                                ...           a year ago
  • 3.24.0                                ...           a year ago
  • 3.23.0                                ...           a year ago
  • 3.22.0                                ...           a year ago
  • 3.21.0                                ...           a year ago
  • 3.20.1                                ...           a year ago
  • 3.20.0                                ...           a year ago
  • 3.19.0                                ...           a year ago
  • 3.18.0                                ...           a year ago
  • 3.17.3                                ...           a year ago
  • 3.17.2                                ...           a year ago
  • 3.17.1                                ...           a year ago
  • 3.17.0                                ...           a year ago
  • 3.16.0                                ...           a year ago
  • 3.15.2                                ...           a year ago
  • 3.15.1                                ...           a year ago
  • 3.15.0                                ...           a year ago
  • 3.14.0                                ...           a year ago
  • 3.13.2                                ...           a year ago
  • 3.13.1                                ...           a year ago
  • 3.13.0                                ...           a year ago
  • 3.12.0                                ...           a year ago
  • 3.11.0                                ...           a year ago
  • 3.10.0                                ...           a year ago
  • 3.9.0                                ...           a year ago
  • 3.8.0                                ...           a year ago
  • 3.7.2                                ...           a year ago
  • 3.7.1                                ...           a year ago
  • 3.7.0                                ...           a year ago
  • 3.6.3                                ...           a year ago
  • 3.6.2                                ...           a year ago
  • 3.6.1                                ...           a year ago
  • 3.6.0                                ...           a year ago
  • 3.5.1                                ...           a year ago
  • 3.5.0                                ...           a year ago
  • 3.4.2                                ...           a year ago
  • 3.4.1                                ...           a year ago
  • 3.4.0                                ...           a year ago
  • 3.3.5                                ...           a year ago
  • 3.3.4                                ...           a year ago
  • 3.3.3                                ...           a year ago
  • 3.3.2                                ...           a year ago
  • 3.3.1                                ...           a year ago
  • 3.3.0                                ...           a year ago
  • 3.2.0                                ...           a year ago
  • 3.1.0                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.26.0                                ...           a year ago
  • 2.25.0                                ...           a year ago
  • 2.24.1                                ...           a year ago
  • 2.24.0                                ...           a year ago
  • 2.23.0                                ...           a year ago
  • 2.22.0                                ...           a year ago
  • 2.21.0                                ...           a year ago
  • 2.20.0                                ...           a year ago
  • 2.19.0                                ...           a year ago
  • 2.18.7                                ...           a year ago
  • 2.18.6                                ...           a year ago
  • 2.18.5                                ...           a year ago
  • 2.18.4                                ...           a year ago
  • 2.18.3                                ...           a year ago
  • 2.18.2                                ...           a year ago
  • 2.18.1                                ...           a year ago
  • 2.18.0                                ...           a year ago
  • 2.17.2                                ...           a year ago
  • 2.17.1                                ...           a year ago
  • 2.17.0                                ...           a year ago
  • 2.16.0                                ...           a year ago
  • 2.15.0                                ...           a year ago
  • 2.14.0                                ...           a year ago
  • 2.13.1                                ...           a year ago
  • 2.13.0                                ...           a year ago
  • 2.12.0                                ...           a year ago
  • 2.11.1                                ...           a year ago
  • 2.11.0                                ...           a year ago
  • 2.10.1                                ...           a year ago
  • 2.10.0                                ...           a year ago
  • 2.9.0                                ...           a year ago
  • 2.8.0                                ...           a year ago
  • 2.7.1                                ...           a year ago
  • 2.7.0                                ...           a year ago
  • 2.6.1                                ...           a year ago
  • 2.6.0                                ...           a year ago
  • 2.5.0                                ...           a year ago
  • 2.4.0                                ...           a year ago
  • 2.3.0                                ...           a year ago
  • 2.2.0                                ...           a year ago
  • 2.1.1                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.6.0                                ...           a year ago
  • 1.5.0                                ...           a year ago
  • 1.4.0                                ...           a year ago
  • 1.3.3                                ...           2 years ago
  • 1.3.2                                ...           2 years ago
  • 1.3.1                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.2                                ...           2 years ago
  • 1.2.1                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 99
This Month 99
Last Day 30
Last Week 154
Last Month 4,108
Dependencies (90)
Dev Dependencies (15)

Copyright 2014 - 2016 © taobao.org |