Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require extension rule #252

Closed
calebmer opened this issue Apr 21, 2016 · 2 comments
Closed

Require extension rule #252

calebmer opened this issue Apr 21, 2016 · 2 comments

Comments

@calebmer
Copy link

Could a rule be created to require the addition of an extension when importing?

So for example this would be an error:

import './hello/world' // Where we are actually importing `./hello/world.js`
import './hello/star' // Where we are actually importing `./hello/star.json`
import './hello/moon' // Where we are actually importing `./hello/moon/index.js`

But the following would not be an error:

import './hello/world.js'
import './hello/star.json'
import './hello/moon/index.js'

Why? Well the import search algorithm is faster for one, not just in Node.JS, but also for Browserify, Webpack, and Haste (React Native module system). You are also guaranteed in every module system there is you will be importing the same file.

Also, if you are watching some of the conversations at nodejs/ng and nodejs/node-eps there has recently been a swell of discussion of module loading with the EPS proposing implementing ES modules in node. One point of the conversation is removing the ability for index.js to automatically be loaded, and changing other assumed aspects of loading entirely. To be completely future proof and to avoid the footguns mentioned above this rule would be very nice to have.

@benmosher
Copy link
Member

Implemented by #250, should be merged and published soon 😎

@calebmer
Copy link
Author

Nice! Awesome work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants