-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Labels
area:cliIssues with Prettier's Command Line InterfaceIssues with Prettier's Command Line Interfacearea:ignore.prettierignore file, --ignore-path CLI option, /* prettier-ignore */ comments and so on.prettierignore file, --ignore-path CLI option, /* prettier-ignore */ comments and so onstatus:needs investigationIssues that need additional investigation, e.g. to understand whether the reported behavior is a bugIssues that need additional investigation, e.g. to understand whether the reported behavior is a bug
Description
prettier does not prune directories from the tree when they are ignored by .prettierignore. This seems to mean that there is no way to avoid errors from directories which are not readable by the user running prettier.
Environments
- Prettier Version: 2.4.1
- Running Prettier via: CLI
- Runtime: Node.js v14
- Operating System: openSUSE Linux
- Prettier plugins (if any): none
Steps to reproduce
mkdir -p prettier-test/ignore-me/root-only-dir
cd prettier-test/
echo ignore-me > .prettierignore
echo '{}' > foo.json
echo '{}' > ignore-me/root-only-dir/foo.json
sudo chown root:root ignore-me/root-only-dir/
sudo chmod 700 ignore-me/root-only-dir/Expected behavior
prettier -c . runs with no errors.
Actual behavior
prettier -c . issues an EACCES error due to trying to read root-only-dir and failing:
$ prettier -c . --loglevel debug
[debug] normalized argv: {"_":["."],"color":true,"editorconfig":true,"loglevel":"debug","config-precedence":"cli-override","debug-repeat":0,"ignore-path":".prettierignore","plugin":[],"plugin-search-dir":[],"check":true}
Checking formatting...
[error] Unable to expand directory: .
[error] EACCES: permission denied, scandir '/home/adam/prettier-test/ignore-me/root-owned-dir'
All matched files use Prettier code style!
Example use case
If docker containers are run from a subtree, this may cause files and directories owned by root. It should be possible to tell prettier to prune that entire subtree from its search.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:cliIssues with Prettier's Command Line InterfaceIssues with Prettier's Command Line Interfacearea:ignore.prettierignore file, --ignore-path CLI option, /* prettier-ignore */ comments and so on.prettierignore file, --ignore-path CLI option, /* prettier-ignore */ comments and so onstatus:needs investigationIssues that need additional investigation, e.g. to understand whether the reported behavior is a bugIssues that need additional investigation, e.g. to understand whether the reported behavior is a bug