简体   繁体   中英

Eslint isn't checking .ts or .tsx files

When I run yarn lint or eslint directly, it's not checking my .ts or .tsx files at all.

Have tried fiddling with various configuration options. I've installed the appropriate plugins and parsers.

{
  "extends": ["airbnb", "eslint", "eslint:recommended", "plugin:react/recommended", "plugin:import/typescript"],
  "parser": "@typescript-eslint/parser",
  "env": {
    "browser": true
  },
  "plugins": ["react", "jsx-a11y", "import", "@typescript-eslint"],
  "parserOptions": {
    "ecmaVersion": 7,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "rules": {
    "max-len": [
      "error",
      120,
      2,
      {
        "ignoreUrls": true,
        "ignoreStrings": true,
        "ignoreComments": true,
        "ignoreTrailingComments": true,
        "ignoreRegExpLiterals": true
      }
    ],
    "import/extensions": ["error", "never", { "packages": "always" }],
    "react/jsx-filename-extension": ["warn", { "extensions": [".js", ".jsx"] }],
  },
  "settings": {
    "import/resolver": {
      "babel-module": {},
      "node": {
        "extensions": [".js", ".jsx", ".json", ".ts", ".tsx"]
      }
    },
    "import/parsers": {
      "@typescript-eslint/parser": [".ts", ".tsx"]
    }   
  }
}

If I pass --ext "ts,tsx" to eslint, the errors I get are completely off (it seems to be treating the files like JS files).

I have VSCode and VSCode seems to be linting all my files correctly (js as JS, ts and tsx as Typescript).

尝试运行yarn run eslint src/**/*.{js,ts,tsx}其中src是您想要 lint 的目录

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM