-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Enhance import/default to validate require('...').default
#754
Comments
In our codebase, we generally approach this by 1) convert all Can you elaborate on what "this functionality" means? If you're referring to babel's |
@ljharb thanks for the tip. For clarity, here's how I would update default.md:
Our legacy code uses a pattern I haven't been able to convert to ES modules: function (model) {
assert(model instanceof require('path/to/module'))
...
} I don't believe there's a way to do inline import and moving those to the top might generate circular dependencies. Our best bet is to keep commonJS for inline requires and make sure If the linter knows about export default here, could it be enhanced to check require statements? |
You're correct that the only way to do inline import is |
@ljharb I opened a PR with a proposal. Let me know what you think. Thanks. |
@ljharb I thought I'd try your approach and hit a wall pretty quickly. Apparently Webpack 2 isn't so happy about mixing |
Closing per #755 (comment) |
As we transition from commonJS to ES modules, we want to convert
module.exports = ...
toexport default ...
. The challenge is detecting whether commonJS requires explicitlyrequire('...').default
.I was thinking about creating a PR enhancing
import/default
with this functionality. If so, should it be on by default or configurable? If configurable, what should I name the option? Should this be a new rule altogether?Note: I'd rather clean up the source then leverage something like babel-plugin-add-module-exports.
The text was updated successfully, but these errors were encountered: