Suppressing CssSyntaxError for inline styles in svelte files
See original GitHub issueWhat is the problem you’re trying to solve?
Hello, I am currently trying to implement stylelint in a project that uses svelte and several postcss plugins. The problem occurs in the parsing of inline styles in the svelte file.
We sometimes use the style tag of an html element to define a dynamic custom property as in the following case:
<nav
class="Menu"
slot="sticky"
style="
--nbMenuItems: { displayedItems.length };
{ getStyleUrlVars({ arrowRight }) }"
>
The output in this case is
<nav class="Menu svelte-1q3olh0" slot="sticky" style="--nbMenuItems: 3;--arrowRight: url('/client/assets/icon_arrow-2_right-7f4ce63b.svg');">
Here I get an error
src/components/AnchorMenu/AnchorMenu.svelte
40:7 ✖ Unknown word CssSyntaxError
I would like to turn off the parsing for inline style tags. Is this possible?
this is also the case with "defaultSeverity": "warning",
as discussed here
Thanks in advance and for all the hard work that goes into stylelint!
What solution would you like to see?
I would like to have an option that allows for parsing only content between <style> tags but otherwise the possibility of doing something like this
<nav
class="Menu"
slot="sticky"
style="
--nbMenuItems: { displayedItems.length };
/* stylelint-disable-line */
{ getStyleUrlVars({ arrowRight }) }
/* stylelint-enable-line */
"
>
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Advanced styling / Inline styles • Svelte Tutorial
Great, now you can style the paragraph using variables that change based on your input without having to make a class for every...
Read more >Ignoring code - Stylelint
Ignoring code. You can ignore: within files; files entirely. Within files. You can temporarily turn off rules using special comments in your CSS....
Read more >“Syntax Error: Error: PostCSS plugin postcss-import requires ...
src/index.css Syntax Error: Error: PostCSS plugin tailwindcss requires PostCSS ... It is required that your private key files are NOT accessible by others....
Read more >esbuild-linux-arm64: Versions - Openbase
Source maps are JSON files that map from compiled code back to the original code. ... esbuild example.css --log-override:css-syntax-error=error.
Read more >Symfony: How To Enable Validation Errors From A Subform ...
Navigate to Tools Debug File Validation from the left sidebar menu of the book dashboard; Click Choose File and ... CSS syntax error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey everyone!
The following fix worked for me:
Install these dependencies:
Add
stylelint-config-html/svelte
toextends
Hope this helps!
If you are using a js file for your config, changing it to use
postcss-safe-parser
for CSS parsing withpostcss-html
will make the parser accept some syntax errors. So it may work for you.You may need to explicitly install postcss-safe-parser.
https://github.com/ota-meshi/postcss-html#advanced-use-cases https://github.com/postcss/postcss-safe-parser