Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

putout

> 数据库
Open source

Pluggable and configurable JavaScript Linter, code transformer and formatter with superpowers : built-in support of js, jsx, ts, markdown, yaml, toml, jso

797 stars0 likes2 views
WebsiteGitHub

About

Pluggable and configurable JavaScript Linter, code transformer and formatter with superpowers : built-in support of js, jsx, ts, markdown, yaml, toml, jso

Putout NPM version Build Status Coverage Status DeepScan

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;
  • ✅ JSON;
  • ✅ SQL;
  • ✅ Yaml;
  • ✅ TOML;
  • ✅ Markdown;
  • ✅ Ignore;
  • ✅ Dockerfile;

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 CommonJS to ESM
  • 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:
javascript
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:

bash
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 :

…

To skip prefix node_modules/.bin/, update your $PATH variable in with .bashrc:

bash
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 error messages. Another way is to use traditional version control tactics. Before running Putout you should do a git commit. Then after running Putout, you’ll be able to inspect the changes it made using git diff and git status. You still have the chance to run git checkout -- . at any time to revert all the changes that Putout has made. If you need more fine-grained control, you can also use git add -p or git add -i to interactively stage only the changes you want to keep.

Environment variables

Putout supports the following environment variables:

  • PUTOUT_CONFIG_FILE - path to configuration file;
  • PUTOUT_FILES - files that should be processed split by comma (,);

Example:

PUTOUT_FILES=lib,test putout --fix

Usage with Deno

When you need to run Putout in Deno, use @putout/bundle:

javascript
import putout from 'https://esm.sh/@putout/bundle';
import removeDebugger from 'https://esm.sh/@putout/plugin-remove-debugger?alias=putout:@putout/bundle';
import declare from 'https://esm.sh/@putout/plugin-declare?alias=putout:@putout/bundle';

putout('isFn(fn); debugger', {
    plugins: [
        ['remove-debugger', removeDebugger],
        ['declare', declare],
    ],
});

// returns
({
    code: `const isFn = a => typeof a === 'function';\nisFn(fn);`,
    places: [],
});

What is Ruler?

When you need to change configuration file use Ruler instead of editing the file manually.

Ruler can:

  • ✅ putout --enable [rule];
  • ✅ putout --disable [rule];
  • ✅ putout --enable-all;
  • ✅ putout --disable-all;

☝️Remember, Ruler should never be used with --fix, because unclear things makes Putout angry and you can find him barking at you:

 '--fix' cannot be used with ruler toggler ('--enable', '--disable')

✂️ How Ruler can help me?

You may want to convert your CommonJS to ESM since node v12 supports it without a flag.

Convert CommonJS to ESM

☝️ I have a package.json

Well, if you have no type field or type=commonjs your package will be converted to CommonJS automatically. To convert to ESM just set type=module.

☝️ I have .cjs or .mjs files

They will be converted automatically to CommonJS and ESM accordingly.

☝️ I want to run only one rule

Let's suppose you have a file called index.js:

javascript
const unused = 5;

module.exports = function() {
    return promise();
};

async function promise(a) {
    return Promise.reject(Error('x'));
}

You call putout --fix index.js and see that file is changed:

javascript
'use strict';

module.exports = async function() {
    return await promise();
};

async function promise() {
    throw Error('x');
}

But for some reason you don't want so many changes.

☝️ Remember, safe mode of eslint-plugin-putout has the most dangerous rules disabled, so it can be used as auto fix on each save in your IDE.

So, if you want to convert it to ESM keeping everything else untouched use Ruler: it can easily disable all rules Putout finds.

putout index.js --disable-all will find next errors:

…

It will create config file .putout.json:

json
{
    "rules": {
        "variables/remove-unused": "off",
        "convert-to-arrow-function": "off",
        "nodejs/add-missing-strict-mode": "off",
        "promises/convert-reject-to-throw":

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptastbabelbabel-plugincodemod

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库