【发布时间】:2021-01-10 18:54:18
【问题描述】:
我已按照本指南设置.eslintrc 配置。
我还按照本指南在 Visual Studio 中启用了 ESLint:
https://stackoverflow.com/a/44458832/3850405
我的问题是我想使用项目特定的配置而不是全局 ESLint 配置。
该指南设置了一个.eslintrc.js 文件,因此我尝试切换到与C:\Users\Oscar\.eslintrc 具有相同结构的文件。
尝试将.eslintrc 放在解决方案、项目的根文件夹和我的ClientApp 文件夹中,但没有收到任何东西。是否可以在 Visual Studio 中使用项目特定的 ESLint 配置并接收构建错误/警告?
运行命令 npx eslint . --ext .js,.jsx,.ts,.tsx 给了我正确的错误,但 Visual Studio 没有显示错误。
.eslintrc:
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"jest"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:react/recommended"
],
"env": {
"browser": true,
"node": true,
"jest/globals": true
},
"rules": {
"no-console": [
"error",
{ "allow": [ "warn", "error" ] }
]
}
}
【问题讨论】:
-
有没有想过这个问题?
-
明确地说,您是说您没有看到promised in the MS docs 的行为,对吧? "如果您想为特定目录使用特定的 ESLint 配置,您可以将配置文件添加到该目录,该文件夹或任何子目录中包含的所有文件都将使用该配置文件而不是全局配置文件。 ”(我认为这也行不通。)
标签: visual-studio visual-studio-2019 eslint eslintrc typescript-eslint