当我使用```styleLint-scss'''''''''''' 我在这里有一些情况。 我使用SASS-LOADER在React应用中使用SCSS,并使用StyleLint和IT stylelint-SCSS的扩展名称SCSS/CSS。 我从这里借了一些代码:...

问题描述 投票:0回答:1
stylelint

scs/css使用

stylelint-scss

和它的扩展名来缩写scss/css。

i从这里借了一些代码:
https://medium.com/dev-channel/usish-sass-sass-to-automatory-pick-text-colors-4ba7645d2796
,我正在尝试在文件中使用它。这就是我的方式:
@function luminance($color) {
  $red: nth(linear-channel-values(), red($color) + 1);
  $green: nth(linear-channel-values(), green($color) + 1);
  $blue: nth(linear-channel-values(), blue($color) + 1);

  @return 0.2126 * $red + 0.7152 * $green + 0.0722 * $blue;
}

然后stylelint-scss向我投诉:

WARNING in
src/assets/scss/helpers.scss
 282:9Expected list.nth instead of nth        scss/no-global-function-names
 282:38Expected color.red instead of red       scss/no-global-function-names
 283:11Expected list.nth instead of nth        scss/no-global-function-names
 283:40Expected color.green instead of green   scss/no-global-function-names
 284:10Expected list.nth instead of nth        scss/no-global-function-names
 284:39Expected color.blue instead of blue     scss/no-global-function-names

,所以我将我的

nth
函数调用更改为

list.nth
...然后我得到另一个投诉:

@use "sass:color"; @use "sass:list"; @function luminance($color) { $red: list.nth(linear-channel-values(), color.red($color) + 1); $green: list.nth(linear-channel-values(), color.green($color) + 1); $blue: list.nth(linear-channel-values(), color.blue($color) + 1); @return 0.2126 * $red + 0.7152 * $green + 0.0722 * $blue; }

ERROR in ./src/assets/scss/index.scss (./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/postcss-loader/src??ref--6-2!./node_modules/sass-loader/dist/cjs.js!./node_modules/resolve-url-loader!./src/assets/scss/index.scss)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Invalid CSS after "  $red: list": expected expression (e.g. 1px, bold), was ".nth(linear-channel"
        on line 282 of src/assets/scss/helpers.scss
        from line 7 of /Users/ogabay/Projects/mercury/app/pennypal/src/assets/scss/index.scss
>>   $red: list.nth(linear-channel-values(), color.red($color) + 1);

   ------------^

 @ ./src/assets/scss/index.scss 2:26-262 43:4-64:5 46:18-254
 @ ./src/index.jsx
在这里与

stylelint-scss
sass-loader

我遇到了同一问题。如果StyleLint-SCSS要求您使用
list.nth
,请确保每个调用的SCSS文件包括
list.nth

。如果进行更改后,它仍然会引发错误,请尝试重新启动开发服务器并清除高速缓存。
css webpack sass sass-loader stylelint
1个回答
0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.