-
-
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
Fix incorrect position for Less in declaration-no-important #5438
Comments
@nwalters512 Thanks for the report, using the template and for the initial sleuthing (especially identifying that a single quote is involved somehow). I can reproduce the issue for Less using the demo. It doesn't seem to be an issue with the Scss parser. The issue could be with the rule, the upstream parser (postcss-less) or the interplay between these. I'll label as bug. Please consider contributing if you have time. I believe postcss-less is maintained by a single volunteer who would be grateful for help. There are steps on how to fix a bug in a rule in the Developer guide. (Branch from |
@jeddy3 Thanks for the links to the demo reproduction and ruling out the Scss parser. I'll attempt to contribute a fix - I can target v14, but if the issue ends up being in stylelint, would it be possible to to backport it to v13? If it's in |
Probably not, I'm afraid. We really only have the capacity to maintain one branch as we've just a handful of volunteers working on stylelint, and so we haven't committed to |
Understood! Really appreciate all the effort you and the other volunteers put into this tool. |
I think I've narrowed this down to an issue with the const less = `.a {\n // '\n outline-width: 0 !important;\n}\n\n/** ' */`; When parsed, this produces the following (JSON-stringified) AST: {
"raws": {
"semicolon": false,
"after": ""
},
"type": "root",
"nodes": [
{
"raws": {
"before": "",
"between": " ",
"semicolon": true,
"after": "\\n"
},
"type": "rule",
"nodes": [
{
"raws": {
"before": "\\n ",
"begin": "//",
"left": " ",
"right": ""
},
"type": "comment",
"source": {
"inputId": 0,
"start": {
"offset": 7,
"line": 2,
"column": 3
},
"end": {
"offset": 7,
"line": 2,
"column": 3
}
},
"inline": true,
"text": "'"
},
{
"raws": {
"before": "\\n ",
"between": ": "
},
"type": "decl",
"source": {
"inputId": 0,
"start": {
"offset": 3,
"line": 2,
"column": 3
},
"end": {
"offset": 30,
"line": 2,
"column": 30
}
},
"prop": "outline-width",
"important": true,
"value": "0"
}
],
"source": {
"inputId": 0,
"start": {
"offset": 0,
"line": 1,
"column": 1
},
"end": {
"offset": 32,
"line": 3,
"column": 1
}
},
"selector": ".a"
},
{
"raws": {
"before": "\\n\\n",
"left": "",
"right": " "
},
"type": "comment",
"source": {
"inputId": 0,
"start": {
"offset": 35,
"line": 5,
"column": 1
},
"end": {
"offset": 42,
"line": 5,
"column": 8
}
},
"text": "* '"
}
],
"source": {
"inputId": 0,
"start": {
"offset": 0,
"line": 1,
"column": 1
}
},
"inputs": [
{
"hasBOM": false,
"css": ".a {\\n // '\\n outline-width: 0 !important;\\n}\\n\\n/** ' */",
"id": "<input css lE58i->"
},
{
"hasBOM": false,
"css": "\\n outline-width: 0 !important;\\n}\\n\\n/** ' */",
"id": "<input css YU0Mvn>"
}
]
} Notice this node in particular: {
"raws": {
"before": "\\n ",
"between": ": "
},
"type": "decl",
"source": {
"inputId": 0,
"start": {
"offset": 3,
"line": 2,
"column": 3
},
"end": {
"offset": 30,
"line": 2,
"column": 30
}
},
"prop": "outline-width",
"important": true,
"value": "0"
} I would expect |
Ahh, this looks like it's probably relevant: shellscape/postcss-less#154. That explains where the second |
Yes, very likely related.
I'll label as upstream.
|
I reported this upstream: shellscape/postcss-less#163. Still trying to work on a fix for it! |
Aaaaaand my attempt at a fix: shellscape/postcss-less#164 |
For files with specifically formatted comments, the
declaration-no-import
rule reports errors at the incorrect location in the document. Here's one example:I was able to reproduce with
declaration-no-import
, though I can't rule out that something similar doesn't happen with other rules.This is about as minimal as I could get and still reproduce it. A few things to note:
/* ... */
'
) is removed from either comment13.13.1
For the reproduction, I invoked the stylelint CLI with
stylelint path/to/file.less
Yes, it appears to be related to LESS double-slash comments (
// ...
)I expected the
declaration-no-important
rule to flag an error on the!important
keyword on line 3.The error was flagged on the word "with" on line 2.
The text was updated successfully, but these errors were encountered: