How to allow // comments in scss within Stylelint (Unknown Word)
Asked Answered
D

3

8

I'm new to Stylelint. I tried to understand docs and searched GitHub, but all explanations are full of double negatives and I'm confused!
The problem is that when I use // for comments, it throws Unknown word (CssSyntaxError)Stylelint(CssSyntaxError).

Examples:

How can I solve this issue, or perhaps disable Stylelint check on commented lines?

Diapophysis answered 8/12, 2021 at 18:43 Comment(1)
Yes, /* works correctly but I want to use //.Diapophysis
D
9

Stylelint is designed for CSS - the language has come a long way in the last few years and extensions like SCSS and Less are often not needed.

However, Stylelint can - through community custom syntaxes and plugins - be extended to support SCSS. The easiest way to do this is by extending the stylelint-config-standard-scss shared config. This config, created by the SCSS community, includes the postcss-scss syntax and stylelint-scss plugin - a collection of rules specific to SCSS - and configures Stylelint's built-in rules for SCSS.

You should first install the config as a dependency:

npm i --save-dev stylelint-config-standard-scss

And then set your configuration object (e.g. your .stylelintrc.json file) to:

{
  "extends": "stylelint-config-standard-scss"
}

The problem is that when I use // for comments, it throws Unknown word (CssSyntaxError)Stylelint(CssSyntaxError).

Double slash comments (//) are not standard CSS and can't be parsed by the CSS parser built into Stylelint, hence the syntax error. The SCSS parser included in the stylelint-config-standard-scss shared config can parser double slash comments correctly.

Derte answered 8/12, 2021 at 20:47 Comment(0)
P
4

I removed this extension called "stylelint-plus" from vs code and this solved my issue.

Photodrama answered 30/3 at 14:2 Comment(0)
W
2

yes when i am uninstall extenstion "stylelint-plus" so solve my problem Unknown word (CssSyntaxError)Stylelint(CssSyntaxError)

Whelp answered 12/4 at 14:7 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Vat

© 2022 - 2024 — McMap. All rights reserved.