Skip to content

putout v23.4.0

Choose a tag to compare

@coderaiser coderaiser released this 29 Dec 14:03
· 12421 commits to master since this release

Share code with 🐊Putout Editor

image

The whip and rope are necessary,
Else he might stray off down
some dusty road.
Being well-trained, he becomes
naturally gentle.
Then, unfettered, he obeys his master.
(c) Zen Ten Bulls

Hi folks! When you write plugin for 🐊Putout there is a lot things to consider:

  • how part of JavaScript called in AST;
  • what type of plugin to use;
  • how to make fast check of all edge cases of transformation;

And there is an answer to all of this questions 🥁:
🐊Putout Editor! It exists for a long time, but now it has ability to share the code ☘️!

For example you can edit a brand new rule package-json/add-type.

Add module type with package-json/add-type

A couple more words about new transformation. What it does is:

{
    "name": "hello",
    "version": "1.0.0",
+   "type": "commonjs"
}

adds type of used module to package.json.
How it does it you ask? Read next!

Find the properties with operator.findProperties

When you need to find properties in your package.json or any ObjectExpression or ObjectPattern you can use findProperties:

const {homepagePath} = findProperties(__aPath, ['homepage']);

It takes a path and array of top-level elements you need to traverse, and if the found they returned with Path prefix, so you can manipulate them in any way you like 😏!

That's all for today! Have a good day and nice transformations 🦉!

🔥 feature

  • (package) @putout/plugin-package-json v2.0.0
  • (@putout/package-json) drop support of putout < 23
  • (@putout/plugin-putout) declare: add findProperties
  • (@putout/plugin-package-json) add add-type
  • (@putout/operate) add findProperties