Skip to content

[Fix] order: ignore requires in template literal#1940

Merged
ljharb merged 1 commit into
import-js:masterfrom
chiawendt:issue-1936
Nov 11, 2020
Merged

[Fix] order: ignore requires in template literal#1940
ljharb merged 1 commit into
import-js:masterfrom
chiawendt:issue-1936

Conversation

@chiawendt

Copy link
Copy Markdown
Contributor

Fixes #1936.

@ljharb

ljharb commented Nov 10, 2020

Copy link
Copy Markdown
Member

Thanks! It seems like a more general fix is in order; the only requires that this rule should warn on are module-level requires, whether in a template literal or not.

@coveralls

coveralls commented Nov 10, 2020

Copy link
Copy Markdown

Coverage Status

Coverage increased (+2.5%) to 97.904% when pulling 957092a on golopot:issue-1936 into 6cd1fe1 on benmosher:master.

@chiawendt

chiawendt commented Nov 11, 2020

Copy link
Copy Markdown
Contributor Author

It sounds great to only warn on module-level requires! There are two cases I am unsure about, they are not strictly module-level requires:

const bar = require('foo').bar
const foo = require('foo')()

I handled both of them anyway, if just for backward compatibility.

@ljharb ljharb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice.

@ljharb

ljharb commented Nov 11, 2020

Copy link
Copy Markdown
Member

Those are module-level requires, even tho they're immediately destructured. Thanks for handling them!

@ljharb
ljharb merged commit 957092a into import-js:master Nov 11, 2020
@mAAdhaTTah

Copy link
Copy Markdown

@golopot Thank you for fixing!

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

import/order complains about inline requires

4 participants