npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, πŸ‘‹, I’m Ryan HefnerΒ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you πŸ™

Β© 2026 – Pkg Stats / Ryan Hefner

@putout/plugin-putout

v29.35.0

Published

🐊Putout plugin helps with plugins development

Downloads

55,460

Readme

@putout/plugin-putout NPM version

🐊Putout plugin helps with plugins development.

Install

npm i @putout/plugin-putout -D

Rules

File rules

Config

{
    "rules": {
        "putout/add-await-to-progress": "on",
        "putout/add-crawl-file": "on",
        "putout/add-path-arg-to-filter": "on",
        "putout/add-path-arg-to-fix": "on",
        "putout/add-path-arg-to-match": "on",
        "putout/add-path-arg-to-visitors": "on",
        "putout/add-places-to-compare-places": "on",
        "putout/add-push-arg": "on",
        "putout/add-test-args": "on",
        "putout/add-track-file": "on",
        "putout/add-traverse-args": "on",
        "putout/apply-async-formatter": "on",
        "putout/apply-create-nested-directory": "on",
        "putout/apply-create-test": "on",
        "putout/apply-declare": "on",
        "putout/apply-destructuring": "on",
        "putout/apply-destructuring-to-options": "on",
        "putout/apply-engine-node-version": "off",
        "putout/apply-exports": "off",
        "putout/apply-exports-to-add-args": "on",
        "putout/apply-exports-to-match-files": "on",
        "putout/apply-exports-to-rename-files": "on",
        "putout/apply-fixture-name-to-message": "on",
        "putout/apply-for-of-to-track-file": "on",
        "putout/apply-get-binding": "on",
        "putout/apply-insert-after": "on",
        "putout/apply-insert-before": "on",
        "putout/apply-lowercase-to-node-builders": "on",
        "putout/apply-name-to-is-identifier": "on",
        "putout/apply-namespace-specifier": "on",
        "putout/apply-parens": "on",
        "putout/apply-processors-destructuring": "on",
        "putout/apply-remove": "on",
        "putout/apply-rename": "on",
        "putout/apply-report": "on",
        "putout/apply-short-processors": "on",
        "putout/apply-string-to-property-key": "on",
        "putout/apply-transform-with-options": "on",
        "putout/apply-traverser-to-ignore": "on",
        "putout/apply-type-check": "on",
        "putout/apply-vars": "on",
        "putout/check-declare": "on",
        "putout/check-match": "on",
        "putout/check-replace-code": ["on", {
            "once": true
        }],
        "putout/convert-add-argument-to-add-args": "on",
        "putout/convert-babel-types": "on",
        "putout/convert-destructuring-to-identifier": "on",
        "putout/convert-dirname-to-url": "on",
        "putout/convert-get-file-content-to-read-file-content": "on",
        "putout/convert-get-rule-to-require": "on",
        "putout/convert-include-to-traverse": "on",
        "putout/convert-match-to-function": "on",
        "putout/convert-method-to-property": "on",
        "putout/convert-node-to-path-in-get-template-values": "on",
        "putout/convert-number-to-numeric": "on",
        "putout/convert-plugins-element-to-tuple": "on",
        "putout/convert-process-to-find": "on",
        "putout/convert-progress-to-track-file": "on",
        "putout/convert-push-object-to-push-path": "on",
        "putout/convert-putout-test-to-create-test": "on",
        "putout/convert-replace-to-function": "on",
        "putout/convert-replace-to-traverse": "on",
        "putout/convert-replace-with": "on",
        "putout/convert-replace-with-multiple": "on",
        "putout/convert-report-to-function": "on",
        "putout/convert-to-no-transform-code": "on",
        "putout/convert-traverse-to-include": "on",
        "putout/convert-traverse-to-replace": "on",
        "putout/convert-traverse-to-scan": "on",
        "putout/convert-traverse-to-super-traverse": "on",
        "putout/convert-url-to-dirname": "on",
        "putout/create-test": "on",
        "putout/declare": "on",
        "putout/declare-path-variable": "on",
        "putout/declare-template-variables": "on",
        "putout/includer": "on",
        "putout/move-require-on-top-level": "on",
        "putout/remove-empty-array-from-process": "on",
        "putout/remove-empty-object-from-transform": "on",
        "putout/remove-message-from-no-report-after-transform": "on",
        "putout/remove-unused-get-properties-argument": "on",
        "putout/remove-useless-printer-option": "on",
        "putout/remove-useless-source-argument": "on",
        "putout/replace-test-message": "on",
        "putout/shorten-imports": "on",
        "putout/simplify-replace-template": "on",
        "putout/sort-readme-file": "on",
        "putout/convert-replacer-to-includer": "on",
        "putout/remove-useless-match": "on",
        "putout/remove-useless-type-check-declaration": "on",
        "putout/shorten-path-get": "on"
    }
}

