remark-lint-mdx-jsx-quote-style
raw JSON → 1.0.1 verified Fri May 01 auth: no javascript
A remark-lint rule that warns when MDX JSX attribute value markers violate a configured style (single or double quotes). Current stable version is 1.0.1, released as part of the remark-lint monorepo. It is ESM-only, requires Node.js 16+, and is designed for use with the unified ecosystem. Key differentiators: it supports a 'consistent' mode to detect and enforce the first style used, and integrates with remark-mdx for auto-fixing. Unlike generic quote linters, it specifically targets MDX JSX attributes.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/remark-lint-mdx-jsx-quote-style from /path/to/project not supported. ↓
cause Using require() on an ESM-only package.
fix
Change to import: import remarkLintMdxJsxQuoteStyle from 'remark-lint-mdx-jsx-quote-style'
error TypeError: remarkLintMdxJsxQuoteStyle is not a function ↓
cause The package's default export may not be invoked correctly; usually due to incorrect import syntax.
fix
Ensure the import is correct: import remarkLintMdxJsxQuoteStyle from 'remark-lint-mdx-jsx-quote-style' and then use it with .use(remarkLintMdxJsxQuoteStyle)
error TypeError: Cannot read properties of undefined (reading 'type') ↓
cause The rule is used outside a unified pipeline or without remark-parse.
fix
Ensure the unified pipeline includes .use(remarkParse) and .use(remarkLint) before this rule.
error SyntaxError: Unexpected token 'export' at ...remark-lint-mdx-jsx-quote-style/src/index.js:1 ↓
cause Node.js version is too old (<16) to support ESM syntax.
fix
Upgrade Node.js to 16+ or use a transpiler like esbuild.
Warnings
breaking The package is ESM-only; it cannot be required with CommonJS. ↓
fix Use import or switch to a dynamic import() if using CommonJS.
breaking Node.js version must be 16 or higher. ↓
fix Upgrade Node.js to 16+ or use an older version of the package.
gotcha The default export is a function that expects a unified plugin context; using it incorrectly as a middleware can cause runtime errors. ↓
fix Always use with .use() in a unified pipeline.
gotcha The 'consistent' option (default) will detect the first quote style and enforce it, which may conflict with formatters that use a different style. ↓
fix Specify an explicit style like '"' or "'" to avoid detection uncertainty.
deprecated No deprecation warnings; the package is actively maintained. ↓
fix N/A
Install
npm install remark-lint-mdx-jsx-quote-style yarn add remark-lint-mdx-jsx-quote-style pnpm add remark-lint-mdx-jsx-quote-style Imports
- remarkLintMdxJsxQuoteStyle wrong
const { remarkLintMdxJsxQuoteStyle } = require('remark-lint-mdx-jsx-quote-style')correctimport remarkLintMdxJsxQuoteStyle from 'remark-lint-mdx-jsx-quote-style' - Options wrong
import { Options } from 'remark-lint-mdx-jsx-quote-style'correctimport type { Options } from 'remark-lint-mdx-jsx-quote-style' - Style wrong
const Style = require('remark-lint-mdx-jsx-quote-style').Stylecorrectimport type { Style } from 'remark-lint-mdx-jsx-quote-style'
Quickstart
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import remarkLint from 'remark-lint';
import remarkLintMdxJsxQuoteStyle from 'remark-lint-mdx-jsx-quote-style';
import { read } from 'to-vfile';
import { reporter } from 'vfile-reporter';
const file = await read('example.mdx');
await unified()
.use(remarkParse)
.use(remarkLint)
.use(remarkLintMdxJsxQuoteStyle, '"') // enforce double quotes
.use(remarkStringify)
.process(file);
console.error(reporter(file));