IssueRaiser

prettier recurses into directories ignored by .prettierignore

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 ```sh 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 i

Posted by aspiers on Sep 22, 2021, 4:03 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments

github (Sysadmin)

prettier recurses into directories ignored by .prettierignore

aspiersSep 22, 2021, 4:03 PM

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 ```sh 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 i

Comments (0)

No comments yet. Start the discussion.

Comment on this issue