add-await-to-progress

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

const {replaceWith} = require('putout').operator;

module.exports.fix = (path) => {
    replaceWith(path, identifier('hello'));
};

βœ… Example of correct code

module.exports.fix = (path) => {
    path.replaceWithMultiple([
        identifier('hello'),
    ]);
};

add-crawl-file

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

const {replaceWithMultiple} = require('putout').operator;

module.exports.fix = (path) => {
    replaceWithMultiple(path, [
        identifier('hello'),
    ]);
};

βœ… Example of correct code

module.exports.replace = {
    'let __a = __b': 'const __b = __a',
};

add-path-arg-to-filter

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

createTest(__dirname, {
    printer: 'putout',
    plugins: [
        ['putout/create-test', plugin],
    ],
});

βœ… Example of correct code

const {isNumberLiteral} = types;
isNumberLiteral(node);

add-path-arg-to-fix

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

__putout_processor_json({
    rules: {
        'putout/create-test': ['on', {
            add: [
                ['printer', 'putout'],
            ],
        }],
    },
});

βœ… Example of correct code

createTest(__dirname, {
    'putout/create-test': plugin,
});

add-path-arg-to-match

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

const {isNumericLiteral} = types;
isNumericLiteral(node);

βœ… Example of correct code

import putoutTest from '@putout/test';

const test = putoutTest(__dirname, {
    'remove-unused-variables': rmVars,
});

add-path-arg-to-visitors

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

import {createTest} from '@putout/test';

const test = createTest(__dirname, {
    'remove-unused-variables': rmVars,
});

βœ… Example of correct code

t.transform('nested-not-block', [
    ['convert-if-to-jmp', convertIfToJmp],
    convertDoWhileToJnz,
]);

add-push-arg

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

t.transform('nested-not-block', [
    ['convert-if-to-jmp', convertIfToJmp],
    ['convert-do-while-to-jnz', convertDoWhileToJnz],
]);

βœ… Example of correct code

export const fix = ({path}) => {
    removeClassName(path, SELECTED);
};
push({
    path: child,
});

add-test-args

❌ Example of incorrect code

export const fix = (path) => {
    removeClassName(path, SELECTED);
};
push(child);

βœ… Example of correct code

test('plugin-apply-destructuring: transform: array: destructuring', (t) => {
    const code = 'const {name} = array[0]';
    
    t.transform(code, '');
    t.end();
});

add-track-file

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

module.exports.replace = () => ({
    'let __a = __b': 'const __b = __a',
});

βœ… Example of correct code

export const fix = () => {};
export const replace = () => ({
    [__json]: (path) => {
        const __aPath = path.get('arguments.0');
        const {importsPath} = getProperties(__aPath, ['imports']);
    },
});

add-traverse-args

Checkout in 🐊Putout Editor. Supported args:

  • push:

❌ Example of incorrect code

test('plugin-apply-destructuring: transform: array: destructuring', (t) => {
    const code = 'const {name} = array[0]';
    
    t.noTransformCode(code);
    t.end();
});

βœ… Example of correct code

module.exports.fix = (path) => {
    path.replaceWith(identifier('hello'));
};

apply-async-formatter

❌ Example of incorrect code

test('formatter: codeframea', (t) => {
    t.format(codeframe, 1);
    t.end();
});

βœ… Example of correct code

test('formatter: codeframea', async ({format}) => {
    await format(codeframe, 1);
});

apply-create-nested-directory

Checkout in Putout Editor.

❌ Example of incorrect code

const dirPath = createDirectory(path, '/hello/world');
const dirPath2 = createNestedDirectory(path, 'world');

βœ… Example of correct code

const dirPath = createNestedDirectory(path, '/hello/world');
const dirPath2 = createDirectory(path, 'world');

apply-create-test

❌ Example of incorrect code

const test = require('@putout/test')({
    'remove-debugger': plugin,
});

βœ… Example of correct code

const {createTest} = require('@putout/test');
const test = createTest({
    'remove-debugger': plugin,
});

apply-declare

Better to use Declareator instead of operator.declare(). Check out in 🐊Putout Editor.

❌ Example of incorrect code

const {operator} = require('putout');
const {declare} = operator;

module.exports = declare({
    tryCatch: `import tryCatch from 'try-catch'`,
    tryToCatch: `import tryToCatch from 'try-to-catch'`,
});

