question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[import/extensions] 2.20.0 still shows errors for importing TS files from JS files without an extension

See original GitHub issue
C:\projects\path\to\code\ReduxDevTools.jsx
  6:40  error  Missing file extension for "../utilities/cookies"  import/extensions

This is the same error I was getting on 2.19.1 (as seen in https://github.com/benmosher/eslint-plugin-import/issues/1558). The error does not appear in 2.18.3.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:19 (1 by maintainers)

github_iconTop GitHub Comments

115reactions
Methuselah96commented, Jan 23, 2020

Nevermind, this is working correctly for when I set this in the rules:

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

and set this in the settings:

    'import/resolver': {
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx', '.json']
      }
    },

I believe in 2.18.3 it wasn’t reporting errors that it should have been reporting based on my config (I was not overriding the default import/extensions that is used in airbnb which only allows for normal JavaScript files).

13reactions
thinh105commented, Apr 30, 2020

Nevermind, this is working correctly for when I set this in the rules:

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

and set this in the settings:

    'import/resolver': {
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx', '.json']
      }
    },

I believe in 2.18.3 it wasn’t reporting errors that it should have been reporting based on my config (I was not overriding the default import/extensions that is used in airbnb which only allows for normal JavaScript files).

I got the same problem with .vue file and it took me a whole day, read every single thread about these 2 rules (import/extensions and import/no-unresolved), and still got errors.

after trying your setting, it works like a charm, and I still have no idea why 😐

here are my .eslintrc.js file

rules: {
 //...
    'import/extensions': [
      'error',
      'ignorePackages',
      {
        js: 'never',
        mjs: 'never',
        jsx: 'never',
        ts: 'never',
        tsx: 'never',
        vue: 'never',
      },
    ],
  },
  settings: {
    'import/resolver': {
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.vue'],
      },
    },
  },
Read more comments on GitHub >

github_iconTop Results From Across the Web

[import/extensions] 2.20.0 still shows errors for importing TS ...
[import/extensions] 2.20.0 still shows errors for importing TS files from JS files without an extension #1615.
Read more >
Typescript eslint - Missing file extension "ts" import/extensions
I have installed eslint-plugin-import & eslint-import-resolver-typescript. And I cannot figure out why, I got that error. node.js · typescript ...
Read more >
tsc-esm-fix - npm
src/main/ts/q/u/x/index.ts:1:21 - error TS2835: Relative import paths need explicit file ... Injects .js extensions into .d.ts libdef files.
Read more >
eslint-plugin-import | Yarn - Package Manager
This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names.
Read more >
TSConfig Reference - Docs on every TSConfig option
Intro to the TSConfig Reference. A TSConfig file in a directory indicates that the directory is the root of a TypeScript or JavaScript...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found