Using postcss-lit as Custom Syntax with Stylelint makes most editors / Stylelint LSP throw babel parser errors in some cases.
Errors are usually thrown when writing incomplete syntax (which is very common in LSP context).
Of course it's normal for the parser to fail with incomplete syntax but the issue is that it throws errors instead of failing silently.
Using other custom syntaxes like postcss-styled-syntax fixes the issue.
As explained in the repo, the issue occurs with VSCode & WebStorm.
The error content:
[Error - 10:48:54 PM] [language-server] Error running lint | uri: "file:///home/flo-perso/Projects/postcss-lit-stylelint/wc-test.js" error: {"code":"BABEL_PARSER_SYNTAX_ERROR","reasonCode":"UnterminatedString","loc":{"line":9,"column":32,"index":168},"pos":168,"name":"SyntaxError","message":"Unterminated string constant. (9:32)","stack":"SyntaxError: Unterminated string constant. (9:32)\n at constructor (/home/flo-perso/Projects/postcss-lit-stylelint/node_modules/@babel/parser/lib/index.js:359:19)\n at TypeScriptParserMixin.raise (/home/flo-perso/Projects/postcss-lit-stylelint/node_modules/@babel/parser/lib/index.js:3266:19)\n at Object.unterminated (/home/flo-perso/Projects/postcss-lit-stylelint/node_modules/@babel/parser/lib/index.js:2334:20)\n at readStringContents (/home/flo-perso/Projects/postcss-lit-stylelint/node_modules/@babel/parser/lib/index.js:2076:16)\n at TypeScriptParserMixin.readString (/home/flo-perso/Projects/postcss-lit-stylelint/node_modules/@babel/parser/lib/index.js:3165:9)\n at TypeScriptParserMixin.getTokenFromCode (/home/flo-perso/Projects/postcss-lit-stylelint/node_modules/@babel/parser/lib/index.js:2925:14)\n at TypeScriptParserMixin.getTokenFromCode (/home/flo-perso/Projects/postcss-lit-stylelint/node_modules/@babel/parser/lib/index.js:6851:11)\n at TypeScriptParserMixin.getTokenFromCode (/home/flo-perso/Projects/postcss-lit-stylelint/node_modules/@babel/parser/lib/index.js:9640:11)\n at TypeScriptParserMixin.nextToken (/home/flo-perso/Projects/postcss-lit-stylelint/node_modules/@babel/parser/lib/index.js:2449:10)\n at TypeScriptParserMixin.next (/home/flo-perso/Projects/postcss-lit-stylelint/node_modules/@babel/parser/lib/index.js:2362:10)"}
Screenshots of the errors
![VSCode error collapsed](https://github.com/user-attachments/assets/d305d9e8-a8be-46e2-99db-548cb436d081)
![image](https://github.com/user-attachments/assets/adbef956-8b6d-4217-8aba-c0fd67e3edee)
![image](https://github.com/user-attachments/assets/e51edbcd-f2f5-4a6b-9069-809840eda85c)
Using
postcss-lit
as Custom Syntax with Stylelint makes most editors / Stylelint LSP throw babel parser errors in some cases. Errors are usually thrown when writing incomplete syntax (which is very common in LSP context).Of course it's normal for the parser to fail with incomplete syntax but the issue is that it throws errors instead of failing silently. Using other custom syntaxes like postcss-styled-syntax fixes the issue.
Steps to reproduce
I've created a small repo to make it easy to reproduce: https://github.com/florian-sanders/postcss-lit-stylelint
As explained in the repo, the issue occurs with VSCode & WebStorm.
The error content:
Screenshots of the errors
![VSCode error collapsed](https://github.com/user-attachments/assets/d305d9e8-a8be-46e2-99db-548cb436d081) ![image](https://github.com/user-attachments/assets/adbef956-8b6d-4217-8aba-c0fd67e3edee) ![image](https://github.com/user-attachments/assets/e51edbcd-f2f5-4a6b-9069-809840eda85c)