Search code examples
javascripttypescriptbuild

How to resolve "Definition for rule '@typescript-eslint/rule-name' was not found"


I'm trying to add TypeScript compilation to an existing Javascript project.

AFAIK this is supposed to be possible (even easy), and you can incrementally spread TS through the codebase. Unfortunately this isn't what I'm seeing - after adding typescript and trying to start the project, I get this error for every single file in the project:

Definition for rule '@typescript-eslint/rule-name' was not found

enter image description here

There is no instance of the string rule-name anywhere in my source code.

This is my tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": "src",
    "noImplicitAny": false,
    "sourceMap": true,
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "esModuleInterop": true,
    "jsx": "react",
    "skipLibCheck": true
  },
  "include": [
    "src",
    "types"
  ],
  "exclude": [
    "node_modules",
    "build"
  ]
}

I have tried adding "checkJs": false to the config and restarting but that doesn't change anything.

I haven't been able to track down anything online about this "rule-name" problem. It really looks like this is a placeholder text of some sort, but I can't find the source.

Can anybody suggest anything that might help me get this project to build?


Solution

  • If you're using react-app-rewired and customize-cra, you need to make sure you use disableEsLint from the latter; otherwise linting errors become typescript errors and prevent compilation.