从子目录运行 eslint

Sag*_*Low 7 javascript eslint devops azure-devops eslintrc

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

cd path/to/subproject
Run Code Online (Sandbox Code Playgroud)

和:

"lint": "tsc && eslint -c .eslintrc.js ./**/*.ts --"
Run Code Online (Sandbox Code Playgroud)

或者

"lint": "tsc && eslint -c ./.eslintrc.js ./**/*.ts --"
Run Code Online (Sandbox Code Playgroud)

还在根目录中尝试过:

"lint": "tsc && eslint -c path/to/subproject/.eslintrc.js ./**/*.ts --"
Run Code Online (Sandbox Code Playgroud)

或者

"lint": "tsc && eslint -c .eslintrc.js ./**/*.ts --"
Run Code Online (Sandbox Code Playgroud)

npm run lint --prefix path/to/subproject/
Run Code Online (Sandbox Code Playgroud)

但它不断引用根项目.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
Run Code Online (Sandbox Code Playgroud)

环境是使用 Ubuntu 16.04 的 Azure DevOps 管道

Sag*_*Low 9

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

module.exports = {
    "extends": [
        "configname"
    ],
    "root": true
}
Run Code Online (Sandbox Code Playgroud)

请参阅此处的文档