[英]Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. The file does not match your project config: .eslintrc.js
I've just used create-react-app to start a new typescript react app and then installed firebase. I ran firebase init
, selected the typescript option, enabled es lint and enabled functions.我刚刚使用 create-react-app 启动了一个新的 typescript react 应用程序,然后安装了 firebase。我运行了
firebase init
,选择了 typescript 选项,启用了 es lint 和启用的功能。
As soon as I uncommented the boilerplate function code in functions/index.ts, I noticed some warnings in VS Code...一旦我取消注释 functions/index.ts 中的样板 function 代码,我注意到 VS Code 中的一些警告......
functions/eslintrc.js:函数/eslintrc.js:
Giving error: "Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. The file does not match your project config: .eslintrc.js. The file must be included in at least one of the projects provided"给出错误: “解析错误:已为@typescript-eslint/parser设置了“parserOptions.project”。该文件与您的项目配置不匹配:.eslintrc.js。该文件必须至少包含在提供的项目之一中“
functions/tsconfig.json:函数/tsconfig.json:
functions/src/index.ts:函数/src/index.ts:
giving error: "Parsing error: Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'.eslint"给出错误: “解析错误:‘--jsx’选项的参数必须是:‘preserve’、‘react-native’、‘react’.eslint”
functions/package.json:功能/包.json:
{
"name": "functions",
"scripts": {
"lint": "eslint --ext .js,.ts .",
"build": "tsc",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "14"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^9.8.0",
"firebase-functions": "^3.14.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.8.0",
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.22.0",
"firebase-functions-test": "^0.2.0",
"typescript": "^3.8.0"
},
"private": true
}
I don't understand these errors.我不明白这些错误。 Can someone please help?
有人可以帮忙吗?
Thanks谢谢
further to the above excellent suggestion by Evelyn Hathaway, and after I installed just the functions with no hosting and I changed the ".eslingrc.js: file除了 Evelyn Hathaway 提出的上述出色建议,在我只安装了没有托管的功能之后,我更改了“.eslingrc.js:文件
FROM从
.eslingrc.js
parserOptions: {
project: ["tsconfig.json",
"tsconfig.dev.json"],
to到
.eslingrc.js
parserOptions: {
project: ["./functions/tsconfig.json",
"./functions/tsconfig.dev.json"],
At last the seemed to work after I spent a frustrating day.....在我度过了令人沮丧的一天之后,终于似乎工作了......
The first error from TypeScript ESLint is related to not being able to find a project tsconfig.json
that matches your functions. TypeScript ESLint 的第一个错误与无法找到与您的功能匹配的项目
tsconfig.json
有关。
To fix this, we need to tell TypeScript ESLint where the other tsconfig.json
is by editing your parserOptions
.要解决此问题,我们需要通过编辑您的
parserOptions
来告诉 TypeScript ESLint 其他tsconfig.json
在哪里。
.eslintrc.js
// [...]
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": [
"./tsconfig.json",
"./functions/tsconfig.json",
]
}
// [...]
To fix the parsing issue related to JSX for your React files, you must add the jsx
compiler option to your tsconfig.json
configurations that include JSX.要修复与 React 文件的 JSX 相关的解析问题,必须将
jsx
编译器选项添加到包含 JSX 的tsconfig.json
配置中。 This will likely be your non-function configuration, and you will most likely need to set it to react-jsx
for React v17+ or react
in all other cases for Create React App.这可能是您的非功能配置,您很可能需要将其设置为
react-jsx
以用于 React v17+ 或在所有其他情况下对 Create React App 进行react
。
tsconfig.json
{
"compilerOptions": {
"jsx": "react-jsx"
// [...]
}
// [...]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.