remark-lint
rule to warn when the style of specifying
the URL of images and links is incorrect.
- What is this?
- When should I use this?
- Presets
- Install
- Use
- API
- Examples
- Compatibility
- Contribute
- License
This package checks for media (image and link) style: whether references or resources are used.
You can use this package to check that the style of specifying the URL of images and links is correct.
This plugin is not included in presets maintained here.
This package is ESM only. In Node.js (version 16+), install with npm:
npm install remark-lint-media-style
In Deno with esm.sh
:
import remarkLintMediaStyle from 'https://esm.sh/remark-lint-media-style@1'
In browsers with esm.sh
:
<script type="module">
import remarkLintMediaStyle from 'https://esm.sh/remark-lint-media-style@1?bundle'
</script>
On the API:
import remarkLint from 'remark-lint'
import remarkLintMediaStyle from 'remark-lint-media-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(remarkLintMediaStyle)
.use(remarkStringify)
.process(file)
console.error(reporter(file))
On the CLI:
remark --frail --use remark-lint --use remark-lint-media-style .
On the CLI in a config file (here a package.json
):
…
"remarkConfig": {
"plugins": [
…
"remark-lint",
+ "remark-lint-media-style",
…
]
}
…
This package exports no identifiers.
It exports the TypeScript types
Options
and
Style
.
The default export is
remarkLintMediaStyle
.
Warn when the style of specifying the URL of images and links is incorrect.
-
options
(Options
, default:'consistent'
) — preferred style or whether to detect the first style and warn for further differences
Transform (Transformer
from unified
).
Configuration (TypeScript type).
-
'consistent'
— detect the first used style and warn when further rules differ; “reference-reuse” cannot be detected -
Style
— style to prefer
Style (TypeScript type).
-
'reference'
— prefer references -
'reference-reuse'
— allow resources when used once, prefer references otherwise -
'resource'
— prefer resources
[Mercury][] and [Venus][].
[mercury]: https://example.com/mercury/
[venus]: https://example.com/venus/
No messages.
[Mercury](https://example.com/mercury/) and
[Venus](https://example.com/venus/).
No messages.
When configured with 'reference-reuse'
.
[Mercury](https://example.com/mercury/),
[Venus][], and [Earth][].
**[Venus][]** is the second planet from the Sun.
[venus]: https://example.com/venus/
[earth]: https://example.com/earth/
No messages.
When configured with 'reference'
.
[Mercury](https://example.com/mercury/),
[Venus](https://example.com/venus/), and
[Earth][].
[earth]: https://example.com/earth/
1:1-1:40: Unexpected resource for url `https://example.com/mercury/`, expected a definition and a reference to it
2:1-2:36: Unexpected resource for url `https://example.com/venus/`, expected a definition and a reference to it
When configured with 'resource'
.
[Mercury](https://example.com/mercury/),
[Venus](https://example.com/venus/), and
[Earth][].
[earth]: https://example.com/earth/
3:1-3:10: Unexpected reference for url `https://example.com/earth/`, expected resource
When configured with 'reference-reuse'
.
[Mercury](https://example.com/mercury/),
[Venus](https://example.com/venus/), and [Earth][].
**[Venus](https://example.com/venus/)** is the second planet from the Sun.
[earth]: https://example.com/earth/
2:1-2:36: Unexpected resource for reused url `https://example.com/venus/`, expected a definition and a reference to it
4:3-4:38: Unexpected resource for reused url `https://example.com/venus/`, expected a definition and a reference to it
When configured with 'reference-reuse'
.
[Mercury](https://example.com/mercury/).
[mercury]: https://example.com/mercury/
1:1-1:40: Unexpected resource for reused url `https://example.com/mercury/`, expected a reference to `mercury`
When configured with '🌍'
.
1:1: Unexpected value `🌍` for `options`, expected `'reference-reuse'`, `'reference'`, `'resource'`, or `'consistent'`
[mercury]: https://example.com/mercury/
[venus]: https://example.com/venus/
No messages.
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-media-style@1
,
compatible with Node.js 16.
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.