βœ… Example of correct code

module.exports.declare = () => ({
    tryCatch: `import tryCatch from 'try-catch'`,
    tryToCatch: `import tryToCatch from 'try-to-catch'`,
});

apply-destructuring

Check out in 🐊Putout Editor.

❌ Example of incorrect code

const putout = require('putout');

βœ… Example of correct code

const {putout} = require('putout');

apply-destructuring-to-options

Check out in 🐊Putout Editor.

❌ Example of incorrect code

export const filter = (path, options) => {};

βœ… Example of correct code

export const filter = (path, {options}) => {};

apply-engine-node-version

Check out in 🐊Putout Editor.

{
    "name": "@putout/plugin-variables",
    "peerDependencies": {
        "putout": ">=41"
    },
    "license": "MIT",
    "engines": {
-       "node": ">=20"
+       "node": ">=22"
    }
}

apply-exports

Check out in 🐊Putout Editor. Possible configuration:

{
    "rules": {
        "putout/apply-exports": ["on", {
            "addArgs": [
                "report",
                "fix",
                "scan"
            ]
        }]
    }
}

❌ Example of incorrect code

export default createRenameProperty([
    ...v32,
    ...v29,
]);

βœ… Example of correct code

export const {
    report,
    fix,
    scan,
} = createRenameProperty([
    ...v32,
    ...v29,
]);

apply-exports-to-add-args

Check out in 🐊Putout Editor.

❌ Example of incorrect code

export default addArgs(__args);

βœ… Example of correct code

export const {
    report,
    fix,
    traverse,
} = addArgs(__args);

apply-exports-to-match-files

Check out in 🐊Putout Editor.

❌ Example of incorrect code

export default matchFiles({
    '*.cjs': plugin,
});

βœ… Example of correct code

export const {
    report,
    fix,
    scan,
} = matchFiles({
    '*.cjs': plugin,
});

apply-exports-to-rename-files

Check out in 🐊Putout Editor.

❌ Example of incorrect code

export default renameFiles({
    type: 'module',
    mask: '*.mjs',
    rename(name) {
        return name.replace(/mjs$/, 'js');
    },
});

βœ… Example of correct code

export const {
    report,
    fix,
    scan,
} = renameFiles({
    type: 'module',
    mask: '*.mjs',
    rename(name) {
        return name.replace(/mjs$/, 'js');
    },
});

apply-for-of-to-track-file

The Generator object is returned by a generator function and it conforms to both the iterable protocol and the iterator protocol.

(c) MDN

trackFile is generator function used to count progress that can be used in Scanner.

Checkout in 🐊Putout Editor

❌ Example of incorrect code

module.exports.scan = (path, {push, trackFile}) => {
    trackFile(path, '*.swp').map(push);
};

βœ… Example of correct code

module.exports.scan = (path, {push, trackFile}) => {
    for (const file of trackFile(path, '*.swp')) {
        push(file);
    }
};

apply-get-binding

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

path.scope.getBinding('require');

βœ… Example of correct code

getBinding(path, 'require');

apply-insert-after

Better to use insertAfter(a, b) method of operator. It helps to avoid duplication of comments.

❌ Example of incorrect code

export const fix = (path) => {
    path.insertAfter(path.get('init'));
};

βœ… Example of correct code

import {operator} from 'putout';

const {insertAfter} = operator;

export const fix = (path) => {
    insertAfter(path, path.get('init'));
};

apply-insert-before

Better to use insertBefore(a, b) method of operator.

❌ Example of incorrect code

export const fix = (path) => {
    path.insertBefore(path.get('init'));
};

βœ… Example of correct code

import {operator} from 'putout';

const {insertBefore} = operator;

export const fix = (path) => {
    insertBefore(path, path.get('init'));
};

apply-lowercase-to-node-builders

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

path.node = Identifier('x');

βœ… Example of correct code

path.node = identifier('x');

apply-name-to-is-identifier

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

isIdentifier(path, 'hello');

βœ… Example of correct code

isIdentifier(path, {
    name: 'hello',
});

apply-namespace-specifier

Most likely what you need is esm/resolve-imported-file.

❌ Example of incorrect code

import rmUnused from '@putout/plugin-remove-unused-variables';

βœ… Example of correct code

import * as rmUnused from '@putout/plugin-remove-unused-variables';

apply-parens

Better use addParens(path) method of operator instead of using path.node.extra to have support of both printers:

  • βœ… @putout/printer;
  • βœ… babel;

Check out in 🐊Putout Editor.

