remark-lint-mdx-jsx-quote-style
remark-lint
rule to warn when MDX JSX attribute value
markers violate a given style.
Contents
- What is this?
- When should I use this?
- Presets
- Install
- Use
- API
- Recommendation
- Fix
- Examples
- Compatibility
- Contribute
- License
What is this?
This package checks the style of MDX JSX attribute value markers.
When should I use this?
You can use this package to check that the style of MDX JSX attribute value markers is consistent.
Presets
This plugin is not included in presets maintained here.
Install
This package is ESM only. In Node.js (version 16+), install with npm:
npm install remark-lint-mdx-jsx-quote-style
In Deno with esm.sh
:
import remarkLintMdxJsxQuoteStyle from 'https://esm.sh/remark-lint-mdx-jsx-quote-style@1'
In browsers with esm.sh
:
<script type="module">
import remarkLintMdxJsxQuoteStyle from 'https://esm.sh/remark-lint-mdx-jsx-quote-style@1?bundle'
</script>
Use
On the API:
import remarkLint from 'remark-lint'
import remarkLintMdxJsxQuoteStyle from 'remark-lint-mdx-jsx-quote-style'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
import {read} from 'to-vfile'
import {unified} from 'unified'
import {reporter} from 'vfile-reporter'
const file = await read('example.md')
await unified()
.use(remarkParse)
.use(remarkLint)
.use(remarkLintMdxJsxQuoteStyle)
.use(remarkStringify)
.process(file)
console.error(reporter(file))
On the CLI:
remark --frail --use remark-lint --use remark-lint-mdx-jsx-quote-style .
On the CLI in a config file (here a package.json
):
…
"remarkConfig": {
"plugins": [
…
"remark-lint",
+ "remark-lint-mdx-jsx-quote-style",
…
]
}
…
API
This package exports no identifiers.
It exports the TypeScript types
Options
and
Style
.
The default export is
remarkLintMdxJsxQuoteStyle
.
unified().use(remarkLintMdxJsxQuoteStyle[, options])
Warn when MDX JSX attribute value markers violate a given style.
Parameters
options
(Options
, default:'consistent'
) — preferred style or whether to detect the first style and warn for further differences
Returns
Transform (Transformer
from unified
).
Options
Configuration (TypeScript type).
Type
type Options = Style | 'consistent'
Style
Style (TypeScript type).
Type
type Style = '"' | '\''
Recommendation
In HTML,
attributes are commonly written with double quotes.
It’s recommended to go with that.
To configure this rule with '"'
.
Fix
remark-mdx
formats titles with double
quotes by default.
Pass quote: "'"
to use single quotes.
Examples
ok-consistent.mdx
In
👉 Note: this example uses MDX (
remark-mdx
).
<a href="https://example.com/venus/">Venus</a> and
<a href="https://example.com/earth/">Earth</a>.
Out
No messages.
not-ok-consistent.mdx
In
👉 Note: this example uses MDX (
remark-mdx
).
<a href="https://example.com/venus/">Venus</a> and
<a href='https://example.com/earth/'>Earth</a>.
Out
2:4-2:37: Unexpected JSX quote markers `'`, expected `"`
double-quote.mdx
When configured with '"'
.
In
👉 Note: this example uses MDX (
remark-mdx
).
<a href="https://example.com/venus/">Venus</a> and
<a href='https://example.com/earth/'>Earth</a>.
Out
2:4-2:37: Unexpected JSX quote markers `'`, expected `"`
single-quote.mdx
When configured with "'"
.
In
👉 Note: this example uses MDX (
remark-mdx
).
<a href="https://example.com/venus/">Venus</a> and
<a href='https://example.com/earth/'>Earth</a>.
Out
1:4-1:37: Unexpected JSX quote markers `"`, expected `'`
other-attributes.mdx
In
👉 Note: this example uses MDX (
remark-mdx
).
<Mercury closest />,
<Venus aphelion={0.728213} />, and
<Earth {...people} />.
Out
No messages.
whitespace.mdx
When configured with '"'
.
In
👉 Note: this example uses MDX (
remark-mdx
).
<Mars symbol = "♂" />.
Out
No messages.
not-ok.mdx
When configured with '🌍'
.
Out
1:1: Unexpected value `🌍` for `options`, expected `'"'`, `"'"`, or `'consistent'`
Compatibility
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line,
remark-lint-mdx-jsx-quote-style@1
,
compatible with Node.js 16.
Contribute
See contributing.md
in remarkjs/.github
for ways
to get started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.