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

Fix overwriting of dynamic import() CallExpression #1218

Merged
merged 1 commit into from
Apr 12, 2019

Conversation

vikr01
Copy link
Contributor

@vikr01 vikr01 commented Oct 21, 2018

Closes #1035
Closes #1166

So turns out, dynamic imports were already supported in moduleVisitor but they were being overwritten if commonjs or amd options were set.

  • Fixed by saving the current CallExpression and including it in the function that's overwriting it.
  • Added test cases for import() in rules using the moduleVisitor. Not sure why, but I couldn't get the no-cycle rule to throw errors with import().
  • Fixes issues with parser babel-eslint not working with no-cycle, due to the "flow workaround" for eslint@<5

This might be breaking for some users, though.

Also since import() can work with URLs, maybe we should use something like isURL from validator to ignore URL imports?

 - fix import() to work with no-cycle
 - add tests using multiple imports in no-cycle

Fixes import-js#1035. Fixes import-js#1166.
@coveralls
Copy link

coveralls commented Oct 21, 2018

Coverage Status

Coverage decreased (-0.002%) to 97.863% when pulling 70a59fe on vikr01:fix/dynamic-import into e4850df on benmosher:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 97.349% when pulling 19f7442 on vikr01:fix/dynamic-import into b4a2f11 on benmosher:master.

tests/src/rules/no-cycle.js Outdated Show resolved Hide resolved
utils/moduleVisitor.js Show resolved Hide resolved
utils/moduleVisitor.js Show resolved Hide resolved
utils/moduleVisitor.js Outdated Show resolved Hide resolved
@edmorley
Copy link

@ljharb thank you for reviewing this and the related #1231.
Do we need a second reviewer, if so, who is best to ask? :-)

Copy link
Member

@benmosher benmosher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great, thanks! need to re-run tests for this after #1254 lands but otherwise LGTM!

@corradio
Copy link

corradio commented Apr 2, 2019

any updates here? Would be great to have this merged

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

Successfully merging this pull request may close these issues.

no-cycle rule not working with babel-eslint parser Lint Dynamic Imports for no-unresolved
6 participants