2 years ago

#63276

test-img

Anup Bhattarai

Error: ESLint configuration in --config is invalid

I am facing the error while using the command npm run start:

Error: ESLint configuration in --config is invalid:- Unexpected top-level property "compilerOptions".

I cannot figure out the cause of the error. I tried adding root:true and many other solutions that i stumbled upon.

My package.json File :

{
  "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"
  }
}

My eslintric.js file :

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",
  ],
};

My tsconfig.json File :

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

When I run the npm run start without the prebuild in the script my application works.

json

typescript

formatter

eslintrc

0 Answers

Your Answer

Accepted video resources