错误:--config 中的 ESLint 配置无效

Anu*_*rai 6 json formatter typescript eslintrc

我在使用命令npm run start时遇到错误:

错误:--config 中的 ESLint 配置无效:- 意外的顶级属性“compilerOptions”。

我无法找出错误的原因。我尝试添加root:true和我偶然发现的许多其他解决方案。

我的 package.json 文件:

{
  "name": "discord-bot",
  "version": "1.0.0",
  "description": "",
  "main": "dist/WebServer.js",
  "scripts": {
    "prebuild": "eslint . --ext .js,.jsx,.ts,.tsx -c tsconfig.json --fix",
    "lint": "eslint . --ext .ts,.tsx",
    "lint-and-fix": "eslint . --ext .ts,.tsx --fix",
    "build": "tsc",
    "prestart": "npm run build",
    "start": "node .",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Anup",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.2"
  },
  "devDependencies": {
    "@types/express": "^4.17.13",
    "@types/node": "^17.0.9",
    "@typescript-eslint/eslint-plugin": "^5.10.0",
    "@typescript-eslint/parser": "^5.10.0",
    "eslint": "^8.7.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "typescript": "^4.5.4"
  }
}
Run Code Online (Sandbox Code Playgroud)

我的 eslintric.js 文件:

module.exports = {
  root: true,
  parser: "@typescript-eslint/parser",
  parserOptions: {
    tsconfigRootDir: __dirname,
    project: ["./tsconfig.json"],
  },
  plugins: ["@typescript-eslint"],
  env: {
    node: true,
    jest: true,
  },
  ignorePatterns: ['.eslintrc.js'],
  extends: [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/recommended-requiring-type-checking",
    "prettier",
  ],
};
Run Code Online (Sandbox Code Playgroud)

我的 tsconfig.json 文件:

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es6",
    "noImplicitAny": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "dist",
    "baseUrl": ".",
    "paths": {
      "*": ["node_modules/*"]
    }
  },
  "include": ["Web/*"]
}
Run Code Online (Sandbox Code Playgroud)

当我在脚本中没有预构建的情况下运行npm run start时,我的应用程序可以正常工作。