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

feat(typescript-estree): support Import Assertions #4074

Merged

Conversation

sosukesuzuki
Copy link
Contributor

@sosukesuzuki sosukesuzuki commented Oct 30, 2021

PR Checklist

Overview

Adds support for Import Assertions syntax.

Based on #4073

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @sosukesuzuki!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@bradzacher bradzacher added the AST PRs and Issues about the AST structure label Nov 2, 2021
@bradzacher bradzacher mentioned this pull request Nov 2, 2021
8 tasks
@netlify
Copy link

netlify bot commented Nov 11, 2021

✔️ Deploy Preview for typescript-eslint ready!

🔨 Explore the source changes: d78acb4

🔍 Inspect the deploy log: https://app.netlify.com/sites/typescript-eslint/deploys/618cda2f3084e10008d093a2

😎 Browse the preview: https://deploy-preview-4074--typescript-eslint.netlify.app

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

as part of this could you please also add a method to the scope-manager Referencer?

It should just be an empty method with a comment explaining like "import assertions are module metadata and thus have no variables to reference"

For example this is a similar method for PrivateIdentifier:

protected PrivateIdentifier(): void {
// private identifiers are members on classes and thus have no variables to to reference
}

This will ensure that we don't create a variable for the identifier or create any references

@@ -16,6 +16,9 @@ type AdditionalKeys = {
};

const additionalKeys: AdditionalKeys = {
// Stage 3 Import Assertions
ImportAttribute: [],
Copy link
Member

Choose a reason for hiding this comment

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

You will need to declare this so that ESLint will traverse these nodes

Suggested change
ImportAttribute: [],
ImportAttribute: ['key', 'value'],

@codecov
Copy link

codecov bot commented Nov 11, 2021

Codecov Report

Merging #4074 (d78acb4) into master (ae130f1) will increase coverage by 0.41%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #4074      +/-   ##
==========================================
+ Coverage   92.71%   93.13%   +0.41%     
==========================================
  Files         209      174      -35     
  Lines        9985     9628     -357     
  Branches     3042     3008      -34     
==========================================
- Hits         9258     8967     -291     
+ Misses        311      248      -63     
+ Partials      416      413       -3     
Flag Coverage Δ
unittest 93.13% <100.00%> (+0.41%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...pt-estree/src/ts-estree/estree-to-ts-node-types.ts 100.00% <ø> (ø)
packages/typescript-estree/src/convert.ts 98.25% <100.00%> (+<0.01%) ⬆️
...es/experimental-utils/src/ts-eslint-scope/Scope.ts
.../experimental-utils/src/ts-eslint-scope/analyze.ts
...ages/experimental-utils/src/ts-eslint/CLIEngine.ts
.../experimental-utils/src/ts-eslint/ParserOptions.ts
...ils/src/ast-utils/eslint-utils/ReferenceTracker.ts
...es/experimental-utils/src/ts-eslint-scope/index.ts
...l-utils/src/eslint-utils/batchedSingleLineTests.ts
...l-utils/src/ast-utils/eslint-utils/astUtilities.ts
... and 28 more

@sosukesuzuki sosukesuzuki marked this pull request as ready for review November 11, 2021 09:17
@sosukesuzuki
Copy link
Contributor Author

@bradzacher Thank you for your review, I've addressed your comments!

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for this!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AST PRs and Issues about the AST structure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants