【问题标题】:Running eslint from subdirectory从子目录运行 eslint
【发布时间】:2020-02-04 02:49:39
【问题描述】:

我的项目包含一个具有自己的.eslintrc 的子项目(即在./path/to/subproject 下)
我正在尝试运行lint,但它要么进入根项目.eslintrc 文件,要么找不到.eslintrc 文件
我在package.json中尝试了以下配置:

cd path/to/subproject

和:

"lint": "tsc && eslint -c .eslintrc.js ./**/*.ts --"

"lint": "tsc && eslint -c ./.eslintrc.js ./**/*.ts --"

也在根目录中尝试过:

"lint": "tsc && eslint -c path/to/subproject/.eslintrc.js ./**/*.ts --"

"lint": "tsc && eslint -c .eslintrc.js ./**/*.ts --"

npm run lint --prefix path/to/subproject/

但它一直引用根项目.eslintrc文件:

Oops! Something went wrong! :(

ESLint: 6.4.0.

ESLint couldn't find the config "configname" to extend from. Please check that the name of the config is correct.

The config "configname" was referenced from the config file in "/home/vsts/work/1/s/.eslintrc.js". <-- this is the wrong .eslintrc

环境是带有 Ubuntu 16.04 的 Azure DevOps 管道

【问题讨论】:

标签: javascript azure-devops devops eslint eslintrc


【解决方案1】:

看来eslint 支持这个
我要做的就是将"root": true 添加到我的 eslint 配置文件中,它现在看起来像这样:

module.exports = {
    "extends": [
        "configname"
    ],
    "root": true
}

参见文档here

【讨论】:

    猜你喜欢
    • 2017-08-11
    • 1970-01-01
    • 2020-01-15
    • 2014-01-10
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    • 2018-06-20
    • 2023-01-30
    相关资源
    最近更新 更多