🐊 Pluggable and configurable JavaScript Linter, code transformer and formatter, drop-in ESLint superpower replacement 💪 with built-in support for js, jsx, typescript, flow, markdown, yaml and json. Write declarative codemods in a simplest possible way 😏
Installations
npm install @putout/plugin-putout
Developer Guide
Typescript
No
Module System
CommonJS, ESM
Min. Node Version
>=18
Node Version
22.13.0
NPM Version
10.9.0
Releases
Contributors
Languages
JavaScript (99.09%)
TypeScript (0.65%)
HTML (0.17%)
WebAssembly (0.05%)
CSS (0.02%)
Svelte (0.01%)
Developer
Download Statistics
Total Downloads
1,831,740
Last Day
2,896
Last Week
11,698
Last Month
51,047
Last Year
691,293
GitHub Statistics
722 Stars
14,734 Commits
41 Forks
10 Watching
46 Branches
24 Contributors
Bundle Size
71.69 kB
Minified
15.05 kB
Minified + Gzipped
Package Meta Information
Latest Version
22.12.0
Package Id
@putout/plugin-putout@22.12.0
Unpacked Size
144.56 kB
Size
28.74 kB
File Count
72
NPM Version
10.9.0
Node Version
22.13.0
Publised On
22 Jan 2025
Total Downloads
Cumulative downloads
Total Downloads
1,831,740
Last day
3%
2,896
Compared to previous day
Last week
-9.2%
11,698
Compared to previous week
Last month
1.7%
51,047
Compared to previous month
Last year
67.4%
691,293
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
@putout/plugin-putout ![NPM version](https://img.shields.io/npm/v/@putout/plugin-putout.svg?style=flat&longCache=true)
🐊Putout plugin helps with plugins development.
Install
npm i @putout/plugin-putout -D
Rules
- ✅ add-await-to-progress;
- ✅ add-index-to-import;
- ✅ add-places-to-compare-places;
- ✅ add-path-arg-to-fix;
- ✅ add-path-arg-to-visitors;
- ✅ add-test-args;
- ✅ add-traverse-args;
- ✅ add-track-file;
- ✅ apply-async-formatter;
- ✅ apply-create-test;
- ✅ apply-declare;
- ✅ apply-for-of-to-track-file;
- ✅ apply-fixture-name-to-message;
- ✅ apply-insert-after;
- ✅ apply-insert-before;
- ✅ apply-vars;
- ✅ apply-namespace-specifier;
- ✅ apply-processors-destructuring;
- ✅ apply-remove;
- ✅ apply-rename;
- ✅ apply-short-processors;
- ✅ check-match;
- ✅ check-replace-code;
- ✅ convert-add-argument-to-add-args;
- ✅ convert-babel-types;
- ✅ convert-destructuring-to-identifier;
- ✅ convert-dirname-to-url;
- ✅ convert-find-to-traverse;
- ✅ convert-get-rule-to-require;
- ✅ convert-match-to-function;
- ✅ convert-method-to-property;
- ✅ convert-node-to-path-in-get-template-values;
- ✅ convert-number-to-numeric;
- ✅ convert-process-to-find;
- ✅ convert-progress-to-track-file;
- ✅ convert-putout-test-to-create-test;
- ✅ convert-replace-to-function;
- ✅ convert-replace-with;
- ✅ convert-replace-with-multiple;
- ✅ convert-report-to-function;
- ✅ convert-to-no-transform-code;
- ✅ convert-include-to-traverse;
- ✅ convert-traverse-to-include;
- ✅ convert-traverse-to-replace;
- ✅ convert-traverse-to-scan;
- ✅ convert-url-to-dirname;
- ✅ create-test;
- ✅ declare;
- ✅ declare-template-variables;
- ✅ declare-path-variable;
- ✅ includer;
- ✅ move-require-on-top-level;
- ✅ remove-empty-array-from-process;
- ✅ remove-unused-get-properties-argument;
- ✅ remove-useless-printer-option;
- ✅ rename-operate-to-operator;
- ✅ replace-operate-with-operator;
- ✅ replace-test-message;
- ✅ shorten-imports;
- ✅ simplify-replace-template;
Config
1{ 2 "rules": { 3 "putout/add-places-to-compare-places": "on", 4 "putout/add-path-arg-to-fix": "on", 5 "putout/add-path-arg-to-visitors": "on", 6 "putout/add-test-args": "on", 7 "putout/add-traverse-args": "on", 8 "putout/add-track-file": "on", 9 "putout/add-await-to-progress": "on", 10 "putout/add-index-to-import": "on", 11 "putout/apply-create-test": "on", 12 "putout/apply-async-formatter": "on", 13 "putout/apply-declare": "on", 14 "putout/apply-processors-destructuring": "on", 15 "putout/apply-rename": "on", 16 "putout/apply-remove": "on", 17 "putout/apply-insert-before": "on", 18 "putout/apply-insert-after": "on", 19 "putout/apply-vars": "on", 20 "putout/apply-short-processors": "on", 21 "putout/apply-namespace-specifier": "on", 22 "putout/apply-for-of-to-track-file": "on", 23 "putout/apply-fixture-name-to-message": "on", 24 "putout/check-match": "on", 25 "putout/check-replace-code": ["on", { 26 "once": true 27 }], 28 "putout/convert-putout-test-to-create-test": "on", 29 "putout/convert-to-no-transform-code": "on", 30 "putout/convert-number-to-numeric": "on", 31 "putout/convert-replace-with": "on", 32 "putout/convert-replace-with-multiple": "on", 33 "putout/convert-replace-to-function": "on", 34 "putout/convert-match-to-function": "on", 35 "putout/convert-babel-types": "on", 36 "putout/convert-destructuring-to-identifier": "on", 37 "putout/convert-node-to-path-in-get-template-values": "on", 38 "putout/convert-include-to-traverse": "on", 39 "putout/convert-traverse-to-include": "on", 40 "putout/convert-traverse-to-replace": "on", 41 "putout/convert-traverse-to-scan": "on", 42 "putout/convert-process-to-find": "on", 43 "putout/convert-method-to-property": "on", 44 "putout/convert-add-argument-to-add-args": "on", 45 "putout/convert-dirname-to-url": "on", 46 "putout/convert-url-to-dirname": "on", 47 "putout/convert-report-to-function": "on", 48 "putout/convert-get-rule-to-require": "on", 49 "putout/convert-progress-to-track-file": "on", 50 "putout/create-test": "on", 51 "putout/shorten-imports": "on", 52 "putout/declare": "on", 53 "putout/declare-template-variables": "on", 54 "putout/declare-path-variable": "on", 55 "putout/includer": "on", 56 "putout/move-require-on-top-level": "on", 57 "putout/replace-test-message": "on", 58 "putout/remove-unused-get-properties-argument": "on", 59 "putout/remove-empty-array-from-process": "on", 60 "putout/remove-useless-printer-option": "on", 61 "putout/simplify-replace-template": "on" 62 } 63}
apply-processors-destructuring
❌ Example of incorrect code
1test('', async (t) => { 2 await t.process({}); 3});
✅ Example of correct code
1test('', async ({process}) => { 2 await process({}); 3});
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
1export const match = () => ({ 2 '__putout_processor_ignore(__a)': ({__a}) => { 3 const list = __a.elements.map(getValue); 4 }, 5 '__putout_processor_filesystem(__a)': ({__a}) => { 6 const list = __a.elements.map(getValue); 7 }, 8});
✅ Example of correct code
1export const match = () => ({ 2 [__ignore]: ({__array}) => { 3 const list = __array.elements.map(getValue); 4 }, 5 [__filesystem]: ({__object}) => { 6 const list = __object.elements.map(getValue); 7 }, 8});
apply-rename
Better use rename(path, from, to)
method of operator
.
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1export const fix = ({path, from, to}) => { 2 path.scope.rename(from, to); 3};
✅ Example of correct code
1import {operator} from 'putout'; 2 3const {rename} = operator; 4 5export const fix = ({path, from, to}) => { 6 rename(path, from, to); 7};
apply-remove
Better to use remove(path)
method of operator
.
It helps to preserve comments.
❌ Example of incorrect code
1export const fix = (path) => { 2 path.remove(); 3};
✅ Example of correct code
1import {operator} from 'putout'; 2 3const {remove} = operator; 4 5export const fix = (path) => { 6 remove(path); 7};
apply-insert-before
Better to use insertBefore(a, b)
method of operator
.
❌ Example of incorrect code
1export const fix = (path) => { 2 path.insertBefore(path.get('init')); 3};
✅ Example of correct code
1import {operator} from 'putout'; 2 3const {insertBefore} = operator; 4 5export const fix = (path) => { 6 insertBefore(path, path.get('init')); 7};
apply-insert-after
Better to use insertAfter(a, b)
method of operator
.
It helps to avoid duplication of comments.
❌ Example of incorrect code
1export const fix = (path) => { 2 path.insertAfter(path.get('init')); 3};
✅ Example of correct code
1import {operator} from 'putout'; 2 3const {insertAfter} = operator; 4 5export const fix = (path) => { 6 insertAfter(path, path.get('init')); 7};
apply-vars
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1export const replace = () => ({ 2 '__a(__args': ({}, path) => { 3 return true; 4 }, 5}); 6 7export const match = () => ({ 8 '__a(__args': ({}, path) => { 9 return ''; 10 }, 11});
✅ Example of correct code
1export const replace = () => ({ 2 '__a(__args': (vars, path) => { 3 return true; 4 }, 5}); 6 7export const match = () => ({ 8 '__a(__args': (vars, path) => { 9 return ''; 10 }, 11});
apply-declare
Better to use Declareator
instead of operator.declare()
.
Check out in 🐊Putout Editor.
❌ Example of incorrect code
1const {operator} = require('putout'); 2const {declare} = operator; 3 4module.exports = declare({ 5 tryCatch: `import tryCatch from 'try-catch'`, 6 tryToCatch: `import tryToCatch from 'try-to-catch'`, 7});
✅ Example of correct code
1module.exports.declare = () => ({ 2 tryCatch: `import tryCatch from 'try-catch'`, 3 tryToCatch: `import tryToCatch from 'try-to-catch'`, 4});
apply-async-formatter
❌ Example of incorrect code
1test('formatter: codeframea', (t) => { 2 t.format(codeframe, 1); 3 t.end(); 4});
✅ Example of correct code
1test('formatter: codeframea', async ({format}) => { 2 await format(codeframe, 1); 3});
apply-create-test
❌ Example of incorrect code
1const test = require('@putout/test')({ 2 'remove-debugger': plugin, 3});
✅ Example of correct code
1const {createTest} = require('@putout/test'); 2 3const test = createTest({ 4 'remove-debugger': plugin, 5});
apply-for-of-to-track-file
The Generator object is returned by a
generator function
and it conforms to both the iterable protocol and theiterator
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
1module.exports.scan = (path, {push, trackFile}) => {
2 trackFile(path, '*.swp').map(push);
3};
✅ Example of correct code
1module.exports.scan = (path, {push, trackFile}) => { 2 for (const file of trackFile(path, '*.swp')) { 3 push(file); 4 } 5};
create-test
Add properties to createTest
options, here is exmample of .putout.json
:
1{ 2 "rules": { 3 "putout/create-test": ["on", { 4 "add": [ 5 ["printer", "putout"] 6 ] 7 }] 8 } 9}
Check it out in 🐊Putout Editor.
❌ Example of incorrect code
1createTest(__dirname, {
2 'putout/create-test': plugin,
3});
✅ Example of correct code
1createTest(__dirname, { 2 printer: 'putout', 3 plugins: [ 4 ['putout/create-test', plugin], 5 ], 6});
convert-number-to-numeric
Prevent Babel
warning: The node type NumberLiteral has been renamed to NumericLiteral
.
❌ Example of incorrect code
1const {isNumberLiteral} = types; 2isNumberLiteral(node);
✅ Example of correct code
1const {isNumericLiteral} = types; 2isNumericLiteral(node);
convert-putout-test-to-create-test
Fixes results of @putout/convert-commonjs-to-esm work.
❌ Example of incorrect code
1import putoutTest from '@putout/test';
2
3const test = putoutTest(__dirname, {
4 'remove-unused-variables': rmVars,
5});
✅ Example of correct code
1import {createTest} from '@putout/test';
2
3const test = createTest(__dirname, {
4 'remove-unused-variables': rmVars,
5});
convert-to-no-transform-code
❌ Example of incorrect code
1test('plugin-apply-destructuring: transform: array: destructuring', (t) => { 2 const code = 'const {name} = array[0]'; 3 4 t.transform(code, ''); 5 t.end(); 6});
✅ Example of correct code
1test('plugin-apply-destructuring: transform: array: destructuring', (t) => { 2 const code = 'const {name} = array[0]'; 3 4 t.noTransformCode(code); 5 t.end(); 6});
convert-replace-with
❌ Example of incorrect code
1module.exports.fix = (path) => { 2 path.replaceWith(Identifier('hello')); 3};
✅ Example of correct code
1const {replaceWith} = require('putout').operator; 2 3module.exports.fix = (path) => { 4 replaceWith(path, Identifier('hello')); 5};
convert-replace-with-multiple
❌ Example of incorrect code
1module.exports.fix = (path) => { 2 path.replaceWithMultiple([ 3 Identifier('hello'), 4 ]); 5};
✅ Example of correct code
1const {replaceWithMultiple} = require('putout').operator; 2 3module.exports.fix = (path) => { 4 replaceWithMultiple(path, [ 5 Identifier('hello'), 6 ]); 7};
convert-replace-to-function
❌ Example of incorrect code
1module.exports.replace = { 2 'let __a = __b': 'const __b = __a', 3};
✅ Example of correct code
1module.exports.replace = () => ({ 2 'let __a = __b': 'const __b = __a', 3});
convert-match-to-function
❌ Example of incorrect code
1module.exports.match = { 2 'let __a = __b': () => false, 3};
✅ Example of correct code
1module.exports.match = () => ({ 2 'let __a = __b': () => false, 3});
convert-babel-types
❌ Example of incorrect code
1const { 2 ObjectExpression, 3 SpreadElement, 4 isObjectExpression, 5 isIdentifier, 6} = require('@babel/types');
✅ Example of correct code
1const { 2 ObjectExpression, 3 SpreadElement, 4 isObjectExpression, 5 isIdentifier, 6} = require('putout').types;
convert-destructuring-to-identifier
❌ Example of incorrect code
1module.exports.replace = () => ({ 2 'const __a = __b': ({}) => {}, 3 'const __c = __d': ({}, path) => {}, 4});
✅ Example of correct code
1module.exports.replace = () => ({ 2 'const __a = __b': (vars) => {}, 3 'const __c = __d': (vars, path) => {}, 4});
convert-node-to-path-in-get-template-values
❌ Example of incorrect code
1const {__a, __b} = getTemplateValues(path.node, 'const __a = __b');
✅ Example of correct code
1const {__a, __b} = getTemplateValues(path, 'const __a = __b');
shorten-imports
❌ Example of incorrect code
1const parseOptions = require('putout/lib/parse-options');
✅ Example of correct code
1const parseOptions = require('putout/parse-options');
convert-include-to-traverse
Checkout in 🐊*Putout Editor.
❌ Example of incorrect code
1export const include = () => ({ 2 ClassDeclaration(path) {}, 3});
✅ Example of correct code
1export const traverse = () => ({ 2 ClassDeclaration(path) {}, 3});
convert-traverse-to-include
❌ Example of incorrect code
1module.exports.traverse = ({push}) => ({ 2 TSTypeAssertion(path) { 3 push(path); 4 }, 5});
✅ Example of correct code
1module.exports.include = () => [ 2 'TSTypeAssertion', 3];
convert-traverse-to-replace
❌ Example of incorrect code
1module.exports.traverse = () => ({ 2 'async (__a) => __b': 'async ({process}) => __b', 3});
✅ Example of correct code
1module.exports.replace = () => ({ 2 'async (__a) => __b': 'async ({process}) => __b', 3});
convert-traverse-to-scan
Checkout in 🐊Putout Editor:
❌ Example of incorrect code
1module.exports.traverse = ({push, options}) => ({ 2 [__filesystem](path) { 3 const {names} = options; 4 5 for (const name of names) { 6 const files = findFile(path, name); 7 8 for (const file of files) { 9 push({ 10 name, 11 path: file, 12 }); 13 } 14 } 15 }, 16});
✅ Example of correct code
1module.exports.scan = (path, {push, options}) => { 2 const {names} = options; 3 4 for (const name of names) { 5 const files = findFile(path, name); 6 7 for (const file of files) { 8 push(file, { 9 name, 10 }); 11 } 12 } 13};
convert-process-to-find
❌ Example of incorrect code
1module.exports.preProcess = () => {}; 2module.exports.postProcess = () => {};
✅ Example of correct code
1module.exports.branch = (rawSource) => []; 2module.exports.merge = (processedSource, list) => '';
convert-method-to-property
- property simpler to work with;
- support of
convert-destructuring-to-identifier
which isReplacer
, whileconvert-method-to-property
isIncluder
(searches forObjectMethod
node);
❌ Example of incorrect code
1module.exports.match = () => ({ 2 'module.exports.traverse = __a'({}, path) {}, 3});
✅ Example of correct code
1module.exports.match = () => ({ 2 'module.exports.traverse = __a': ({}, path) => {}, 3});
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
1module.exports.replace = () => ({ 2 'if (__a = __b) __body': 'if (__a === "__b") __body', 3});
☝️ 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.
check-match
Checks that Replacer match()
keys exists in replace
.
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1module.exports.match = () => ({ 2 '__a = __b': (vars, path) => {}, 3}); 4 5module.exports.replace = () => ({ 6 '__a = __': '__a', 7});
☝️ 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.
declare
Depends on @putout/convert-esm-to-commonjs and @putout/declare.
❌ Example of incorrect code
1compare(a, 'const __a = __b'); 2isIdentifier(a);
✅ Example of correct code
1const {operator, types} = require('putout'); 2 3const {compare} = operator; 4const {isIdentifier} = types; 5 6compare(a, 'const __a = __b'); 7isIdentifier(a);
declare-template-variables
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1export const match = () => ({ 2 '__a(__args': (vars, path) => { 3 fn(x); 4 5 return __args[__a]; 6 }, 7});
✅ Example of correct code
1export const match = () => ({ 2 '__a(__args': ({__args, __a}, path) => { 3 fn(x); 4 5 return __args[__a]; 6 }, 7});
declare-path-variable
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1export const match = () => ({ 2 '__x __a __expr': ({__x}) => { 3 if (path.isNextPunctuator(assign)) 4 return false; 5 6 return isOneOfKeywords(__x, ['const', 'let', 'var']); 7 }, 8});
✅ Example of correct code
1export const match = () => ({ 2 '__x __a __expr': ({__x}) => { 3 if (path.isNextPunctuator(assign)) 4 return false; 5 6 return isOneOfKeywords(__x, ['const', 'let', 'var']); 7 }, 8});
add-places-to-compare-places"
❌ Example of incorrect code
comparePlaces
takes two or more arguments.
Checkout in 🐊Putout Editor.
1comparePlaces('hello');
✅ Example of correct code
1comparePlaces('hello', []);
add-path-arg-to-fix
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1export const fix = () => { 2 path.remove(); 3};
✅ Example of correct code
1export const fix = (path) => { 2 path.remove(); 3};
add-path-arg-to-visitors
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1export const traverse = () => ({ 2 TSUnionType() { 3 console.log(path); 4 }, 5});
✅ Example of correct code
1export const traverse = () => ({ 2 TSUnionType(path) { 3 console.log(path); 4 }, 5});
add-test-args
❌ Example of incorrect code
1test('', () => { 2 comparePlaces(); 3});
✅ Example of correct code
1test('', ({comparePlaces}) => { 2 comparePlaces(); 3});
add-traverse-args
Checkout in 🐊Putout Editor. Supported args:
push
:
❌ Example of incorrect code
1module.exports.traverse = () => ({ 2 '__a.replace(/__b/g, __c)': (path) => { 3 push(path); 4 }, 5});
✅ Example of correct code
1module.exports.traverse = ({push}) => ({ 2 '__a.replace(/__b/g, __c)': (path) => { 3 push(path); 4 }, 5});
❌ Example of incorrect code
1module.exports.traverse = () => ({ 2 ImportDeclaration(path) { 3 const {node} = path; 4 const {name} = node.specifiers[0].local; 5 6 store('name', name); 7 }, 8});
✅ Example of correct code
1module.exports.traverse = ({store}) => ({ 2 ImportDeclaration(path) { 3 const {node} = path; 4 const {name} = node.specifiers[0].local; 5 6 store('name', name); 7 }, 8});
❌ Example of incorrect code
1export const traverse = () => ({ 2 ImportDeclaration(path) { 3 listStore(path); 4 }, 5});
✅ Example of correct code
1module.exports.traverse = ({listStore}) => ({ 2 ImportDeclaration(path) { 3 listStore(path); 4 }, 5});
❌ Example of incorrect code
1export const traverse = () => ({ 2 'module.exports.match = __object': pathStore, 3});
✅ Example of correct code
1export const traverse = ({pathStore}) => ({ 2 'module.exports.match = __object': pathStore, 3});
add-await-to-progress
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1test('', ({progress}) => { 2 progress(); 3});
✅ Example of correct code
1test('', async ({progress}) => { 2 await progress(); 3});
add-track-file
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1export const scan = (root, {push, progress}) => { 2 trackFile(); 3};
✅ Example of correct code
1export const scan = (root, {push, progress, trackFile}) => { 2 trackFile(); 3};
add-index-to-import
ESM doesn't add index.js
, so it can be left after @putout/plugin-convert-esm-to-commonjs
.
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1import insertRust from './insert-rust.js'; 2import addAction from './add-action.js'; 3 4export const rules = {};
✅ Example of correct code
1import insertRust from './insert-rust/index.js'; 2import addAction from './add-action/index.js'; 3 4export const rules = {};
convert-add-argument-to-add-args
❌ Example of incorrect code
1const {operator} = require('putout'); 2const {addArgument} = operator; 3 4module.exports = addArgument({ 5 t: ['t', 'test("__a", (__args) => __body)'], 6});
✅ Example of correct code
1const {operator} = require('putout'); 2const {addArgs} = operator; 3 4module.exports = addArgs({ 5 t: ['t', 'test("__a", (__args) => __body)'], 6});
convert-dirname-to-url
❌ Example of incorrect code
1import {createTest} from '@putout/test'; 2import plugin from '@putout/plugin-debugger'; 3import {createSimport} from 'simport'; 4 5const {__dirname} = createSimport(import.meta.url); 6 7const test = createTest(__dirname, { 8 'remove-debugger': plugin, 9});
✅ Example of correct code
1import {createTest} from '@putout/test'; 2import plugin from '@putout/plugin-debugger'; 3 4const test = createTest(import.meta.url, { 5 'remove-debugger': plugin, 6});
convert-url-to-dirname
❌ Example of incorrect code
1const {createTest} = require('@putout/test'); 2const plugin = require('@putout/plugin-debugger'); 3 4const test = createTest(__dirname, { 5 'remove-debugger': plugin, 6});
✅ Example of correct code
1const {createTest} = require('@putout/test'); 2const plugin = require('@putout/plugin-debugger'); 3 4const test = createTest(import.meta.url, { 5 'remove-debugger': plugin, 6});
convert-report-to-function
❌ Example of incorrect code
1module.exports.report = `'report' should be a 'function'`;
✅ Example of correct code
1module.exports.report = () => `'report' should be a 'function'`;
convert-progress-to-track
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1module.exports.scan = (root, {push, progress}) => { 2 const files = findFile(root, ['*']); 3 const n = files.length; 4 5 for (const [i, file] of files.entries()) { 6 push(file); 7 progress({ 8 i, 9 n, 10 }); 11 } 12};
✅ Example of correct code
1module.exports.scan = (root, {push, trackFile}) => { 2 for (const file of trackFile(root, ['*'])) { 3 push(file); 4 } 5};
convert-get-rule-to-require
- ✅ import Nested plugins in Deno and Browser;
- ✅ easier bundle with rollup without
dynamicRequireTargets
; - ✅ easier to migrate to ESM;
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1module.exports.rules = {
2 ...getRule('remove-unused-variables'),
3};
✅ Example of correct code
1const removeUnusedVariables = require('./remove-unused-variables'); 2 3module.exports.rules = { 4 'remove-unused-variables': removeUnusedVariables, 5};
move-require-on-top-level
❌ Example of incorrect code
1const test = require('@putout/test')(__dirname, { 2 'remove-debugger': require('..'), 3}); 4 5test('remove debugger: report', (t) => { 6 t.transform('debugger', { 7 'remove-debugger': require('..'), 8 }); 9 t.end(); 10});
✅ Example of correct code
1const removeDebugger = require('..'); 2 3const test = require('@putout/test')(__dirname, { 4 'remove-debugger': removeDebugger, 5}); 6 7test('remove debugger: report', (t) => { 8 t.transform('debugger', { 9 'remove-debugger': removeDebugger, 10 }); 11 t.end(); 12});
includer
❌ Example of incorrect code
1module.exports.include = () => 'cons __a = __b'; 2module.exports.exclude = () => 'var __a = __b'; 3module.exports.include = 'cons __a = __b'; 4module.exports.exclude = 'var __a = __b'; 5 6module.exports.include = [ 7 'cons __a = __b', 8]; 9 10module.exports.exclude = [ 11 'var __a = __b', 12];
✅ Example of correct code
1module.exports.include = () => [ 2 'cons __a = __b', 3]; 4 5module.exports.exclude = () => [ 6 'var __a = __b', 7]; 8 9module.exports.include = () => [ 10 'cons __a = __b', 11]; 12 13module.exports.exclude = () => [ 14 'var __a = __b', 15]; 16 17module.exports.include = () => [ 18 'cons __a = __b', 19]; 20 21module.exports.exclude = () => [ 22 'var __a = __b', 23];
replace-test-message
Checks that test message
and used operator
are synchronized.
Check it out in 🐊Putout Editor.
❌ Example of incorrect code
1test('plugin-putout: rename-operate-to-operator: transform: operator exist', (t) => { 2 t.noTransform('operator'); 3 t.end(); 4}); 5 6test('plugin-putout: rename-operate-to-operator: report: operator exist', (t) => { 7 t.noReport('operator'); 8 t.end(); 9});
✅ Example of correct code
1test('plugin-putout: rename-operate-to-operator: no transform: operator exist', (t) => { 2 t.noTransform('operator'); 3 t.end(); 4}); 5 6test('plugin-putout: rename-operate-to-operator: no report: operator exist', (t) => { 7 t.noReport('operator'); 8 t.end(); 9});
remove-empty-array-from-process
Check it out in 🐊Putout Editor.
❌ Example of incorrect code
1await process('input', []);
✅ Example of correct code
1await process('input');
remove-unused-get-properties-argument
Check it out in 🐊Putout Editor.
❌ Example of incorrect code
1const { 2 overridesPath, 3 parserPath, 4 rulesPath, 5} = getProperties(__jsonPath, [ 6 'parser', 7 'rules', 8 'overrides', 9 'extends', 10]);
✅ Example of correct code
1const { 2 overridesPath, 3 parserPath, 4 rulesPath, 5} = getProperties(__jsonPath, ['parser', 'rules', 'extends']);
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
1const test = createTest(__dirname, {
2 printer: 'putout',
3 plugins: [
4 ['remove-unchanged-zero-declarations', plugin],
5 ],
6});
✅ Example of correct code
1const test = createTest(__dirname, { 2 plugins: [ 3 ['remove-unchanged-zero-declarations', plugin], 4 ], 5});
simplify-replace-template
Checkout in 🐊Putout Editor.
❌ Example of incorrect code
1module.exports.replace = () => ({ 2 'if (__a) {__b} else {__c}': () => 'if (__a) __b; else __c', 3});
✅ Example of correct code
1module.exports.replace = () => ({ 2 'if (__a) {__b} else {__c}': 'if (__a) __b; else __c', 3});
apply-fixture-name-to-message"
Checkout in 🐊Putout Editor.
1test('flatlint: convert-comma-to-semicolon: no report: xxx', (t) => { 2 t.noReport('array'); 3 t.end(); 4});
✅ Example of correct code
1test('flatlint: convert-comma-to-semicolon: no report: array', (t) => { 2 t.noReport('array'); 3 t.end(); 4});
License
MIT
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
30 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
no binaries found in the repo
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/nodejs-pr.yml:1
- Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1
- Info: no jobLevel write permissions found
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs-pr.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs-pr.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs-pr.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs-pr.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs-pr.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs-pr.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs-pr.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs-pr.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/nodejs.yml:58: update your workflow using https://app.stepsecurity.io/secureworkflow/coderaiser/putout/nodejs.yml/master?enable=pin
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 4 third-party GitHubAction dependencies pinned
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Score
4.8
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to @putout/plugin-putout
putout
🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json
@putout/plugin-putout-config
🐊Putout plugin helps to maintain putout config
@putout/plugin-regexp
🐊Putout plugin helps with regexp
@putout/plugin-gitignore
🐊Putout plugin helps with .gitignore