Closed igitur closed 1 year ago
Maybe we would need to install the plugins globally to be used with a config?
@creyD Is there anything I can do from my side to check that?
It should be possible to do it like this: prettier_plugins: '@trivago/prettier-plugin-sort-imports prettier-plugin-tailwindcss --global'
No, that unfortunately doesn't work.
Looks like the @trivago/prettier-plugin-sort-imports prettier-plugin-tailwindcss --global
is implicitly parsed as 3 separate strings.
I can try submit a PR to add a new option to install prettier and/or its plugins globally, but how does one test GitHub actions locally?
@igitur That's very generous of you to offer, thanks a lot! I myself didn't find a way yet, at least not with the way this action is built (I think docker based actions are more easily tested). What I always do is to create a separate test repo with just one js file in it and the action configured to creyd/prettier_action@latest (you would need to replace the username with your own name to test against your own action and you could exchange latest with any version statement or a branch etc). Hope this helps!
Lots of debugging but I got closer. Because I'm using prettier and its plugins via a require()
, I have install them in the project folder, which in this case is /home/runner/work/react-wordle/react-wordle/
. Reference: https://docs.npmjs.com/cli/v8/configuring-npm/folders/ (Install it locally if you're going to require() it.
).
But for some reason (and I can't figure out why), everything that is installed locally gets installed to /home/runner/work/_actions/creyD/prettier_action/v4.2/
.
npm prefix
yields /home/runner/work/_actions/creyD/prettier_action/v4.2/
so clearly npm believes that is the 'local' folder. A pwd
yields /home/runner/work/react-wordle/react-wordle/
so I don't understand why the difference.
And it's this discrepancy between the 2 directories that makes prettier unable to find the plugin module.
I solved this by amending my lint.yml
Github actions file to run a npm install
first (I have prettier and the plugins in my package.json
too). This works for me, but for people who don't have the library entries in a package.json
this won't work and I still believe there must a be more elegant solution.
How would you advise to go forward? @igitur Should we mark this issue as solved or are you still working on a fix?
Happy to close this.
What exactly happened? Steps to reproduce the behavior:
Due to an incompatibility between 2 prettier plugins (
@trivago/prettier-plugin-sort-imports
andprettier-plugin-tailwindcss
), I'm using a workaround as described here. This requires me to use a prettier.config.js instead of a.prettierrc
with contents below:Here is my workflow config:
The output complains that it can't find the
@trivago/prettier-plugin-sort-imports
plugin:What should've happened? I expect the plugin files to be found and executed properly.
How did it look?
Where did you encounter the problem? https://github.com/cwackerfuss/react-wordle/runs/7820780587?check_suite_focus=true