question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`--ignore-path` not respected when prettier executes in a subdirectory

See original GitHub issue

Environments:

  • Prettier Version: 1.19.1
  • Running Prettier via: CLI
  • Runtime: Node.js v13.8.0
  • Operating System: macOS, etc.

Steps to reproduce: Repo for reproducing: https://github.com/heylookltsme/prettier-bug

  1. .prettierignore file at the root of a project
  2. .prettierrc in subdirectories of the project
  3. Run prettier in a subdirectory, passing the --ignore-path
  4. The .prettierignore file is not respected

Correct behavior when run from the root: corinne_hoener_vimeo____projects_prettier-bug-2

Bad behavior when run from a subdirectory: corinne_hoener_vimeo____projects_prettier-bug_web1

Expected behavior: The .prettierignore file is respected when prettier is run in a subdirectory.

Actual behavior: Prettier fails to ignore files when it’s run in a subdirectory.

It seems like the issue is that .prettierignore must be at the root of the repo, but if prettier is executing in a subdirectory, then the ignored patterns aren’t matching because it’s comparing the file path relative to the current working directory, not to the root where the .prettierignore file lives.

I think I have a fix. This fixes the issue for me locally. I’ll submit a PR for feedback.

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
thorn0commented, Mar 5, 2020

In the meantime, you can do npm install prettier/prettier to install the very latest version from GitHub.

npm install prettier/prettier#next is the latest.

1reaction
thorn0commented, Feb 18, 2020

The release should happen very soon. Stay tuned. Thanks for the contribution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignoring Code - Prettier
Use .prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.
Read more >
Make .gitignore ignore everything except a few files
After reading the gitignore documentation (here) i found out that if you exclude a folder first that the filenames in the subfolder are...
Read more >
Configuration Files - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
pretty-quick - npm
Start using pretty-quick in your project by running `npm i pretty-quick`. ... You can run pretty-quick as a pre-commit hook using husky ....
Read more >
add_subdirectory — CMake 3.25.1 Documentation
Adds a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.txt and code files are located.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found