【问题标题】:Not getting results or error from stylelint / stylelint-config-styled-components没有从 stylelint / stylelint-config-styled-components 得到结果或错误
【发布时间】:2018-10-09 05:21:08
【问题描述】:

我正在一个 react 项目上安装 stylelint-config-styled-components

当我执行npm run lint:css(或直接通过 CLI 使用 stylelint 命令)时,我没有得到任何结果。我故意添加了额外的空格和重复的样式声明,所以肯定应该有一些来自 stylelint 的反馈,我违反了规则。但是,我什么也没得到,甚至没有错误消息。有什么想法吗?

我已经安装了以下软件包:

  • stylelint 9.1.3
  • stylelint-config-recommended 2.1.0
  • stylelint-config-styled-components 0.1.1
  • stylelint-processor-styled-components 1.3.1

我在package.json 中使用以下脚本:

"scripts": {
    //other scripts
    "lint:css": "stylelint './src/**/*.js'"
}

我的.stylelintrc的内容:

{
 "processors": ["stylelint-processor-styled-components"],
 "extends": [
   "stylelint-config-recommended",
   "stylelint-config-styled-components"
 ]
}

我的项目的文件结构(我试过直接在文件上运行命令,结果相同,所以我认为找不到 .js 文件不是问题)

-root
    -.stylelintrc
    -src
      -Components
        -Directory
          -ThingIWantLinted.js
        -AnotherDirectory
          -AnotherThingTolint.js

【问题讨论】:

  • 这里也一样。我按照Styled Components website 上的详细步骤操作,但一无所获。我还运行了stylelint './src/**/*.js' --formatter verbose,它确实列出了它应该检查的文件,但它们都返回 OK(绿色),即使其中一些有明显的问题。

标签: reactjs styled-components npm-scripts stylelint


【解决方案1】:

也遇到了这个问题。升级到 stylelint 9.4.0 现在 lint 结果显示如预期。

参考问题。 https://github.com/stylelint/stylelint/pull/3261

【讨论】:

  • 我刚刚重新审视这个问题,并用上面列出的所有内容的最新版本更新了我的项目:“stylelint”:“^9.7.1”,“stylelint-config-recommended”:“^ 2.1.0”,“stylelint-config-styled-components”:“^0.1.1”,“stylelint-processor-styled-components”:“^1.5.0”,但是,现在我收到错误“错误: EMFILE:打开的文件太多”我检查了其他一些堆栈溢出帖子并尝试安装守望者。这并没有改变任何东西。
  • 在做出上述评论后,我确实确定 linting 在其他机器上运行/工作,所以这确实有效!打开文件太多的问题是无关的。
【解决方案2】:

除了 (')

    "scripts": {
    //other scripts
    "lint:css": "stylelint ./src/**/*.js"
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-06
    • 1970-01-01
    • 1970-01-01
    • 2022-06-11
    • 2021-12-05
    • 1970-01-01
    • 2020-10-02
    • 1970-01-01
    相关资源
    最近更新 更多