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
Add --rule and --no-stylelintrc CLI flags #4331
Comments
I don't understand the usefulness of this feature.
Isn't it the same as modifying CLI command? |
What I'm proposing is that One problem with doing it in a standalone tool is having to reimplement all of the same configuration loading logic that stylelint does. If that's just using the cosmiconfig API, then I guess it's not a huge deal. But I still think that giving people a way to focus on one or more rules — even just to spot-check a change they're making, particularly in big refactors — would be super useful. |
It will be confusing for people who use
I see you're using it in unofficial way :) |
Ah yeah, good point. 🤔 If you're still open to this idea, I'd be happy to hash out alternatives, such as:
My original proposal for
Yeah, it was the best way that I see to do it without spawning a |
I see this feature as not something that would benefit majority of our users. Therefore, I think I'm curious what @stylelint/contributors think. |
Looking at the ESLInt
That brings parity of ESLint to stylelint, also allows only a single rule to be used? |
That being said I'm not sure it's core functionality for this project and my current opinion is leaning towards it remaining separate. |
Looks like you can specify
I'm all for API parity where possible to help people easily move between tools and I think this falls under that remit |
Also note that without the |
Funnily enough, I needed this feature earlier today when working through stylelint/stylelint-demo#27 (comment) as I would've liked to have done: % echo "a:b(a:(f)) {}" | npx stylelint --rule 'selector-no-vendor-prefix: true' --no-stylelintrc I'd be happy to see the same
Shall I mark as an enhancement and help wanted? |
IMO |
For the usability side: I frequently use stylelint as a rule-to-prevent-it-in-the-future as well as a codemod to fix current issues. I'm working in a very large monorepo where I can't go in and run --fix on everything at once because it would hit too many rules across the board and touch more code than I could verify. |
Thanks for chiming in with your use case, @betaorbust. It makes sense. If anyone has time to implement these new options (
|
I now reconsider this issue.
|
Reconsidering this issue's original motivation, it seems that the following option would be just required: # Run with only rules defined in an existing config file (e.g. .stylelintrc.js)
stylelint --rule declaration-property-value-allowed-list "src/**/*.css"
# Or --only may be more intuitive than --rule
stylelint --only declaration-property-value-allowed-list "src/**/*.css" // .stylelintrc.js
module.exports = {
rules: {
// other rules ...
"declaration-property-value-allowed-list": {
"transform": ["/scale/"],
"whitespace": "nowrap",
"/color/": ["/^green/"],
// other values ...
},
// other rules ...
}
}; |
👍 (or
👎 (see #4331 (comment)) |
We should have switched this issue back to It feels like a 3rd party @Mouvedia It's fantastic that you're eager to contribute and move Stylelint forward. But, as with all these historical issues, it's best to ask if they're still relevant before picking them up as many are still open (and labelled with |
It's the second time that I have picked up an issue which status has been reverted from ready to implement to needs discussion. Minutes before I was about to turn the draft to ready to review I saw your message. See also #7252 (comment) which prompted me to restart my efforts. |
The sudden reversal as I send the PR is kind of weird and not motivating me nor reassuring me. I think the
What are the unanswered concerns and questions?
|
@Mouvedia Sorry for the sudden reversal. But you still have not answered my question (#7252 (comment)) since I was surprised by the |
I can reduce the scope of the PR if you want. But IMHO this feature needs to reach a minimum threshold to be really useful.
What I am unsure about is whether I really need
I was trusting the label. More than @jeddy3's reversal, it's his timing that really surprised me. |
@Mouvedia I believe there is still room to discuss new CLI flags and syntax for configuring a rule before entering implementation details. Also, if a 3rd-party package would do the same instead, we'd not need to increase code or dependency. We have to consider if the Stylelint core should provide this feature or if it'd be worth it. |
I intended to catch this before more work was done. Unfortunately, I was too late. The timing was coincidental. As I mentioned in the We can also create a new issue to look into other ways of improving how we manage issues and contributions, e.g. automatically relabelling issues when they reach a certain age. |
We could do that and slightly emend the issue template. @jeddy3 should I close this issue and its PR? |
Yes, I think so. A 3rd-party package would help us avoid increasing our code and dependencies. I've renamed the label. |
Stylelint autofixes turn out to be a really good way to refactor large codebases. However, it's painful having to modify your config by hand, and if you're extending an external config it's even trickier.
My proposal is a rule filter that could be enabled via the CLI, as in:
or via the Node API:
Ideally, rules would be matched against the fully loaded config. It could be as simple as:
Prior art
eslint has a
--rule
option, as mentioned in eslint/eslint#6333. Generally I think parity between the two is good, so having a--rule
option would be nice, too.There's also a standalone tool called eslint-nibble that provides a nicer UX for tackling lots of rule violations. This is probably the route that I'll go if there isn't any interest in making these changes to stylelint directly. Either way, I'm happy to help with the implementation too.
The text was updated successfully, but these errors were encountered: