putout v22.5.0
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
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 libIt 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
