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 descriptions in stylelint command comments #4840
Comments
@glen-84 Thanks for the request and for using the template. Mimicking the ESLint implementation sounds good to me, i.e. the reason must come after The feature offers an optional, convenient and consistent way for authors to describe the reason for using a disable command. It is a better solution than the old I've labelled the issue as ready to implement. Please consider contributing if you have time. |
Is it sufficient to add the 3rd line here: const rules = fullText
.slice(command.length)
.split('--')[0].trim() // Allow for description (f.e. /* stylelint-disable a, b -- Description */).
.split(',')
.filter(Boolean)
.map((r) => r.trim()); in Assumptions:
If so, how many/what tests should be written? |
I suspect it will be.
Those assumptions are correct. You should add an explicit warning about double hyphens to the rule docs as part of the pull request.
Write as many tests as you need to feel confident that the feature works as expected. You want to add: For example, you'll want to test that |
Note that eslint does not interpret it as a description if there is no whitespace before or after the hyphen. |
Is it necessary to have that limitation? I could change it to Edit: Actually this might be the better option. |
I have checked the eslint source code. .split(/\s-{2,}\s/u)[0].trim() If you use this, the following comments are probably also valid: /* stylelint-disable rule-name
----------
description */ |
It looks like this isn't working on stylelint.io/demo. Is that just because the demo site uses an out-of-date version of stylelint? |
@nex3 There hasn't been a release since the feature was merged. |
Ah, gotcha! 👍 |
Describing/justifying disable directives, so that they aren't used unless necessary, and other developers know why they were used.
See the equivalent in ESLint:
Example:
The text was updated successfully, but these errors were encountered: