Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
prettier-plugin-mdx-no-text-child
Advanced tools
Add this plugin as a dev dependency:
NPM | Yarn |
---|---|
|
|
And that's it, Prettier will automatically load the plugin based on the package name (prettier-plugin-*
).
MDX is a markdown extension that allows insertion of JSX inside the Markdown markup. This is especially useful for referencing custom component.
Example:
# This is the header
<Info>
This is an info block.
</Info>
In MDX, the line break after the opening tag is meaningful and define what the child node is:
MDX markup | JSX result |
---|---|
|
|
MDX markup | JSX result |
|
|
As custom components are often used in MDX to wrap other elements (i.e. an image with a caption), this behavior leads to mistakes and unexpected results.
Example:
MDX markup | JSX result |
---|---|
|
|
See this issue for more context: https://github.com/mdx-js/mdx/issues/628
Prettier supports MDX since the version 1.15.0. By default, Prettier formats the previous example as is:
<Info>
This is not a **paragraph**.
But **this one** is.
+
</Info>
Prettier inserts a line break before the closing tag, but it doesn't insert a line break after the opening tag because it would change the meaning of the code (and Prettier is only about formatting).
Well, this plugin does:
<Info>
+
This is not a **paragraph**.
But **this one** is.
+
</Info>
This is a 0.x version because this plugin is currently just smart enough to suit my own needs.
To enter 1.0, it needs to be more flexible and have options to exclude specific tags, or insert line breaks only if there are multiple children.
It more need more test cases, there are a LOT of untested situations where the formatting can go wrong.
FAQs
Add this plugin as a dev dependency:
We found that prettier-plugin-mdx-no-text-child demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.