-
-
Notifications
You must be signed in to change notification settings - Fork 929
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
Config overrides function #4377
Conversation
@hudochenkov I'd love your input on whether the |
Looks like I also might need some help on resolving some of the Flow errors, too 😬 |
@shawnbot Thanks for PR, looks good! I think we need to support "smart" merge, too. (maybe in another PR) Could you please create test case with @hudochenkov new problem with Windows in CI =( Maybe our previous hack (with commands chaining) is unnecessary now UPD: Oh, it is only about Node.js api =( Won't this approach work for object as well? |
I think this is more useful
I think this is not possible in current stylelint design, we can not rely on syntax when overriding config. As I can see we can use babel approach here. Something like:
So under the hood we can create |
I was meaning to use
|
Closing, as we've decided to go a different direction. ✌️ |
This implements the proposal in #4374. TL;DR:
configOverrides
can be a function that takes a fully resolved config and either modifies it in place and/or returns a new one:--rules
CLI optionAs a demonstration of how this works, I've also implemented a fix for #4331 with a new CLI flag:
--rules <comma-separated-list>
adds an config override that filters the configuration'srules
object to include only the named rules in the list.I haven't added docs for this yet, but I wanted to be sure that this change was welcome before doing so. I think it's super useful and would love not to have to maintain stylelint-only. 😁
File filters?
This might pave the way for a solution to #3128, but I'm honestly not sure where in stylelint's configuration "lifecycle" the configuration is augmented, and it's entirely possible that this happens before the config is applied to individual files. If so, a follow-up would need to be necessary to either:
configOverrides()
for each file, and pass the file information to it; orEither way, this mechanism is only available in JS configs, and won't work in JSON or YAML.