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.

Custom file extensions

See original GitHub issue

I’m using eslint-import-resolver-alias along with eslint-import-resolver-typescript.

I have the following alias: ["@dpStores", path.resolve(__dirname, './src/stores')]

But have the following eslint error when I try to import a types.tsx file without specifying the extension: image

If I specify the extension it works just fine. Importing files without an extension works fine when not using an alias.

This is my resolver settings in .eslintrc: "settings": { "import/resolver": { "node": true, "eslint-import-resolver-typescript": true, "alias": [ ["@dpStores", path.resolve(__dirname, './src/stores')] ] } }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
johvincommented, May 6, 2018

Version 1.1.0 is released to support custom file extensions. @Tsury You can try again with the following configuration in your .eslintrc.js file.

"settings": {
  "import/resolver": {
    "alias": {
      "map": [
        ["@dpStores", path.resolve(__dirname, './src/stores')]
      ],
      "extensions": ['.js', '.ts', '.tsx', '.d.ts', '.json']
    }
  }
}

@dhlavaty You can solve your problem with a similar configuration as above, like "extensions": ['.jsx', '.js', '.json']

1reaction
johvincommented, May 2, 2018

@Tsury Actually, eslint-import-resolver-alias uses Node.js native package resolution to find a module and does not support custom file extensions now. That’s why it works fine when you specify the extension. I’m going to add this new feature recently and hope that will be helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I make and run my own file extension? - Super User
Save a file with your custom extension. Open the file in Windows Explorer and it will ask you how to open it. Choose...
Read more >
How to create my own file extension like .odt or .doc? [closed]
The file extension is .txt which typically indicates that the file contains text data. To create your own file extension all you need...
Read more >
What is it? How to open a CUSTOM file? - FILExt
CUSTOM files mostly belong to Personal Paint by Amiga. This is a file of the form: UITEXT.xxx where the file extension denotes the...
Read more >
Create Your Own Custom File Type - C# Corner
This article describes a simple approach to creating a custom file type. In the example provided, a custom file type is created around...
Read more >
Custom file types (TMS) - Phrase
Custom file types based on XML, TXT, HTML or JSON that are defined by filename and extension can be automatically detected and imported....
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