... with prettier
Homepage https://prettier.io↗
import prettier from "https://unpkg.com/prettier@2.3.0/esm/standalone.mjs";
import parserBabel from "https://unpkg.com/prettier@2.3.0/esm/parser-babel.mjs";
console.log(
prettier.format("const html=/* HTML */ `<DIV> </DIV>`", {
parser: "babel",
plugins: [parserBabel],
})
);
return (async fn => { // intentionally [sic] badly formatted
const p = await import(
'https://unpkg.com/prettier@2.3.0/esm/standalone.mjs')
const b = await
import('https://unpkg.com/prettier@2.3.0/esm/parser-babel.mjs')
const format
= p.default.format
const babelPlugin
= b.default
const thisCellsSource = this.children[0].children[0].data.value
return format(thisCellsSource, { parser: "babel",plugins: [babelPlugin]})
})()
Implementing as a transformer !plugin
see Transformers
// make me
// prettier
//...
// thanks
return async fn=>{}
Edit and save the above cell to have it automatically formatted by Prettier using the transformer !plugin
implemented above.