@putout/plugin-printer 
🐊Putout adds support of transformations for @putout/printer
.
Install
npm i @putout/plugin-printer -D
Rules
Config
{
"rules": {
"printer/add-args": "on",
"printer/apply-breakline": "on",
"printer/apply-linebreak": "on",
"printer/apply-computed-print": "on",
"printer/apply-types": "on",
"printer/declare": "on",
"printer/remove-args": "on"
}
}
apply-breakline
-print.newline();
-indent();
print.breakline();
apply-linebreak;
-indent();
-print.newline();
print.linebreak();
apply-types
Checkout in 🐊Putout Editor.
-const {isIdentifier} = require('@babel/types');
+const {types} = require('@babel/types');
+const {isIdentifier} = types;
add-args
❌ Example of incorrect code
module.exports = {
TSPropertySignature(path) {
const {optional} = path.node;
print('__key');
maybe.print(optional, '?');
},
};
✅ Example of correct code
module.exports = {
TSPropertySignature(path, {print, maybe}) {
const {optional} = path.node;
print('__key');
maybe.print(optional, '?');
},
};
apply-computed-print
❌ Example of incorrect code
print(path.get('block'));
✅ Example of correct code
print('__block');
remove-args
❌ Example of incorrect code
print.indent(is);
✅ Example of correct code
print.indent();
declare
❌ Example of incorrect code
isIdentifier();
test('', (t) => {
t.print(fixture.returnStatement);
});
✅ Example of correct code
const {types} = require('@putout/babel');
const {createTest} = require('#test');
const {test, fixture} = createTest(__dirname);
const {isIdentifier} = types;
isIdentifier();
test('', (t) => {
t.print(fixture.returnStatement);
});
remove-legacy-test-declaration
-const {printExtension} = require('../../../test/printer');
-const {readFixtures} = require('../../../test/fixture');
-
-const fixture = readFixtures(__dirname);
-
-const test = extend({
- print: printExtension,
-});
License
MIT