Typescript – Eslint not working with the TypeScript syntax

eslinttypescript

I am trying to configure eslint for my REACT-TypeScript project. It was previously using tslint which is going to deprecate soon. I have gone through the web and finally was able to create my .eslintrc.json:

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "project": "./tsconfig.json",
    "ecmaVersion": 2018,
    "sourceType": "module"
  },
  "env": {
    "browser": true,
    "jest/globals": true
  },
  "extends": [
    "airbnb",
    "plugin:react/recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:import/typescript",
    "prettier/@typescript-eslint",
    "plugin:prettier/recommended"
  ],
  "plugins": ["@typescript-eslint", "react-hooks", "jest", "prettier"],
  "ignorePatterns": ["src/serviceWorker.ts", "src/enums.ts", "node_modules/"],

  "rules": { },
  "settings": {
    "import/extensions": [".js", ".jsx", ".ts", ".tsx"],
    "import/parsers": {
      "@typescript-eslint/parser": [".ts", ".tsx"]
    },
    "import/resolver": {
      "node": {
        "extensions": [".js", ".jsx", ".ts", ".tsx"]
      }
    }
  },
  "prettier/prettier": [
    "error",
    {
      "singleQuote": true,
      "semi": "error"
    }
  ]
}

When I run the lint command, it throws errors about the TypeScript syntax. Here are few:

enter image description here

enter image description here

All links on google are now purple and still, I can't seem to figure out what's wrong. Please help me to see this through.

Best Answer

To me your configuration seems good. If it is a Typescript error there is nothing you can do with ESLint. Just upgrade Typescript.

Just in case check this ESLint Prettier Typescript configuration which is a reference to me https://levelup.gitconnected.com/setting-up-eslint-with-prettier-typescript-and-visual-studio-code-d113bbec9857? it is close to yours

Related Topic