$ npm install @putout/plugin-putout
πPutout plugin helps with plugins development.
npm i @putout/plugin-putout -D
{
"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"
}
}
Checkout in πPutout Editor.
const {replaceWith} = require('putout').operator;
module.exports.fix = (path) => {
replaceWith(path, identifier('hello'));
};
module.exports.fix = (path) => {
path.replaceWithMultiple([
identifier('hello'),
]);
};
Checkout in πPutout Editor.
const {replaceWithMultiple} = require('putout').operator;
module.exports.fix = (path) => {
replaceWithMultiple(path, [
identifier('hello'),
]);
};
module.exports.replace = {
'let __a = __b': 'const __b = __a',
};
Checkout in πPutout Editor.
createTest(__dirname, {
printer: 'putout',
plugins: [
['putout/create-test', plugin],
],
});
const {isNumberLiteral} = types;
isNumberLiteral(node);
Checkout in πPutout Editor.
__putout_processor_json({
rules: {
'putout/create-test': ['on', {
add: [
['printer', 'putout'],
],
}],
},
});
createTest(__dirname, {
'putout/create-test': plugin,
});
Checkout in πPutout Editor.
const {isNumericLiteral} = types;
isNumericLiteral(node);
import putoutTest from '@putout/test';
const test = putoutTest(__dirname, {
'remove-unused-variables': rmVars,
});
Checkout in πPutout Editor.
import {createTest} from '@putout/test';
const test = createTest(__dirname, {
'remove-unused-variables': rmVars,
});
t.transform('nested-not-block', [
['convert-if-to-jmp', convertIfToJmp],
convertDoWhileToJnz,
]);
Checkout in πPutout Editor.
t.transform('nested-not-block', [
['convert-if-to-jmp', convertIfToJmp],
['convert-do-while-to-jnz', convertDoWhileToJnz],
]);
export const fix = ({path}) => {
removeClassName(path, SELECTED);
};
push({
path: child,
});
export const fix = (path) => {
removeClassName(path, SELECTED);
};
push(child);
test('plugin-apply-destructuring: transform: array: destructuring', (t) => {
const code = 'const {name} = array[0]';
t.transform(code, '');
t.end();
});
Checkout in πPutout Editor.
module.exports.replace = () => ({
'let __a = __b': 'const __b = __a',
});
export const fix = () => {};
export const replace = () => ({
[__json]: (path) => {
const __aPath = path.get('arguments.0');
const {importsPath} = getProperties(__aPath, ['imports']);
},
});
Checkout in πPutout Editor. Supported args:
push:test('plugin-apply-destructuring: transform: array: destructuring', (t) => {
const code = 'const {name} = array[0]';
t.noTransformCode(code);
t.end();
});
module.exports.fix = (path) => {
path.replaceWith(identifier('hello'));
};
test('formatter: codeframea', (t) => {
t.format(codeframe, 1);
t.end();
});
test('formatter: codeframea', async ({format}) => {
await format(codeframe, 1);
});
Checkout in Putout Editor.
const dirPath = createDirectory(path, '/hello/world');
const dirPath2 = createNestedDirectory(path, 'world');
const dirPath = createNestedDirectory(path, '/hello/world');
const dirPath2 = createDirectory(path, 'world');
const test = require('@putout/test')({
'remove-debugger': plugin,
});
const {createTest} = require('@putout/test');
const test = createTest({
'remove-debugger': plugin,
});
Better to use Declareator instead of operator.declare().
Check out in πPutout Editor.
const {operator} = require('putout');
const {declare} = operator;
module.exports = declare({
tryCatch: `import tryCatch from 'try-catch'`,
tryToCatch: `import tryToCatch from 'try-to-catch'`,
});
module.exports.declare = () => ({
tryCatch: `import tryCatch from 'try-catch'`,
tryToCatch: `import tryToCatch from 'try-to-catch'`,
});
Check out in πPutout Editor.
const putout = require('putout');
const {putout} = require('putout');
Check out in πPutout Editor.
export const filter = (path, options) => {};
export const filter = (path, {options}) => {};
Check out in πPutout Editor.
{
"name": "@putout/plugin-variables",
"peerDependencies": {
"putout": ">=41"
},
"license": "MIT",
"engines": {
- "node": ">=20"
+ "node": ">=22"
}
}
Check out in πPutout Editor. Possible configuration:
{
"rules": {
"putout/apply-exports": ["on", {
"addArgs": [
"report",
"fix",
"scan"
]
}]
}
}
export default createRenameProperty([
...v32,
...v29,
]);
export const {
report,
fix,
scan,
} = createRenameProperty([
...v32,
...v29,
]);
Check out in πPutout Editor.
export default addArgs(__args);
export const {
report,
fix,
traverse,
} = addArgs(__args);
Check out in πPutout Editor.
export default matchFiles({
'*.cjs': plugin,
});
export const {
report,
fix,
scan,
} = matchFiles({
'*.cjs': plugin,
});
Check out in πPutout Editor.
export default renameFiles({
type: 'module',
mask: '*.mjs',
rename(name) {
return name.replace(/mjs$/, 'js');
},
});
export const {
report,
fix,
scan,
} = renameFiles({
type: 'module',
mask: '*.mjs',
rename(name) {
return name.replace(/mjs$/, 'js');
},
});
The Generator object is returned by a
generator functionand it conforms to both the iterable protocol and theiteratorprotocol.(c) MDN
trackFile is generator function used to count progress that can be used in Scanner.
Checkout in πPutout Editor
module.exports.scan = (path, {push, trackFile}) => {
trackFile(path, '*.swp').map(push);
};
module.exports.scan = (path, {push, trackFile}) => {
for (const file of trackFile(path, '*.swp')) {
push(file);
}
};
Checkout in πPutout Editor.
path.scope.getBinding('require');
getBinding(path, 'require');
Better to use insertAfter(a, b) method of operator.
It helps to avoid duplication of comments.
export const fix = (path) => {
path.insertAfter(path.get('init'));
};
import {operator} from 'putout';
const {insertAfter} = operator;
export const fix = (path) => {
insertAfter(path, path.get('init'));
};
Better to use insertBefore(a, b) method of operator.
export const fix = (path) => {
path.insertBefore(path.get('init'));
};
import {operator} from 'putout';
const {insertBefore} = operator;
export const fix = (path) => {
insertBefore(path, path.get('init'));
};
Checkout in πPutout Editor.
path.node = Identifier('x');
path.node = identifier('x');
Checkout in πPutout Editor.
isIdentifier(path, 'hello');
isIdentifier(path, {
name: 'hello',
});
Most likely what you need is esm/resolve-imported-file.
import rmUnused from '@putout/plugin-remove-unused-variables';
import * as rmUnused from '@putout/plugin-remove-unused-variables';
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.
path.node.extra.parenthesized = false;
path.node.extra.parenthesized = true;
if (!path.node.extra?.parenthesized)
return;
removeParens(path);
addParens(path);
if (!hasParens(path))
return;
test('', async (t) => {
await t.process({});
});
test('', async ({process}) => {
await process({});
});
test('', async (t) => {
await t.process({});
});
test('', async ({process}) => {
await process({});
});
Better to use remove(path) method of operator.
It helps to preserve comments.
export const fix = (path) => {
path.remove();
};
import {operator} from 'putout';
const {remove} = operator;
export const fix = (path) => {
remove(path);
};
Better use rename(path, from, to) method of operator.
Check out in πPutout Editor.
export const fix = ({path, from, to}) => {
path.scope.rename(from, to);
};
import {operator} from 'putout';
const {rename} = operator;
export const fix = ({path, from, to}) => {
rename(path, from, to);
};
Checkout in πPutout Editor.
t.noReport('rename-files-full', {
from: ['/'],
to: [],
});
t.noReportWithOptions('rename-files-full');
t.noReport('a', 'Use b');
t.report('a');
t.noReportWithOptions('rename-files-full', {
from: ['/'],
to: [],
});
t.noReport('rename-files-full');
t.report('a', 'Use b');
t.noReport('a');
Apply short names of processors, for example __json instead of __putout_processor_json . Checkout out in πPutout Editor.
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);
},
});
export const match = () => ({
[__ignore]: ({__array}) => {
const list = __array.elements.map(getValue);
},
[__filesystem]: ({__object}) => {
const list = __object.elements.map(getValue);
},
});
Checkout in πPutout Editor.
export const replace = {
[`section('@select', select(__args))`]: ({__args}, path) => {
__args.unshift(identifier('id'));
return path;
},
};
export const replace = {
'section("@select", select(__args))"': ({__args}, path) => {
__args.unshift(identifier('id'));
return path;
},
};
Checkout in πPutout Editor.
t.transform('submenu', {
submenuIndex: 1,
insideSubmenu: true,
});
t.transformWithOptions('submenu', {
submenuIndex: 1,
insideSubmenu: true,
});
Checkout in πPutout Editor.
export const {
report,
match,
replace,
} = ignore({
type: __json,
name: '.nycrc.json',
field: 'exclude',
list: ['*.config.*'],
});
export const {
report,
fix,
traverse,
} = ignore({
type: __json,
name: '.nycrc.json',
field: 'exclude',
list: ['*.config.*'],
});
Checkout in πPutout Editor.
export const replace = () => ({
'__a(__args': ({}, path) => {
return true;
},
});
export const match = () => ({
'__a(__args': ({}, path) => {
return '';
},
});
export const replace = () => ({
'__a(__args': (vars, path) => {
return true;
},
});
export const match = () => ({
'__a(__args': (vars, path) => {
return '';
},
});
Checks that Declarator transform is possible. Checkout in πPutout Editor:
export const match = () => ({
'nemesis.getChar()': () => {
return path.parentPath.isExpressionStatement();
},
'getChar()': ({__a}) => {
return path.parentPath.isExpressionStatement();
},
});
export const match = () => ({
'nemesis.getChar()': (vars, path) => {
return path.parentPath.isExpressionStatement();
},
'getChar()': ({__a}, path) => {
return path.parentPath.isExpressionStatement();
},
});
Checks that Replacer match() keys exists in replace.
Checkout in πPutout Editor.
export const scan = (root, {trackFile}) => {
for (const file of trackFile(root, names)) {
push(file);
}
};
export const scan = (root, {trackFile, push}) => {
for (const file of trackFile(root, names)) {
push(file);
}
};
Checks that Replacer transform is possible.
Pass once=false to always fail no matter how many fixCounts passed.
export const traverse = () => ({
TSUnionType() {
console.log(path);
},
});
export const traverse = () => ({
TSUnionType(path) {
console.log(path);
},
});
test('', () => {
comparePlaces();
});
test('', ({comparePlaces}) => {
comparePlaces();
});
module.exports.preProcess = () => {};
module.exports.postProcess = () => {};
module.exports.branch = (rawSource) => [];
module.exports.merge = (processedSource, list) => '';
module.exports.match = () => ({
'module.exports.traverse = __a'({}, path) {},
});
module.exports.match = () => ({
'module.exports.traverse = __a': ({}, path) => {},
});
module.exports.traverse = () => ({
'__a.replace(/__b/g, __c)': (path) => {
push(path);
},
});
module.exports.traverse = ({push}) => ({
'__a.replace(/__b/g, __c)': (path) => {
push(path);
},
});
module.exports.traverse = () => ({
ImportDeclaration(path) {
const {node} = path;
const {name} = node.specifiers[0].local;
store('name', name);
},
});
module.exports.traverse = ({store}) => ({
ImportDeclaration(path) {
const {node} = path;
const {name} = node.specifiers[0].local;
store('name', name);
},
});
export const traverse = () => ({
ImportDeclaration(path) {
listStore(path);
},
});
module.exports.traverse = ({listStore}) => ({
ImportDeclaration(path) {
listStore(path);
},
});
export const traverse = () => ({
'module.exports.match = __object': pathStore,
});
export const traverse = ({pathStore}) => ({
'module.exports.match = __object': pathStore,
});
To read file content use readFileContent and never confuse.
Checkout in πPutout Editor.
const {operator} = require('putout');
const {addArgument} = operator;
module.exports = addArgument({
t: ['t', 'test("__a", (__args) => __body)'],
});
const {operator} = require('putout');
const {addArgs} = operator;
module.exports = addArgs({
t: ['t', 'test("__a", (__args) => __body)'],
});
dynamicRequireTargets;Checkout in πPutout Editor.
export const scan = (root, {push, progress}) => {
trackFile();
};
export const scan = (root, {push, progress, trackFile}) => {
trackFile();
};
Checkout in π*Putout Editor.
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.
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,
});
}
}
},
});
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-destructuring-to-identifier which is Replacer, while convert-method-to-property is Includer (searches for ObjectMethod node);export const filter = () => {
return path.isStringLiteral();
};
export const filter = (path) => {
return path.isStringLiteral();
};
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.
Prevent Babel warning: The node type NumberLiteral has been renamed to NumericLiteral.
const {
ObjectExpression,
SpreadElement,
isObjectExpression,
isIdentifier,
} = require('@babel/types');
const {
ObjectExpression,
SpreadElement,
isObjectExpression,
isIdentifier,
} = require('putout').types;
Checkout in πPutout Editor.
const {__a, __b} = getTemplateValues(path.node, 'const __a = __b');
const {__a, __b} = getTemplateValues(path, 'const __a = __b');
export const fix = () => {
path.remove();
};
export const fix = (path) => {
path.remove();
};
Checkout in πPutout Editor.
const parseOptions = require('putout/lib/parse-options');
const parseOptions = require('putout/parse-options');
Fixes results of @putout/convert-commonjs-to-esm work.
module.exports.replace = () => ({
'const __a = __b': ({}) => {},
'const __c = __d': ({}, path) => {},
});
module.exports.replace = () => ({
'const __a = __b': (vars) => {},
'const __c = __d': (vars, path) => {},
});
export const traverse = () => ({
[__markdown]: (path) => {
traverse();
},
});
export const traverse = () => ({
[__markdown]: (path) => {
superTraverse(path, {
'__a(__b, __c)': (path) => {},
});
},
});
comparePlaces takes two or more arguments.
Checkout in πPutout Editor.
comparePlaces('hello');
comparePlaces('hello', []);
Checkout in πPutout Editor.
module.exports.traverse = () => ({
'async (__a) => __b': 'async ({process}) => __b',
});
module.exports.replace = () => ({
'async (__a) => __b': 'async ({process}) => __b',
});
export const include = () => ({
ClassDeclaration(path) {},
});
export const traverse = () => ({
ClassDeclaration(path) {},
});
module.exports.traverse = ({push}) => ({
TSTypeAssertion(path) {
push(path);
},
});
module.exports.include = () => [
'TSTypeAssertion',
];
export const scan = (root, {push, progress}) => {
crawlFile();
};
export const scan = (root, {push, progress, crawlFile}) => {
crawlFile();
};
## 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);
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.
export const match = () => ({
'__a(__args': (vars, path) => {
fn(x);
return __args[__a];
},
});
export const match = () => ({
'__a(__args': ({__args, __a}, path) => {
fn(x);
return __args[__a];
},
});
Checkout in πPutout Editor:
export const match = () => ({
'__x __a __expr': ({__x}) => {
if (path.isNextPunctuator(assign))
return false;
return isOneOfKeywords(__x, ['const', 'let', 'var']);
},
});
export const match = () => ({
'__x __a __expr': ({__x}) => {
if (path.isNextPunctuator(assign))
return false;
return isOneOfKeywords(__x, ['const', 'let', 'var']);
},
});
Checkout in πPutout Editor.
compare(a, 'const __a = __b');
isIdentifier(a);
import {operator, types} from 'putout';
const {compare} = operator;
const {isIdentifier} = types;
compare(a, 'const __a = __b');
isIdentifier(a);
test('', ({progress}) => {
progress();
});
test('', async ({progress}) => {
await progress();
});
Add properties to createTest options, here is example of .putout.json:
Check it out in πPutout Editor.
module.exports.match = {
'let __a = __b': () => false,
};
module.exports.match = () => ({
'let __a = __b': () => false,
});
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,
});
import {createTest} from '@putout/test';
import plugin from '@putout/plugin-debugger';
const test = createTest(import.meta.url, {
'remove-debugger': plugin,
});
Checkout in πPutout Editor.
module.exports.report = `'report' should be a 'function'`;
module.exports.report = () => `'report' should be a 'function'`;
Checkout in πPutout Editor.
const {createTest} = require('@putout/test');
const plugin = require('@putout/plugin-debugger');
const test = createTest(__dirname, {
'remove-debugger': plugin,
});
const {createTest} = require('@putout/test');
const plugin = require('@putout/plugin-debugger');
const test = createTest(import.meta.url, {
'remove-debugger': plugin,
});
Checkout in πPutout Editor.
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,
});
}
};
module.exports.scan = (root, {push, trackFile}) => {
for (const file of trackFile(root, ['*'])) {
push(file);
}
};
module.exports.rules = getRule('remove-unused-variables');
const removeUnusedVariables = require('./remove-unused-variables');
module.exports.rules = {
'remove-unused-variables': removeUnusedVariables,
};
const content = getFileContent(file);
const content = readFileContent(file);
Check it out in πPutout Editor.
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',
];
module.exports.include = () => [
'const __a = __b',
];
module.exports.exclude = () => [
'var __a = __b',
];
export const include = () => [
'cons __a = __b',
];
export const exclude = () => [
'var __a = __b',
];
Check it out in πPutout Editor.
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();
});
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();
});
Check it out in πPutout Editor.
test('hello', (t) => {
t.transform('nested-labels', {});
});
test('hello', (t) => {
t.transform('nested-labels');
});
Check it out in πPutout Editor.
await process('input', []);
await process('input');
Check it out in πPutout Editor.
putout printer used by default, so there is no need to pass it.
const {
overridesPath,
parserPath,
rulesPath,
} = getProperties(__jsonPath, [
'parser',
'rules',
'overrides',
'extends',
]);
const {
overridesPath,
parserPath,
rulesPath,
} = getProperties(__jsonPath, ['parser', 'rules', 'extends']);
Check it out in πPutout Editor.
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();
});
test('github: set-message-of-commit-fixes: no report after transform', (t) => {
t.noReportAfterTransform('set-message-of-commit-fixes');
t.end();
});
Checks that test message and used operator are synchronized.
Check it out in πPutout Editor.
const test = require('@putout/test')(__dirname, {
'remove-debugger': require('..'),
});
test('remove debugger: report', (t) => {
t.transform('debugger', {
'remove-debugger': require('..'),
});
t.end();
});
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();
});
const test = createTest(__dirname, {
printer: 'putout',
plugins: [
['remove-unchanged-zero-declarations', plugin],
],
});
const test = createTest(__dirname, {
plugins: [
['remove-unchanged-zero-declarations', plugin],
],
});
Checkout in πPutout Editor.
module.exports.replace = () => ({
'if (__a) {__b} else {__c}': () => 'if (__a) __b; else __c',
});
module.exports.replace = () => ({
'if (__a) {__b} else {__c}': 'if (__a) __b; else __c',
});
Checkout in πPutout Editor:
add-missing-semicolon;sort-contents;sort-headings;sort-config;sort-readme-file;Checkout in πPutout Editor.
test('flatlint: convert-comma-to-semicolon: no report: xxx', (t) => {
t.noReport('array');
t.end();
});
test('flatlint: convert-comma-to-semicolon: no report: array', (t) => {
t.noReport('array');
t.end();
});
Checkout in πPutout Editor.
if (a.type === 'CallExpression') {}
if (isCallExpression(a)) {}
Checkout in πPutout Editor.
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)',
});
export const fix = () => {};
export const include = () => [
'const [__a, {__b}] = __c(__d, __e)',
'const [__a, {__b = {}} = {}] = __c(__d, __e)',
];
Checkout in πPutout Editor.
export const match = () => ({
'const [__a, {__b}] = __c(__d, __e)': () => true,
'const [__a, {__b = {}} = {}] = __c(__d, __e)': () => true,
});
Checkout in πPutout Editor.
const isStringLiteral = (arg) => arg.type === 'StringLiteral';
Checkout in πPutout Editor.
const elements = path.get('arguments')[0].get('elements');
const elements = path.get('arguments.0.elements');
MIT
© 2010 - cnpmjs.org x YWFE | Home | YWFE