-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
prettierIgnore key in package.json? #3460
Comments
It's not currently implemented. We don't currently look at the package.json at all. We use cosmiconfig for configuration which is separate to the ignore file handling. |
@azz that is not true. You can add the |
@lipis Yeah that’s the “we use cosmicconfig” part, but we don’t look the package.json for ignore.. those are two completely separate flows |
@duailibe I see :) |
What's the incentive for putting this in package.json anyway? |
@azz the only reason I can think of is keeping the config format options as close to ESlint as possible because many people use it alongside ESlint and would expect the options to be the same. I could be wrong but not allowing Maybe more people prefer using files to package.json keys ( |
I don't find "because ESLint does it this way" a particularly compelling reason. I think people like to put all kinds of things in their package.json files that don't really belong, and this seems like one of those things. |
@azz you're right that's not a compelling reason, but assuming that it shouldn't belong in package.json is a pretty sweeping dismissal of another dev's potential needs. By that reasoning using package.json shouldn't be an option for If you don't want to do it, that's fine, I won't lose sleep over an extra file. But don't attribute it to wanting to keep package.json clean fwiw, standard also allows exclusions in package.json, though it's a different format: https://standardjs.com/index.html#how-do-i-ignore-files |
I was looking through the documentation for how to add the ignore list to my package.json config a few days ago, actually. My reasoning is that I don't like adding new files to my top-level folder, and while I can get around that with the Idk. Not a huge deal, but a minor annoyance for me. |
yeah I thought the community was moving toward project configurations inside |
Cosmic config supports this by default, so I see no reason to not support this in |
Just FYI (this is not a justification) we don't use |
Ah I wasn't aware, thanks. Would it be a good idea to use it for ignore or can there be only one config per project? |
|
|
cosmiconfig can be configured to look for whatever file names you choose. You're right by default it includes |
Exactly. I'm working on writing a common ground (boilerplate) for a larger company and the more config I can combine in one place, the better. It will make it more flexible and more transportable. This issue hasn't changed in a year, what's the status? |
Updated link to ESLint implementation. It’s really simple, although they don’t use cosmiconfig for it. https://github.com/eslint/eslint/blob/master/lib/cli-engine/ignored-paths.js I’m tempted to make a PR; anyone else interested, though? I have plenty of other open source on my plate. |
Interested in making a PR for the same. Do I need to worry about cosmicconfig or can we go how eslint is doing it? |
ESLint is going to allow specifying ignore patterns in config (see eslint/eslint#12274), was it considered to do the same for Prettier? That way it would be possible to specify them everywhere it can be configured, including |
I see this is tagged as "discussion needed", but it appears to have gone stale. Is there any way we can get to a definitive yes or no here? This seems to be an expected feature by a significant group of people, including myself, and the path to implementation, while perhaps not as straightforward as hoped, is certainly not treacherous or fraught. My argument toward "yes" is simply that there is no semantic difference to the user between types of config. From a user perspective, config is config, and any options that appear in the help text ( One more thing to consider: Who does it harm to implement this? Will anyone (users, documenters or project contributors) say "oh my god, this was such a bad idea"? Probably not.... So if there's virtually no cost (after the cost of implementation) and there's significant gain, why not just do it? |
I think we should use logic from eslint eslint/eslint#12274, allow to use |
I've opened a PR here - would appreciate some feedback. |
check |
I agree with some folks here that we should go for 📖 Docs on I’ve asked @mataha if they want to continue with #12672. Either way, it'd be great to see |
Adding ignore patterns has also been requested many times here #13088 |
In the new config file system (blog post), the key is called |
This is top result for me when searching how to add ignore patterns to package.json. Seems like a reasonable request, why still no action on it? Just the maintainers don't like it so we suck it up? |
@binaryben That is unfair and unnecessary. The maintainers might have various reasons that they haven't yet got to this, but we don't know what they are. Do we have to remind you this is open source and free? No I'm not a maintainer, and yes I want something similar. Rather than complaining, I did something. My first attempt (linked literally just above your comment) had some reasonable concerns raised, and I've a second attempt under way, unfortunately, I too haven't had much time recently. |
@Standard8 I meant no offence or complaint, just an honest enquiry about the state of this issue and reasoning for wherever it is where it is. Thanks for pointing out the work you're doing. Most of what I had read was bikeshedding and I'll admit I didn't read past yangwao's comment so I did miss your PR. |
Hey, I'm a maintainer. Sorry for letting you down. Personally I want to support this too. But it's not simple to support, for example we need know where is package.json, so we can know what are those patterns related to. My plan is to add multiple ignore files support first, then treat package.json with ignorePatterns as an Update: we also support external package name as |
Do you mean using I'm curious about why we're heading towards This was the approach I was heading towards as a follow-up to #14223 although I did come across a few complications with that. I definitely don't want to derail your efforts though, I'm more checking what you're intended there, and seeing if I should continue my efforts or not (I'm thinking probably not). At the end of the day I'd love any sort of multi-file support, so anything is a bonus. |
I would love to see this feature, in my case we are having tons of config/ignore files in the root of repo, that's why I'm trying to limit them and hide all of that in |
For me, I just mainly wanna reduce the number of |
I agree with @kachkaev , and I would also love to see support for As an added benefit, with this feature, we can reuse all
Note: eslint-gitignore actually just reads all On another note, should this feature request be tracked here, or in #4708 ? I feel that they overlap somewhat. |
Just my two pence, but it would be great to cut down on the various ignore files and be able to maintain a single one (prettier / eslint etc) for auto formatting etc. Being as they all use the same format I don't see this should be doable. Specifying the file path of the ignore file via package.json is a great idea +1 from me! |
You can pass |
Thank you for mentioning this as I didn't know that this was possible. |
No, it should be using the same ignore list as ESLint. That being said, if you still have issues configuring it, I'd recommend installing |
I just stumbled upon this - honestly, I found it really odd that -some- configuration can go in package.json but not ignores. It's intuitive to put it there if that's where you want to put it. The fact that prettier supports all these different areas only adds to confusion - took me about half an hour to get everything wired up correctly. Some areas suggest prettierrc, others the json file, others in different files together. |
I think it's a bit easier to set up Prettier 3 now with |
The best location would be within Prettier config, rather than scattered into more files like Better DX to just have one way and one config file:
|
Although there's a risk of splitting the discussion, I've just filed #15481 asking for supporting the configuration in the same way as ESLint (i.e. via Whilst I respect the desire to have all the configuration in one file, as per the reasons I mention there, |
Hi engineers, opened #16286 for this and added tests. I'd like some reviews before moving on to adding docs. Feel free to take a look, thanks! |
ESlint currently allows ignore options to be set in
package.json
under theeslintIgnore
key: https://eslint.org/docs/user-guide/configuring#using-eslintignore-in-packagejsonI noticed there's no mention of a
prettierIgnore
option in the docs (https://prettier.io/docs/en/ignore.html). I also tried adding a similar key for prettier like this, which did nothing:At this point I'm pretty sure this isn't possible currently, but I wanted to make sure. Are there plans to add this in or is this intentionally left out?
The text was updated successfully, but these errors were encountered: