【发布时间】:2020-12-23 19:11:39
【问题描述】:
我尝试在我的React/TypeScript project 之一中实现 eslint。我使用 eslint 的 cli yarn eslint --init 和 airbnb 配置创建了我的 .eslintrc.js:
module.exports = {
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"airbnb"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint"
],
"rules": {
}
};
但是当我运行 eslint 时,我的所有 .tsx 文件都会出现此错误:
0:0 错误解析错误:提供的 lib 值无效:es2021
我所有的文件都以 React 的导入开始:
import * as React from 'react';
...
作为某人知道问题是什么?
【问题讨论】:
-
如果您使用整个 AirBnB 规则集,我怀疑您会遇到大量不兼容的规则。没有在考虑 Typescript 的情况下指定它。
标签: javascript reactjs typescript eslint