❌ Example of incorrect code

path.node.extra.parenthesized = false;
path.node.extra.parenthesized = true;

if (!path.node.extra?.parenthesized)
    return;

βœ… Example of correct code

removeParens(path);
addParens(path);

if (!hasParens(path))
    return;

apply-processors-destructuring

❌ Example of incorrect code

test('', async (t) => {
    await t.process({});
});

βœ… Example of correct code

test('', async ({process}) => {
    await process({});
});

apply-processors-destructuring

❌ Example of incorrect code

test('', async (t) => {
    await t.process({});
});

βœ… Example of correct code

test('', async ({process}) => {
    await process({});
});

apply-remove

Better to use remove(path) method of operator. It helps to preserve comments.

❌ Example of incorrect code

export const fix = (path) => {
    path.remove();
};

βœ… Example of correct code

import {operator} from 'putout';

const {remove} = operator;

export const fix = (path) => {
    remove(path);
};

apply-rename

Better use rename(path, from, to) method of operator. Check out in 🐊Putout Editor.

❌ Example of incorrect code

export const fix = ({path, from, to}) => {
    path.scope.rename(from, to);
};

βœ… Example of correct code

import {operator} from 'putout';

const {rename} = operator;

export const fix = ({path, from, to}) => {
    rename(path, from, to);
};

apply-report

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

t.noReport('rename-files-full', {
    from: ['/'],
    to: [],
});
t.noReportWithOptions('rename-files-full');
t.noReport('a', 'Use b');
t.report('a');

βœ… Example of correct code

t.noReportWithOptions('rename-files-full', {
    from: ['/'],
    to: [],
});
t.noReport('rename-files-full');
t.report('a', 'Use b');
t.noReport('a');

apply-short-processors

Apply short names of processors, for example __json instead of __putout_processor_json . Checkout out in 🐊Putout Editor.

❌ Example of incorrect code

export const match = () => ({
    '__putout_processor_ignore(__a)': ({__a}) => {
        const list = __a.elements.map(getValue);
    },
    '__putout_processor_filesystem(__a)': ({__a}) => {
        const list = __a.elements.map(getValue);
    },
});

βœ… Example of correct code

export const match = () => ({
    [__ignore]: ({__array}) => {
        const list = __array.elements.map(getValue);
    },
    [__filesystem]: ({__object}) => {
        const list = __object.elements.map(getValue);
    },
});

apply-string-to-property-key

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

export const replace = {
    [`section('@select', select(__args))`]: ({__args}, path) => {
        __args.unshift(identifier('id'));
        return path;
    },
};

βœ… Example of correct code

export const replace = {
    'section("@select", select(__args))"': ({__args}, path) => {
        __args.unshift(identifier('id'));
        return path;
    },
};

apply-transform-with-options

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

t.transform('submenu', {
    submenuIndex: 1,
    insideSubmenu: true,
});

βœ… Example of correct code

t.transformWithOptions('submenu', {
    submenuIndex: 1,
    insideSubmenu: true,
});

apply-traverser-to-ignore

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

export const {
    report,
    match,
    replace,
} = ignore({
    type: __json,
    name: '.nycrc.json',
    field: 'exclude',
    list: ['*.config.*'],
});

βœ… Example of correct code

export const {
    report,
    fix,
    traverse,
} = ignore({
    type: __json,
    name: '.nycrc.json',
    field: 'exclude',
    list: ['*.config.*'],
});

apply-vars

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

export const replace = () => ({
    '__a(__args': ({}, path) => {
        return true;
    },
});
export const match = () => ({
    '__a(__args': ({}, path) => {
        return '';
    },
});

βœ… Example of correct code

export const replace = () => ({
    '__a(__args': (vars, path) => {
        return true;
    },
});
export const match = () => ({
    '__a(__args': (vars, path) => {
        return '';
    },
});

check-declare

Checks that Declarator transform is possible. Checkout in 🐊Putout Editor:

❌ Example of incorrect code

export const match = () => ({
    'nemesis.getChar()': () => {
        return path.parentPath.isExpressionStatement();
    },
    'getChar()': ({__a}) => {
        return path.parentPath.isExpressionStatement();
    },
});

βœ… Example of correct code

export const match = () => ({
    'nemesis.getChar()': (vars, path) => {
        return path.parentPath.isExpressionStatement();
    },
    'getChar()': ({__a}, path) => {
        return path.parentPath.isExpressionStatement();
    },
});

check-match

Checks that Replacer match() keys exists in replace. Checkout in 🐊Putout Editor.

❌ Example of incorrect code

