StyleLint 在 Github 操作中运行时抛出错误

StyleLint throws error when running in Github action

提问人:Grant mitchell 提问时间:2/19/2023 最后编辑:Grant mitchell 更新时间:2/19/2023 访问量:267

问:

我一直在试图深入研究这个问题,但我无法弄清楚哪里出了问题。正如你所看到的,下面是这个特定规则 https://stylelint.io/user-guide/rules/declaration-block-no-redundant-longhand-properties/ 发生错误的地方。任何建议和帮助将不胜感激:)。

node_modules/stylelint/lib/rules/declaration-block-no-redundant-longhand-properties/index.js:117
                            .map((p) => transformedDeclarationNodes.get(p)?.value.trim())
                                                                           ^

SyntaxError:意外的标记 '.'

我的 linter 配置文件


{
  "extends": "stylelint-config-recommended-scss",
  "plugins":["stylelint-prettier"],
  "rules": {
    "prettier/prettier": true,
    "scss/dollar-variable-pattern": null,
    "block-no-empty": null,
    "rule-empty-line-before":["always",{"ignore":["first-nested"]}],
    "scss/selector-no-redundant-nesting-selector": true,
    "font-family-no-missing-generic-family-keyword": [true,{"ignoreFontFamilies":["MAIN_THEME"]}],
    "color-function-notation": "legacy",
    "alpha-value-notation": "number",
    "scss/dollar-variable-colon-space-after": "always",
    "scss/dollar-variable-colon-space-before": "never",
    "unit-allowed-list": ["px","vmin","em","rem","deg","%","vh","vw","s"],
    "declaration-block-no-redundant-longhand-properties":[true, {
      "severity": "warning"
    }],
    "selector-class-pattern": "^.*$",
    "number-max-precision":2,
    "keyframes-name-pattern": "^[a-zA-Z]+?(?:-+[a-zA-Z]{2,10}){1,3}$"
  }
}

我的 CI 操作文件

name: something
on: [pull_request]

jobs:
  buildnode:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-node@v3
      with:
        node-version: '12.x'

    - name: install modules
      run: npm install

    - name: run scss linter
      run: npm run styleLinter

    - name: run js linter
      run: npm run linter

    - name: build web app
      run: npm run build

    - name: test the code
      run: npm test
javascript json 样式 scss-lint

评论


答:

0赞 Grant mitchell 2/19/2023 #1

styleLint 的节点版本已过期,因此我更新到 18 解决了该问题。