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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer-destructuring but for default dynamic imports #2349

Open
fregante opened this issue Jan 4, 2022 · 2 comments
Open

prefer-destructuring but for default dynamic imports #2349

fregante opened this issue Jan 4, 2022 · 2 comments

Comments

@fregante
Copy link

fregante commented Jan 4, 2022

Minor style change, similar to the native prefer-destructuring, but for default.

馃憥

const confetti = (await import('confetti')).default;

馃憤

const {default: confetti} = await import('confetti');
@fregante
Copy link
Author

fregante commented Jan 4, 2022

The main reason for this is that I dislike parens around await calls, but in practice I think this leads to more readable code, especially if Prettier is used:

Before

Screen Shot 12

Here there's also #1407 making the linter complain

After

Screen Shot 13

@ljharb
Copy link
Member

ljharb commented Jan 4, 2022

The general community consensus seems to be that destructuring with renaming is less clear than the non-destructuring alternative.

Ideally this is the sort of thing that would be an option on prefer-destructuring, but i doubt eslint will accept it since it's a style change, unless there's an argument for it being "support for await import() syntax"

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