gpt4 book ai didi

css - 在没有评论的情况下禁用 SCSS Linting

转载 作者:行者123 更新时间:2023-12-02 04:49:46 29 4
gpt4 key购买 nike

我有一个 SCSS 文件,第一行有一个字符集指令。

@charset 'UTF-8';

并且我们使用 scss-lint 来强制使用单引号以及一大堆其他东西。

问题是,除非使用双引号,否则 @charset 指令似乎不起作用。所以我尝试使用 scss-disable 注释指令。

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

出于某种原因,这根本不起作用。 linter 仍然将双引号捕获为错误。我检查了禁用所有选项,这似乎可以解决问题。

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

但事实证明,@charset 必须是文件中的第一部分。

作为引用,我们需要明确指定 UTF-8,因为我们在 content 插入中使用 unicode 字符。我的开发机器采用 Unicode 并且构建良好,但除非我们包含该指令,否则我们的 CI 服务器不会构建。

除了从我们的 linting 列表中排除具有 unicode 的文件之外,还有更好的方法来处理这个问题吗?

最佳答案

您是否尝试过简单地删除该行?根据官方 SASS 文档,如果未设置,则假定它是 UTF-8 作为标准!

Encodings

When running on Ruby 1.9 and later, Sass is aware of the character encoding of documents. Sass follows the CSS spec to determine the encoding of a stylesheet, and falls back to the Ruby string encoding. This means that it first checks the Unicode byte order mark, then the @charset declaration, then the Ruby string encoding. If none of these are set, it will assume the document is in UTF-8.

如果将 UTF-8 编码添加为 HTML 标准,W3 也是如此:

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

关于css - 在没有评论的情况下禁用 SCSS Linting,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29899024/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com