Repository navigation
Closed
Labels
Description
I'm using Stylelint with minimal config like the following { "rules": { "no-browser-hacks": true } }
This check uses postcss-selector-parser module
When linting the following LESS file:
.my-mixin() when (@a = 5), (@b = 3) {
color: red;
}I'm getting the error:
TypeError: Cannot read property 'value' of undefined
at Parser.parentheses (C:\Users\thybzi\AppData\Roaming\npm\node_modules\stylelint\node_modules\postcss-selector-parser\dist\parser.js:305:17)
at Parser.parse (C:\Users\thybzi\AppData\Roaming\npm\node_modules\stylelint\node_modules\postcss-selector-parser\dist\parser.js:531:22)
at Parser.loop (C:\Users\thybzi\AppData\Roaming\npm\node_modules\stylelint\node_modules\postcss-selector-parser\dist\parser.js:517:18)
at new Parser (C:\Users\thybzi\AppData\Roaming\npm\node_modules\stylelint\node_modules\postcss-selector-parser\dist\parser.js:104:21)
at Processor.process (C:\Users\thybzi\AppData\Roaming\npm\node_modules\stylelint\node_modules\postcss-selector-parser\dist\processor.js:26:21)
at Plugin.<anonymous> (C:\Users\thybzi\AppData\Roaming\npm\node_modules\stylelint\node_modules\stylehacks\dist\plugins\bodyEmpty.js:36:67)
at Plugin.<anonymous> (C:\Users\thybzi\AppData\Roaming\npm\node_modules\stylelint\node_modules\stylehacks\dist\plugin.js:40:29)
at C:\Users\thybzi\AppData\Roaming\npm\node_modules\stylelint\node_modules\postcss\lib\container.js:148:26
at Root.each (C:\Users\thybzi\AppData\Roaming\npm\node_modules\stylelint\node_modules\postcss\lib\container.js:114:22)
at Root.walk (C:\Users\thybzi\AppData\Roaming\npm\node_modules\stylelint\node_modules\postcss\lib\container.js:147:21)Seems to be postcss-selector-parser (not stylelint) bug.
If you need any additional info, I'll try to provide it.
Reacted by Bartek Igielski
Activity
ben-eb commentedon Jul 8, 2017
OK so I've had a chance to look at this now, the problem is that the value enclosed in parentheses doesn't neatly fit into the idea of CSS selectors as the parser understands it. You can see this if you remove the rest of the string:
Produces the following tree:
You can see that
(@a = 5)is being parsed as a combinator node, due to the space token. Adding proper support for this is not something that I personally am wanting to do because I am not a Less user, and my original intention for the module was to parse CSS selector strings.I think it might be quite a lot of work to parse Less selectors properly, but I am willing to accept code that implements this parsing, so long as it can fit neatly into the module and is well tested.