微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

stylelint-scss-是否可以禁用双斜杠注释?

如何解决stylelint-scss-是否可以禁用双斜杠注释?

我正在使用style-lint插入 Scss 文件 styled-components (通过使用不同的styleint.config文件)。

注释掉有效的CSS(https://github.com/styled-components/stylelint-processor-styled-components/issues/299)后,Stylint似乎有待解决

我可以不使用双斜杠注释,而可以使用块注释(/* block comment */),但是我想要保持一致:样式组件中的css和Scss文件共享相同的css语法。

我的想法是禁止对样式组件和Scss文件使用双斜杠注释。

// file: stylelint.config.styledComponents.js

module.exports = {
  processors: [
    'stylelint-processor-styled-components',],extends: [
    'stylelint-config-standard','stylelint-config-styled-components',rules: {
    // enforce block comments
    'no-invalid-double-slash-comments': true,},};

这是关于Scss文件的:

// file: stylelint.config.scss.js

module.exports = {
  extends: [
    'stylelint-config-standard',plugins: [
    'stylelint-scss',rules: {
    //
    // `scss/at-rule-no-unkNown` is basically a wrapper around the mentioned core rule,//   but with added Scss-specific @-directives. So if you use the core rule,@if,@extend
    //   and other Sass-y things will get warnings. You must disable stylelint's core rule to
    //   make this rule work
    //
    // source: https://github.com/kristerkari/stylelint-scss/blob/master/src/rules/at-rule-no-unkNown/README.md#at-rule-no-unkNown
    //
    'at-rule-no-unkNown': null,'scss/at-rule-no-unkNown': true,// Report errors for unkNown pseudo-classes with exception for :export
    'selector-pseudo-class-no-unkNown': [true,{
      ignorePseudoClasses: ['export'],}],// Override rules to match styles used in styled-components
    //
    // Following rules comes from diffing the print-config results
    //   from styled-components and scss files 
    'no-missing-end-of-source-newline': null,'no-empty-source': null,'value-no-vendor-prefix': [true],'property-no-vendor-prefix': [true],// enforce block comments
    'no-invalid-double-slash-comments': true,};

使用双斜杠注释时,Linging Scss文件不会出错。有办法吗?

解决方法

no-invalid-double-slash-comments rule不允许particular type on double slash comment in CSS。引用the docs

如果您使用的预处理器允许//个单行注释(例如Sass,Less,Stylus),则此规则不会对此有所抱怨。它们由您的预处理器编译成标准CSS注释,因此stylelint会认为它们有效。

我不认为存在禁止SCSS双斜杠注释的现有规则。但是,您可以write a simple plugin执行此操作。我建议您使用comment-no-loud rule中的stylelint-scss plugin pack作为蓝图。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?