export const scan = (root, {trackFile}) => {
    for (const file of trackFile(root, names)) {
        push(file);
    }
};

βœ… Example of correct code

export const scan = (root, {trackFile, push}) => {
    for (const file of trackFile(root, names)) {
        push(file);
    }
};

check-replace-code

Checks that Replacer transform is possible. Pass once=false to always fail no matter how many fixCounts passed.

❌ Example of incorrect code

export const traverse = () => ({
    TSUnionType() {
        console.log(path);
    },
});

βœ… Example of correct code

export const traverse = () => ({
    TSUnionType(path) {
        console.log(path);
    },
});

convert-add-argument-to-add-args

❌ Example of incorrect code

test('', () => {
    comparePlaces();
});

βœ… Example of correct code

test('', ({comparePlaces}) => {
    comparePlaces();
});

convert-babel-types

❌ Example of incorrect code

module.exports.preProcess = () => {};
module.exports.postProcess = () => {};

βœ… Example of correct code

module.exports.branch = (rawSource) => [];
module.exports.merge = (processedSource, list) => '';

convert-destructuring-to-identifier

❌ Example of incorrect code

module.exports.match = () => ({
    'module.exports.traverse = __a'({}, path) {},
});

βœ… Example of correct code

module.exports.match = () => ({
    'module.exports.traverse = __a': ({}, path) => {},
});

convert-dirname-to-url

❌ Example of incorrect code

module.exports.traverse = () => ({
    '__a.replace(/__b/g, __c)': (path) => {
        push(path);
    },
});

βœ… Example of correct code

module.exports.traverse = ({push}) => ({
    '__a.replace(/__b/g, __c)': (path) => {
        push(path);
    },
});

❌ Example of incorrect code

module.exports.traverse = () => ({
    ImportDeclaration(path) {
        const {node} = path;
        const {name} = node.specifiers[0].local;
        
        store('name', name);
    },
});

βœ… Example of correct code

module.exports.traverse = ({store}) => ({
    ImportDeclaration(path) {
        const {node} = path;
        const {name} = node.specifiers[0].local;
        
        store('name', name);
    },
});

❌ Example of incorrect code

export const traverse = () => ({
    ImportDeclaration(path) {
        listStore(path);
    },
});

βœ… Example of correct code

module.exports.traverse = ({listStore}) => ({
    ImportDeclaration(path) {
        listStore(path);
    },
});

❌ Example of incorrect code

export const traverse = () => ({
    'module.exports.match = __object': pathStore,
});

βœ… Example of correct code

export const traverse = ({pathStore}) => ({
    'module.exports.match = __object': pathStore,
});

convert-get-file-content-to-read-file-content

To read file content use readFileContent and never confuse.

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

const {operator} = require('putout');
const {addArgument} = operator;

module.exports = addArgument({
    t: ['t', 'test("__a", (__args) => __body)'],
});

βœ… Example of correct code

const {operator} = require('putout');
const {addArgs} = operator;

module.exports = addArgs({
    t: ['t', 'test("__a", (__args) => __body)'],
});

convert-get-rule-to-require

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

export const scan = (root, {push, progress}) => {
    trackFile();
};

βœ… Example of correct code

export const scan = (root, {push, progress, trackFile}) => {
    trackFile();
};

convert-include-to-traverse

Checkout in 🐊*Putout Editor.

❌ Example of incorrect code

module.exports.replace = () => ({
    'if (__a = __b) __body': 'if (__a === "__b") __body',
});

☝️ There is no fix for this rule, it used internally to be more confident about test coverage, because of declaration form, transforms cannon be checked by nyc and c8, and uncovered lines can find unfixable false positives when running on code. This is additional tests, if you forget to test some case (from a big list of rules that is supported) it will be checked with this rule and make transforms more stable.

convert-match-to-function

❌ Example of incorrect code

module.exports.traverse = ({push, options}) => ({
    [__filesystem](path) {
        const {names} = options;
        
        for (const name of names) {
            const files = findFile(path, name);
            
            for (const file of files) {
                push({
                    name,
                    path: file,
                });
            }
        }
    },
});

βœ… Example of correct code

module.exports.scan = (path, {push, options}) => {
    const {names} = options;
    
    for (const name of names) {
        const files = findFile(path, name);
        
        for (const file of files) {
            push(file, {
                name,
            });
        }
    }
};

convert-method-to-property

❌ Example of incorrect code

export const filter = () => {
    return path.isStringLiteral();
};

βœ… Example of correct code

export const filter = (path) => {
    return path.isStringLiteral();
};

