-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accept multiple --ignore-path
s
#14332
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8f9d3a1
Accept multiple `--ignore-path`s
fisker 0cacfbd
Fix
fisker be70daa
Fix after rebase
fisker 79bc5ed
Linting
fisker b73548b
Update usage
fisker 054b8ef
Minor tweak
fisker 5ed6a00
Update docs
fisker 8d12ad8
Fix example
fisker b8d0c55
Use assert instead of snapshot
fisker 9f4b4d8
Add test
fisker b70565f
Update snapshot
fisker 38b7e9c
Update 14332.md
fisker 6ceb80e
Remove useless function
fisker d3c7cd0
Merge branch 'multiple-ignore-path' of github.com:fisker/prettier int…
fisker 4062dfa
Update 14332.md
fisker 5549f99
Merge branch 'main' into multiple-ignore-path
fisker 98a061b
Merge branch 'multiple-ignore-path' of github.com:fisker/prettier int…
fisker 6e65d08
Update index.d.ts
fisker 4f08332
Update api.md
fisker be0bb4b
Update api.md
fisker File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#### Accept multiple `--ignore-path` (#14332 by @fisker) | ||
|
||
You can now pass multiple `--ignore-path`. | ||
|
||
```console | ||
prettier . --ignore-path=.prettier-ignore --ignore-path=.eslintignore | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
tests/integration/__tests__/__snapshots__/ignore-path.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ignore file when using --debug-check (stderr) 1`] = `""`; | ||
|
||
exports[`ignore file when using --debug-check (stdout) 1`] = `"other-regular-modules.js"`; | ||
|
||
exports[`ignore file when using --debug-check (write) 1`] = `[]`; | ||
|
||
exports[`ignore path (stderr) 1`] = `""`; | ||
|
||
exports[`ignore path (stdout) 1`] = `"regular-module.js"`; | ||
|
||
exports[`ignore path (write) 1`] = `[]`; | ||
|
||
exports[`outputs files as-is if no --write (stderr) 1`] = `""`; | ||
|
||
exports[`outputs files as-is if no --write (stdout) 1`] = `"'use strict';"`; | ||
|
||
exports[`outputs files as-is if no --write (write) 1`] = `[]`; | ||
|
||
exports[`support .prettierignore (stderr) 1`] = `""`; | ||
|
||
exports[`support .prettierignore (stdout) 1`] = `"other-regular-modules.js"`; | ||
|
||
exports[`support .prettierignore (write) 1`] = `[]`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we first read all files in a loop, combine them into a sing big string and then call
createIgnore({ allowRelativePaths: true }).add(combinedContent)
? That's how I was imagining multiple ignore paths to work from a user perspective. Combining file contents can simplify howwithNodeModules
is implemented: it will be just a new line appended tocombinedContent
, so need for introducing[undefined]
etc.Here is an example setup setup where a combined approach kinda matters: 🐸 njt / .prettierignore. This file has three sections, the first of which is specific to Prettier and the other two are copy-pasted from other files. Keeping these secions in sync between files is painful but necessary right now.
With this PR in, I can imagine removing sections named
Same as in .gitignore
andShared between linters
. To do that, I will be able to add this line to.prettierrc.cjs
:ignorePath: [".prettierignore", ".gitignore", ".sharedlintignore"]
. That will be great actually!If we have several independent
createIgnore
calls plusisIgnoredFunctions.some(...)
, the overall behavior of the ignorer may differ from what we'd get by ‘concatenating‘ ignore files. This may mismatch user expectations and lead to confusion.Having said that, I’m not an expert is how ignore files are usually combined. If what you have implemented is common for other linters, I might be the only person who would be confused by the output of
isIgnoredFunctions.some(...)
, compared to having a singlecreateIgnore
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1, they can be in different directories, they can't be simply concated. We need to know what the patterns related to.
should
foo/a.js
be ignored? I think user may expect it be ignored, because it's ignored in.ignore1
file. But if we treat this case likeI'm not sure what's expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see... I forgot about ignore files sitting in different directories 🤔 You are right then, we need multiple calls to
createIgnore
! In that case, the full list of ignored files is a union of ignore statements in individual files. Makes sense now, ignore me 😅There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fisker sorry to ask so late ; it is not told in the docs if the multiple ignore paths would respect their own root folder. for example, how would the final ignore list look like for
prettier --ignore-path .ignore1,subfolder/.ignore2 --check subfolder/
? (usecase is: running prettier at root level of a monorepo)