π Pluggable and configurable JavaScript Linter, code transformer and formatter with built-in ESLint and Babel support for js, jsx typescript, flow, markdown, yaml and json. Write declarative codemods in a simplest possible way π
MIT License
Bot releases are visible (Hide)
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
βWho am I? Not the body, because it is decaying; not the mind, because the brain will decay with the body; not the personality, nor the emotions, for these also will vanish with death.β
(c) Ramana Maharshi
Hi folks π!
The time is come for a new big release! It has much less breaking changes then previous one.
Anyways some significant things been changes...
recast
: @putout/printer
This spring I understand that Iβm tired of poor maintenance of recast
. Just like JSCodeshift
it doesnβt evolve by time: if you want use it - fix bugs by yourself, add feature by yourself and maybe couple months or years after you PR will be merged.
I got AST enlightenment π§π½ββοΈ and understand that I have all the knowledges to write my own printer
, which Iβll support with a pleasure:
Babel
receives AST and returns string
with well-formatted JavaScript code.format
used to override output characters.semantic
used to override logic of formatting.@putout/printer
is built-in to πPutout, so you have ability to gain full control of your source code with no additional linters and formatters needed.
recast
no longer used as default printer, so if you want it for some reason update .putout.json
with:
{
"printer": "recast"
}
remove-useless-variables/await
moved to promises/remove-useless-variables
If you disabled this rule, change your .putout.json
with:
{
"rules": {
- "remove-useless-variables/await": "off",
+ "promises/remove-useless-variables": "off"
}
}
async () => {
const result = transformer.transform(realTransformer, transformCode, code, parser);
const result2 = await Promise.resolve(result);
return result2;
};
async () => {
const result = transformer.transform(realTransformer, transformCode, code, parser);
return result;
};
@putout/minify
Actually formatting code is not the only feature of @putout/printer
, it is also used for minification with @putout/plugin-minify, a plugin that contains a lot of rules to make code as small as possible.
git status --porcelain
Just got rid of isomorphic-git
, and switched to a library I worked year ago: @putout/git-status-porcelain to implement --staged
flag which works on a similar to lint-staged
way: lint only changed files.
git-status-porcelain
get names of files that was:
in your git repository. Also after changing some of these files it helps us to add them back to staged
state so they was ready to be committed easily with:
git commit -m 'π₯π'
So now putout --staged --fix
works about 10 times faster since everything is made by git
it has very interesting text format that is easy to parse. It contains a 3-characters length string that consists of a couple big characters and space, like:
M
- modified;MM
- modified, staged and then changed;R
- renamed;With this information you can get the most important information without any parsing of binary files and filtering all the results using JavaScript. This is a slow process, and latest release of isomorphic-git
just made --staged
speed about 100 times slower. Now it works about 10 times faster π.
simplify-boolean-return
A couple linters started to suggest me to modify my code this way:
-if (a)
- return true;
-
-return false;
+return a;
Iβm not sure how much this code becames more readable but cognitive load becomes less on one IfStatement
, and there is less to run and less to read, so for you to decideπ€· (but you should know that I just updated my codebases with this rule π) if you donβt need it update your .putout.json
with:
{
"rules": {
"simplify-boolean-return": "off"
}
}
That's all for today π¦!
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago
Published by coderaiser over 1 year ago