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

fix: incompatible with some react rules #489

Merged
merged 15 commits into from
Dec 20, 2023
Merged

fix: incompatible with some react rules #489

merged 15 commits into from
Dec 20, 2023

Conversation

JounQin
Copy link
Member

@JounQin JounQin commented Dec 9, 2023

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

close #437
close #488


Note: This PR's target is release-v2 branch, so the release workflow should be run on release-v2 branch

cc @wooorm

@JounQin JounQin added 🐛 type/bug This is a problem 🏡 area/internal This affects the hidden internals labels Dec 9, 2023
@JounQin JounQin self-assigned this Dec 9, 2023
Copy link

changeset-bot bot commented Dec 9, 2023

🦋 Changeset detected

Latest commit: 93766b3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
eslint-mdx Patch
eslint-plugin-mdx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@JounQin JounQin marked this pull request as draft December 9, 2023 17:15
Copy link

codesandbox-ci bot commented Dec 9, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cd50b12) 100.00% compared to head (93766b3) 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##           release-v2      #489   +/-   ##
============================================
  Coverage      100.00%   100.00%           
============================================
  Files              19        19           
  Lines             188       188           
  Branches           32        32           
============================================
  Hits              188       188           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JounQin JounQin marked this pull request as ready for review December 10, 2023 16:03
@@ -363,33 +381,52 @@ runAsWorker(
processed.add(node)

function handleChildren(
node: BlockContent | MdastLiteral | PhrasingContent,
node: BlockContent | Literal | Paragraph | PhrasingContent,
Copy link
Member

Choose a reason for hiding this comment

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

  • Paragraph is in BlockContent.
  • Why is Literal there? That’s an abstract class that you most likely don’t need. What do you need? Perhaps you can replace all this with Parents from mdast?

Copy link
Member Author

Choose a reason for hiding this comment

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

For example Code in jsx:

<div>
 ```ts
 export default 'hello world'
 ```
</div>

Copy link
Member

Choose a reason for hiding this comment

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

Code is in BlockContent already

Literal is an abstract interface. It doesn’t have a type. It’s useful for tools that introduce new node types.
Code is an actual node, with a type, that extends Literal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'm using Literal for supporting all other possible Literal types.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just removed the unnecessary Code type, thanks for pointing it out.

Copy link
Member

Choose a reason for hiding this comment

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

If you want to support arbitrary literals (and parents), use Literal and Parent?

But I don’t see it as useful. I recommend using the content types

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm fixing known issues for legacy v2, your suggestion may be applied to master branch instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

@wooorm Hi, are we good to merge this PR as-is for v2 only? I'll cherry pick the commit and adopt your review on v3 later.

Copy link
Member

Choose a reason for hiding this comment

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

sure, fine to apply it later!

JSXElement['children']
>((acc, child) => {
? (
node.children as Array<BlockContent | Literal | PhrasingContent>
Copy link
Member

Choose a reason for hiding this comment

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

If you just want every node, use Nodes from mdast.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, this PR still targets release-v2 with @types/mdast v3.

packages/eslint-mdx/src/worker.ts Outdated Show resolved Hide resolved
packages/eslint-plugin-mdx/README.md Show resolved Hide resolved
@JounQin JounQin requested a review from wooorm December 16, 2023 07:04
@JounQin JounQin merged commit f9ff397 into release-v2 Dec 20, 2023
19 checks passed
@JounQin JounQin deleted the fix/437 branch December 20, 2023 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏡 area/internal This affects the hidden internals 🐛 type/bug This is a problem
Development

Successfully merging this pull request may close these issues.

None yet

3 participants