Skip to content

Replace null in ArrayExpression and ArrayPattern with Null node#9857

Open
fisker wants to merge 7 commits intoprettier:mainfrom
fisker:null-node
Open

Replace null in ArrayExpression and ArrayPattern with Null node#9857
fisker wants to merge 7 commits intoprettier:mainfrom
fisker:null-node

Conversation

@fisker
Copy link
Copy Markdown
Member

@fisker fisker commented Dec 10, 2020

Description

Add a dummy node for null in array, so we can attach comments. This solution should work for other similar problem, like #9787 (comment) or for(;;);

Fixes #1013
Fixes #9299

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@fisker fisker marked this pull request as ready for review December 10, 2020 10:31
}
}

function replaceNullElements(node, ast, options) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a comment that explain motivation to introduce Null node or link to this PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Contributor

@sosukesuzuki sosukesuzuki left a comment

Choose a reason for hiding this comment

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

@thorn0 Could you review?

@brody2consult
Copy link
Copy Markdown

brody2consult commented Jan 8, 2021

This solution should work for other similar problem, like #9787 (comment) or for(;;);

Are these tracked somewhere?

By for(;;) do you mean something like for(/*a*/;;)?

And I thought of one more case:

call(foo,,/*a*/,/*b*/,bar)

@fisker
Copy link
Copy Markdown
Member Author

fisker commented Jan 13, 2021

By for(;;) do you mean something like for(/a/;;)?

Yes, opened an issue to track this #10046

@so1ve
Copy link
Copy Markdown
Contributor

so1ve commented Aug 3, 2023

🤔 Still blocked?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Line comments printed incorrectly in arrays consisting only of empty slots Inline comments in list destructuring moved to wrong side of comma

4 participants