相关疑难解决方法(0)

解析错误:按照 ​​Firebase Cloud Functions 初始化说明后无法读取文件“\tsconfig.json”eslint

问题

在我的 TypeScript 项目在 VSCode 中初始化后,使用 firebase 工具按照官方文档编写 Firebase Cloud Functions,文件的第一行index.ts显示错误:

Parsing error: Cannot read file '\tsconfig.json' eslint [1,1] 在此输入图像描述

并且.eslintrc.js显示错误:

File is a CommonJS module; it may be converted to an ES6 module.ts(80001) 在此输入图像描述

由于所有文件都是自动生成的,这些错误完全令人惊讶,我想摆脱它们。

版本

作为记录,以下是安装的版本:

npm      --version 8.1.3
tsc      --version 4.4.4
node     --version 17.0.1
firebase --version 9.22.0
Run Code Online (Sandbox Code Playgroud)

安装流程

这些是我在 VSCode 的 powershell 中使用的命令以及一些信息/警告:

>npm install -g firebase-tools
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade …
Run Code Online (Sandbox Code Playgroud)

firebase typescript eslint google-cloud-functions

32
推荐指数
2
解决办法
2万
查看次数

ESLint:解析错误:无法在 WSL2 上的 WebStorm IDE 上读取文件 tsconfig.json

当克隆我的存储库并在 WSL2 上执行 npm install 时,我在 IDE 上针对项目中的所有 .ts 文件收到此 ESLint 错误:

ESLint:解析错误:无法读取文件\\wsl$\ubuntu-20.04\home\project_directory\tsconfig.json

这是因为我parserOptions在我的.eslintrc.json文件中出现的。

我尝试解决这个问题:

  • 我按照这个线程: Parsing error: Cannot read file '.../tsconfig.json'.eslint,通过将我的 json 转换为 js 文件并使用__dirname. 但这并不能解决我的问题。
  • 我还尝试进入我的 IDE 并手动eslint从我的项目的node_modules. 似乎没有什么可以为我消除这个错误。
  • 奇怪的是,如果我在 Windows(而不是 WSL)上克隆我的存储库,并在 Windows 上打开该项目,该项目工作正常并且eslint没有显示任何问题。不知道为什么它在 WSL 上的工作效果不一样。

任何帮助将不胜感激,因为我不确定下一步该做什么。

.eslintrc.json

{
    "env": {
        "browser": true,
        "es2021": true,
        "node": true,
        "jest": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:@typescript-eslint/recommended-requiring-type-checking",
        "prettier"
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": 2021,
        "sourceType": …
Run Code Online (Sandbox Code Playgroud)

npm webstorm typescript eslint windows-subsystem-for-linux

5
推荐指数
0
解决办法
4333
查看次数

我的“.eslintrc.js”文件出错 - “解析错误:已为@typescript-eslint/parser 设置了“parserOptions.project”。

ESLint 似乎无法解析“.eslintrc.js”文件

重现步骤:我建立了一个新的“hello world”TypeScript 项目,如下所示:

# Make a new directory for our new project
mkdir test
# Go into the new directory
cd test
# Create a "package.json" file
npm init --yes
# Install TypeScript
npm install typescript --save-dev
# Install ESLint (the linter)
npm install eslint --save-dev
# Install the Airbnb ESLint config (the most popular linting config in the world)
npm install eslint-config-airbnb-typescript --save-dev
# The import plugin for ESLint is needed for the Airbnb config to …
Run Code Online (Sandbox Code Playgroud)

typescript eslint

4
推荐指数
1
解决办法
3980
查看次数

'Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.' 是什么意思。IntelliJ IDE 系列中的错误?

当我打开.vue文件时,我的 IntelliJ IDEA 中出现以下错误:

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: XX\XX\CurrentFile.vue.
The file must be included in at least one of the projects provided.
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

当然,如果你教我解决方案,我会很高兴,但首先我知道它意味着什么以及为什么会出现。

我怀疑这是某种错误或不准确的错误消息。实验上已知:

  1. 有时它会出现,有时 - 不。
  2. 更新 eslint 时总是出现。
  3. 如果eslint从控制台运行某个.vue文件,eslint 将正确完成执行。所以看起来它不是 eslint 错误。

我的 Eslint 配置(YAML):

Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: XX\XX\CurrentFile.vue.
The file must be included in at least …
Run Code Online (Sandbox Code Playgroud)

intellij-idea typescript eslint vue.js

1
推荐指数
1
解决办法
7306
查看次数