【发布时间】:2020-02-18 23:01:12
【问题描述】:
我用--template typescript创建了一个新的 React Native 项目
我删除了作为样板文件一部分的template 目录。
然后我继续添加 ESLint:
module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: ["airbnb-typescript-prettier"]
};
但是,当我打开 babel.config.js 时,我收到此错误
解析错误:“parserOptions.project”已为@typescript-eslint/parser 设置。
该文件与您的项目配置不匹配:
/Users/Dan/site/babel.config.js。文件必须包含在至少一个提供的项目中。eslint
【问题讨论】:
-
在
tsconfig.js文件中添加babel.config.js: "include": [ "next-env.d.ts", "*/.ts", "*/.tsx”、“postcss.config.js”、“.eslintrc.js”] -
@HimanshuTanwar 不需要包含
babel.config.js,只是不要用 ESLint TypeScript 解析器解析它。看看my answer 的另一种方法,只解析 TS 文件。
标签: typescript eslint typescript-eslint