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

Auto fix for rule "first" #1040

Closed
fnknzzz opened this issue Mar 9, 2018 · 3 comments
Closed

Auto fix for rule "first" #1040

fnknzzz opened this issue Mar 9, 2018 · 3 comments

Comments

@fnknzzz
Copy link
Contributor

fnknzzz commented Mar 9, 2018

I would like to work on the rule first auto fixer. The small and controllable problem should be auto fixed. If can be merged, I may start working now. The strategy is put the no-first import declarations into the bottom of the first import declarations.

@ljharb
Copy link
Member

ljharb commented Mar 9, 2018

That sounds fine, as long as the following criteria apply:

  1. imports are never re-ordered relative to each other, even if absolute-first is set.
  2. if an import creates an identifier, and that identifier is referenced at module level before the import itself, that must also not be re-ordered.

@fnknzzz
Copy link
Contributor Author

fnknzzz commented Mar 12, 2018

About the second point.
const foo = bar; import bar from './bar.js';
This won't be re-ordered?

@fnknzzz fnknzzz closed this as completed Mar 12, 2018
@fnknzzz fnknzzz reopened this Mar 12, 2018
@ljharb
Copy link
Member

ljharb commented Mar 13, 2018

@fengkfengk correct, because that code will currently throw a TDZ error, and that error should be maintained by the autofixer.

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