Skip to content

putout v22.5.0

Choose a tag to compare

@coderaiser coderaiser released this 04 Dec 20:57
· 12729 commits to master since this release

Putout gets more ESM-friendly

β€œWisdom tells me I am nothing. Love tells me I am everything. And between the two my life flows.”
― Nisargadatta Maharaj

image

Giorgio Liberale da Udine, Crocodile (16th c.)

Hi friends πŸ‘‹ ! EcmaScript Modules gets more and more popular, and 🐊Putout goes towards community needs, and added some sweets in todays release 🍬 .

ESM Formatters

That's right! Formatters now can be in one of two formats CommonJS:

module.exports = function formatter({name, source, places, index, count, filesCount, errorsCount}) {
    return '';
}

or ESM:

export default function formatter({name, source, places, index, count, filesCount, errorsCount}) {
    return '';
}

Both supported πŸ₯³ !

And they can be async functions as well 🎈:

export default async function formatter({name, source, places, index, count, filesCount, errorsCount}) {
    return '';
}

Since ESLint v8.4.0 has support of async functions and 🐊Putout has @putout/formatter-eslint which supports all ESLint formatters this way:

ESLINT_FORMATTER=pretty putout --format eslint lib

It will work as well with promises starting from this release πŸŽ‚ .

async tests for formatters

Since formatters can be ESM and async, tests for them should support this change. And with @putout/test v4.0.0, it looks this way:

test('formatter: codeframe', async ({format}) => {
    await format(codeframe);
});

What if I want to help with converting built-in formatters?

That's awesome πŸŽ‰ ! You definitely can, and it's highly appreciated 🎈! You can find all the information in Convert formatters to ESM issue.

Also good first issue will always help you to find beginners-friendly issues, so you can helps a lot to project in a simplest possible way πŸš€ .

Have a nice day and happy coding ⌨️ !

🐞 fix

  • (@putout/plugin-convert-mock-require-to-mock-import) handle no stopAll case

πŸ”₯ feature

  • (@putout/plugin-declare-undefined-variables) add support of simport
  • (package) @putout/formatter-progress-bar v2.0.0
  • (@putout/test) format: improve ability to test ESM
  • (@putout/plugin-convert-commonjs-to-esm) require: call: exclude dot dot
  • (@putout/plugin-declare-undefined-variables) add fresh-import
  • (@putout/formatter-progress-bar) convert to ESM
  • (package) @putout/plugin-convert-commonjs-to-esm v6.0.0
  • (package) @putout/formatter-progress v3.0.0
  • (@putout/formatter-progress) convert to ESM
  • (@putout/plugin-convert-commonjs-to-esm) drop support of putout < 22
  • (@putout/plugin-convert-commonjs-to-esm) require: improve support of namespaces: PascalCase -> kebabCase
  • (@putout/test) v4.0.0
  • (putout) add support of ESM formatters
  • (@putout/formatter-eslint) convert to ESM
  • (@putout/formatter-eslint) convert to async
  • (@putout/test) format: convert to async
  • (putout) add support of async formatters
  • (@putout/plugin-declare-undefined-variables) add support of zlib
  • (@putout/plugin-declare-undefined-variables) logical: add id
  • (@putout/plugin-declare-undefined-variables) add logical