我正在尝试将linting集成到使用CRA创建的应用程序中,该应用程序使用类型记录。
在终端上复制的步骤
create-react-app my-app --typescript./node_modules/.bin/eslint --init
我的.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代码是否突出显示。
然而,这种情况并没有发生。
发布于 2019-10-07 06:41:57
在VS代码上向settings.json添加以下代码片段是可行的。
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],发布于 2020-02-23 16:34:41
在React中有两种设置类型的ESLint。
yarn start和保存文件时)由于互联网上有太多(不需要)的信息,我在这里中用一种简单得多的方式写了一篇关于这一点的文章。
https://stackoverflow.com/questions/58264433
复制相似问题