Skip to content

putout v25.0.0

Choose a tag to compare

@coderaiser coderaiser released this 17 Feb 18:37
· 11666 commits to master since this release

image

Drop support of node < 16

Among the maxims on Lord Naoshige’s wall there was this one: ”Matters of’ great concern should be treated lightly.”
Master lttei commented, “Matters of small concern should be treated seriously.”

(c) Yamamoto Tsunetomo "Hagakure"

Hi folks!
The time is came for a new release 🎉 !

We drop support of node versions < 16. "Why is so?" - you ask. The main goal of 🐊Putout is bringing best practices in software development process. And one of best practices is updating dependencies in time.

Node v16 stable, LTS, and I see no reason to wait for about a year while everybody drop v14.
Anyways if you cannot upgrade just use 🐊Putout v24, and if you have any problems create an issue I'm always here to help :).

apply-array-at

Among one’s affairs there should not be more than two or three matters of what one could call great concern.
If these are deliberated upon during ordinary times, they can be understood. Thinking about things previously
and then handling them lightly when the time comes is what this is all about.

(c) Yamamoto Tsunetomo "Hagakure"

The second reason of dropping old versions is adapting and popularizing new constructions like array.at(). So from now on @putout/plugin-apply-array-at is bundled and will help you, when you want to get last element of an array.

❌ Example of incorrect code

const array = [1, 2, 3];
console.log(array[array.length - 1]);

✅ Example of correct code

const array = [1, 2, 3];
console.log(array.at(-1));

apply-array-at is written in 🦎PutoutScript and looks this way:

module.exports.replace = () => ({
    '__a[__a.length - __b]': '__a.at(-__b)',
});

So much power in so little code, breathtaking isn't it 😏?

☝️ Wandering why still in CommonJS and not ESM? Worry not! Wait until eslint/eslint#15394 resolved: we need eslint-plugin-putout working! Anyways convert-commonjs-to-esm is ready 🤺, and when the time is come — conversion unavoidable ✊.

try-catch

With help of try-catch rules big and ugly try-catch blocks will be converted to small and beautiful calls.

❌ Example of incorrect code

try {
    say('hello');
} catch (error) {
    log(error);
}

✅ Example of correct code

import tryCatch from 'try-catch';
const [error] = tryCatch(say, 'hello');

if (error)
    log(error);

This all possible with help of:

Here is reasoning of using try-catch instead of old syntax construction.

New loaders API

To face an event anew solve it lightly is difficult if you are not resolved beforehand,
and there will always be uncertainty in hitting your mark.
However, if the foundation is laid previously, you can think of the saying,
“Matters of great concern should be treated lightly,” as your own basis for action.

(c) Yamamoto Tsunetomo "Hagakure"

Node v14 has one type of loaders:

And node v16 has other:

That's not fun at all to support both of them 😅...

☝️ So mock-import, zenload and 🎩EScover also updated to support only latest version of API.

That's all for today. Have a good day and take care of your codebases 🦔!

🔥 feature

  • (package) @putout/plugin-github v3.0.0
  • (putout) drop support of node < 16
  • (@putout/plugin-github) set-node-versions: 14, 16, 17 -> 16, 17
  • (@putout/plugin-github) drop support of putout < 25
  • (package) @putout/operator-declare v4.0.0
  • (package) @putout/plugin-convert-map-to-for-of v2.0.0
  • (package) @putout/plugin-regexp v5.0.0
  • (package) @putout/processor-markdown v6.0.0
  • (@putout/processor-markdown) drop support of putout < 25
  • (@putout/plugin-regexp) drop support of putout < 25
  • (@putout/plugin-convert-map-to-for-of) drop support of putout < 25
  • (@putout/operator-declare) drop support of putout < 25
  • (putout) add @putout/plugin-apply-array-at
  • (@putout/plugin-remove-unused-variables) get-vars: getScopeUID: rm useless done
  • (@putout/operator-declare) parseCode: rm useless name argument
  • (@putout/test) supertape v7.0.0
  • (@putout/test) reuse options
  • (eslint-plugin-putout) add remove-newline-after-last-element (#95)
  • (@putout/plugin-putout) add convert-match-to-function
  • (@putout/plugin-putout) check-replace-code: add support of ObjectExpression
  • (@putout/plugin-putout) add convert-replace-to-function
  • (@putout/engine-runner) replace: add match property value validation: ☝️ Looks like 'match' property value is not a 'function', but 'string' with value 'xxx'.
  • (@putout/engine-loader) validate-plugin: improve error message: ☝️ Cannot determine type of plugin fn. Here is list of supported plugins: https://git.io/JqcMn
  • (@putout/plugin-remove-empty) pattern: improve support of function arguments
  • (@putout/engine-runner) add ☝️ Looks like you passed template value with a wrong type. Allowed: string, node and path. Received: true