stylelint-scss - 有没有办法禁用双斜杠注释?
stylelint-scss - Is there a way to disable double-slash-comments?
我正在使用 style-lint 对 Scss 文件和 styled-components(通过使用不同的 styleint.config 个文件)。
当有效 css 被注释掉 (https://github.com/styled-components/stylelint-processor-styled-components/issues/299) 时,Stylint 似乎有一个未解决的问题。
我可以不使用双斜杠注释而是块注释(/* block comment */
)但我想要一致性:css in styled-components and Scss files sharing same 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,
},
};
Linting Scss 文件在使用双斜杠注释时不会出错。有办法做到这一点吗?
no-invalid-double-slash-comments
rule disallows a particular type on double slash comment in CSS. Quoting from the docs:
If you are using a preprocessor that allows //
single-line comments (e.g. Sass, Less, Stylus), this rule will not complain about those. They are compiled into standard CSS comments by your preprocessor, so stylelint will consider them valid.
我不认为存在禁止 SCSS double-slash 评论的现有规则。但是,您可以write a simple plugin to do this. I suggest you use the comment-no-loud
rule from the stylelint-scss plugin pack作为蓝图。
我正在使用 style-lint 对 Scss 文件和 styled-components(通过使用不同的 styleint.config 个文件)。
当有效 css 被注释掉 (https://github.com/styled-components/stylelint-processor-styled-components/issues/299) 时,Stylint 似乎有一个未解决的问题。
我可以不使用双斜杠注释而是块注释(/* block comment */
)但我想要一致性:css in styled-components and Scss files sharing same 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,
},
};
Linting Scss 文件在使用双斜杠注释时不会出错。有办法做到这一点吗?
no-invalid-double-slash-comments
rule disallows a particular type on double slash comment in CSS. Quoting from the docs:
If you are using a preprocessor that allows
//
single-line comments (e.g. Sass, Less, Stylus), this rule will not complain about those. They are compiled into standard CSS comments by your preprocessor, so stylelint will consider them valid.
我不认为存在禁止 SCSS double-slash 评论的现有规则。但是,您可以write a simple plugin to do this. I suggest you use the comment-no-loud
rule from the stylelint-scss plugin pack作为蓝图。