convert-node-to-path-in-get-template-values

❌ Example of incorrect code

module.exports.declare = () => ({
    isNumber: 'const isNumber = () => {}',
    isString: 'const isNumber = () => {}',
});

☝️ There is no fix for this rule, it used internally to be more confident about test coverage, because of declaration form, transforms cannon be checked by nyc and c8, and uncovered lines can find unfixable false positives when running on code. This is additional tests, if you forget to test some case (from a big list of rules that is supported) it will be checked with this rule and make transforms more stable.

convert-number-to-numeric

Prevent Babel warning: The node type NumberLiteral has been renamed to NumericLiteral.

❌ Example of incorrect code

const {
    ObjectExpression,
    SpreadElement,
    isObjectExpression,
    isIdentifier,
} = require('@babel/types');

βœ… Example of correct code

const {
    ObjectExpression,
    SpreadElement,
    isObjectExpression,
    isIdentifier,
} = require('putout').types;

convert-plugins-element-to-tuple

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

const {__a, __b} = getTemplateValues(path.node, 'const __a = __b');

βœ… Example of correct code

const {__a, __b} = getTemplateValues(path, 'const __a = __b');

convert-process-to-find

❌ Example of incorrect code

export const fix = () => {
    path.remove();
};

βœ… Example of correct code

export const fix = (path) => {
    path.remove();
};

convert-push-object-to-push-path

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

const parseOptions = require('putout/lib/parse-options');

βœ… Example of correct code

const parseOptions = require('putout/parse-options');

convert-putout-test-to-create-test

Fixes results of @putout/convert-commonjs-to-esm work.

❌ Example of incorrect code

module.exports.replace = () => ({
    'const __a = __b': ({}) => {},
    'const __c = __d': ({}, path) => {},
});

βœ… Example of correct code

module.exports.replace = () => ({
    'const __a = __b': (vars) => {},
    'const __c = __d': (vars, path) => {},
});

convert-replace-to-function

❌ Example of incorrect code

export const traverse = () => ({
    [__markdown]: (path) => {
        traverse();
    },
});

βœ… Example of correct code

export const traverse = () => ({
    [__markdown]: (path) => {
        superTraverse(path, {
            '__a(__b, __c)': (path) => {},
        });
    },
});

add-places-to-compare-places"

❌ Example of incorrect code

comparePlaces takes two or more arguments.

Checkout in 🐊Putout Editor.

comparePlaces('hello');

βœ… Example of correct code

comparePlaces('hello', []);

convert-replace-to-traverse

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

module.exports.traverse = () => ({
    'async (__a) => __b': 'async ({process}) => __b',
});

βœ… Example of correct code

module.exports.replace = () => ({
    'async (__a) => __b': 'async ({process}) => __b',
});

convert-replace-with

❌ Example of incorrect code

export const include = () => ({
    ClassDeclaration(path) {},
});

βœ… Example of correct code

export const traverse = () => ({
    ClassDeclaration(path) {},
});

convert-replace-with-multiple

❌ Example of incorrect code

module.exports.traverse = ({push}) => ({
    TSTypeAssertion(path) {
        push(path);
    },
});

βœ… Example of correct code

module.exports.include = () => [
    'TSTypeAssertion',
];

convert-report-to-function

❌ Example of incorrect code

export const scan = (root, {push, progress}) => {
    crawlFile();
};

βœ… Example of correct code

export const scan = (root, {push, progress, crawlFile}) => {
    crawlFile();
};

convert-to-no-transform-code

❌ Example of incorrect code

