Typescript eslint - Missing file extension “ts” import/extensions

前端 未结 2 1952
孤城傲影
孤城傲影 2021-02-03 16:38

I have a simple Node/Express app made with Typescript. And eslint give me the error

Missing file extension "ts" for "./lib/env" import/extensi         


        
相关标签:
2条回答
  • 2021-02-03 17:29

    Add the following code to rules:

    "rules": {
       "import/extensions": [
          "error",
          "ignorePackages",
          {
            "js": "never",
            "jsx": "never",
            "ts": "never",
            "tsx": "never"
          }
       ]
    }
    

    airbnb ESLint config leads the problem.

    0 讨论(0)
  • 2021-02-03 17:40

    Add this to rules in your eslint config:

    "rules": {
      "import/extensions": "off"
    }
    

    This disables the rule, since airbnb's config enables it.

    0 讨论(0)
提交回复
热议问题