eslint-plugin-import: [import/extensions] 2.22.0 still shows `without an extension` error for importing tsx files from tsx files

Almost like #1615, but getting error on my Github CI which uses the same yarn.lock file.

    2:22  error    Missing file extension for "../../components/organisms/document"  import/extensions

my lock file:

eslint-plugin-import@^2.22.0:
  version "2.22.0"
  resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.22.0.tgz#92f7736fe1fde3e2de77623c838dd992ff5ffb7e"
  integrity sha512-66Fpf1Ln6aIS5Gr/55ts19eUuoDhAbZgnr6UxK5hbDx6l/QgQgx61AePq+BV4PP2uXQFClgMVzep5zZ94qqsxg==
  dependencies:
    array-includes "^3.1.1"
    array.prototype.flat "^1.2.3"
    contains-path "^0.1.0"
    debug "^2.6.9"
    doctrine "1.5.0"
    eslint-import-resolver-node "^0.3.3"
    eslint-module-utils "^2.6.0"
    has "^1.0.3"
    minimatch "^3.0.4"
    object.values "^1.1.1"
    read-pkg-up "^2.0.0"
    resolve "^1.17.0"
    tsconfig-paths "^3.9.0"

EDIT My yarn lock file had eslint-plugin-import@2.20.1 also present. The lint was working fine at my local system.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 16 (5 by maintainers)

Most upvoted comments

I ran into a similar issue (e.g. jsx files not registering with this rule) and adding some settings to the resolver settings fixed the issue:

Inside eslint.json:

{
"settings": {
    "import/resolver": {
      "node": {
        "extensions": [".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx"]
      }
    }
  }
}

Add the following rule:

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

hey @ljharb, I didn’t get a chance to recreate this issue. Busy with office work now. I will try to create one as soon as possible. I went ahead with 2.20.1 which solved the issue for me. (Hence closed this for now)

For future readers who have same issue: Could you please open a sandbox where the issue persists?