Disable SCSS Linting without comment

I have an SCSS file with a charset directive on the first line.

@charset 'UTF-8';

      

And we use scss-lint to provide single quotes next to a whole host of other things.

The problem is that the directive @charset

doesn't work unless you use double quotes. So I tried using the scss-disable comment directive.

// scss-lint:disable SingleQuotes
@charset "UTF-8";
// scss-lint:enable SingleQuotes

      

For some reason, it didn't work. Linter still perceived double quotes as an error. I checked the disable all option, which seemed to do the trick.

// scss-lint:disable all
@charset "UTF-8";
// scss-lint:enable all

      

But it turns out it @charset

should be the first in the file.

For reference, we need to explicitly specify UTF-8 because we are using Unicode characters in the insert content

. My development machine assumes Unicode and it builds fine, but our CI server will not be built unless we include the directive.

Is there a better way to deal with this than just exclude files with unicode from our rename list?

+3


source to share


1 answer


Have you tried just deleting the line? According to the official SASS documentation, if none of these are installed, it is assumed to be UTF-8 as standard!

Encoding

When running Ruby 1.9 and later, Sass knows the document encoding symbol. Sass follows the CSS specification to define the stylesheet encoding and falls back to Ruby string encoding. This means it first checks the Unicode byte order marker, then @charset, and then the Ruby lowercase encoding. If none of these, the document is assumed to be in UTF-8.



The same goes for W3 if you add UTF-8 encoding as HTML standard:

You should always use UTF-8 as the encoding for your style sheets and your HTML pages, and declare this encoding in your HTML. If you do, there is no need to declare the encoding of your sheet style.

0


source







All Articles