Putout
π Pluggable and configurable JavaScript Linter, code transformer and formatter with superpowers πͺ: built-in support of js, jsx, ts, markdown, yaml, toml, json and ignore. Write declarative codemods in a simplest possible way π
Install / Use
/learn @coderaiser/PutoutREADME
Putout

Perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away.
(c) Antoine de Saint ExupΓ©ry
πPutout is a JavaScript Linter, pluggable and configurable code transformer, drop-in ESLint replacement with built-in code printer and ability to fix syntax errors. It has lots of transformations that keeps your codebase in a clean state, removing any code smell and making code readable according to best practices.
The main target is JavaScript, but:
- β JSX;
- β TypeScript;
- β Yaml;
- β TOML;
- β Markdown;
- β JSON;
- β Ignore;
are also supported. Here is how it looks like:
Table of contents
- π€·ββοΈ In doubt about using πPutout?
- π Whom should I thank for this project exist?
- π€·ββοΈ Why does this project exist?
- πͺ¬Core Concepts
- π Installation
- π Usage
- π¦ Usage with Deno
- π What is Ruler?
- βοΈ How Ruler can help me?
- π Convert
CommonJStoESM - π Architecture
- π² The Tree of Syntax
- π΄ Laws of the Jungle
- π API
- π¨ Built-in transformations
- π οΈ Syntax errors
- π Operators
- π Plugins
- π¦ Formatters
- π¦ Configuration
- 𧬠Plugins API
- π΄ codemods
- πΎ rulesdir
- β£ Integration with ESLint
- βοΈ Integration with Babel
- π Integration with Yarn
- β Using Putout as Loader
- πͺ Exit Codes
- π¦ Real-world uses
- π» Versioning policy
- π I want contribute
- π License
π€·ββοΈ In doubt about using πPutout?
Check out couple variants of plugins that does the same: linting debugger statement:
- β SWCLint no-debugger: 49 lines;
- β RSLint no-debugger: 48 lines;
- β ESLint no-debugger: 43 lines;
- β Rome no-debugger: 28 lines;
- π Putout remove-debugger: 5 lines:
export const report = () => `Avoid 'debugger' statement`;
export const replace = () => ({
debugger: '',
});
Choose wisely, competitors cannot even fixβ¦ π€«
Drop-in ESLint replacement
πPutout in addition to own format .putout.json supports both eslint.config.js and .eslintrc.json, it has ability to autodect format you use.
Also it works good with monorepository, since it uses eslint.config.js that is closer to linting file, instead of cwd of ESLint run.
π Whom should I thank for this project exist?
If I have seen further, it is by standing upon the shoulders of giants.
(c) Isaac Newton
- πͺESLint for stable releases and future proof API.
- πͺBabel for amazing API documented in Handbook and responsiveness of a team.
- πͺPrettier for minimalistic options and uniform codestyle.
- πͺJSCodeshift for making codemods simple and popular.
π€·ββοΈ Why does this project exist?
- βESLint avoids fixes that could change the runtime behavior.
- βBabel has no ability to report errors, it only runs transformations.
- βPrettier is a formatter.
- βJSCodeshift has no config and plugins support.
πPutout on the other hand can make more drastic code transformations that directly affects your codebase making it a better place to code π»:
- β fixes Reference Errors;
- β declares variables;
- β converts CommonJS to ESM;
- β ...and much more π!
π Installation
To install πPutout as a development dependency, run:
npm i putout -D
Make sure that you are running a relatively recent (β₯16) version of Node.
π Usage
Grown-ups never understand anything by themselves, and it is tiresome for children to be always and forever explaining things to them.
(c) Antoine de Saint-ExupΓ©ry
πPutout tries to be clear and likes a lot to explain things. So when you write putout --help most likely you will hear gladly purr :
Usage: putout [options] [path]
Options:
-h, --help display this help and exit
-v, --version output version information and exit
-f, --format [formatter] use a specific output format, the default is: 'progress-bar' locally and 'dump' on CI
-s, --staged add staged files when in git repository
-i, --interactive set lint options using interactive menu
--fix apply fixes of errors to code
--fix-count [count = 10] count of fixes rounds
--rulesdir use additional rules from directory
--transform [replacer] apply Replacer, for example 'var __a = __b -> const __a = __b', read about Replacer https://git.io/JqcMn
--plugins [plugins] a comma-separated list of plugins to use
--enable [rule] enable the rule and save it to '.putout.json' walking up parent directories
--disable [rule] disable the rule and save it to '.putout.json' walking up parent directories
--enable-all enable all found rules and save them to '.putout.json' walking up parent directories
--disable-all disable all found rules (set baseline) and save them to '.putout.json' walking up parent directories
--match [pattern] read '.putout.json' and convert 'rules' to 'match' according to 'pattern'
--fresh generate a fresh cache
--no-config avoid reading '.putout.json'
--no-ci disable the CI detection
--no-cache disable the cache
--no-worker disable worker thread
To skip prefix node_modules/.bin/, update your $PATH variable in with .bashrc:
echo 'PATH="$PATH:node_modules/.bin"' >> ~/.bashrc
source ~/.bashrc
To find possible transform places in a folder named lib, run:
putout lib
To find possible transform places in multiple folders, such as folders named lib and test, run:
putout lib test
To apply the transforms, use --fix:
putout lib test --fix
βοΈCommit your code before running πPutout
Developers, myself included, usually prefer to make all code changes manually, so that nothing happens to our code without reviewing it first. That is until we trust a tool to make those changes safely for us. An example is WebStorm, which we trust when renaming a class or a method. Since πPutout may still feel like a new tool, not all of us will be able to trust it immediately.
A good way to gain trust is two run without --fix option, and observe e
