Steps to reproduce:
Create a plugin that exports a custom printer for JS and/or CSS:
module.exports = {
printers: {
estree: myJSPrinter,
postcss: myCSSPrinter
}
}
Then run Prettier with this plugin on a JS or CSS file.
Expected behavior:
The plugin's printer is the one that's used for formatting.
Actual behavior:
The default printer is used, no matter what the plugin offers. That's because the array of plugins has the internal plugins first, the external plugins last, and then the printer to use is the first one that matches the AST format.
Why would anyone need it?
The WordPress community uses a formatting style with a lot of spaces inside parens:
function Label( { date } ) {
const [ translate ] = useTranslate();
return ( <span>{ translate( 'Updated %s', moment( date ).fromNow() ) }</span> );
}
We've been maintaining a fork that adds a --paren-spacing option for the last two years. Now we would like to turn it into a plugin and publish it to NPM as prettier-plugin-wordpress.
Then users could install the official prettier package and configure it to use the wordpress plugin. All editor integrations that search for node_modules/prettier/index.js and other packages that have prettier as peer dependency would use the right version.
Thoughts? Would the team be interested in a PR that swaps the order of the plugin array or searches in it using findLast?
Steps to reproduce:
Create a plugin that exports a custom printer for JS and/or CSS:
Then run Prettier with this plugin on a JS or CSS file.
Expected behavior:
The plugin's printer is the one that's used for formatting.
Actual behavior:
The default printer is used, no matter what the plugin offers. That's because the array of plugins has the internal plugins first, the external plugins last, and then the printer to use is the first one that matches the AST format.
Why would anyone need it?
The WordPress community uses a formatting style with a lot of spaces inside parens:
We've been maintaining a fork that adds a
--paren-spacingoption for the last two years. Now we would like to turn it into a plugin and publish it to NPM asprettier-plugin-wordpress.Then users could install the official
prettierpackage and configure it to use thewordpressplugin. All editor integrations that search fornode_modules/prettier/index.jsand other packages that haveprettieras peer dependency would use the right version.Thoughts? Would the team be interested in a PR that swaps the order of the plugin array or searches in it using
findLast?