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 multi-line single-line disable descriptions #4886
Comments
This is probably due CSS comment being a single comment entity. While in Sass-style it's two separate comments. |
It looks like you're right... if I add any text after the As a user, though, I'd expect stylelint to treat multiple adjacent inline comments as a single unified comment (which is incidentally how they're exposed in Sass's own AST). For example, I'd also expect the following to disable the lint: a {
// stylelint-disable-next-line color-no-invalid-hex --
// foo
color: #FF;
} Without support for this, #4868 would be of limited use in Sass files, since descriptions would have to be very short or risk overflowing line-length limits and producing readability problems. |
That's very interesting. It would be great if postcss-scss matched this behaviour so that both the following are single comment nodes: /* stylelint-disable declaration-no-important --
* some long-winded description */ // stylelint-disable declaration-no-important --
// some long-winded description @nex3 Can you raise this issue upstream about this? If it can't be resolved upstream, we can work around it in stylelint. |
Done: postcss/postcss-scss#109 In the meantime, @jathak is working on a pull request to work around this representation issue in stylelint. |
Good stuff. It looks like the change will be made upstream, but we can work around it in stylelint in the interim. |
In stylelint 13.7.0 they now treat multiline SCSS comments as a single comment [1] which means the disabling techniques we previously used no longer work. By adopting this new syntax the reasons are also understood to be associated with the rule and can allow switching on the reportDescriptionlessDisables option [2] which can require the disabling of rules to always be documented. For example ``` // comment describing disabling // stylelint-disable indentation ``` is treated as a comment of: "comment describing disabling stylelint-disable indentation" Instead this can be resolved with the following technique: ``` // stylelint-disable indentation -- comment describing // disabling ``` This therefore updates all of the stylelint disabling of rules to match this pattern. [1]: stylelint/stylelint#4886
In stylelint 13.7.0 they now treat multiline SCSS comments as a single comment [1] which means the disabling techniques we previously used no longer work. By adopting this new syntax the reasons are also understood to be associated with the rule and can allow switching on the reportDescriptionlessDisables option [2] which can require the disabling of rules to always be documented. For example ``` // comment describing disabling // stylelint-disable indentation ``` is treated as a comment of: "comment describing disabling stylelint-disable indentation" Instead this can be resolved with the following technique: ``` // stylelint-disable indentation -- comment describing // disabling ``` This therefore updates all of the stylelint disabling of rules to match this pattern. [1]: stylelint/stylelint#4886
With CSS-style multiline comments, it's possible to write disable descriptions (#4848) that span multiple lines:
Unfortunately, this doesn't work with Sass-style single-line comments (when parsed as the SCSS syntax of course):
N/A
Tested with 30bacfc
CLI with
stylelint test.css --config scripts/visual-config.json
Yes, it's related to SCSS comments.
I expected the description to be ignored and the lint to be disabled.
The lint was not disabled and still produced a warning
test.scss 4:10 ✖ Unexpected invalid hex color "#FF" color-no-invalid-hex
The text was updated successfully, but these errors were encountered: