[英]How to set up Airbnb ESLint in VS Code?
I've tried for hours to set up ESLint using the Airbnb linter in Visual Studio Code.我已经尝试了几个小时来使用 Visual Studio Code 中的 Airbnb linter 设置 ESLint。 I ran the commands found here: https://www.npmjs.com/package/eslint-config-airbnb and set the peer dependencies to the correct versions, but still no luck.
我运行了在这里找到的命令: https : //www.npmjs.com/package/eslint-config-airbnb并将对等依赖项设置为正确的版本,但仍然没有运气。 I always get this error:
我总是收到这个错误:
Unexpected top-level property "“extends”".
意外的顶级属性“扩展”。 .
. Please see the 'ESLint' output channel for details.
有关详细信息,请参阅“ESLint”输出通道。
Does anyone know of a fix for this?有谁知道解决这个问题? I've read so many blogs and threads to no avail and am at the point where it seems like it's just more hassle than it's worth, though everyone says the Airbnb style guide is best for React.
我已经阅读了很多博客和主题,但都无济于事,现在看起来似乎比它的价值更麻烦,尽管每个人都说 Airbnb 风格指南最适合 React。
npx install-peerdeps --dev eslint-config-airbnb
.npx install-peerdeps --dev eslint-config-airbnb
。package.json
file under the eslintConfig
property, like so: "eslintConfig": { "extends": "airbnb" }
eslintConfig
属性下的package.json
文件中添加基本配置,如下所示: "eslintConfig": { "extends": "airbnb" }
If you've done all of the above steps and are still getting the error you mentioned, see this thread , where a number of potential solutions are mentioned in the comments.如果您已完成上述所有步骤但仍然遇到您提到的错误,请参阅此线程,其中评论中提到了许多潜在的解决方案。
Specifically, in your case it sounds like your configuration is not getting read properly, for whatever reason.具体来说,在您的情况下,无论出于何种原因,您的配置听起来都没有正确读取。 I would try adding it to your
package.json
as mentioned above to see if that solves it.我会尝试如上所述将其添加到您的
package.json
中,看看是否能解决它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.