postcss-selector-parser icon indicating copy to clipboard operation
postcss-selector-parser copied to clipboard

broken ast

Open vankop opened this issue 6 years ago • 10 comments

regarding to https://github.com/stylelint/stylelint/issues/4049

.foo1, // this comments is marked as an error
.foo2 {
    color: #fff;
}

Parsers // this comments is marked as an error as selectors

vankop avatar Jul 31 '19 10:07 vankop

Known issue, we should rewrite parser whole, now we parse comments as part of ast, but it is invalid, we should use leadingComments, trailingComments and etc as do babel (try this in https://astexplorer.net/), it is allow to keep ast clean and works with comments in right way (without pain)

alexander-akait avatar Jul 31 '19 11:07 alexander-akait

Is it possible to contribute? or this issue still is in discussion?

vankop avatar Jul 31 '19 11:07 vankop

@vankop it is breaking change, anyway let's do it, in future we should use safe option and throw error on this syntax when for pure css

alexander-akait avatar Jul 31 '19 11:07 alexander-akait

@evilebottnawi I will take this.

vankop avatar Aug 26 '19 15:08 vankop

:+1:

alexander-akait avatar Aug 26 '19 15:08 alexander-akait

@evilebottnawi should we skip comments in .toString() method?

Currently https://github.com/postcss/postcss-selector-parser/blob/master/src/tests/util/helpers.js#L24 we expect that comments will be in output

vankop avatar Aug 29 '19 10:08 vankop

No, we should print comments

alexander-akait avatar Aug 29 '19 10:08 alexander-akait

Sorry I was a bit stuck with stringifying comments correctly and gave up =) I hope I will find time on the next week or will create WIP PR.

vankop avatar Sep 26 '19 11:09 vankop

This issue is occurring in upgrade for angular 12, and i also get this criptic error message that the angular people says comes from this progam after I replace all the // comments: Error: Unexpected '/'. Escaping Social characters with \ may help

Shouldn't the error message give a location where this error occurs?

daddyschmack avatar Apr 29 '21 16:04 daddyschmack

@daddyschmack just helped a teammate with this. Apparently this is a problem with CRLF or something related to Stylelint's ignoreFiles.

guilhermetod avatar Aug 12 '21 17:08 guilhermetod