How to resolve: "Definition for rule '@typescript-eslint/consistent-type-assertions' was not found"

ezagala picture ezagala · Sep 20, 2019 · Viewed 10.1k times · Source

My React app is not failing to compile due to the error: Definition for rule '@typescript-eslint/consistent-type-assertions' was not found

I'm kind of at a loss. I'm unable to find any current rule definitions in the project. The project was compiling initially. The error started after I restructured the app.

The app is failing to compile with error: Definition for rule '@typescript-eslint/consistent-type-assertions' was not found

packge.json -

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@types/react-dom": "16.9.0",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-router-dom": "^5.0.1",
    "react-scripts": "3.1.1",
    "styled-components": "^4.3.2",
    "typescript": "^3.5.3"
  },
  "scripts": {
    "start": "PORT=3005 react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --transformIgnorePatterns",
    "e2e": "./node_modules/.bin/cypress open"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@testing-library/dom": "^6.1.0",
    "@testing-library/jest-dom": "^4.0.1",
    "@testing-library/react": "^9.1.3",
    "@types/jest": "^24.0.18",
    "@types/lodash": "^4.14.137",
    "@types/node": "^12.7.2",
    "@types/react": "^16.9.2",
    "@types/react-router-dom": "^4.3.4",
    "@types/styled-components": "^4.1.18",
    "babel-jest": "^24.9.0",
    "cypress": "^3.4.1"
  }
}

Answer

kmgt picture kmgt · Sep 23, 2019

Just update react-scripts to version 3.1.2. I solved it by uninstall and install again. In command line:

uninstall:

npm uninstall react-scripts

and install again:

npm i react-scripts