New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to integrate in pre-commit with plugins #7407
Comments
Where does |
Here's another idea: try passing |
pre-commit handles environments automatically in its cache dir, and they're named differently each time. However, if I add
Tried, but no luck: - repo: https://github.com/prettier/prettier
rev: "1.19.1"
hooks:
- id: prettier
name: prettier with xml plugin
args:
- --plugin=@prettier/plugin-xml
additional_dependencies:
- "@prettier/plugin-xml@0.5.0"
files: \.xml$ fails with:
|
I think you need to open an issue in the |
Turns out the path to the directory we need can be found in the |
ping @asottile @chriskuehl @struys any of you could help resolving our doubts here please? Thanks |
Here's a reproduction which does not involve FROM ubuntu:bionic
RUN : \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
curl \
dumb-init \
gnupg2 \
software-properties-common \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN : \
&& curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
&& echo "deb https://deb.nodesource.com/node_12.x bionic main" > /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN npm install -g prettier@1.19.1 @prettier/plugin-xml@0.5.0
RUN echo '<x/>' > t.xml
CMD ["dumb-init", "prettier", "--plugin=@prettier/plugin-xml", "t.xml"] build: docker build -t test . run: docker run --rm -ti test output: $ docker run --rm -ti test
/usr/lib/node_modules/prettier/bin-prettier.js:15954
throw err;
^
Error: Cannot find module '@prettier/plugin-xml' from '/'
at Function.sync (/usr/lib/node_modules/prettier/bin-prettier.js:15952:13)
at /usr/lib/node_modules/prettier/bin-prettier.js:44147:29
at Array.map (<anonymous>)
at loadPlugins (/usr/lib/node_modules/prettier/bin-prettier.js:44139:59)
at Object.getSupportInfo (/usr/lib/node_modules/prettier/bin-prettier.js:44211:16)
at updateContextOptions (/usr/lib/node_modules/prettier/bin-prettier.js:46186:33)
at pushContextPlugins (/usr/lib/node_modules/prettier/bin-prettier.js:46213:3)
at updateContextArgv (/usr/lib/node_modules/prettier/bin-prettier.js:46224:3)
at Object.createContext (/usr/lib/node_modules/prettier/bin-prettier.js:46176:3)
at Object.run (/usr/lib/node_modules/prettier/bin-prettier.js:46257:24) {
code: 'MODULE_NOT_FOUND'
} |
IMHO Prettier, as a code formatter that supports pre-commit and plugins, should handle this case and make sure both can be used together. 🤔 |
fixed by #7508 This works for me: - repo: https://github.com/prettier/prettier
rev: "2.0.2"
hooks:
- id: prettier
additional_dependencies:
- "@prettier/plugin-xml@0.7.2"
args:
- --plugin=@prettier/plugin-xml
files: \.xml$ |
Environments:
Steps to reproduce:
All I want to do is to integrate the prettier-xml plugin into pre-commit.
I tried with this, but it doesn't work:
Expected behavior: Reformat xml files
Actual behavior:
Running
pre-commit run -a
:Workaround:
Configuration from prettier/plugin-xml#17 (comment) works, but I guess that's not what you want to recommend to use.
The text was updated successfully, but these errors were encountered: