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

Created on 16 Jul 2020  路  8Comments  路  Source: benmosher/eslint-plugin-import

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 [email protected] also present. The lint was working fine at my local system.

help wanted

All 8 comments

Add the following rule:

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

Closing this. Hardcoded 2.20.1 for now. Didn't get chance to reproduce.

I'm going to reopen it; if something broke in a non-major, we need to fix it.

rules: [ "import/extensions": [ "error", "ignorePackages", { "ts": "never", "tsx": "never", "js": "never", "jsx": "never" } ], settings: { 'import/parsers': { '@typescript-eslint/parser': ['.ts', '.tsx'], }, 'import/resolver': { typescript: {}, }, "import/extensions": [ ".js", ".jsx", ".ts", ".tsx" ] }
By adding that, it worked for me, maybe help you as well.

@asimkt do those settings work for you?

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?

    "import/extensions": [
        "error",
        "ignorePackages",
        {
          "ts": "never",
          "tsx": "never",
          "js": "never",
          "jsx": "never"
        }
      ],
    settings: {
      'import/parsers': {
        '@typescript-eslint/parser': ['.ts', '.tsx'],
      },
      'import/resolver': {
        typescript: {},
      },
      "import/extensions": [
        ".js",
        ".jsx",
        ".ts",
        ".tsx"
      ]
    }

By adding that, it worked for me, maybe help you as well.

Adding the Above did not help :(

I can confirm that the error still exists. Seems like you have to do either as @doasync suggested in https://github.com/benmosher/eslint-plugin-import/issues/1857#issuecomment-660556902 or revert to a previous version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JustFly1984 picture JustFly1984  路  41Comments

nevir picture nevir  路  40Comments

steve-taylor picture steve-taylor  路  24Comments

ljharb picture ljharb  路  29Comments

yenbekbay picture yenbekbay  路  44Comments