## Rules
-- βœ… [remove-illegal-strict-mode](#remove-useless-strict-mode);
-- βœ… [add-node-prefix](#add-node-prefix);
+- βœ… [add-node-prefix](#add-node-prefix);
+- βœ… [remove-illegal-strict-mode](#remove-useless-strict-mode);

convert-traverse-to-include

❌ Example of incorrect code

module.exports.match = () => ({
    '__a = __b': (vars, path) => {},
});
module.exports.replace = () => ({
    '__a = __': '__a',
});

☝️ There is no fix for this rule, it used internally to be more confident about test coverage, because of declaration form, transforms cannon be checked by nyc and c8, and uncovered lines can find unfixable false positives when running on code. This is additional tests, if you forget to test some case (from a big list of rules that is supported) it will be checked with this rule and make transforms more stable.

convert-traverse-to-replace

❌ Example of incorrect code

export const match = () => ({
    '__a(__args': (vars, path) => {
        fn(x);
        return __args[__a];
    },
});

βœ… Example of correct code

export const match = () => ({
    '__a(__args': ({__args, __a}, path) => {
        fn(x);
        return __args[__a];
    },
});

convert-traverse-to-scan

Checkout in 🐊Putout Editor:

❌ Example of incorrect code

export const match = () => ({
    '__x __a __expr': ({__x}) => {
        if (path.isNextPunctuator(assign))
            return false;
        
        return isOneOfKeywords(__x, ['const', 'let', 'var']);
    },
});

βœ… Example of correct code

export const match = () => ({
    '__x __a __expr': ({__x}) => {
        if (path.isNextPunctuator(assign))
            return false;
        
        return isOneOfKeywords(__x, ['const', 'let', 'var']);
    },
});

convert-traverse-to-super-traverse

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

compare(a, 'const __a = __b');
isIdentifier(a);

βœ… Example of correct code

import {operator, types} from 'putout';

const {compare} = operator;
const {isIdentifier} = types;

compare(a, 'const __a = __b');
isIdentifier(a);

convert-url-to-dirname

❌ Example of incorrect code

test('', ({progress}) => {
    progress();
});

βœ… Example of correct code

test('', async ({progress}) => {
    await progress();
});

create-test

Add properties to createTest options, here is example of .putout.json:

Check it out in 🐊Putout Editor.

❌ Example of incorrect code

module.exports.match = {
    'let __a = __b': () => false,
};

βœ… Example of correct code

module.exports.match = () => ({
    'let __a = __b': () => false,
});

declare

❌ Example of incorrect code

import {createTest} from '@putout/test';
import plugin from '@putout/plugin-debugger';
import {createSimport} from 'simport';

const {__dirname} = createSimport(import.meta.url);

const test = createTest(__dirname, {
    'remove-debugger': plugin,
});

βœ… Example of correct code

import {createTest} from '@putout/test';
import plugin from '@putout/plugin-debugger';

const test = createTest(import.meta.url, {
    'remove-debugger': plugin,
});

declare-path-variable

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

module.exports.report = `'report' should be a 'function'`;

βœ… Example of correct code

module.exports.report = () => `'report' should be a 'function'`;

declare-template-variables

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

const {createTest} = require('@putout/test');
const plugin = require('@putout/plugin-debugger');

const test = createTest(__dirname, {
    'remove-debugger': plugin,
});

βœ… Example of correct code

const {createTest} = require('@putout/test');
const plugin = require('@putout/plugin-debugger');

const test = createTest(import.meta.url, {
    'remove-debugger': plugin,
});

convert-progress-to-track

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

module.exports.scan = (root, {push, progress}) => {
    const files = findFile(root, ['*']);
    const n = files.length;
    
    for (const [i, file] of files.entries()) {
        push(file);
        progress({
            i,
            n,
        });
    }
};

βœ… Example of correct code

module.exports.scan = (root, {push, trackFile}) => {
    for (const file of trackFile(root, ['*'])) {
        push(file);
    }
};

includer

❌ Example of incorrect code

module.exports.rules = getRule('remove-unused-variables');

βœ… Example of correct code

const removeUnusedVariables = require('./remove-unused-variables');

module.exports.rules = {
    'remove-unused-variables': removeUnusedVariables,
};

move-require-on-top-level

❌ Example of incorrect code

const content = getFileContent(file);

βœ… Example of correct code

const content = readFileContent(file);

remove-empty-array-from-process

Check it out in 🐊Putout Editor.

❌ Example of incorrect code

module.exports.include = () => 'cons __a = __b';
module.exports.exclude = () => 'var __a = __b';
module.exports.include = 'cons __a = __b';
module.exports.exclude = 'var __a = __b';
module.exports.include = [
    'cons __a = __b',
];
module.exports.exclude = [
    'var __a = __b',
];
export const include = [
    'cons __a = __b',
];
export const exclude = [
    'var __a = __b',
];

βœ… Example of correct code

module.exports.include = () => [
    'const __a = __b',
];
module.exports.exclude = () => [
    'var __a = __b',
];
export const include = () => [
    'cons __a = __b',
];
export const exclude = () => [
    'var __a = __b',
];

remove-empty-object-from-transform

Check it out in 🐊Putout Editor.

❌ Example of incorrect code

test('plugin-putout: rename-operate-to-operator: transform: operator exist', (t) => {
    t.noTransform('operator');
    t.end();
});

test('plugin-putout: rename-operate-to-operator: report: operator exist', (t) => {
    t.noReport('operator');
    t.end();
});

βœ… Example of correct code

test('plugin-putout: rename-operate-to-operator: no transform: operator exist', (t) => {
    t.noTransform('operator');
    t.end();
});

test('plugin-putout: rename-operate-to-operator: no report: operator exist', (t) => {
    t.noReport('operator');
    t.end();
});

remove-message-from-no-report-after-transform

Check it out in 🐊Putout Editor.

❌ Example of incorrect code

test('hello', (t) => {
    t.transform('nested-labels', {});
});

βœ… Example of correct code

test('hello', (t) => {
    t.transform('nested-labels');
});

remove-unused-get-properties-argument

Check it out in 🐊Putout Editor.

❌ Example of incorrect code

await process('input', []);

βœ… Example of correct code

await process('input');

remove-useless-printer-option

Check it out in 🐊Putout Editor.

putout printer used by default, so there is no need to pass it.

❌ Example of incorrect code

const {
    overridesPath,
    parserPath,
    rulesPath,
} = getProperties(__jsonPath, [
    'parser',
    'rules',
    'overrides',
    'extends',
]);

βœ… Example of correct code

const {
    overridesPath,
    parserPath,
    rulesPath,
} = getProperties(__jsonPath, ['parser', 'rules', 'extends']);

remove-useless-source-argument

Check it out in 🐊Putout Editor.

❌ Example of incorrect code

test('github: set-message-of-commit-fixes: no report after transform', (t) => {
    t.noReportAfterTransform('set-message-of-commit-fixes', `Set 'message' of 'Commit fixes'`);
    t.end();
});

βœ… Example of correct code

test('github: set-message-of-commit-fixes: no report after transform', (t) => {
    t.noReportAfterTransform('set-message-of-commit-fixes');
    t.end();
});

replace-test-message

Checks that test message and used operator are synchronized. Check it out in 🐊Putout Editor.

❌ Example of incorrect code

const test = require('@putout/test')(__dirname, {
    'remove-debugger': require('..'),
});

test('remove debugger: report', (t) => {
    t.transform('debugger', {
        'remove-debugger': require('..'),
    });
    t.end();
});

βœ… Example of correct code

const removeDebugger = require('..');
const test = require('@putout/test')(__dirname, {
    'remove-debugger': removeDebugger,
});

test('remove debugger: report', (t) => {
    t.transform('debugger', {
        'remove-debugger': removeDebugger,
    });
    t.end();
});

shorten-imports

❌ Example of incorrect code

const test = createTest(__dirname, {
    printer: 'putout',
    plugins: [
        ['remove-unchanged-zero-declarations', plugin],
    ],
});

βœ… Example of correct code

const test = createTest(__dirname, {
    plugins: [
        ['remove-unchanged-zero-declarations', plugin],
    ],
});

simplify-replace-template

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

module.exports.replace = () => ({
    'if (__a) {__b} else {__c}': () => 'if (__a) __b; else __c',
});

βœ… Example of correct code

module.exports.replace = () => ({
    'if (__a) {__b} else {__c}': 'if (__a) __b; else __c',
});

sort-readme-file

Checkout in 🐊Putout Editor:

apply-fixture-name-to-message"

Checkout in 🐊Putout Editor.

test('flatlint: convert-comma-to-semicolon: no report: xxx', (t) => {
    t.noReport('array');
    t.end();
});

βœ… Example of correct code

test('flatlint: convert-comma-to-semicolon: no report: array', (t) => {
    t.noReport('array');
    t.end();
});

apply-type-check

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

if (a.type === 'CallExpression') {}

βœ… Example of correct code

if (isCallExpression(a)) {}

convert-replacer-to-includer

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

export const replace = () => ({
    'const [__a, {__b}] = __c(__d, __e)': 'const [__a, {__b}] = __c(__d, __e)',
    'const [__a, {__b = {}} = {}] = __c(__d, __e)': 'const [__a, {__b = {}} = {}] = __c(__d, __e)',
});

βœ… Example of correct code

export const fix = () => {};
export const include = () => [
    'const [__a, {__b}] = __c(__d, __e)',
    'const [__a, {__b = {}} = {}] = __c(__d, __e)',
];

remove-useless-match

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

export const match = () => ({
    'const [__a, {__b}] = __c(__d, __e)': () => true,
    'const [__a, {__b = {}} = {}] = __c(__d, __e)': () => true,
});

βœ… Example of correct code

remove-useless-type-check-declaration

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

const isStringLiteral = (arg) => arg.type === 'StringLiteral';

βœ… Example of correct code

shorten-path-get

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

const elements = path.get('arguments')[0].get('elements');

βœ… Example of correct code

const elements = path.get('arguments.0.elements');

License

MIT