问题描述
我已经从--template typescript
的《创建React App入门指南》中创建了一个React应用。
https://create-react-app.dev/docs/getting-started/
我已经扩展了配置以使用ESLint。
package.json:
{
"eslintConfig": {
"extends": ["react-app","shared-config"],"rules": {
"additional-rule": "warn"
},"overrides": [
{
"files": ["**/*.ts?(x)"],"rules": {
"additional-typescript-only-rule": "warn"
}
}
]
}
}
https://create-react-app.dev/docs/setting-up-your-editor/
ESLint在运行npm run build
时工作正常,并显示在Chrome开发者控制台中,但是在Visual Studio中,出现以下错误:
(ESLint)无法加载要从中扩展的配置“ shared-config”。 引用自:
我该如何进行这项工作?
解决方法
"shared-config"
指的是已发布的配置,实际上是供参考的,就像没有"additional-typescript-only-rule"
这样的规则一样。
要解决您的错误消息,您只需删除条目或将其替换为适当的共享配置即可(例如"eslint-config-airbnb"
)。不过,请确保安装所有添加的新配置。