Skip to content

Missing file extension "ts" for [...] / passing through enhanced-resolve's options. #233

Open
@Patryk-B

Description

@Patryk-B

I am trying to supply eslint-import-resolver-typescript with custom extensionAlias option. Is this the correct way:

{
  "plugins": ["import"],
  "settings": {
    "import/parsers": {
      "@typescript-eslint/parser": [".ts", ".tsx"]
    },
    "import/resolver": {
      "typescript": {
        "alwaysTryTypes": true,
        "project": "./tsconfig.json",
        
        "extensionAlias": {

          ".js": [ ".ts", ".d.ts", ".js" ],
          ".cjs": [ ".cts", ".d.cts", ".cjs" ],
          ".mjs": [ ".mts", ".d.mts", ".mjs" ],

          ".ts": [ ".js", ".d.ts", ".ts" ],
          ".cts": [ ".cjs", ".d.cts", ".cts" ],
          ".mts": [ ".mjs", ".d.mts", ".mts" ],
        }
      }
    }
  },
  "rules": {
    "import/extensions": [
      "error"
      "always",
      {
	    "ignorePackages": false
      }
    ]
  }
}

bc it doesn't seem to work...

What am i trying to achieve?

I am trying to fix Missing file extension "ts" for [...] linting error from import/extensions rule by trying to "teach" eslint-import-resolver-typescript resolver to treat ".js" as aliases for ".ts" extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions