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

[Tests] no-unresolved: add tests for import() #2012

Merged
merged 1 commit into from
May 13, 2021

Conversation

davidbonnet
Copy link
Contributor

@davidbonnet davidbonnet commented Mar 24, 2021

Dynamic imports landed in EcmaScript 2020, and Eslint now parses it out of the box.
However, the AST node containing the dynamic import is an ImportExpression, which is ignored by the no-unresolved rule.

@davidbonnet davidbonnet changed the title [Fix] no-unresolved Check dynamic imports when using the built-in Eslint parser [Fix] no-unresolved: Check dynamic imports when using the built-in Eslint parser Mar 24, 2021
@ljharb
Copy link
Member

ljharb commented Mar 24, 2021

Thanks, the fix seems great. This is blocked for now on #1986, unfortunately.

@ljharb ljharb force-pushed the fix-dynamic-import branch 2 times, most recently from 1fa34fb to 834921a Compare May 12, 2021 06:50
@@ -85,7 +92,7 @@ function runResolverTests(resolver) {
options: [{ commonjs: true }] }),
],

invalid: [
invalid: [].concat(
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious why the [].concat() is needed. :)

Copy link
Member

Choose a reason for hiding this comment

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

because RuleTester requires an array of objects, so there's no way to conditionally provide an ignoreable value, so we have to use [].concat() and have the conditional helper return an empty array, since concat flatMaps over arrays.

@ljharb ljharb force-pushed the fix-dynamic-import branch 2 times, most recently from 5837636 to 14acb5b Compare May 12, 2021 15:01
@ljharb
Copy link
Member

ljharb commented May 12, 2021

@davidbonnet tests still seem to be failing here, so i think this one needs a bit more investigation. @aladdin-add if your PR can get the tests passing, that'd be great too.

@coveralls
Copy link

coveralls commented May 12, 2021

Coverage Status

Coverage increased (+1.0%) to 82.398% when pulling ad2a619 on davidbonnet:fix-dynamic-import into 96ed3c7 on benmosher:master.

@ljharb ljharb changed the title [Fix] no-unresolved: Check dynamic imports when using the built-in Eslint parser [Tests] no-unresolved: add tests for import() May 13, 2021
@ljharb ljharb changed the title [Tests] no-unresolved: add tests for import() [Tests] no-unresolved: add tests for import() May 13, 2021
@ljharb ljharb force-pushed the fix-dynamic-import branch 2 times, most recently from 9d4a107 to ad2a619 Compare May 13, 2021 19:56
@ljharb ljharb merged commit ad2a619 into import-js:master May 13, 2021
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.

4 participants