Open michael13491 opened 4 years ago
@michael13491 I faced the same issue. It looks like prettier and pretty-quick treats .prettierignore
file differently. Prettier try to apply ignore patterns against files relative to the current working directory (foo/test.js
, index.js
etc), but pretty-quick try to check file names relative to root of your repo (webapp/foo/test.js
, webapp/index.js
etc). I think that's why your patterns don't work for pretty-quick. I didn't check but something like that should work:
# ignore everything except foo dir
/*
!**/foo
Another option is to move .prettierignore
to the root of your project (since pretty-quick apply root .prettierignore
then one from working directory: docs ) but then content also should be updated slightly:
# ignore everything except foo dir
/*
!/webapp/foo
@andrei-ilyukovich you helped me resolve my problem, thank you! I was struggling to figure this out.
Facing the same issue. Wouldn't the straight-forward solution be that pretty-quick should only consider files inside the folder from which it's being called? (instead of the whole surrounding git repository)
This is also a significant problem for me, so switching to running prettier inside lint-staged for now
Same here
Same here
Yeah cant use this with monorepo in this state
A minimal but runnable online reproduction is required.
I've observed something that could potentially be triggering the issue.
pretty-quick
uses the ignore
library to parse .prettierignore
. Notably, the ignore
library is specifically designed to comply with the gitignore specification.
prettier
on the other hand, utilizes the micromatch
library (which behaves differently than the gitignore specification) to parse the .prettierignore
file.
@SukkaW Thanks for your efforts here! I think we should align with prettier.
@SukkaW Thanks for your efforts here! I think we should align with prettier.
Under the hood it is the picomatch
(which I introduced back in #180) that powers the micromatch
. We could simply replace the ignore
with the picomatch
and the behavior should have be aligned then.
Hi,
I have an issue that is similar to https://github.com/azz/pretty-quick/issues/14
My project folder structure is:
.prettierignore contains:
My problem is that pretty-quick does not seem to read .prettierignore rule correctly.
When I run
npx pretty-quick --check
, it fails to find foo/test.js as changed file. However, when i runnpx prettier --check "**/*.js"
, it will pick up foo/test.jsIf I remove the rules in .prettierignore, pretty-quick is able to pick up the changed files:
So it seems to me that pretty-quick is not reading the ignore rules correctly or am I missing something?