{"id":26236,"library":"remark-lint-mdx-jsx-self-close","title":"remark-lint-mdx-jsx-self-close","description":"A remark-lint rule that warns when closing tags are used for empty MDX JSX elements, enforcing self-closing syntax where possible. Current stable version is 1.0.1, released as part of the remark-lint monorepo. ESM-only, requires Node.js 16+. Ships TypeScript types. Part of the unified/remark ecosystem for linting Markdown and MDX files. Differentiates from general JSX linting by focusing specifically on MDX syntax and leveraging remark's AST.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/remarkjs/remark-lint#main","tags":["javascript","close","jsx","lint","mdx","remark","remark-lint","remark-lint-rule","rule","typescript"],"install":[{"cmd":"npm install remark-lint-mdx-jsx-self-close","lang":"bash","label":"npm"},{"cmd":"yarn add remark-lint-mdx-jsx-self-close","lang":"bash","label":"yarn"},{"cmd":"pnpm add remark-lint-mdx-jsx-self-close","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for the unified processing pipeline","package":"unified","optional":false},{"reason":"Required to use lint rules; provides the lint infrastructure","package":"remark-lint","optional":false},{"reason":"Needed for parsing Markdown/MDX input","package":"remark-parse","optional":true},{"reason":"Needed for stringifying output","package":"remark-stringify","optional":true}],"imports":[{"note":"This package is ESM-only since v1.0.0; CommonJS require is not supported.","wrong":"const remarkLintMdxJsxSelfClose = require('remark-lint-mdx-jsx-self-close')","symbol":"remarkLintMdxJsxSelfClose","correct":"import remarkLintMdxJsxSelfClose from 'remark-lint-mdx-jsx-self-close'"},{"note":"The package exports a single default function, not a named export. Named import will result in undefined.","wrong":"import { remarkLintMdxJsxSelfClose } from 'remark-lint-mdx-jsx-self-close'","symbol":"default export","correct":"import remarkLintMdxJsxSelfClose from 'remark-lint-mdx-jsx-self-close'"},{"note":"Types are bundled with the package; you can use `import remarkLintMdxJsxSelfClose from 'remark-lint-mdx-jsx-self-close'` with TypeScript and it will infer the type.","wrong":null,"symbol":"TypeScript types","correct":"import type { Plugin } from 'unified'"}],"quickstart":{"code":"import remarkLint from 'remark-lint'\nimport remarkLintMdxJsxSelfClose from 'remark-lint-mdx-jsx-self-close'\nimport remarkParse from 'remark-parse'\nimport remarkStringify from 'remark-stringify'\nimport { unified } from 'unified'\nimport { reporter } from 'vfile-reporter'\n\nconst file = await unified()\n  .use(remarkParse)\n  .use(remarkLint)\n  .use(remarkLintMdxJsxSelfClose)\n  .use(remarkStringify)\n  .process('<a href=\"https://example.com\"></a>')\n\nconsole.error(reporter(file))","lang":"typescript","description":"Demonstrates how to use the rule with the unified pipeline to lint MDX JSX self-closing tags."},"warnings":[{"fix":"Use import syntax or dynamic import(). For Node.js <16, upgrade or use an ESM-compatible runtime.","message":"Package is ESM-only starting from v1.0.0; CommonJS require() will fail.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use an additional rule like remark-lint-no-html-void-element or MDX-specific linting for void elements.","message":"The rule does not check for void elements (e.g., <br>, <img>); those are MDX-specific and may still need explicit self-closing.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your files are parsed as MDX (with remark-mdx) for the rule to work correctly.","message":"The rule only applies to JSX elements in MDX, not to HTML-like elements or custom components.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"","message":"None","severity":"deprecated","affected_versions":""}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"npm install remark-lint-mdx-jsx-self-close and use import instead of require.","cause":"Package not installed or CommonJS require used while package is ESM-only.","error":"Cannot find module 'remark-lint-mdx-jsx-self-close'"},{"fix":"Convert to import or use dynamic import().","cause":"Using require() to load an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Use import remarkLintMdxJsxSelfClose from 'remark-lint-mdx-jsx-self-close'","cause":"Named import instead of default import.","error":"TypeError: remarkLintMdxJsxSelfClose is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}