-
-
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
Exclude files via configuration rules #14785
base: main
Are you sure you want to change the base?
Conversation
I'm not totally happy with having made two not-so-obvious alternate ways to ignore files. I think this makes config easier to understand, but I'd like to eventually see |
Thanks for your contribution. I don't have a good solution for #4708, but I don't think we can accept this solution either. |
With all due respect, it's been 5 years since #4708 was requested. This PR is the only one which has attempted to fulfill even a portion of #4708's request. If this isn't acceptable, then a top-level option named If there hasn't been any solution for five years, I think this PR qualifies as "good enough". The pain point isn't "we have one additional file in our project", the pain point is "using prettier in a monorepo feels like more hassle than manually formatting files" Below are the current options for sharing prettier ignores across projects. All of them are worse than what this PR offers. Multiple This does not require justification as to why it's awful. Use 3rd party tooling to handle prettier ignores Declaring this as a recommended method is just declaring prettier an incomplete tool. Hack other config options This is objectively worse than what this PR enables. Compare; {
"overrides": [
{
"files": "dist/**/*",
"options": { "requirePragma": true },
},
],
// vs
"overrides": [
{
"files": "dist/**/*",
"options": { "parser": "ignore" }
}
]
} This PR makes the config significantly easier to understand, and as an unnecessary bonus it's a few characters shorter.
This is what I'm trying out currently in my monorepo. It's truely awful, and because under {
"scripts": {
"lint": "prettier --ignore-path ../../.prettierignore --check ."
}
} For monorepos, prettier is more trouble than it's worth. After this PR, prettier will be the obviously easiest option. This PR ought to have been merged in 2018. |
Also, run into this issue when working within a monorepo 🙋🏽♂️. Was really surprised Prettier didn't have this option yet. With ESLint, it's as simple as this: {
"ignorePatterns": ["temp.js", "**/vendor/*.js"],
"rules": {
//...
}
} |
The ideal solution is implement |
I considered using |
What are the issues blocking this from being accepted? |
@fisker could you please take a look at this and let me know either (1) what I need to to do in order to move this PR forward or (2) that this PR is unwelcome and should be closed? Thank you. |
Personally, I really don't like the idea, I'd rather implement One important thing worth to mention, current implementation not really "ignore" the file, it will replace EOL(maybe more than this, not sure). And it will read/write files. |
I agree @fisker,
- Rotu, #14785 (comment) Let's merge this PR so we can have an implementation for this feature request, and work on making it perfect later. It's taken over 5 years (#4708 - June 17 2018) to get to this stage, who knows how long it will be before From what you've said, the only blocker is;
@rotu given that you implemented and tested this PR I think it's best to come to you for this - what are your thoughts/findings on the above inquiry? |
We need to fix this before the merge, ignore should ignores all |
The decision to not do I changed the approach and it now leaves whitespace alone. BUT I think the test fixture is mangling the data before it gets fed into the test case (i.e. the |
This was something I had considered, but I didn't know how to articulate that concern. I suppose it might work similar to the priority Having an ignorant parser is much clearer, and while I stand by agreeing with Fisker that
|
Any decision on this? Is it going to be merged or are we going to continue with poor monorepo support? |
@fisker since you last commented the concern you rose has been addressed by a new commit. Assuming that commit correctly addresses that concern (which it appears to do), can we have this merged and released in the next minor bump? |
What do you think we add support for |
I don’t quite understand the why. It seems like “ignore” is mutually exclusive with a choice of parser (so it’s clear that when a file is ignored, no parser will be used). Making it a separate flag makes it orthogonal to choice of parser. Is there a reason to ignore a file AND to specify a parser? |
Following use case for ignorePatterns not mentioned in this discussion We have a global prettier config for the whole company. the same way we do for eslint. our prettier config looks like this: module.exports = require('@teckro/prettier-config/prettier.config'); Today, I cannot have a global config to ignore build/ , public/ and coverage/ folders. This issue is very similar to the mono repo issue.. except it's even more of a burden because everything is split into different repo |
I agree with @rotu on this. Additionally, this PR resolves the issue effectively, and given that this issue has been open for over 5 years I don't see any value in continuing the discussion over fixing a problem that's been around - I stress again - for over 5 years. This PR has been open for a long time, during which precisely one minor issue has been found and swiftly resolved. In response then to your original question, "What do you think we add support for |
An issue with this was raised in #15322 which I actually agree with (#15322 (comment)) To be clear; I still very much think
|
I’m rather fond of I say ship it. I just care that this functionality exists, not how you spell the config. |
@fisker What needs to happen to get this merged in? |
Merged in master, freshened up the description. @fisker, @sosukesuzuki Could we please get this merged in? |
Description
Add a new parser named "ignore". This allows excluding files via the existing configuration file using
override
rules.This is similar to
.prettierignore
, but:.prettierrc
, removing a file (config option to ignore paths #4708) and allowing rules to be distributed in plugins as with other configurationprettier
is invoked (.prettierignore is ignored when inside of a subdirectory #12923)This PR does not remove
.prettierignore
but I recommend it be deprecated in the future.Checklist
docs/
directory).changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