Skip to content
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 support for enabling a rule with stylelint-command comments #5554

Open
AndreasNasman opened this issue Sep 21, 2021 · 7 comments
Open

Add support for enabling a rule with stylelint-command comments #5554

AndreasNasman opened this issue Sep 21, 2021 · 7 comments
Labels
status: ask to implement ask before implementing as may no longer be relevant type: enhancement a new feature that isn't related to rules

Comments

@AndreasNasman
Copy link

What is the problem you're trying to solve?

Enabling a rule (with options) using stylelint-commands.

What solution would you like to see?

Being possible to write e.g.

/* stylelint declaration-no-important: [ true, { severity: 'warning' } ] */

to enable declaration-no-important with warning severity for a single file.

@AndreasNasman
Copy link
Author

For reference, ESLint has this feature. Is this something that's already possible to do in Stylelint? I tried the one I mentioned in the comment above and a couple of variations, but couldn't figure out a working one.

@ybiquitous
Copy link
Member

@AndreasNasman Thanks for the suggestion. As I know, stylelint doesn't have such a feature. For example, see the demo.
But I think this idea is interesting.

@ybiquitous ybiquitous added status: needs discussion triage needs further discussion type: enhancement a new feature that isn't related to rules labels Sep 22, 2021
@ybiquitous
Copy link
Member

Currently, stylelint has two kinds of comments: stylelint-disable and stylelint-enable
See: https://stylelint.io/user-guide/ignore-code/

@jeddy3 jeddy3 added status: ready to implement is ready to be worked on by someone and removed status: needs discussion triage needs further discussion labels Sep 25, 2021
@jeddy3
Copy link
Member

jeddy3 commented Sep 25, 2021

This feature SGTM. It's likely related to #2643 as files are linted first and then errors within disable ranges are removed. Feel free to investigate how the stylelint-commands code can be rearchitected to facilitate a new /* stylelint .. */ command comment, as it'll involve gathering the stylelint-commands before any linting happens so that the final configuration is known beforehand.

Now is a good time to look into this as the internals have been improved as we move towards releasing 14.0.0 (see #5542 & #5521, in particular).

These command comments should take the highest precedence, over overrides and (the yet to be added) --rules flag.

I've labelled the issue as ready to implement. Please consider contributing if you have time.

@jeddy3 jeddy3 changed the title Enabling a rule with stylelint-commands (comments) Add support for enabling a rule with stylelint-command comments Sep 25, 2021
@stof
Copy link
Contributor

stof commented Nov 23, 2021

eslint-enable does not support enabling unknown rules. It is only about re-enabling rules. And the eslint command configuring new rules is only supported at the beginning of the file AFAIK

@AndreasNasman
Copy link
Author

AndreasNasman commented Nov 27, 2021

Not sure what you mean @stof. You can enable/disable/customize ESLint rules through comments anywhere in a file. The rules also don't have to be configured in eslintrc beforehand, so they can be 'enabled from scratch' so to say. This issue is not about enabling unknown rules, it's about improving the Stylelint comments to allow for customizing of available rules. 🙂

Copy link
Contributor

This issue is older than one month. Please ask before opening a pull request, as it may no longer be relevant.

@github-actions github-actions bot added status: ask to implement ask before implementing as may no longer be relevant and removed status: ready to implement is ready to be worked on by someone labels Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ask to implement ask before implementing as may no longer be relevant type: enhancement a new feature that isn't related to rules
Development

No branches or pull requests

4 participants