![](/img/trans.png)
[英]Yarn 3.x PNP typescript CRA eslint not working with VSCode
[英]React CRA with typescript not working with eslint
我正在尝试将 linting 集成到使用 CRA 创建的应用程序中,该应用程序使用 typescript。
在终端上重现的步骤
create-react-app my-app --typescript
./node_modules/.bin/eslint --init
My.eslintrc json 文件如下所示
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"airbnb"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint"
],
"rules": {
"semi":"warn"
}
}
我通常通过删除分号来检查 lint 是否有效,以查看 vs 代码是否突出显示。
然而它不会发生。
将以下代码段添加到 VS 代码上的 settings.json 有效。
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
在 React CRA 中有两种设置 ESLint。
yarn start
和保存文件时)由于互联网上有太多(不需要)信息,我在这里以更简单的方式创建了一篇关于此的文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.