prettier / prettier/prettier

Why can't we set `.prettierignore` to not be subject to `fast-glob` file scanning?

Open
#15,482 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli
Dominant language
JavaScript
Stars
52.3k
Forks
5k
Avg merge
19h 2m
Merged PRs (30d)
117

Description

Thank you for developing the library. I always use it.

I think that .prettierignore allows prettier to set files not to be formatted, but I think that 'not formatting' ≠ 'it should be set up to be exempt from fast-glob'.
Intuitively, I thought that the behavior was that since it was not subject to prettier, it was not subject to fast-glob, but is that not the case?
https://github.com/prettier/prettier/blob/d4d4b185e0ddc3e0dd839b873e2ee7fe8131b684/src/cli/expand-patterns.js#L112

In case you're wondering, I understand that if I use !./data', it is not subject to fast-glob.

npx prettier --ignore-unknown --write . '!./data'

Prettier 3.0.3

Input:

npx prettier --ignore-unknown --write .

Output:

$ npx prettier --ignore-unknown --write . 
[error] Unable to expand directory: ".".
[error] EACCES: permission denied, scandir '/home/study/workspace/node-express/data/mysql/#innodb_redo'

./data is a directory that is created by docker (root user) and causes permission error.

Expected behavior:

If .prettierignore is below, it is not eligible to be scanned by fast-glob and no error is generated.

## .prettierignore
data

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/cli/expand-patterns.js around line 112 and reproduce the reported command with a root-owned data directory and a .prettierignore entry. Trace how ignore patterns are handled relative to fast-glob, then verify that the expected behavior is covered by a regression test or clearly documented if the behavior is intentional.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.