google / gts

☂️ TypeScript style guide, formatter, and linter.

Home Page:https://github.com/google/gts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"gts lint" returns an error "ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin"."

Yankee-by opened this issue · comments

"gts lint" returns an error "ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin"."

gts lint
version: 12

Oops! Something went wrong! :(

ESLint: 7.22.0

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/Users/username/WebstormProjects".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "../.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

node: v12.10

I have tried to install it manually (package.json)

{
  "name": "gsocial",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "gts lint",
    "clean": "gts clean",
    "compile": "tsc",
    "fix": "gts fix"
  },
  "devDependencies": {
    ...
    "@typescript-eslint/eslint-plugin": "^4.22.1",
    "eslint-plugin-react": "^7.23.1",
    "eslint-plugin-react-hooks": "^4.2.0",
    "gts": "^3.1.0",
    "typescript": "^4.1.3"
     ...
  }
}

tsconfig.json:

{
 "extends": "./node_modules/gts/tsconfig-google.json",
 "compilerOptions": {
   "lib": ["dom"],
   "outDir": "build",
   "allowJs": true,
   "skipLibCheck": true,
   "noEmit": true,
   "esModuleInterop": true,
   "moduleResolution": "node",
   "resolveJsonModule": true,
   "isolatedModules": true,
   "jsx": "preserve",
   "module": "esnext",
   "baseUrl": ".",
   "paths": {
     "@/*": ["src/*"],
   }
 },
 "include": [
   "src/**/*.ts",
   "test/**/*.ts",
   "next-env.d.ts",
   "**/*.ts",
   "**/*.tsx",
 ],
 "exclude": [
   "node_modules"
 ]
}

.eslintrc,json:

{
  "extends": "./node_modules/gts/",
  "overrides": [
    {
      "extends": ["plugin:react/recommended", "plugin:react-hooks/recommended"],
      "files": ["*.ts", "*.tsx"],
      "rules": {
        "@typescript-eslint/no-explicit-any": "off",
        "@typescript-eslint/no-shadow": "error",
        "no-shadow": "off",
        "react-hooks/exhaustive-deps": "warn",
        "react-hooks/rules-of-hooks": "error",
        "react/prop-types": "off"
      }
    }
  ]
}

By the error "The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/Users/username/WebstormProjects"." but it is not a project directory. It is parent dir for my projects.

for some reason eslint used the .eslintrc.json from the parent dir. fixed