![](/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.