mirror of
https://github.com/remarkjs/remark-lint.git
synced 2024-10-05 15:49:09 +03:00
Refactor docs
This commit is contained in:
parent
3d11bb50cf
commit
547188ec6f
22
package.json
22
package.json
@ -1,11 +1,12 @@
|
||||
{
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
@ -117,12 +118,17 @@
|
||||
"@ungap/structured-clone": "^1.0.0",
|
||||
"c8": "^8.0.0",
|
||||
"comment-parser": "^1.0.0",
|
||||
"control-pictures": "^2.0.0",
|
||||
"estree-util-is-identifier-name": "^3.0.0",
|
||||
"github-slugger": "^2.0.0",
|
||||
"mdast-util-find-and-replace": "^3.0.0",
|
||||
"mdast-util-from-markdown": "^2.0.0",
|
||||
"mdast-util-gfm": "^3.0.0",
|
||||
"mdast-util-to-markdown": "^2.0.0",
|
||||
"mdast-util-to-string": "^4.0.0",
|
||||
"mdast-zone": "^6.0.0",
|
||||
"micromark-extension-gfm": "^3.0.0",
|
||||
"micromark-util-normalize-identifier": "^2.0.0",
|
||||
"parse-author": "^2.0.0",
|
||||
"prettier": "^3.0.0",
|
||||
"remark": "^15.0.0",
|
||||
@ -133,6 +139,7 @@
|
||||
"remark-toc": "^9.0.0",
|
||||
"remark-validate-links": "^13.0.0",
|
||||
"strip-indent": "^4.0.0",
|
||||
"to-vfile": "^8.0.0",
|
||||
"type-coverage": "^2.0.0",
|
||||
"type-fest": "^4.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
@ -140,10 +147,13 @@
|
||||
"unist-builder": "^4.0.0",
|
||||
"unist-util-remove-position": "^5.0.0",
|
||||
"vfile": "^6.0.0",
|
||||
"vfile-find-down": "^7.0.0",
|
||||
"vfile-reporter": "^8.0.0",
|
||||
"vfile-sort": "^4.0.0",
|
||||
"xo": "^0.56.0"
|
||||
},
|
||||
"scripts": {
|
||||
"generate": "node --conditions development script/build-plugins.js && node --conditions development script/build-presets.js",
|
||||
"generate": "node --conditions development script/build-packages.js",
|
||||
"build": "tsc --build --clean && tsc --build && type-coverage",
|
||||
"format": "remark . --frail --output --quiet && prettier . --log-level warn --write && xo --fix",
|
||||
"test": "npm run build && npm run generate && npm run format && npm run test-coverage",
|
||||
@ -152,8 +162,8 @@
|
||||
},
|
||||
"prettier": {
|
||||
"bracketSpacing": false,
|
||||
"singleQuote": true,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"useTabs": false
|
||||
|
2
packages/remark-lint-blockquote-indentation/.npmrc
Normal file
2
packages/remark-lint-blockquote-indentation/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,18 +1,41 @@
|
||||
/**
|
||||
* remark-lint rule to warn when block quotes are indented too much or
|
||||
* too little.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the “indent” of block quotes: the `>` (greater than)
|
||||
* marker *and* the spaces before content.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that the “indent” of block quotes is
|
||||
* consistent.
|
||||
* Indent here is the `>` (greater than) marker and the spaces before content.
|
||||
* You can use this rule to check markdown code style.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `'consistent'`) are accepted:
|
||||
* ### `unified().use(remarkLintBlockquoteIndentation[, options])`
|
||||
*
|
||||
* * `number` (example: `2`)
|
||||
* — preferred indent of `>` and spaces before content
|
||||
* * `'consistent'`
|
||||
* — detect the first used style and warn when further block quotes differ
|
||||
* Warn when block quotes are indented too much or too little.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
* — either a preferred indent or whether to detect the first style
|
||||
* and warn for further differences
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Options = number | 'consistent'
|
||||
* ```
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
@ -34,10 +57,11 @@
|
||||
*
|
||||
* Due to this, it’s recommended to configure this rule with `2`.
|
||||
*
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-blockquote-indentation]: #unifieduseremarklintblockquoteindentation-options
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module blockquote-indentation
|
||||
* @summary
|
||||
* remark-lint rule to warn when block quotes are indented too much or
|
||||
* too little.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
|
@ -13,11 +13,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-blockquote-indentation"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-blockquote-indentation",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -25,7 +21,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-blockquote-indentation
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when block quotes are indented too much or
|
||||
[`remark-lint`][github-remark-lint] rule to warn when block quotes are indented too much or
|
||||
too little.
|
||||
|
||||
## Contents
|
||||
@ -21,7 +21,8 @@ too little.
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintBlockquoteIndentation[, config])`](#unifieduseremarklintblockquoteindentation-config)
|
||||
* [`unified().use(remarkLintBlockquoteIndentation[, options])`](#unifieduseremarklintblockquoteindentation-options)
|
||||
* [`Options`](#options)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -30,41 +31,39 @@ too little.
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the “indent” of block quotes: the `>` (greater than)
|
||||
marker *and* the spaces before content.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that the “indent” of block quotes is
|
||||
consistent.
|
||||
Indent here is the `>` (greater than) marker and the spaces before content.
|
||||
You can use this rule to check markdown code style.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `2` |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-blockquote-indentation
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintBlockquoteIndentation from 'https://esm.sh/remark-lint-blockquote-indentation@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -77,17 +76,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintBlockquoteIndentation from 'remark-lint-blockquote-indentation'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintBlockquoteIndentation)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -96,7 +99,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-blockquote-indentation example.md
|
||||
remark --frail --use remark-lint --use remark-lint-blockquote-indentation .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -117,19 +120,34 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintBlockquoteIndentation`.
|
||||
It exports the [TypeScript][typescript] type
|
||||
[`Options`][api-options].
|
||||
The default export is
|
||||
[`remarkLintBlockquoteIndentation`][api-remark-lint-blockquote-indentation].
|
||||
|
||||
### `unified().use(remarkLintBlockquoteIndentation[, config])`
|
||||
### `unified().use(remarkLintBlockquoteIndentation[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when block quotes are indented too much or too little.
|
||||
|
||||
The following options (default: `'consistent'`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `number` (example: `2`)
|
||||
— preferred indent of `>` and spaces before content
|
||||
* `'consistent'`
|
||||
— detect the first used style and warn when further block quotes differ
|
||||
* `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
— either a preferred indent or whether to detect the first style
|
||||
and warn for further differences
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Options = number | 'consistent'
|
||||
```
|
||||
|
||||
## Recommendation
|
||||
|
||||
@ -214,71 +232,79 @@ Paragraph.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-blockquote-indentation@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-options]: #options
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-blockquote-indentation.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-blockquote-indentation
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-blockquote-indentation.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-blockquote-indentation
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-blockquote-indentation]: #unifieduseremarklintblockquoteindentation-options
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-blockquote-indentation.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-blockquote-indentation
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-blockquote-indentation
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-blockquote-indentation
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-checkbox-character-style/.npmrc
Normal file
2
packages/remark-lint-checkbox-character-style/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,4 +1,11 @@
|
||||
/**
|
||||
* remark-lint rule to warn when list item checkboxes violate a given
|
||||
* style.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the character used in checkboxes.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that the style of GFM tasklists is
|
||||
@ -6,33 +13,60 @@
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `'consistent'`) are accepted:
|
||||
* ### `unified().use(remarkLintCheckboxCharacterStyle[, options])`
|
||||
*
|
||||
* * `Object` with the following fields:
|
||||
* * `checked` (`'x'`, `'X'`, or `'consistent'`, default: `'consistent'`)
|
||||
* — preferred character to use for checked checkboxes
|
||||
* * `unchecked` (`'·'` (a space), `'»'` (a tab), or `'consistent'`,
|
||||
* default: `'consistent'`)
|
||||
* — preferred character to use for unchecked checkboxes
|
||||
* * `'consistent'`
|
||||
* — detect the first used styles and warn when further checkboxes differ
|
||||
* Warn when list item checkboxes violate a given style.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
* — either preferred values or whether to detect the first styles
|
||||
* and warn for further differences
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Options = Styles | 'consistent'
|
||||
* ```
|
||||
*
|
||||
* ### `Styles`
|
||||
*
|
||||
* Styles (TypeScript type).
|
||||
*
|
||||
* ###### Fields
|
||||
*
|
||||
* * `checked` (`'X'`, `'x'`, or `'consistent'`, default: `'consistent'`)
|
||||
* — preferred style to use for checked checkboxes
|
||||
* * `unchecked` (`'␉'` (a tab), `'␠'` (a space), or `'consistent'`, default:
|
||||
* `'consistent'`)
|
||||
* — preferred style to use for unchecked checkboxes
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* It’s recommended to set `options.checked` to `'x'` (a lowercase X) as it
|
||||
* prevents an extra keyboard press and `options.unchecked` to `'·'` (a space)
|
||||
* prevents an extra keyboard press and `options.unchecked` to `'␠'` (a space)
|
||||
* to make all checkboxes align.
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* formats checked checkboxes using `'x'` (lowercase X) and unchecked checkboxes
|
||||
* using `'·'` (a space).
|
||||
* [`remark-stringify`][github-remark-stringify] formats checked checkboxes
|
||||
* using `'x'` (lowercase X) and unchecked checkboxes using `'␠'` (a space).
|
||||
*
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-checkbox-character-style]: #unifieduseremarklintcheckboxcharacterstyle-options
|
||||
* [api-styles]: #styles
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module checkbox-character-style
|
||||
* @summary
|
||||
* remark-lint rule to warn when list item checkboxes violate a given
|
||||
* style.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
@ -53,14 +87,14 @@
|
||||
*
|
||||
* - [ ] List item
|
||||
* - [ ] List item
|
||||
* - [ ]··
|
||||
* - [ ]␠␠
|
||||
* - [ ]
|
||||
*
|
||||
* @example
|
||||
* {"name": "ok.md", "config": {"unchecked": "\t"}, "gfm": true}
|
||||
*
|
||||
* - [»] List item
|
||||
* - [»] List item
|
||||
* - [␉] List item
|
||||
* - [␉] List item
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "label": "input", "gfm": true}
|
||||
@ -68,7 +102,7 @@
|
||||
* - [x] List item
|
||||
* - [X] List item
|
||||
* - [ ] List item
|
||||
* - [»] List item
|
||||
* - [␉] List item
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "label": "output", "gfm": true}
|
||||
|
@ -14,11 +14,7 @@
|
||||
"style",
|
||||
"task"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-checkbox-character-style"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-checkbox-character-style",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -26,7 +22,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-checkbox-character-style
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when list item checkboxes violate a given
|
||||
[`remark-lint`][github-remark-lint] rule to warn when list item checkboxes violate a given
|
||||
style.
|
||||
|
||||
## Contents
|
||||
@ -21,7 +21,9 @@ style.
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintCheckboxCharacterStyle[, config])`](#unifieduseremarklintcheckboxcharacterstyle-config)
|
||||
* [`unified().use(remarkLintCheckboxCharacterStyle[, options])`](#unifieduseremarklintcheckboxcharacterstyle-options)
|
||||
* [`Options`](#options)
|
||||
* [`Styles`](#styles)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Examples](#examples)
|
||||
@ -31,9 +33,7 @@ style.
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the character used in checkboxes.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
@ -42,28 +42,29 @@ consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-checkbox-character-style
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintCheckboxCharacterStyle from 'https://esm.sh/remark-lint-checkbox-character-style@4'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -76,17 +77,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintCheckboxCharacterStyle from 'remark-lint-checkbox-character-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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintCheckboxCharacterStyle)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -95,7 +100,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-checkbox-character-style example.md
|
||||
remark --frail --use remark-lint --use remark-lint-checkbox-character-style .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -116,35 +121,58 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintCheckboxCharacterStyle`.
|
||||
It exports the [TypeScript][typescript] types
|
||||
[`Options`][api-options] and
|
||||
[`Styles`][api-styles].
|
||||
The default export is
|
||||
[`remarkLintCheckboxCharacterStyle`][api-remark-lint-checkbox-character-style].
|
||||
|
||||
### `unified().use(remarkLintCheckboxCharacterStyle[, config])`
|
||||
### `unified().use(remarkLintCheckboxCharacterStyle[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when list item checkboxes violate a given style.
|
||||
|
||||
The following options (default: `'consistent'`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `Object` with the following fields:
|
||||
* `checked` (`'x'`, `'X'`, or `'consistent'`, default: `'consistent'`)
|
||||
— preferred character to use for checked checkboxes
|
||||
* `unchecked` (`'·'` (a space), `'»'` (a tab), or `'consistent'`,
|
||||
default: `'consistent'`)
|
||||
— preferred character to use for unchecked checkboxes
|
||||
* `'consistent'`
|
||||
— detect the first used styles and warn when further checkboxes differ
|
||||
* `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
— either preferred values or whether to detect the first styles
|
||||
and warn for further differences
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Options = Styles | 'consistent'
|
||||
```
|
||||
|
||||
### `Styles`
|
||||
|
||||
Styles (TypeScript type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `checked` (`'X'`, `'x'`, or `'consistent'`, default: `'consistent'`)
|
||||
— preferred style to use for checked checkboxes
|
||||
* `unchecked` (`'␉'` (a tab), `'␠'` (a space), or `'consistent'`, default:
|
||||
`'consistent'`)
|
||||
— preferred style to use for unchecked checkboxes
|
||||
|
||||
## Recommendation
|
||||
|
||||
It’s recommended to set `options.checked` to `'x'` (a lowercase X) as it
|
||||
prevents an extra keyboard press and `options.unchecked` to `'·'` (a space)
|
||||
prevents an extra keyboard press and `options.unchecked` to `'␠'` (a space)
|
||||
to make all checkboxes align.
|
||||
|
||||
## Fix
|
||||
|
||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
formats checked checkboxes using `'x'` (lowercase X) and unchecked checkboxes
|
||||
using `'·'` (a space).
|
||||
[`remark-stringify`][github-remark-stringify] formats checked checkboxes
|
||||
using `'x'` (lowercase X) and unchecked checkboxes using `'␠'` (a space).
|
||||
|
||||
## Examples
|
||||
|
||||
@ -154,7 +182,7 @@ When configured with `{ checked: 'x' }`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][github-remark-gfm]).
|
||||
|
||||
```markdown
|
||||
- [x] List item
|
||||
@ -171,7 +199,7 @@ When configured with `{ checked: 'X' }`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][github-remark-gfm]).
|
||||
|
||||
```markdown
|
||||
- [X] List item
|
||||
@ -188,14 +216,12 @@ When configured with `{ unchecked: ' ' }`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][github-remark-gfm]).
|
||||
|
||||
```markdown
|
||||
- [ ] List item
|
||||
- [ ] List item
|
||||
- [ ]··
|
||||
- [ ]␠␠
|
||||
- [ ]
|
||||
```
|
||||
|
||||
@ -209,13 +235,11 @@ When configured with `{ unchecked: '\t' }`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||
|
||||
> 👉 **Note**: `»` represents a tab.
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][github-remark-gfm]).
|
||||
|
||||
```markdown
|
||||
- [»] List item
|
||||
- [»] List item
|
||||
- [␉] List item
|
||||
- [␉] List item
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -226,15 +250,13 @@ No messages.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||
|
||||
> 👉 **Note**: `»` represents a tab.
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][github-remark-gfm]).
|
||||
|
||||
```markdown
|
||||
- [x] List item
|
||||
- [X] List item
|
||||
- [ ] List item
|
||||
- [»] List item
|
||||
- [␉] List item
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -266,73 +288,85 @@ When configured with `{ checked: '💩' }`.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-checkbox-character-style@4`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-options]: #options
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
[api-remark-lint-checkbox-character-style]: #unifieduseremarklintcheckboxcharacterstyle-options
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-checkbox-character-style.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-checkbox-character-style
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-checkbox-character-style.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-checkbox-character-style
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-styles]: #styles
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[gfm]: https://github.com/remarkjs/remark-gfm
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-checkbox-character-style.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-checkbox-character-style
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-checkbox-character-style
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-checkbox-character-style
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-gfm]: https://github.com/remarkjs/remark-gfm
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-checkbox-content-indent/.npmrc
Normal file
2
packages/remark-lint-checkbox-content-indent/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,12 +1,29 @@
|
||||
/**
|
||||
* remark-lint rule to warn when GFM tasklist checkboxes are followed by
|
||||
* more than one space.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the space after checkboxes.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that the “indent” after a GFM tasklist
|
||||
* checkbox is a single space.
|
||||
* You can use this package to check that the style of GFM tasklists is
|
||||
* a single space.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* There are no accepted options.
|
||||
* ### `unified().use(remarkLintCheckboxContentIndent)`
|
||||
*
|
||||
* Warn when GFM tasklist checkboxes are followed by more than one space.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* There are no options.
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
@ -27,13 +44,14 @@
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* formats checkboxes and the content after them with a single space between.
|
||||
* [`remark-stringify`][github-remark-stringify] formats checkboxes and the
|
||||
* content after them with a single space between.
|
||||
*
|
||||
* [api-remark-lint-checkbox-content-indent]: #unifieduseremarklintcheckboxcontentindent
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module checkbox-content-indent
|
||||
* @summary
|
||||
* remark-lint rule to warn when GFM tasklist checkboxes are followed by
|
||||
* more than one space.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
|
@ -14,11 +14,7 @@
|
||||
"rule",
|
||||
"task"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-checkbox-content-indent"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-checkbox-content-indent",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -26,7 +22,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-checkbox-content-indent
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when GFM tasklist checkboxes are followed by
|
||||
[`remark-lint`][github-remark-lint] rule to warn when GFM tasklist checkboxes are followed by
|
||||
more than one space.
|
||||
|
||||
## Contents
|
||||
@ -21,7 +21,7 @@ more than one space.
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintCheckboxContentIndent[, config])`](#unifieduseremarklintcheckboxcontentindent-config)
|
||||
* [`unified().use(remarkLintCheckboxContentIndent)`](#unifieduseremarklintcheckboxcontentindent)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Examples](#examples)
|
||||
@ -31,35 +31,34 @@ more than one space.
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the space after checkboxes.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that the “indent” after a GFM tasklist
|
||||
checkbox is a single space.
|
||||
You can use this package to check that the style of GFM tasklists is
|
||||
a single space.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is not included in a preset maintained here.
|
||||
This plugin is not included in presets maintained here.
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-checkbox-content-indent
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintCheckboxContentIndent from 'https://esm.sh/remark-lint-checkbox-content-indent@4'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -72,17 +71,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintCheckboxContentIndent from 'remark-lint-checkbox-content-indent'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintCheckboxContentIndent)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -91,7 +94,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-checkbox-content-indent example.md
|
||||
remark --frail --use remark-lint --use remark-lint-checkbox-content-indent .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -112,14 +115,21 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintCheckboxContentIndent`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintCheckboxContentIndent`][api-remark-lint-checkbox-content-indent].
|
||||
|
||||
### `unified().use(remarkLintCheckboxContentIndent[, config])`
|
||||
### `unified().use(remarkLintCheckboxContentIndent)`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when GFM tasklist checkboxes are followed by more than one space.
|
||||
|
||||
There are no accepted options.
|
||||
###### Parameters
|
||||
|
||||
There are no options.
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
@ -140,8 +150,8 @@ Due to this, it’s recommended to turn this rule on.
|
||||
|
||||
## Fix
|
||||
|
||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
formats checkboxes and the content after them with a single space between.
|
||||
[`remark-stringify`][github-remark-stringify] formats checkboxes and the
|
||||
content after them with a single space between.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -149,7 +159,7 @@ formats checkboxes and the content after them with a single space between.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][github-remark-gfm]).
|
||||
|
||||
```markdown
|
||||
- [ ] List item
|
||||
@ -166,7 +176,7 @@ No messages.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][github-remark-gfm]).
|
||||
|
||||
```markdown
|
||||
- [ ] List item
|
||||
@ -185,73 +195,81 @@ No messages.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-checkbox-content-indent@4`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-checkbox-content-indent.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-checkbox-content-indent
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-checkbox-content-indent.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-checkbox-content-indent
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-checkbox-content-indent]: #unifieduseremarklintcheckboxcontentindent
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[gfm]: https://github.com/remarkjs/remark-gfm
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-checkbox-content-indent.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-checkbox-content-indent
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-checkbox-content-indent
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-checkbox-content-indent
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-gfm]: https://github.com/remarkjs/remark-gfm
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-code-block-style/.npmrc
Normal file
2
packages/remark-lint-code-block-style/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,49 +1,75 @@
|
||||
/**
|
||||
* remark-lint rule to warn when code blocks violate a given style.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the style of code blocks.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that code blocks are consistent.
|
||||
* You can use this package to check that the style of code blocks is
|
||||
* consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `'consistent'`) are accepted:
|
||||
* ### `unified().use(remarkLintCodeBlockStyle[, options])`
|
||||
*
|
||||
* * `'fenced'`
|
||||
* — prefer fenced code blocks:
|
||||
* ````markdown
|
||||
* ```js
|
||||
* code()
|
||||
* ```
|
||||
* ````
|
||||
* * `'indented'`
|
||||
* — prefer indented code blocks:
|
||||
* ```markdown
|
||||
* code()
|
||||
* ```
|
||||
* * `'consistent'`
|
||||
* — detect the first used style and warn when further code blocks differ
|
||||
* Warn when code blocks violate a given style.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
* — preferred style or whether to detect the first style and warn for
|
||||
* further differences
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Options = Style | 'consistent'
|
||||
* ```
|
||||
*
|
||||
* ### `Style`
|
||||
*
|
||||
* Style (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Style = 'indented' | 'fenced'
|
||||
* ```
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* Indentation in markdown is complex, especially because lists and indented
|
||||
* code can interfere in unexpected ways.
|
||||
* Fenced code has more features than indented code: importantly, specifying a
|
||||
* Indentation in markdown is complex as lists and indented code interfere in
|
||||
* unexpected ways.
|
||||
* Fenced code has more features than indented code: it can specify a
|
||||
* programming language.
|
||||
* Since CommonMark took the idea of fenced code from GFM, fenced code became
|
||||
* widely supported.
|
||||
* Since CommonMark took the idea of fenced code from GFM,
|
||||
* fenced code became widely supported.
|
||||
* Due to this, it’s recommended to configure this rule with `'fenced'`.
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* formats code blocks as fenced code when they have a language flag and as
|
||||
* indented code otherwise.
|
||||
* Pass
|
||||
* [`fences: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsfences)
|
||||
* to always use fenced code.
|
||||
* [`remark-stringify`][github-remark-stringify] always formats code blocks as
|
||||
* fenced.
|
||||
* Pass `fences: false` to only use fenced code blocks when they have a
|
||||
* language and as indented code otherwise.
|
||||
*
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-code-block-style]: #unifieduseremarklintcodeblockstyle-options
|
||||
* [api-style]: #style
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module code-block-style
|
||||
* @summary
|
||||
* remark-lint rule to warn when code blocks violate a given style.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
|
@ -12,11 +12,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-code-block-style"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-code-block-style",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -24,7 +20,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-code-block-style
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when code blocks violate a given style.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when code blocks violate a given style.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +20,9 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintCodeBlockStyle[, config])`](#unifieduseremarklintcodeblockstyle-config)
|
||||
* [`unified().use(remarkLintCodeBlockStyle[, options])`](#unifieduseremarklintcodeblockstyle-options)
|
||||
* [`Options`](#options)
|
||||
* [`Style`](#style)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Examples](#examples)
|
||||
@ -30,39 +32,39 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the style of code blocks.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that code blocks are consistent.
|
||||
You can use this package to check that the style of code blocks is
|
||||
consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'fenced'` |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-code-block-style
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintCodeBlockStyle from 'https://esm.sh/remark-lint-code-block-style@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -75,17 +77,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintCodeBlockStyle from 'remark-lint-code-block-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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintCodeBlockStyle)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -94,7 +100,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-code-block-style example.md
|
||||
remark --frail --use remark-lint --use remark-lint-code-block-style .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -115,48 +121,62 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintCodeBlockStyle`.
|
||||
It exports the [TypeScript][typescript] types
|
||||
[`Options`][api-options] and
|
||||
[`Style`][api-style].
|
||||
The default export is
|
||||
[`remarkLintCodeBlockStyle`][api-remark-lint-code-block-style].
|
||||
|
||||
### `unified().use(remarkLintCodeBlockStyle[, config])`
|
||||
### `unified().use(remarkLintCodeBlockStyle[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when code blocks violate a given style.
|
||||
|
||||
The following options (default: `'consistent'`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `'fenced'`
|
||||
— prefer fenced code blocks:
|
||||
````markdown
|
||||
```js
|
||||
code()
|
||||
```
|
||||
````
|
||||
* `'indented'`
|
||||
— prefer indented code blocks:
|
||||
```markdown
|
||||
code()
|
||||
```
|
||||
* `'consistent'`
|
||||
— detect the first used style and warn when further code blocks differ
|
||||
* `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
— preferred style or whether to detect the first style and warn for
|
||||
further differences
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Options = Style | 'consistent'
|
||||
```
|
||||
|
||||
### `Style`
|
||||
|
||||
Style (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Style = 'indented' | 'fenced'
|
||||
```
|
||||
|
||||
## Recommendation
|
||||
|
||||
Indentation in markdown is complex, especially because lists and indented
|
||||
code can interfere in unexpected ways.
|
||||
Fenced code has more features than indented code: importantly, specifying a
|
||||
Indentation in markdown is complex as lists and indented code interfere in
|
||||
unexpected ways.
|
||||
Fenced code has more features than indented code: it can specify a
|
||||
programming language.
|
||||
Since CommonMark took the idea of fenced code from GFM, fenced code became
|
||||
widely supported.
|
||||
Since CommonMark took the idea of fenced code from GFM,
|
||||
fenced code became widely supported.
|
||||
Due to this, it’s recommended to configure this rule with `'fenced'`.
|
||||
|
||||
## Fix
|
||||
|
||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
formats code blocks as fenced code when they have a language flag and as
|
||||
indented code otherwise.
|
||||
Pass
|
||||
[`fences: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsfences)
|
||||
to always use fenced code.
|
||||
[`remark-stringify`][github-remark-stringify] always formats code blocks as
|
||||
fenced.
|
||||
Pass `fences: false` to only use fenced code blocks when they have a
|
||||
language and as indented code otherwise.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -278,71 +298,83 @@ When configured with `'💩'`.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-code-block-style@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-options]: #options
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
[api-remark-lint-code-block-style]: #unifieduseremarklintcodeblockstyle-options
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-code-block-style.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-code-block-style
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-code-block-style.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-code-block-style
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-style]: #style
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-code-block-style.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-code-block-style
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-code-block-style
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-code-block-style
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-definition-case/.npmrc
Normal file
2
packages/remark-lint-definition-case/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,23 +1,39 @@
|
||||
/**
|
||||
* remark-lint rule to warn when definition labels are not lowercase.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the case of definition labels.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that the labels used in definitions
|
||||
* are lowercase.
|
||||
* You can use this package to check that definition labels are consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* ### `unified().use(remarkLintDefinitionCase)`
|
||||
*
|
||||
* Warn when definition labels are not lowercase.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* There are no options.
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* Definitions and references are matched together regardless of casing.
|
||||
* Using uppercase in labels might incorrectly indicate that casing is of
|
||||
* importance.
|
||||
* Using uppercase in definition labels might incorrectly indicate that casing
|
||||
* is of importance.
|
||||
* Due to this, it’s recommended to use lowercase and turn this rule on.
|
||||
*
|
||||
* [api-remark-lint-definition-case]: #unifieduseremarklintdefinitioncase
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module definition-case
|
||||
* @summary
|
||||
* remark-lint rule to warn when definition labels are not lowercase.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
|
@ -12,11 +12,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-definition-case"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-definition-case",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -24,7 +20,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-definition-case
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when definition labels are not lowercase.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when definition labels are not lowercase.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintDefinitionCase[, config])`](#unifieduseremarklintdefinitioncase-config)
|
||||
* [`unified().use(remarkLintDefinitionCase)`](#unifieduseremarklintdefinitioncase)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -29,39 +29,37 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the case of definition labels.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that the labels used in definitions
|
||||
are lowercase.
|
||||
You can use this package to check that definition labels are consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-definition-case
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintDefinitionCase from 'https://esm.sh/remark-lint-definition-case@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -74,17 +72,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintDefinitionCase from 'remark-lint-definition-case'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintDefinitionCase)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -93,7 +95,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-definition-case example.md
|
||||
remark --frail --use remark-lint --use remark-lint-definition-case .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -114,20 +116,27 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintDefinitionCase`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintDefinitionCase`][api-remark-lint-definition-case].
|
||||
|
||||
### `unified().use(remarkLintDefinitionCase[, config])`
|
||||
### `unified().use(remarkLintDefinitionCase)`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when definition labels are not lowercase.
|
||||
|
||||
###### Parameters
|
||||
|
||||
There are no options.
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
Definitions and references are matched together regardless of casing.
|
||||
Using uppercase in labels might incorrectly indicate that casing is of
|
||||
importance.
|
||||
Using uppercase in definition labels might incorrectly indicate that casing
|
||||
is of importance.
|
||||
Due to this, it’s recommended to use lowercase and turn this rule on.
|
||||
|
||||
## Examples
|
||||
@ -160,71 +169,77 @@ No messages.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-definition-case@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-definition-case.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-definition-case
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-definition-case.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-definition-case
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-definition-case]: #unifieduseremarklintdefinitioncase
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-definition-case.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-definition-case
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-definition-case
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-definition-case
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-definition-spacing/.npmrc
Normal file
2
packages/remark-lint-definition-spacing/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,25 +1,40 @@
|
||||
/**
|
||||
* remark-lint rule to warn when consecutive whitespace is used in
|
||||
* a definition label.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the whitepsace in definition labels.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that the labels used in definitions
|
||||
* do not use meaningless white space.
|
||||
* You can use this package to check that definition labels are consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* ### `unified().use(remarkLintDefinitionSpacing)`
|
||||
*
|
||||
* Warn when consecutive whitespace is used in a definition label.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* There are no options.
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* Definitions and references are matched together by collapsing white space.
|
||||
* Using more white space in labels might incorrectly indicate that they are of
|
||||
* Definitions and references are matched together by collapsing whitespace.
|
||||
* Using more whitespace in labels might incorrectly indicate that they are of
|
||||
* importance.
|
||||
* Due to this, it’s recommended to use one space (or a line ending if needed)
|
||||
* and turn this rule on.
|
||||
* Due to this, it’s recommended to use one space and turn this rule on.
|
||||
*
|
||||
* [api-remark-lint-definition-spacing]: #unifieduseremarklintdefinitionspacing
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module definition-spacing
|
||||
* @summary
|
||||
* remark-lint rule to warn when consecutive whitespace is used in
|
||||
* a definition label.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
@ -31,7 +46,7 @@
|
||||
* @example
|
||||
* {"name": "not-ok.md", "label": "input"}
|
||||
*
|
||||
* [example····domain]: http://example.com "Example Domain"
|
||||
* [example␠␠␠␠domain]: http://example.com "Example Domain"
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "label": "output"}
|
||||
|
@ -12,11 +12,7 @@
|
||||
"rule",
|
||||
"spacing"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-definition-spacing"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-definition-spacing",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -24,7 +20,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-definition-spacing
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when consecutive whitespace is used in
|
||||
[`remark-lint`][github-remark-lint] rule to warn when consecutive whitespace is used in
|
||||
a definition label.
|
||||
|
||||
## Contents
|
||||
@ -21,7 +21,7 @@ a definition label.
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintDefinitionSpacing[, config])`](#unifieduseremarklintdefinitionspacing-config)
|
||||
* [`unified().use(remarkLintDefinitionSpacing)`](#unifieduseremarklintdefinitionspacing)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -30,39 +30,37 @@ a definition label.
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the whitepsace in definition labels.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that the labels used in definitions
|
||||
do not use meaningless white space.
|
||||
You can use this package to check that definition labels are consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-definition-spacing
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintDefinitionSpacing from 'https://esm.sh/remark-lint-definition-spacing@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -75,17 +73,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintDefinitionSpacing from 'remark-lint-definition-spacing'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintDefinitionSpacing)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -94,7 +96,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-definition-spacing example.md
|
||||
remark --frail --use remark-lint --use remark-lint-definition-spacing .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -115,22 +117,28 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintDefinitionSpacing`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintDefinitionSpacing`][api-remark-lint-definition-spacing].
|
||||
|
||||
### `unified().use(remarkLintDefinitionSpacing[, config])`
|
||||
### `unified().use(remarkLintDefinitionSpacing)`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when consecutive whitespace is used in a definition label.
|
||||
|
||||
###### Parameters
|
||||
|
||||
There are no options.
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
Definitions and references are matched together by collapsing white space.
|
||||
Using more white space in labels might incorrectly indicate that they are of
|
||||
Definitions and references are matched together by collapsing whitespace.
|
||||
Using more whitespace in labels might incorrectly indicate that they are of
|
||||
importance.
|
||||
Due to this, it’s recommended to use one space (or a line ending if needed)
|
||||
and turn this rule on.
|
||||
Due to this, it’s recommended to use one space and turn this rule on.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -150,10 +158,8 @@ No messages.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
|
||||
```markdown
|
||||
[example····domain]: http://example.com "Example Domain"
|
||||
[example␠␠␠␠domain]: http://example.com "Example Domain"
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -164,71 +170,77 @@ No messages.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-definition-spacing@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-definition-spacing.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-definition-spacing
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-definition-spacing.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-definition-spacing
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-definition-spacing]: #unifieduseremarklintdefinitionspacing
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-definition-spacing.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-definition-spacing
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-definition-spacing
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-definition-spacing
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-emphasis-marker/.npmrc
Normal file
2
packages/remark-lint-emphasis-marker/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,41 +1,79 @@
|
||||
/**
|
||||
* remark-lint rule to warn when emphasis markers are inconsistent.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the style of emphasis markers.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that emphasis markers are consistent.
|
||||
* You can use this package to check that emphasis is consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `'consistent'`) are accepted:
|
||||
* ### `unified().use(remarkLintEmphasisMarker[, options])`
|
||||
*
|
||||
* * `'*'`
|
||||
* — prefer asterisks
|
||||
* * `'_'`
|
||||
* — prefer underscores
|
||||
* * `'consistent'`
|
||||
* — detect the first used style and warn when further emphasis differs
|
||||
* Warn when emphasis markers are inconsistent.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
* — preferred style or whether to detect the first style and warn for
|
||||
* further differences
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Marker`
|
||||
*
|
||||
* Marker (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Marker = '*' | '_'
|
||||
* ```
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Options = Marker | 'consistent'
|
||||
* ```
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* Underscores and asterisks work slightly different: asterisks can form
|
||||
* emphasis in more cases than underscores.
|
||||
* Because underscores are sometimes used to represent normal underscores inside
|
||||
* words, there are extra rules supporting that.
|
||||
* Whether asterisks or underscores are used affects how and whether emphasis
|
||||
* works.
|
||||
* Underscores are sometimes used to represent normal underscores inside words,
|
||||
* so there are extra rules in markdown to support that.
|
||||
* Asterisks are not used in natural language,
|
||||
* so they don’t need these rules,
|
||||
* and thus can form emphasis in more cases.
|
||||
* Asterisks can also be used as the marker of more constructs than underscores:
|
||||
* lists.
|
||||
* Due to having simpler parsing rules, looking more like syntax, and that they
|
||||
* can be used for more constructs, it’s recommended to prefer asterisks.
|
||||
* Due to having simpler parsing rules,
|
||||
* looking more like syntax,
|
||||
* and that they can be used for more constructs,
|
||||
* it’s recommended to prefer asterisks.
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* formats emphasis with asterisks by default.
|
||||
* Pass
|
||||
* [`emphasis: '_'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsemphasis)
|
||||
* to always use underscores.
|
||||
* [`remark-stringify`][github-remark-stringify] formats emphasis with
|
||||
* asterisks by default.
|
||||
* Pass `emphasis: '_'` to always use underscores.
|
||||
*
|
||||
* [api-marker]: #marker
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-emphasis-marker]: #unifieduseremarklintemphasismarker-options
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module emphasis-marker
|
||||
* @summary
|
||||
* remark-lint rule to warn when emphasis markers are inconsistent.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
|
@ -12,11 +12,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-emphasis-marker"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-emphasis-marker",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -24,7 +20,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-emphasis-marker
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when emphasis markers are inconsistent.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when emphasis markers are inconsistent.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +20,9 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintEmphasisMarker[, config])`](#unifieduseremarklintemphasismarker-config)
|
||||
* [`unified().use(remarkLintEmphasisMarker[, options])`](#unifieduseremarklintemphasismarker-options)
|
||||
* [`Marker`](#marker)
|
||||
* [`Options`](#options)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Examples](#examples)
|
||||
@ -30,39 +32,38 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the style of emphasis markers.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that emphasis markers are consistent.
|
||||
You can use this package to check that emphasis is consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'*'` |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-emphasis-marker
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintEmphasisMarker from 'https://esm.sh/remark-lint-emphasis-marker@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -75,17 +76,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintEmphasisMarker from 'remark-lint-emphasis-marker'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintEmphasisMarker)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -94,7 +99,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-emphasis-marker example.md
|
||||
remark --frail --use remark-lint --use remark-lint-emphasis-marker .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -115,40 +120,67 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintEmphasisMarker`.
|
||||
It exports the [TypeScript][typescript] types
|
||||
[`Marker`][api-marker] and
|
||||
[`Options`][api-options].
|
||||
The default export is
|
||||
[`remarkLintEmphasisMarker`][api-remark-lint-emphasis-marker].
|
||||
|
||||
### `unified().use(remarkLintEmphasisMarker[, config])`
|
||||
### `unified().use(remarkLintEmphasisMarker[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when emphasis markers are inconsistent.
|
||||
|
||||
The following options (default: `'consistent'`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `'*'`
|
||||
— prefer asterisks
|
||||
* `'_'`
|
||||
— prefer underscores
|
||||
* `'consistent'`
|
||||
— detect the first used style and warn when further emphasis differs
|
||||
* `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
— preferred style or whether to detect the first style and warn for
|
||||
further differences
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Marker`
|
||||
|
||||
Marker (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Marker = '*' | '_'
|
||||
```
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Options = Marker | 'consistent'
|
||||
```
|
||||
|
||||
## Recommendation
|
||||
|
||||
Underscores and asterisks work slightly different: asterisks can form
|
||||
emphasis in more cases than underscores.
|
||||
Because underscores are sometimes used to represent normal underscores inside
|
||||
words, there are extra rules supporting that.
|
||||
Whether asterisks or underscores are used affects how and whether emphasis
|
||||
works.
|
||||
Underscores are sometimes used to represent normal underscores inside words,
|
||||
so there are extra rules in markdown to support that.
|
||||
Asterisks are not used in natural language,
|
||||
so they don’t need these rules,
|
||||
and thus can form emphasis in more cases.
|
||||
Asterisks can also be used as the marker of more constructs than underscores:
|
||||
lists.
|
||||
Due to having simpler parsing rules, looking more like syntax, and that they
|
||||
can be used for more constructs, it’s recommended to prefer asterisks.
|
||||
Due to having simpler parsing rules,
|
||||
looking more like syntax,
|
||||
and that they can be used for more constructs,
|
||||
it’s recommended to prefer asterisks.
|
||||
|
||||
## Fix
|
||||
|
||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
formats emphasis with asterisks by default.
|
||||
Pass
|
||||
[`emphasis: '_'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsemphasis)
|
||||
to always use underscores.
|
||||
[`remark-stringify`][github-remark-stringify] formats emphasis with
|
||||
asterisks by default.
|
||||
Pass `emphasis: '_'` to always use underscores.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -239,71 +271,83 @@ When configured with `'💩'`.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-emphasis-marker@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-marker]: #marker
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
[api-options]: #options
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-emphasis-marker.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-emphasis-marker
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-emphasis-marker.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-emphasis-marker
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-emphasis-marker]: #unifieduseremarklintemphasismarker-options
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-emphasis-marker.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-emphasis-marker
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-emphasis-marker
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-emphasis-marker
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-fenced-code-flag/.npmrc
Normal file
2
packages/remark-lint-fenced-code-flag/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,31 +1,57 @@
|
||||
/**
|
||||
* remark-lint rule to warn when language flags of fenced code
|
||||
* are not used.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the language flags of fenced code blocks,
|
||||
* whether they exist,
|
||||
* and optionally what values they hold.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that language flags of fenced code
|
||||
* are used and consistent.
|
||||
* You can use this package to check that the style of language flags of fenced
|
||||
* code blocks is consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `undefined`) are accepted:
|
||||
* ### `unified().use(remarkLintFencedCodeFlag[, options])`
|
||||
*
|
||||
* * `Array<string>`
|
||||
* — as if passing `{flags: options}`
|
||||
* * `Object` with the following fields:
|
||||
* * `allowEmpty` (`boolean`, default: `false`)
|
||||
* — allow language flags to be omitted
|
||||
* * `flags` (`Array<string>` default: `[]`)
|
||||
* — specific flags to allow (other flags will result in a warning)
|
||||
* Warn when language flags of fenced code are not used.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options] or `Array<string>`, optional)
|
||||
* — configuration or flags to allow
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* ###### Fields
|
||||
*
|
||||
* * `allowEmpty` (`boolean`, default: `false`)
|
||||
* — allow language flags to be omitted
|
||||
* * `flags` (`Array<string>`, optional)
|
||||
* — flags to allow,
|
||||
* other flags will result in a warning
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* While omitting the language flag is perfectly fine to signal that the code is
|
||||
* plain text, it *could* point to a mistake.
|
||||
* It’s recommended to instead use a certain flag for plain text (such as `txt`)
|
||||
* and to turn this rule on.
|
||||
* While omitting language flags is fine to signal that code is plain text,
|
||||
* it *could* point to a mistake.
|
||||
* It’s recommended to instead use a certain flag for plain text (such as
|
||||
* `txt`) and to turn this rule on.
|
||||
*
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-fenced-code-flag]: #unifieduseremarklintfencedcodeflag-options
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module fenced-code-flag
|
||||
* @summary
|
||||
* remark-lint rule to check that language flags of fenced code are used.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
@ -100,18 +126,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef FlagMap
|
||||
* @typedef Options
|
||||
* Configuration.
|
||||
* @property {boolean | null | undefined} [allowEmpty=false]
|
||||
* Allow language flags to be omitted (default: `false`).
|
||||
* @property {Flags | null | undefined} [flags]
|
||||
* Language flags (optional).
|
||||
*
|
||||
* @typedef {Array<string>} Flags
|
||||
* Language flags.
|
||||
*
|
||||
* @typedef {FlagMap | Flags} Options
|
||||
* Configuration.
|
||||
* @property {ReadonlyArray<string> | null | undefined} [flags]
|
||||
* Flags to allow,
|
||||
* other flags will result in a warning (optional).
|
||||
*/
|
||||
|
||||
import {lintRule} from 'unified-lint-rule'
|
||||
@ -119,6 +140,8 @@ import {pointEnd, pointStart} from 'unist-util-position'
|
||||
import {visit} from 'unist-util-visit'
|
||||
|
||||
const fence = /^ {0,3}([~`])\1{2,}/
|
||||
/** @type {ReadonlyArray<string>} */
|
||||
const emptyFlags = []
|
||||
|
||||
const remarkLintFencedCodeFlag = lintRule(
|
||||
{
|
||||
@ -128,25 +151,27 @@ const remarkLintFencedCodeFlag = lintRule(
|
||||
/**
|
||||
* @param {Root} tree
|
||||
* Tree.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @param {Readonly<Options> | ReadonlyArray<string> | null | undefined} [options]
|
||||
* Configuration or flags to allow (optional).
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
*/
|
||||
function (tree, file, options) {
|
||||
const value = String(file)
|
||||
let allowEmpty = false
|
||||
/** @type {Array<string>} */
|
||||
let allowed = []
|
||||
let allowed = emptyFlags
|
||||
|
||||
if (options && typeof options === 'object') {
|
||||
// Note: casts because `isArray` and `readonly` don’t mix.
|
||||
if (Array.isArray(options)) {
|
||||
allowed = options
|
||||
const flags = /** @type {ReadonlyArray<string>} */ (options)
|
||||
allowed = flags
|
||||
} else {
|
||||
allowEmpty = Boolean(options.allowEmpty)
|
||||
const settings = /** @type {Options} */ (options)
|
||||
allowEmpty = Boolean(settings.allowEmpty)
|
||||
|
||||
if (options.flags) {
|
||||
allowed = options.flags
|
||||
if (settings.flags) {
|
||||
allowed = settings.flags
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-fenced-code-flag"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-flag",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -26,7 +22,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,16 @@
|
||||
|
||||
# remark-lint-fenced-code-flag
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to check that language flags of fenced code are used.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when language flags of fenced code
|
||||
are not used.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +21,8 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintFencedCodeFlag[, config])`](#unifieduseremarklintfencedcodeflag-config)
|
||||
* [`unified().use(remarkLintFencedCodeFlag[, options])`](#unifieduseremarklintfencedcodeflag-options)
|
||||
* [`Options`](#options)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -29,39 +31,40 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the language flags of fenced code blocks,
|
||||
whether they exist,
|
||||
and optionally what values they hold.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that language flags of fenced code
|
||||
are used and consistent.
|
||||
You can use this package to check that the style of language flags of fenced
|
||||
code blocks is consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `{ allowEmpty: false }` |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-fenced-code-flag
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintFencedCodeFlag from 'https://esm.sh/remark-lint-fenced-code-flag@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -74,17 +77,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintFencedCodeFlag from 'remark-lint-fenced-code-flag'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintFencedCodeFlag)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -93,7 +100,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-fenced-code-flag example.md
|
||||
remark --frail --use remark-lint --use remark-lint-fenced-code-flag .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -114,29 +121,42 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintFencedCodeFlag`.
|
||||
It exports the [TypeScript][typescript] type
|
||||
[`Options`][api-options].
|
||||
The default export is
|
||||
[`remarkLintFencedCodeFlag`][api-remark-lint-fenced-code-flag].
|
||||
|
||||
### `unified().use(remarkLintFencedCodeFlag[, config])`
|
||||
### `unified().use(remarkLintFencedCodeFlag[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when language flags of fenced code are not used.
|
||||
|
||||
The following options (default: `undefined`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `Array<string>`
|
||||
— as if passing `{flags: options}`
|
||||
* `Object` with the following fields:
|
||||
* `allowEmpty` (`boolean`, default: `false`)
|
||||
— allow language flags to be omitted
|
||||
* `flags` (`Array<string>` default: `[]`)
|
||||
— specific flags to allow (other flags will result in a warning)
|
||||
* `options` ([`Options`][api-options] or `Array<string>`, optional)
|
||||
— configuration or flags to allow
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `allowEmpty` (`boolean`, default: `false`)
|
||||
— allow language flags to be omitted
|
||||
* `flags` (`Array<string>`, optional)
|
||||
— flags to allow,
|
||||
other flags will result in a warning
|
||||
|
||||
## Recommendation
|
||||
|
||||
While omitting the language flag is perfectly fine to signal that the code is
|
||||
plain text, it *could* point to a mistake.
|
||||
It’s recommended to instead use a certain flag for plain text (such as `txt`)
|
||||
and to turn this rule on.
|
||||
While omitting language flags is fine to signal that code is plain text,
|
||||
it *could* point to a mistake.
|
||||
It’s recommended to instead use a certain flag for plain text (such as
|
||||
`txt`) and to turn this rule on.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -256,71 +276,79 @@ bravo()
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-fenced-code-flag@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-options]: #options
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-fenced-code-flag.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-fenced-code-flag
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-fenced-code-flag.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-fenced-code-flag
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-fenced-code-flag]: #unifieduseremarklintfencedcodeflag-options
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-fenced-code-flag.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-fenced-code-flag
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-fenced-code-flag
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-fenced-code-flag
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-fenced-code-marker/.npmrc
Normal file
2
packages/remark-lint-fenced-code-marker/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,35 +1,70 @@
|
||||
/**
|
||||
* remark-lint rule to warn when fenced code markers are
|
||||
* inconsistent.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks fenced code block markers.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that fenced code markers are consistent.
|
||||
* You can use this package to check that fenced code block markers are
|
||||
* consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `'consistent'`) are accepted:
|
||||
* ### `unified().use(remarkLintFencedCodeMarker[, options])`
|
||||
*
|
||||
* * ``'`'``
|
||||
* — prefer grave accents
|
||||
* * `'~'`
|
||||
* — prefer tildes
|
||||
* * `'consistent'`
|
||||
* — detect the first used style and warn when further fenced code differs
|
||||
* Warn when fenced code markers are inconsistent.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
* — preferred style or whether to detect the first style and warn for
|
||||
* further differences
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Marker`
|
||||
*
|
||||
* Marker (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Marker = '`' | '~'
|
||||
* ```
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Options = Marker | 'consistent'
|
||||
* ```
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* Tildes are extremely uncommon.
|
||||
* Due to this, it’s recommended to configure this rule with ``'`'``.
|
||||
* Tildes are uncommon.
|
||||
* So it’s recommended to configure this rule with ``'`'``.
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* formats fenced code with grave accents by default.
|
||||
* Pass
|
||||
* [`fence: '~'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsfence)
|
||||
* to always use tildes.
|
||||
* [`remark-stringify`][github-remark-stringify] formats fenced code with grave
|
||||
* accents by default.
|
||||
* Pass `fence: '~'` to always use tildes.
|
||||
*
|
||||
* [api-marker]: #marker
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-fenced-code-marker]: #unifieduseremarklintfencedcodemarker-options
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module fenced-code-marker
|
||||
* @summary
|
||||
* remark-lint rule to warn when fenced code markers are inconsistent.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
|
@ -13,11 +13,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-fenced-code-marker"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-marker",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -25,7 +21,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,16 @@
|
||||
|
||||
# remark-lint-fenced-code-marker
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when fenced code markers are inconsistent.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when fenced code markers are
|
||||
inconsistent.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +21,9 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintFencedCodeMarker[, config])`](#unifieduseremarklintfencedcodemarker-config)
|
||||
* [`unified().use(remarkLintFencedCodeMarker[, options])`](#unifieduseremarklintfencedcodemarker-options)
|
||||
* [`Marker`](#marker)
|
||||
* [`Options`](#options)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Examples](#examples)
|
||||
@ -30,39 +33,39 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks fenced code block markers.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that fenced code markers are consistent.
|
||||
You can use this package to check that fenced code block markers are
|
||||
consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | ``'`'`` |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-fenced-code-marker
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintFencedCodeMarker from 'https://esm.sh/remark-lint-fenced-code-marker@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -75,17 +78,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintFencedCodeMarker from 'remark-lint-fenced-code-marker'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintFencedCodeMarker)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -94,7 +101,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-fenced-code-marker example.md
|
||||
remark --frail --use remark-lint --use remark-lint-fenced-code-marker .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -115,34 +122,56 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintFencedCodeMarker`.
|
||||
It exports the [TypeScript][typescript] types
|
||||
[`Marker`][api-marker] and
|
||||
[`Options`][api-options].
|
||||
The default export is
|
||||
[`remarkLintFencedCodeMarker`][api-remark-lint-fenced-code-marker].
|
||||
|
||||
### `unified().use(remarkLintFencedCodeMarker[, config])`
|
||||
### `unified().use(remarkLintFencedCodeMarker[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when fenced code markers are inconsistent.
|
||||
|
||||
The following options (default: `'consistent'`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* ``'`'``
|
||||
— prefer grave accents
|
||||
* `'~'`
|
||||
— prefer tildes
|
||||
* `'consistent'`
|
||||
— detect the first used style and warn when further fenced code differs
|
||||
* `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
— preferred style or whether to detect the first style and warn for
|
||||
further differences
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Marker`
|
||||
|
||||
Marker (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Marker = '`' | '~'
|
||||
```
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Options = Marker | 'consistent'
|
||||
```
|
||||
|
||||
## Recommendation
|
||||
|
||||
Tildes are extremely uncommon.
|
||||
Due to this, it’s recommended to configure this rule with ``'`'``.
|
||||
Tildes are uncommon.
|
||||
So it’s recommended to configure this rule with ``'`'``.
|
||||
|
||||
## Fix
|
||||
|
||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
formats fenced code with grave accents by default.
|
||||
Pass
|
||||
[`fence: '~'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsfence)
|
||||
to always use tildes.
|
||||
[`remark-stringify`][github-remark-stringify] formats fenced code with grave
|
||||
accents by default.
|
||||
Pass `fence: '~'` to always use tildes.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -252,71 +281,83 @@ When configured with `'💩'`.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-fenced-code-marker@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-marker]: #marker
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
[api-options]: #options
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-fenced-code-marker.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-fenced-code-marker
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-fenced-code-marker.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-fenced-code-marker
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-fenced-code-marker]: #unifieduseremarklintfencedcodemarker-options
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-fenced-code-marker.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-fenced-code-marker
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-fenced-code-marker
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-fenced-code-marker
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-file-extension/.npmrc
Normal file
2
packages/remark-lint-file-extension/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,18 +1,32 @@
|
||||
/**
|
||||
* remark-lint rule to warn for unexpected file extensions.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the file extension.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that file extensions are `md`.
|
||||
* You can use this package to check that file extensions are consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `'md'`) are accepted:
|
||||
* ### `unified().use(remarkLintFileExtension[, options])`
|
||||
*
|
||||
* * `string` (example `'markdown'`)
|
||||
* — preferred file extension (no dot)
|
||||
* Warn for unexpected extensions.
|
||||
*
|
||||
* > 👉 **Note**: does not warn when files have no file extensions (such as
|
||||
* > `AUTHORS` or `LICENSE`).
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` (`string`, default: `'md'`)
|
||||
* — preferred file extension
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* Use `md` as it’s the most common.
|
||||
@ -20,9 +34,10 @@
|
||||
* GFM, frontmatter, or math).
|
||||
* Do not use `md` for MDX: use `mdx` instead.
|
||||
*
|
||||
* [api-remark-lint-file-extension]: #unifieduseremarklintfileextension-options
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module file-extension
|
||||
* @summary
|
||||
* remark-lint rule to check the file extension.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
@ -45,11 +60,6 @@
|
||||
* @typedef {import('mdast').Root} Root
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {string} Options
|
||||
* Configuration.
|
||||
*/
|
||||
|
||||
import {lintRule} from 'unified-lint-rule'
|
||||
|
||||
const remarkLintFileExtension = lintRule(
|
||||
@ -60,7 +70,7 @@ const remarkLintFileExtension = lintRule(
|
||||
/**
|
||||
* @param {Root} _
|
||||
* Tree.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* @param {string | null | undefined} [options='md']
|
||||
* Configuration (default: `'md'`).
|
||||
* @returns {undefined}
|
||||
* Nothing.
|
||||
|
@ -13,11 +13,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-file-extension"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-file-extension",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -25,7 +21,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-file-extension
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to check the file extension.
|
||||
[`remark-lint`][github-remark-lint] rule to warn for unexpected file extensions.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintFileExtension[, config])`](#unifieduseremarklintfileextension-config)
|
||||
* [`unified().use(remarkLintFileExtension[, options])`](#unifieduseremarklintfileextension-options)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -29,38 +29,37 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the file extension.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that file extensions are `md`.
|
||||
You can use this package to check that file extensions are consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'md'` |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-file-extension
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintFileExtension from 'https://esm.sh/remark-lint-file-extension@2'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -73,17 +72,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintFileExtension from 'remark-lint-file-extension'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintFileExtension)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -92,7 +95,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-file-extension example.md
|
||||
remark --frail --use remark-lint --use remark-lint-file-extension .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -113,21 +116,26 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintFileExtension`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintFileExtension`][api-remark-lint-file-extension].
|
||||
|
||||
### `unified().use(remarkLintFileExtension[, config])`
|
||||
### `unified().use(remarkLintFileExtension[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
|
||||
The following options (default: `'md'`) are accepted:
|
||||
|
||||
* `string` (example `'markdown'`)
|
||||
— preferred file extension (no dot)
|
||||
Warn for unexpected extensions.
|
||||
|
||||
> 👉 **Note**: does not warn when files have no file extensions (such as
|
||||
> `AUTHORS` or `LICENSE`).
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `options` (`string`, default: `'md'`)
|
||||
— preferred file extension
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
Use `md` as it’s the most common.
|
||||
@ -167,71 +175,77 @@ No messages.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-file-extension@2`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-file-extension.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-file-extension
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-file-extension.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-file-extension
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-file-extension]: #unifieduseremarklintfileextension-options
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-file-extension.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-file-extension
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-file-extension
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-file-extension
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-final-definition/.npmrc
Normal file
2
packages/remark-lint-final-definition/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,23 +1,40 @@
|
||||
/**
|
||||
* remark-lint rule to warn when definitions are used *in* the
|
||||
* document instead of at the end.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks where definitions are placed.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that definitions are placed at the end of
|
||||
* the document.
|
||||
* You can use this package to check that definitions are consistently at the
|
||||
* end of the document.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* ### `unified().use(remarkLintFinalDefinition)`
|
||||
*
|
||||
* Warn when definitions are used *in* the document instead of at the end.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* There are no options.
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* There are different strategies for placing definitions.
|
||||
* The simplest is perhaps to place them all at the bottem of documents.
|
||||
* If you prefer that, turn on this rule.
|
||||
*
|
||||
* [api-remark-lint-final-definition]: #unifieduseremarklintfinaldefinition
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module final-definition
|
||||
* @summary
|
||||
* remark-lint rule to warn when definitions are used *in* the document
|
||||
* instead of at the end.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
|
@ -13,11 +13,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-final-definition"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-final-definition",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -25,7 +21,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,16 +2,16 @@
|
||||
|
||||
# remark-lint-final-definition
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when definitions are used *in* the document
|
||||
instead of at the end.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when definitions are used *in* the
|
||||
document instead of at the end.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -21,7 +21,7 @@ instead of at the end.
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintFinalDefinition[, config])`](#unifieduseremarklintfinaldefinition-config)
|
||||
* [`unified().use(remarkLintFinalDefinition)`](#unifieduseremarklintfinaldefinition)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -30,39 +30,38 @@ instead of at the end.
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks where definitions are placed.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that definitions are placed at the end of
|
||||
the document.
|
||||
You can use this package to check that definitions are consistently at the
|
||||
end of the document.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-final-definition
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintFinalDefinition from 'https://esm.sh/remark-lint-final-definition@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -75,17 +74,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintFinalDefinition from 'remark-lint-final-definition'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintFinalDefinition)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -94,7 +97,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-final-definition example.md
|
||||
remark --frail --use remark-lint --use remark-lint-final-definition .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -115,15 +118,22 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintFinalDefinition`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintFinalDefinition`][api-remark-lint-final-definition].
|
||||
|
||||
### `unified().use(remarkLintFinalDefinition[, config])`
|
||||
### `unified().use(remarkLintFinalDefinition)`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when definitions are used *in* the document instead of at the end.
|
||||
|
||||
###### Parameters
|
||||
|
||||
There are no options.
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
There are different strategies for placing definitions.
|
||||
@ -184,71 +194,77 @@ No messages.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-final-definition@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-final-definition.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-final-definition
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-final-definition.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-final-definition
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-final-definition]: #unifieduseremarklintfinaldefinition
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-final-definition.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-final-definition
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-final-definition
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-final-definition
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-final-newline/.npmrc
Normal file
2
packages/remark-lint-final-newline/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,23 +1,43 @@
|
||||
/**
|
||||
* remark-lint rule to warn when a final line ending is missing.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the final line ending.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that fenced code markers are consistent.
|
||||
* You can use this package to check final line endings.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* ### `unified().use(remarkLintFinalNewline)`
|
||||
*
|
||||
* Warn when a final line ending is missing.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* There are no options.
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* Turn this rule on.
|
||||
* See [StackExchange](https://unix.stackexchange.com/questions/18743) for more
|
||||
* info.
|
||||
* See [StackExchange][] for more info.
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* always adds final line endings.
|
||||
*
|
||||
* [api-remark-lint-final-newline]: #unifieduseremarklintfinalnewline
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
* [stackexchange]: https://unix.stackexchange.com/questions/18743
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* ##### `ok.md`
|
||||
@ -51,8 +71,6 @@
|
||||
* ```
|
||||
*
|
||||
* @module final-newline
|
||||
* @summary
|
||||
* remark-lint rule to warn when files don’t end in a newline.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
|
@ -13,11 +13,7 @@
|
||||
"rule",
|
||||
"unix"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-final-newline"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-final-newline",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -25,7 +21,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-final-newline
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when files don’t end in a newline.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when a final line ending is missing.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintFinalNewline[, config])`](#unifieduseremarklintfinalnewline-config)
|
||||
* [`unified().use(remarkLintFinalNewline)`](#unifieduseremarklintfinalnewline)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Example](#example)
|
||||
@ -30,38 +30,37 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the final line ending.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that fenced code markers are consistent.
|
||||
You can use this package to check final line endings.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-final-newline
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintFinalNewline from 'https://esm.sh/remark-lint-final-newline@2'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -74,17 +73,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintFinalNewline from 'remark-lint-final-newline'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintFinalNewline)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -93,7 +96,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-final-newline example.md
|
||||
remark --frail --use remark-lint --use remark-lint-final-newline .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -114,20 +117,26 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintFinalNewline`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintFinalNewline`][api-remark-lint-final-newline].
|
||||
|
||||
### `unified().use(remarkLintFinalNewline[, config])`
|
||||
### `unified().use(remarkLintFinalNewline)`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when a final line ending is missing.
|
||||
|
||||
###### Parameters
|
||||
|
||||
There are no options.
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
Turn this rule on.
|
||||
See [StackExchange](https://unix.stackexchange.com/questions/18743) for more
|
||||
info.
|
||||
See [StackExchange][] for more info.
|
||||
|
||||
## Fix
|
||||
|
||||
@ -168,71 +177,79 @@ Bravo␀
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-final-newline@2`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-final-newline.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-final-newline
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-final-newline.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-final-newline
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-final-newline]: #unifieduseremarklintfinalnewline
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-final-newline.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-final-newline
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-final-newline
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-final-newline
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[stackexchange]: https://unix.stackexchange.com/questions/18743
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-first-heading-level/.npmrc
Normal file
2
packages/remark-lint-first-heading-level/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,26 +1,65 @@
|
||||
/**
|
||||
* remark-lint rule to warn when the first heading has an unexpected rank.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the rank of the first heading.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check the heading rank of the first heading.
|
||||
* You can use this package to check that the rank of first headings is
|
||||
* consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `1`) are accepted:
|
||||
* ### `unified().use(remarkLintFirstHeadingLevel[, options])`
|
||||
*
|
||||
* * `number` (example `1`)
|
||||
* — expected rank of first heading
|
||||
* Warn when the first heading has an unexpected rank.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options], default: `1`)
|
||||
* — configuration
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Depth`
|
||||
*
|
||||
* Depth (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Depth = 1 | 2 | 3 | 4 | 5 | 6
|
||||
* ```
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Options = Depth
|
||||
* ```
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* In most cases you’d want to first heading in a markdown document to start at
|
||||
* rank 1.
|
||||
* In some cases a different rank makes more sense, such as when building a blog
|
||||
* and generating the primary heading from frontmatter metadata, in which case
|
||||
* a value of `2` can be defined here.
|
||||
* rank `1`.
|
||||
* In some cases a different rank makes more sense,
|
||||
* such as when building a blog and generating the primary heading from
|
||||
* frontmatter metadata,
|
||||
* in which case a value of `2` can be defined here.
|
||||
*
|
||||
* [api-depth]: #depth
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-first-heading-level]: #unifieduseremarklintfirstheadinglevel-options
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module first-heading-level
|
||||
* @summary
|
||||
* remark-lint rule to warn when the first heading has an unexpected rank.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
|
@ -14,11 +14,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-first-heading-level"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-first-heading-level",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -26,7 +22,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-first-heading-level
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when the first heading has an unexpected rank.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when the first heading has an unexpected rank.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +20,9 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintFirstHeadingLevel[, config])`](#unifieduseremarklintfirstheadinglevel-config)
|
||||
* [`unified().use(remarkLintFirstHeadingLevel[, options])`](#unifieduseremarklintfirstheadinglevel-options)
|
||||
* [`Depth`](#depth)
|
||||
* [`Options`](#options)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -29,34 +31,34 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the rank of the first heading.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check the heading rank of the first heading.
|
||||
You can use this package to check that the rank of first headings is
|
||||
consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is not included in a preset maintained here.
|
||||
This plugin is not included in presets maintained here.
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-first-heading-level
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintFirstHeadingLevel from 'https://esm.sh/remark-lint-first-heading-level@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -69,17 +71,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintFirstHeadingLevel from 'remark-lint-first-heading-level'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintFirstHeadingLevel)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -88,7 +94,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-first-heading-level example.md
|
||||
remark --frail --use remark-lint --use remark-lint-first-heading-level .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -109,25 +115,53 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintFirstHeadingLevel`.
|
||||
It exports the [TypeScript][typescript] types
|
||||
[`Depth`][api-depth] and
|
||||
[`Options`][api-options].
|
||||
The default export is
|
||||
[`remarkLintFirstHeadingLevel`][api-remark-lint-first-heading-level].
|
||||
|
||||
### `unified().use(remarkLintFirstHeadingLevel[, config])`
|
||||
### `unified().use(remarkLintFirstHeadingLevel[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when the first heading has an unexpected rank.
|
||||
|
||||
The following options (default: `1`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `number` (example `1`)
|
||||
— expected rank of first heading
|
||||
* `options` ([`Options`][api-options], default: `1`)
|
||||
— configuration
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Depth`
|
||||
|
||||
Depth (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Depth = 1 | 2 | 3 | 4 | 5 | 6
|
||||
```
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Options = Depth
|
||||
```
|
||||
|
||||
## Recommendation
|
||||
|
||||
In most cases you’d want to first heading in a markdown document to start at
|
||||
rank 1.
|
||||
In some cases a different rank makes more sense, such as when building a blog
|
||||
and generating the primary heading from frontmatter metadata, in which case
|
||||
a value of `2` can be defined here.
|
||||
rank `1`.
|
||||
In some cases a different rank makes more sense,
|
||||
such as when building a blog and generating the primary heading from
|
||||
frontmatter metadata,
|
||||
in which case a value of `2` can be defined here.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -273,71 +307,81 @@ Paragraph.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-first-heading-level@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-depth]: #depth
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
[api-options]: #options
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-first-heading-level.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-first-heading-level
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-first-heading-level.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-first-heading-level
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-first-heading-level]: #unifieduseremarklintfirstheadinglevel-options
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-first-heading-level.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-first-heading-level
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-first-heading-level
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-first-heading-level
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-hard-break-spaces/.npmrc
Normal file
2
packages/remark-lint-hard-break-spaces/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,36 +1,53 @@
|
||||
/**
|
||||
* remark-lint rule to warn when more spaces are used than needed
|
||||
* for hard breaks.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the whitespace of hard breaks.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that hard breaks use two spaces and
|
||||
* not more.
|
||||
* You can use this package to check that the number of spaces in hard breaks
|
||||
* are consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* ### `unified().use(remarkLintHardBreakSpaces)`
|
||||
*
|
||||
* Warn when more spaces are used than needed for hard breaks.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* There are no options.
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* Less than two spaces do not create a hard breaks and more than two spaces
|
||||
* have no effect.
|
||||
* Due to this, it’s recommended to turn this rule on.
|
||||
*
|
||||
* [api-remark-lint-hard-break-spaces]: #unifieduseremarklinthardbreakspaces
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module hard-break-spaces
|
||||
* @summary
|
||||
* remark-lint rule to warn when more spaces are used than needed
|
||||
* for hard breaks.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
* @example
|
||||
* {"name": "ok.md"}
|
||||
*
|
||||
* Lorem ipsum··
|
||||
* Lorem ipsum␠␠
|
||||
* dolor sit amet
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "label": "input"}
|
||||
*
|
||||
* Lorem ipsum···
|
||||
* Lorem ipsum␠␠␠
|
||||
* dolor sit amet.
|
||||
*
|
||||
* @example
|
||||
|
@ -14,11 +14,7 @@
|
||||
"size",
|
||||
"spaces"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-hard-break-spaces"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-hard-break-spaces",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -26,7 +22,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-hard-break-spaces
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when more spaces are used than needed
|
||||
[`remark-lint`][github-remark-lint] rule to warn when more spaces are used than needed
|
||||
for hard breaks.
|
||||
|
||||
## Contents
|
||||
@ -21,7 +21,7 @@ for hard breaks.
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintHardBreakSpaces[, config])`](#unifieduseremarklinthardbreakspaces-config)
|
||||
* [`unified().use(remarkLintHardBreakSpaces)`](#unifieduseremarklinthardbreakspaces)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -30,40 +30,39 @@ for hard breaks.
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the whitespace of hard breaks.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that hard breaks use two spaces and
|
||||
not more.
|
||||
You can use this package to check that the number of spaces in hard breaks
|
||||
are consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-hard-break-spaces
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintHardBreakSpaces from 'https://esm.sh/remark-lint-hard-break-spaces@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -76,17 +75,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintHardBreakSpaces)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -95,7 +98,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-hard-break-spaces example.md
|
||||
remark --frail --use remark-lint --use remark-lint-hard-break-spaces .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -116,15 +119,22 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintHardBreakSpaces`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintHardBreakSpaces`][api-remark-lint-hard-break-spaces].
|
||||
|
||||
### `unified().use(remarkLintHardBreakSpaces[, config])`
|
||||
### `unified().use(remarkLintHardBreakSpaces)`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when more spaces are used than needed for hard breaks.
|
||||
|
||||
###### Parameters
|
||||
|
||||
There are no options.
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
Less than two spaces do not create a hard breaks and more than two spaces
|
||||
@ -137,10 +147,8 @@ Due to this, it’s recommended to turn this rule on.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
|
||||
```markdown
|
||||
Lorem ipsum··
|
||||
Lorem ipsum␠␠
|
||||
dolor sit amet
|
||||
```
|
||||
|
||||
@ -152,10 +160,8 @@ No messages.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
|
||||
```markdown
|
||||
Lorem ipsum···
|
||||
Lorem ipsum␠␠␠
|
||||
dolor sit amet.
|
||||
```
|
||||
|
||||
@ -167,71 +173,77 @@ dolor sit amet.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-hard-break-spaces@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-hard-break-spaces.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-hard-break-spaces
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-hard-break-spaces.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-hard-break-spaces
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-hard-break-spaces]: #unifieduseremarklinthardbreakspaces
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-hard-break-spaces.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-hard-break-spaces
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-hard-break-spaces
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-hard-break-spaces
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-heading-increment/.npmrc
Normal file
2
packages/remark-lint-heading-increment/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,27 +1,46 @@
|
||||
/**
|
||||
* remark-lint rule to warn when heading ranks increment with more than
|
||||
* 1 at a time.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the increase of headings.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that heading ranks increment with one
|
||||
* at a time.
|
||||
* You can use this package to check the increase of headings.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* ### `unified().use(remarkLintHeadingIncrement)`
|
||||
*
|
||||
* Warn when heading ranks increment with more than 1 at a time.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* There are no options.
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* While markdown is not only used for HTML, HTML accessibility guidelines
|
||||
* state that headings should increment by one at a time.
|
||||
* As in, say the previous heading had a rank of 2 (so `<h2>`), then the
|
||||
* following heading that is to be considered “inside” it should have a rank of
|
||||
* 3 (`<h3>`).
|
||||
* Due to this, it’s recommended that when HTML output is a goal of the
|
||||
* document, that this rule is turned on.
|
||||
* While markdown is not only used for HTML,
|
||||
* HTML accessibility guidelines state that headings should increment by one at
|
||||
* a time.
|
||||
* As in,
|
||||
* say the previous heading had a rank of 2 (so `<h2>`),
|
||||
* then the following heading that is to be considered “inside” it should have
|
||||
* a rank of 3 (`<h3>`).
|
||||
* Due to this,
|
||||
* when HTML output is a goal of the document,
|
||||
* it’s recommended that this rule is turned on.
|
||||
*
|
||||
* [api-remark-lint-heading-increment]: #unifieduseremarklintheadingincrement
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module heading-increment
|
||||
* @summary
|
||||
* remark-lint rule to warn when heading ranks increment with more than
|
||||
* 1 at a time.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
@ -50,10 +69,6 @@
|
||||
* @typedef {import('mdast').Root} Root
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Heading['depth']} Depth
|
||||
*/
|
||||
|
||||
import {lintRule} from 'unified-lint-rule'
|
||||
import {position} from 'unist-util-position'
|
||||
import {visit} from 'unist-util-visit'
|
||||
@ -70,7 +85,7 @@ const remarkLintHeadingIncrement = lintRule(
|
||||
* Nothing.
|
||||
*/
|
||||
function (tree, file) {
|
||||
/** @type {Depth | undefined} */
|
||||
/** @type {Heading['depth'] | undefined} */
|
||||
let previous
|
||||
|
||||
visit(tree, 'heading', function (node) {
|
||||
|
@ -13,11 +13,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-heading-increment"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-heading-increment",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -25,7 +21,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-heading-increment
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when heading ranks increment with more than
|
||||
[`remark-lint`][github-remark-lint] rule to warn when heading ranks increment with more than
|
||||
1 at a time.
|
||||
|
||||
## Contents
|
||||
@ -21,7 +21,7 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintHeadingIncrement[, config])`](#unifieduseremarklintheadingincrement-config)
|
||||
* [`unified().use(remarkLintHeadingIncrement)`](#unifieduseremarklintheadingincrement)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -30,39 +30,37 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the increase of headings.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that heading ranks increment with one
|
||||
at a time.
|
||||
You can use this package to check the increase of headings.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-heading-increment
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintHeadingIncrement from 'https://esm.sh/remark-lint-heading-increment@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -75,17 +73,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintHeadingIncrement from 'remark-lint-heading-increment'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintHeadingIncrement)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -94,7 +96,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-heading-increment example.md
|
||||
remark --frail --use remark-lint --use remark-lint-heading-increment .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -115,24 +117,34 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintHeadingIncrement`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintHeadingIncrement`][api-remark-lint-heading-increment].
|
||||
|
||||
### `unified().use(remarkLintHeadingIncrement[, config])`
|
||||
### `unified().use(remarkLintHeadingIncrement)`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when heading ranks increment with more than 1 at a time.
|
||||
|
||||
###### Parameters
|
||||
|
||||
There are no options.
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
While markdown is not only used for HTML, HTML accessibility guidelines
|
||||
state that headings should increment by one at a time.
|
||||
As in, say the previous heading had a rank of 2 (so `<h2>`), then the
|
||||
following heading that is to be considered “inside” it should have a rank of
|
||||
3 (`<h3>`).
|
||||
Due to this, it’s recommended that when HTML output is a goal of the
|
||||
document, that this rule is turned on.
|
||||
While markdown is not only used for HTML,
|
||||
HTML accessibility guidelines state that headings should increment by one at
|
||||
a time.
|
||||
As in,
|
||||
say the previous heading had a rank of 2 (so `<h2>`),
|
||||
then the following heading that is to be considered “inside” it should have
|
||||
a rank of 3 (`<h3>`).
|
||||
Due to this,
|
||||
when HTML output is a goal of the document,
|
||||
it’s recommended that this rule is turned on.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -168,71 +180,77 @@ No messages.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-heading-increment@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-heading-increment.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-heading-increment
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-heading-increment.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-heading-increment
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-heading-increment]: #unifieduseremarklintheadingincrement
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-heading-increment.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-heading-increment
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-heading-increment
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-heading-increment
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-heading-style/.npmrc
Normal file
2
packages/remark-lint-heading-style/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,63 +1,83 @@
|
||||
/**
|
||||
* remark-lint rule to warn when headings violate a given style.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the style of headings.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that headings are consistent.
|
||||
* You can use this package to check that the style of headings is consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `'consistent'`) are accepted:
|
||||
* ### `unified().use(remarkLintHeadingStyle[, options])`
|
||||
*
|
||||
* * `'atx'`
|
||||
* — prefer ATX headings:
|
||||
* ```markdown
|
||||
* ## Hello
|
||||
* ```
|
||||
* * `'atx-closed'`
|
||||
* — prefer ATX headings with a closing sequence:
|
||||
* ```markdown
|
||||
* ## Hello ##
|
||||
* ```
|
||||
* * `'setext'`
|
||||
* — prefer setext headings:
|
||||
* ```markdown
|
||||
* Hello
|
||||
* -----
|
||||
* ```
|
||||
* * `'consistent'`
|
||||
* — detect the first used style and warn when further headings differ
|
||||
* Warn when headings violate a given style.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
* — preferred style or whether to detect the first style and warn for
|
||||
* further differences
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Options = Style | 'consistent'
|
||||
* ```
|
||||
*
|
||||
* ### `Style`
|
||||
*
|
||||
* Style (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Style = 'atx' | 'atx-closed' | 'setext'
|
||||
* ```
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* Setext headings are limited in that they can only construct headings with a
|
||||
* rank of one and two.
|
||||
* On the other hand, they do allow multiple lines of content whereas ATX only
|
||||
* allows one line.
|
||||
* The number of used markers in their underline does not matter, leading to
|
||||
* either:
|
||||
* They do allow multiple lines of content where ATX only allows one line.
|
||||
* The number of used markers in their underline does not matter,
|
||||
* leading to either:
|
||||
*
|
||||
* * 1 marker (`Hello\n-`), which is the bare minimum, and for rank 2 headings
|
||||
* looks suspiciously like an empty list item
|
||||
* * using as many markers as the content (`Hello\n-----`), which is hard to
|
||||
* maintain
|
||||
* * an arbitrary number (`Hello\n---`), which for rank 2 headings looks
|
||||
* suspiciously like a thematic break
|
||||
* * 1 marker (`Hello\n-`),
|
||||
* which is the bare minimum,
|
||||
* and for rank 2 headings looks suspiciously like an empty list item
|
||||
* * using as many markers as the content (`Hello\n-----`),
|
||||
* which is hard to maintain and diff
|
||||
* * an arbitrary number (`Hello\n---`), which for rank 2 headings looks
|
||||
* suspiciously like a thematic break
|
||||
*
|
||||
* Setext headings are also rather uncommon.
|
||||
* Setext headings are also uncommon.
|
||||
* Using a sequence of hashes at the end of ATX headings is even more uncommon.
|
||||
* Due to this, it’s recommended to prefer ATX headings.
|
||||
* Due to this,
|
||||
* it’s recommended to use ATX headings, without closing hashes.
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* formats headings as ATX by default.
|
||||
* The other styles can be configured with
|
||||
* [`setext: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionssetext)
|
||||
* or
|
||||
* [`closeAtx: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionscloseatx).
|
||||
* [`remark-stringify`][github-remark-stringify] formats headings as ATX by default.
|
||||
* The other styles can be configured with `setext: true` or `closeAtx: true`.
|
||||
*
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-heading-style]: #unifieduseremarklintheadingstyle-options
|
||||
* [api-style]: #style
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module heading-style
|
||||
* @summary
|
||||
* remark-lint rule to warn when headings violate a given style.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
@ -117,10 +137,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Type | 'consistent'} Options
|
||||
* @typedef {Style | 'consistent'} Options
|
||||
* Configuration.
|
||||
*
|
||||
* @typedef {'atx' | 'atx-closed' | 'setext'} Type
|
||||
* @typedef {'atx' | 'atx-closed' | 'setext'} Style
|
||||
* Styles.
|
||||
*/
|
||||
|
||||
|
@ -14,11 +14,7 @@
|
||||
"setext",
|
||||
"style"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-heading-style"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-heading-style",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -26,7 +22,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-heading-style
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when headings violate a given style.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when headings violate a given style.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +20,9 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintHeadingStyle[, config])`](#unifieduseremarklintheadingstyle-config)
|
||||
* [`unified().use(remarkLintHeadingStyle[, options])`](#unifieduseremarklintheadingstyle-options)
|
||||
* [`Options`](#options)
|
||||
* [`Style`](#style)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Examples](#examples)
|
||||
@ -30,39 +32,38 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the style of headings.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that headings are consistent.
|
||||
You can use this package to check that the style of headings is consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'atx'` |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-heading-style
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintHeadingStyle from 'https://esm.sh/remark-lint-heading-style@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -75,17 +76,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintHeadingStyle from 'remark-lint-heading-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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintHeadingStyle)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -94,7 +99,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-heading-style example.md
|
||||
remark --frail --use remark-lint --use remark-lint-heading-style .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -115,62 +120,71 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintHeadingStyle`.
|
||||
It exports the [TypeScript][typescript] types
|
||||
[`Options`][api-options] and
|
||||
[`Style`][api-style].
|
||||
The default export is
|
||||
[`remarkLintHeadingStyle`][api-remark-lint-heading-style].
|
||||
|
||||
### `unified().use(remarkLintHeadingStyle[, config])`
|
||||
### `unified().use(remarkLintHeadingStyle[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when headings violate a given style.
|
||||
|
||||
The following options (default: `'consistent'`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `'atx'`
|
||||
— prefer ATX headings:
|
||||
```markdown
|
||||
## Hello
|
||||
```
|
||||
* `'atx-closed'`
|
||||
— prefer ATX headings with a closing sequence:
|
||||
```markdown
|
||||
## Hello ##
|
||||
```
|
||||
* `'setext'`
|
||||
— prefer setext headings:
|
||||
```markdown
|
||||
Hello
|
||||
-----
|
||||
```
|
||||
* `'consistent'`
|
||||
— detect the first used style and warn when further headings differ
|
||||
* `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
— preferred style or whether to detect the first style and warn for
|
||||
further differences
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Options = Style | 'consistent'
|
||||
```
|
||||
|
||||
### `Style`
|
||||
|
||||
Style (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Style = 'atx' | 'atx-closed' | 'setext'
|
||||
```
|
||||
|
||||
## Recommendation
|
||||
|
||||
Setext headings are limited in that they can only construct headings with a
|
||||
rank of one and two.
|
||||
On the other hand, they do allow multiple lines of content whereas ATX only
|
||||
allows one line.
|
||||
The number of used markers in their underline does not matter, leading to
|
||||
either:
|
||||
They do allow multiple lines of content where ATX only allows one line.
|
||||
The number of used markers in their underline does not matter,
|
||||
leading to either:
|
||||
|
||||
* 1 marker (`Hello\n-`), which is the bare minimum, and for rank 2 headings
|
||||
looks suspiciously like an empty list item
|
||||
* using as many markers as the content (`Hello\n-----`), which is hard to
|
||||
maintain
|
||||
* 1 marker (`Hello\n-`),
|
||||
which is the bare minimum,
|
||||
and for rank 2 headings looks suspiciously like an empty list item
|
||||
* using as many markers as the content (`Hello\n-----`),
|
||||
which is hard to maintain and diff
|
||||
* an arbitrary number (`Hello\n---`), which for rank 2 headings looks
|
||||
suspiciously like a thematic break
|
||||
|
||||
Setext headings are also rather uncommon.
|
||||
Setext headings are also uncommon.
|
||||
Using a sequence of hashes at the end of ATX headings is even more uncommon.
|
||||
Due to this, it’s recommended to prefer ATX headings.
|
||||
Due to this,
|
||||
it’s recommended to use ATX headings, without closing hashes.
|
||||
|
||||
## Fix
|
||||
|
||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
formats headings as ATX by default.
|
||||
The other styles can be configured with
|
||||
[`setext: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionssetext)
|
||||
or
|
||||
[`closeAtx: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionscloseatx).
|
||||
[`remark-stringify`][github-remark-stringify] formats headings as ATX by default.
|
||||
The other styles can be configured with `setext: true` or `closeAtx: true`.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -262,71 +276,83 @@ When configured with `'💩'`.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-heading-style@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-options]: #options
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
[api-remark-lint-heading-style]: #unifieduseremarklintheadingstyle-options
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-heading-style.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-heading-style
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-heading-style.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-heading-style
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-style]: #style
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-heading-style.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-heading-style
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-heading-style
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-heading-style
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-linebreak-style/.npmrc
Normal file
2
packages/remark-lint-linebreak-style/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,48 +1,81 @@
|
||||
/**
|
||||
* remark-lint rule to warn when line endings violate a given style.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that line endings are consistent.
|
||||
* This package checks the style of line endings.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that the style of line endings is
|
||||
* consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* ### `unified().use(remarkLintLinebreakStyle[, options])`
|
||||
*
|
||||
* The following options (default: `'consistent'`) are accepted:
|
||||
* Warn when line endings violate a given style.
|
||||
*
|
||||
* * `'unix'`
|
||||
* — prefer Unix line endings (`\n`, `␊`):
|
||||
* * `'window'`
|
||||
* — prefer Windows line endings (`\r\n`, `␍␊`):
|
||||
* * `'consistent'`
|
||||
* — detect the first used style and warn when further line endings differ
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
* — preferred style or whether to detect the first style and warn for
|
||||
* further differences
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Options = Style | 'consistent'
|
||||
* ```
|
||||
*
|
||||
* ### `Style`
|
||||
*
|
||||
* Style (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Style = 'unix' | 'windows'
|
||||
* ```
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* In Git projects, you can configure it to automatically switch between line
|
||||
* In Git projects, you can configure to automatically switch between line
|
||||
* endings based on who checks the repo out.
|
||||
* In other places, you might manually want to force that one or the other is
|
||||
* used, in which case this rule can be used and configured.
|
||||
* In other places, you may want to manually force that one or the other is
|
||||
* used.
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* always uses Unix linebreaks.
|
||||
* [`remark-stringify`][github-remark-stringify] always uses Unix linebreaks.
|
||||
*
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-linebreak-style]: #unifieduseremarklintlinebreakstyle-options
|
||||
* [api-style]: #style
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module linebreak-style
|
||||
* @summary
|
||||
* remark-lint rule to warn when line endings don’t match a given style.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2017 Titus Wormer
|
||||
* @license MIT
|
||||
* @example
|
||||
* {"name": "ok-consistent-as-windows.md"}
|
||||
*
|
||||
* Alpha␍␊
|
||||
* Bravo␍␊
|
||||
* Alpha␍␊Bravo␍␊
|
||||
*
|
||||
* @example
|
||||
* {"name": "ok-consistent-as-unix.md"}
|
||||
*
|
||||
* Alpha␊
|
||||
* Bravo␊
|
||||
* Alpha␊Bravo␊
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok-unix.md", "label": "input", "config": "unix", "positionless": true}
|
||||
@ -70,10 +103,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {'unix' | 'windows'} Type
|
||||
* Styles.
|
||||
* @typedef {Type | 'consistent'} Options
|
||||
* @typedef {Style | 'consistent'} Options
|
||||
* Options.
|
||||
*
|
||||
* @typedef {'unix' | 'windows'} Style
|
||||
* Styles.
|
||||
*/
|
||||
|
||||
import {lintRule} from 'unified-lint-rule'
|
||||
|
@ -17,11 +17,7 @@
|
||||
"unix",
|
||||
"windows"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-linebreak-style"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-linebreak-style",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -29,7 +25,8 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus <tituswormer@gmail.com>",
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,25 +2,27 @@
|
||||
|
||||
# remark-lint-linebreak-style
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when line endings don’t match a given style.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when line endings violate a given style.
|
||||
|
||||
## Contents
|
||||
|
||||
* [What is this?](#what-is-this)
|
||||
* [When should I use this?](#when-should-i-use-this)
|
||||
* [When should I use this?](#when-should-i-use-this-1)
|
||||
* [Presets](#presets)
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintLinebreakStyle[, config])`](#unifieduseremarklintlinebreakstyle-config)
|
||||
* [`unified().use(remarkLintLinebreakStyle[, options])`](#unifieduseremarklintlinebreakstyle-options)
|
||||
* [`Options`](#options)
|
||||
* [`Style`](#style)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Examples](#examples)
|
||||
@ -28,36 +30,36 @@
|
||||
* [Contribute](#contribute)
|
||||
* [License](#license)
|
||||
|
||||
## What is this?
|
||||
## When should I use this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the style of line endings.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that line endings are consistent.
|
||||
You can use this package to check that the style of line endings is
|
||||
consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is not included in a preset maintained here.
|
||||
This plugin is not included in presets maintained here.
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-linebreak-style
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintLinebreakStyle from 'https://esm.sh/remark-lint-linebreak-style@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -70,17 +72,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintLinebreakStyle from 'remark-lint-linebreak-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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintLinebreakStyle)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -89,7 +95,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-linebreak-style example.md
|
||||
remark --frail --use remark-lint --use remark-lint-linebreak-style .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -110,33 +116,56 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintLinebreakStyle`.
|
||||
It exports the [TypeScript][typescript] types
|
||||
[`Options`][api-options] and
|
||||
[`Style`][api-style].
|
||||
The default export is
|
||||
[`remarkLintLinebreakStyle`][api-remark-lint-linebreak-style].
|
||||
|
||||
### `unified().use(remarkLintLinebreakStyle[, config])`
|
||||
### `unified().use(remarkLintLinebreakStyle[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when line endings violate a given style.
|
||||
|
||||
The following options (default: `'consistent'`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `'unix'`
|
||||
— prefer Unix line endings (`\n`, `␊`):
|
||||
* `'window'`
|
||||
— prefer Windows line endings (`\r\n`, `␍␊`):
|
||||
* `'consistent'`
|
||||
— detect the first used style and warn when further line endings differ
|
||||
* `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
— preferred style or whether to detect the first style and warn for
|
||||
further differences
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Options = Style | 'consistent'
|
||||
```
|
||||
|
||||
### `Style`
|
||||
|
||||
Style (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Style = 'unix' | 'windows'
|
||||
```
|
||||
|
||||
## Recommendation
|
||||
|
||||
In Git projects, you can configure it to automatically switch between line
|
||||
In Git projects, you can configure to automatically switch between line
|
||||
endings based on who checks the repo out.
|
||||
In other places, you might manually want to force that one or the other is
|
||||
used, in which case this rule can be used and configured.
|
||||
In other places, you may want to manually force that one or the other is
|
||||
used.
|
||||
|
||||
## Fix
|
||||
|
||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
always uses Unix linebreaks.
|
||||
[`remark-stringify`][github-remark-stringify] always uses Unix linebreaks.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -144,11 +173,8 @@ always uses Unix linebreaks.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `␍␊` represents a carriage return and a line feed.
|
||||
|
||||
```markdown
|
||||
Alpha␍␊
|
||||
Bravo␍␊
|
||||
Alpha␍␊Bravo␍␊
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -159,11 +185,8 @@ No messages.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `␊` represents a line feed.
|
||||
|
||||
```markdown
|
||||
Alpha␊
|
||||
Bravo␊
|
||||
Alpha␊Bravo␊
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -176,8 +199,6 @@ When configured with `'unix'`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `␍␊` represents a carriage return and a line feed.
|
||||
|
||||
```markdown
|
||||
Alpha␍␊
|
||||
```
|
||||
@ -194,8 +215,6 @@ When configured with `'windows'`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `␊` represents a line feed.
|
||||
|
||||
```markdown
|
||||
Alpha␊
|
||||
```
|
||||
@ -208,71 +227,83 @@ Alpha␊
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-linebreak-style@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-options]: #options
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
[api-remark-lint-linebreak-style]: #unifieduseremarklintlinebreakstyle-options
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-linebreak-style.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-linebreak-style
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-linebreak-style.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-linebreak-style
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-style]: #style
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-linebreak-style.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-linebreak-style
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-linebreak-style
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-linebreak-style
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-link-title-style/.npmrc
Normal file
2
packages/remark-lint-link-title-style/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,28 +1,57 @@
|
||||
/**
|
||||
* remark-lint rule to warn when link title markers violate a given style.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the style of link title markers.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that title markers are consistent.
|
||||
* You can use this package to check that the style of link title markers is
|
||||
* consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `'consistent'`) are accepted:
|
||||
* ### `unified().use(remarkLintLinkTitleStyle[, options])`
|
||||
*
|
||||
* * `'"'`
|
||||
* — prefer double quotes
|
||||
* * `"'"`
|
||||
* — prefer single quotes
|
||||
* * `'()'`
|
||||
* — prefer parens
|
||||
* * `'consistent'`
|
||||
* — detect the first used style and warn when further titles differ
|
||||
* Warn when link title markers violate a given style.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
* — preferred style or whether to detect the first style and warn for
|
||||
* further differences
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Options = Style | 'consistent'
|
||||
* ```
|
||||
*
|
||||
* ### `Style`
|
||||
*
|
||||
* Style (TypeScript type).
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Style = '"' | '\'' | '()'
|
||||
* ```
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* Parens in titles were not supported in markdown before CommonMark.
|
||||
* While they should work in most places now, not all markdown parsers follow
|
||||
* CommonMark.
|
||||
* Parens for titles also arguably look a bit weird because they’re inside more
|
||||
* parens: `[text](url (title))`.
|
||||
* Before CommonMark, parens for titles were not supported in markdown.
|
||||
* They should now work in most places.
|
||||
* Parens do look a bit weird as they’re inside more parens:
|
||||
* `[text](url (title))`.
|
||||
*
|
||||
* In HTML, attributes are commonly written with double quotes.
|
||||
* Due to this, titles are almost exclusively wrapped in double quotes in
|
||||
@ -30,16 +59,18 @@
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* formats titles with double quotes by default.
|
||||
* Pass
|
||||
* [`quote: "'"`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsquote)
|
||||
* to use single quotes.
|
||||
* [`remark-stringify`][github-remark-stringify] formats titles with double
|
||||
* quotes by default.
|
||||
* Pass `quote: "'"` to use single quotes.
|
||||
* There is no option to use parens.
|
||||
*
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-link-title-style]: #unifieduseremarklintlinktitlestyle-options
|
||||
* [api-style]: #style
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module link-title-style
|
||||
* @summary
|
||||
* remark-lint rule to warn when title markers are inconsistent.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
@ -126,11 +157,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {'"' | '\'' | '()'} Marker
|
||||
* Styles.
|
||||
*
|
||||
* @typedef {Marker | 'consistent'} Options
|
||||
* @typedef {Style | 'consistent'} Options
|
||||
* Configuration.
|
||||
*
|
||||
* @typedef {'"' | '\'' | '()'} Style
|
||||
* Styles.
|
||||
*/
|
||||
|
||||
import {lintRule} from 'unified-lint-rule'
|
||||
|
@ -14,11 +14,7 @@
|
||||
"rule",
|
||||
"style"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-link-title-style"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-link-title-style",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -26,7 +22,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-link-title-style
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when title markers are inconsistent.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when link title markers violate a given style.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +20,9 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintLinkTitleStyle[, config])`](#unifieduseremarklintlinktitlestyle-config)
|
||||
* [`unified().use(remarkLintLinkTitleStyle[, options])`](#unifieduseremarklintlinktitlestyle-options)
|
||||
* [`Options`](#options)
|
||||
* [`Style`](#style)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Examples](#examples)
|
||||
@ -30,39 +32,39 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the style of link title markers.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that title markers are consistent.
|
||||
You can use this package to check that the style of link title markers is
|
||||
consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'"'` |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-link-title-style
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintLinkTitleStyle from 'https://esm.sh/remark-lint-link-title-style@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -75,17 +77,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintLinkTitleStyle from 'remark-lint-link-title-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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintLinkTitleStyle)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -94,7 +100,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-link-title-style example.md
|
||||
remark --frail --use remark-lint --use remark-lint-link-title-style .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -115,31 +121,52 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintLinkTitleStyle`.
|
||||
It exports the [TypeScript][typescript] types
|
||||
[`Options`][api-options] and
|
||||
[`Style`][api-style].
|
||||
The default export is
|
||||
[`remarkLintLinkTitleStyle`][api-remark-lint-link-title-style].
|
||||
|
||||
### `unified().use(remarkLintLinkTitleStyle[, config])`
|
||||
### `unified().use(remarkLintLinkTitleStyle[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when link title markers violate a given style.
|
||||
|
||||
The following options (default: `'consistent'`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `'"'`
|
||||
— prefer double quotes
|
||||
* `"'"`
|
||||
— prefer single quotes
|
||||
* `'()'`
|
||||
— prefer parens
|
||||
* `'consistent'`
|
||||
— detect the first used style and warn when further titles differ
|
||||
* `options` ([`Options`][api-options], default: `'consistent'`)
|
||||
— preferred style or whether to detect the first style and warn for
|
||||
further differences
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Options = Style | 'consistent'
|
||||
```
|
||||
|
||||
### `Style`
|
||||
|
||||
Style (TypeScript type).
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Style = '"' | '\'' | '()'
|
||||
```
|
||||
|
||||
## Recommendation
|
||||
|
||||
Parens in titles were not supported in markdown before CommonMark.
|
||||
While they should work in most places now, not all markdown parsers follow
|
||||
CommonMark.
|
||||
Parens for titles also arguably look a bit weird because they’re inside more
|
||||
parens: `[text](url (title))`.
|
||||
Before CommonMark, parens for titles were not supported in markdown.
|
||||
They should now work in most places.
|
||||
Parens do look a bit weird as they’re inside more parens:
|
||||
`[text](url (title))`.
|
||||
|
||||
In HTML, attributes are commonly written with double quotes.
|
||||
Due to this, titles are almost exclusively wrapped in double quotes in
|
||||
@ -147,11 +174,9 @@ markdown, so it’s recommended to configure this rule with `'"'`.
|
||||
|
||||
## Fix
|
||||
|
||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
formats titles with double quotes by default.
|
||||
Pass
|
||||
[`quote: "'"`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsquote)
|
||||
to use single quotes.
|
||||
[`remark-stringify`][github-remark-stringify] formats titles with double
|
||||
quotes by default.
|
||||
Pass `quote: "'"` to use single quotes.
|
||||
There is no option to use parens.
|
||||
|
||||
## Examples
|
||||
@ -289,71 +314,83 @@ When configured with `'💩'`.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-link-title-style@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-options]: #options
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
[api-remark-lint-link-title-style]: #unifieduseremarklintlinktitlestyle-options
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-link-title-style.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-link-title-style
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-link-title-style.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-link-title-style
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-style]: #style
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-link-title-style.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-link-title-style
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-link-title-style
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-link-title-style
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-list-item-bullet-indent/.npmrc
Normal file
2
packages/remark-lint-list-item-bullet-indent/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,16 +1,32 @@
|
||||
/**
|
||||
* remark-lint rule to warn when list item markers are indented.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks indentation before list item markers.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that list items are not indented.
|
||||
* You can use this package to check that the style of list items is
|
||||
* consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* ### `unified().use(remarkLintListItemBulletIndent)`
|
||||
*
|
||||
* Warn when list item markers are indented.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* There are no options.
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* There is no specific handling of indented list items (or anything else) in
|
||||
* markdown.
|
||||
* There is no specific handling of indented list items in markdown.
|
||||
* While it is possible to use an indent to align ordered lists on their marker:
|
||||
*
|
||||
* ```markdown
|
||||
@ -19,19 +35,21 @@
|
||||
* 100. Hundred
|
||||
* ```
|
||||
*
|
||||
* …such a style is uncommon and a bit hard to maintain: adding a 10th item
|
||||
* means 9 other items have to change (more arduous, while unlikely, would be
|
||||
* …such a style is uncommon and hard to maintain as adding a 10th item
|
||||
* means 9 other items have to change (more arduous while unlikely would be
|
||||
* the 100th item).
|
||||
* Hence, it’s recommended to not indent items and to turn this rule on.
|
||||
* So it is recommended to not indent items and to turn this rule on.
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* formats all items without indent.
|
||||
* [`remark-stringify`][github-remark-stringify] formats all items without
|
||||
* indent.
|
||||
*
|
||||
* [api-remark-lint-list-item-bullet-indent]: #unifieduseremarklintlistitembulletindent
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module list-item-bullet-indent
|
||||
* @summary
|
||||
* remark-lint rule to warn when list items are indented.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
@ -48,8 +66,8 @@
|
||||
*
|
||||
* Paragraph.
|
||||
*
|
||||
* ·* List item
|
||||
* ·* List item
|
||||
* ␠* List item
|
||||
* ␠* List item
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "label": "output"}
|
||||
|
@ -13,11 +13,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-list-item-bullet-indent"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-bullet-indent",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -25,7 +21,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-list-item-bullet-indent
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when list items are indented.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when list item markers are indented.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintListItemBulletIndent[, config])`](#unifieduseremarklintlistitembulletindent-config)
|
||||
* [`unified().use(remarkLintListItemBulletIndent)`](#unifieduseremarklintlistitembulletindent)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Examples](#examples)
|
||||
@ -30,38 +30,38 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks indentation before list item markers.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that list items are not indented.
|
||||
You can use this package to check that the style of list items is
|
||||
consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-list-item-bullet-indent
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintListItemBulletIndent from 'https://esm.sh/remark-lint-list-item-bullet-indent@4'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -74,17 +74,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintListItemBulletIndent from 'remark-lint-list-item-bullet-indent'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintListItemBulletIndent)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -93,7 +97,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-list-item-bullet-indent example.md
|
||||
remark --frail --use remark-lint --use remark-lint-list-item-bullet-indent .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -114,19 +118,25 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintListItemBulletIndent`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintListItemBulletIndent`][api-remark-lint-list-item-bullet-indent].
|
||||
|
||||
### `unified().use(remarkLintListItemBulletIndent[, config])`
|
||||
### `unified().use(remarkLintListItemBulletIndent)`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when list item markers are indented.
|
||||
|
||||
###### Parameters
|
||||
|
||||
There are no options.
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
There is no specific handling of indented list items (or anything else) in
|
||||
markdown.
|
||||
There is no specific handling of indented list items in markdown.
|
||||
While it is possible to use an indent to align ordered lists on their marker:
|
||||
|
||||
```markdown
|
||||
@ -135,15 +145,15 @@ While it is possible to use an indent to align ordered lists on their marker:
|
||||
100. Hundred
|
||||
```
|
||||
|
||||
…such a style is uncommon and a bit hard to maintain: adding a 10th item
|
||||
means 9 other items have to change (more arduous, while unlikely, would be
|
||||
…such a style is uncommon and hard to maintain as adding a 10th item
|
||||
means 9 other items have to change (more arduous while unlikely would be
|
||||
the 100th item).
|
||||
Hence, it’s recommended to not indent items and to turn this rule on.
|
||||
So it is recommended to not indent items and to turn this rule on.
|
||||
|
||||
## Fix
|
||||
|
||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
formats all items without indent.
|
||||
[`remark-stringify`][github-remark-stringify] formats all items without
|
||||
indent.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -166,13 +176,11 @@ No messages.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
|
||||
```markdown
|
||||
Paragraph.
|
||||
|
||||
·* List item
|
||||
·* List item
|
||||
␠* List item
|
||||
␠* List item
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -184,71 +192,79 @@ Paragraph.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-list-item-bullet-indent@4`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-list-item-bullet-indent.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-list-item-bullet-indent
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-list-item-bullet-indent.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-list-item-bullet-indent
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-list-item-bullet-indent]: #unifieduseremarklintlistitembulletindent
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-list-item-bullet-indent.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-list-item-bullet-indent
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-list-item-bullet-indent
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-list-item-bullet-indent
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-list-item-content-indent/.npmrc
Normal file
2
packages/remark-lint-list-item-content-indent/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,12 +1,30 @@
|
||||
/**
|
||||
* remark-lint rule to warn when the indent of list item content is not
|
||||
* consistent.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the indent of list item content.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that list item content is aligned.
|
||||
* You can use this package to check that list item content is indented
|
||||
* consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* ### `unified().use(remarkLintListItemContentIndent)`
|
||||
*
|
||||
* Warn when the indent of list item content is not consistent.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* There are no options.
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* The position of the first child in a list item matters.
|
||||
@ -14,26 +32,27 @@
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* aligns the content of items.
|
||||
* [`remark-stringify`][github-remark-stringify] aligns the content of items.
|
||||
*
|
||||
* [api-remark-lint-list-item-content-indent]: #unifieduseremarklintlistitemcontentindent
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module list-item-content-indent
|
||||
* @summary
|
||||
* remark-lint rule to warn when list item content is not aligned.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
* @example
|
||||
* {"name": "ok.md", "gfm": true}
|
||||
*
|
||||
* 1.·[x] Alpha
|
||||
* ···1. Bravo
|
||||
* 1.␠[x] Alpha
|
||||
* ␠␠␠1. Bravo
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "label": "input", "gfm": true}
|
||||
*
|
||||
* 1.·[x] Charlie
|
||||
* ····1. Delta
|
||||
* 1.␠[x] Charlie
|
||||
* ␠␠␠␠1. Delta
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "label": "output", "gfm": true}
|
||||
|
@ -14,11 +14,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-list-item-content-indent"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-content-indent",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -26,7 +22,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,16 @@
|
||||
|
||||
# remark-lint-list-item-content-indent
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when list item content is not aligned.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when the indent of list item content is not
|
||||
consistent.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +21,7 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintListItemContentIndent[, config])`](#unifieduseremarklintlistitemcontentindent-config)
|
||||
* [`unified().use(remarkLintListItemContentIndent)`](#unifieduseremarklintlistitemcontentindent)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Examples](#examples)
|
||||
@ -30,39 +31,39 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the indent of list item content.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that list item content is aligned.
|
||||
You can use this package to check that list item content is indented
|
||||
consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-list-item-content-indent
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintListItemContentIndent from 'https://esm.sh/remark-lint-list-item-content-indent@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -75,17 +76,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintListItemContentIndent from 'remark-lint-list-item-content-indent'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintListItemContentIndent)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -94,7 +99,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-list-item-content-indent example.md
|
||||
remark --frail --use remark-lint --use remark-lint-list-item-content-indent .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -115,15 +120,22 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintListItemContentIndent`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintListItemContentIndent`][api-remark-lint-list-item-content-indent].
|
||||
|
||||
### `unified().use(remarkLintListItemContentIndent[, config])`
|
||||
### `unified().use(remarkLintListItemContentIndent)`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when the indent of list item content is not consistent.
|
||||
|
||||
###### Parameters
|
||||
|
||||
There are no options.
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
The position of the first child in a list item matters.
|
||||
@ -131,8 +143,7 @@ Further children should align with it.
|
||||
|
||||
## Fix
|
||||
|
||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
aligns the content of items.
|
||||
[`remark-stringify`][github-remark-stringify] aligns the content of items.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -140,13 +151,11 @@ aligns the content of items.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][github-remark-gfm]).
|
||||
|
||||
```markdown
|
||||
1.·[x] Alpha
|
||||
···1. Bravo
|
||||
1.␠[x] Alpha
|
||||
␠␠␠1. Bravo
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -157,13 +166,11 @@ No messages.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][github-remark-gfm]).
|
||||
|
||||
```markdown
|
||||
1.·[x] Charlie
|
||||
····1. Delta
|
||||
1.␠[x] Charlie
|
||||
␠␠␠␠1. Delta
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -174,73 +181,81 @@ No messages.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-list-item-content-indent@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-list-item-content-indent.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-list-item-content-indent
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-list-item-content-indent.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-list-item-content-indent
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-list-item-content-indent]: #unifieduseremarklintlistitemcontentindent
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[gfm]: https://github.com/remarkjs/remark-gfm
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-list-item-content-indent.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-list-item-content-indent
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-list-item-content-indent
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-list-item-content-indent
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-gfm]: https://github.com/remarkjs/remark-gfm
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-list-item-indent/.npmrc
Normal file
2
packages/remark-lint-list-item-indent/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,122 +1,157 @@
|
||||
/**
|
||||
* remark-lint rule to warn when the whitespace after list item markers violate
|
||||
* a given style.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the style of whitespace after list item markers.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that the spacing between list item markers
|
||||
* and content is inconsistent.
|
||||
* You can use this package to check that the style of whitespace after list
|
||||
* item markers and before content is consistent.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `'tab-size'`) are accepted:
|
||||
* ### `unified().use(remarkLintListItemIndent[, options])`
|
||||
*
|
||||
* * `'space'`
|
||||
* — prefer a single space
|
||||
* * `'tab-size'`
|
||||
* — prefer spaces the size of the next tab stop
|
||||
* * `'mixed'`
|
||||
* — prefer `'space'` for tight lists and `'tab-size'` for loose lists
|
||||
* Warn when the whitespace after list item markers violate a given style.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options], default: `'tab-size'`)
|
||||
* — preferred style
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* * `'space'`
|
||||
* — prefer a single space
|
||||
* * `'tab-size'`
|
||||
* — prefer spaces the size of the next tab stop
|
||||
* * `'mixed'`
|
||||
* — prefer `'space'` for tight lists and `'tab-size'` for loose lists
|
||||
*
|
||||
* ###### Type
|
||||
*
|
||||
* ```ts
|
||||
* type Options = 'mixed' | 'space' | 'tab-size'
|
||||
* ```
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* First, some background.
|
||||
* First some background.
|
||||
* The number of spaces that occur after list markers (`*`, `-`, and `+` for
|
||||
* unordered lists, or `.` and `)` for unordered lists) and before the content
|
||||
* on the first line, defines how much indentation can be used for further
|
||||
* lines.
|
||||
* At least one space is required and up to 4 spaces are allowed (if there is no
|
||||
* further content after the marker then it’s a blank line which is handled as
|
||||
* if there was one space; if there are 5 or more spaces and then content, it’s
|
||||
* also seen as one space and the rest is seen as indented code).
|
||||
* unordered lists and `.` and `)` for unordered lists) and before the content
|
||||
* on the first line,
|
||||
* defines how much indentation can be used for further lines.
|
||||
* At least one space is required and up to 4 spaces are allowed.
|
||||
* If there is no further content after the marker then it’s a blank line which
|
||||
* is handled as if there was one space.
|
||||
* If there are 5 or more spaces and then content then it’s also seen as one
|
||||
* space and the rest is seen as indented code.
|
||||
*
|
||||
* There are two types of lists in markdown (other than ordered and unordered):
|
||||
* tight and loose lists.
|
||||
* Regardless of ordered and unordered,
|
||||
* there are two kinds of lists in markdown,
|
||||
* tight and loose.
|
||||
* Lists are tight by default but if there is a blank line between two list
|
||||
* items or between two blocks inside an item, that turns the whole list into a
|
||||
* loose list.
|
||||
* When turning markdown into HTML, paragraphs in tight lists are not wrapped
|
||||
* in `<p>` tags.
|
||||
* items or between two blocks inside an item,
|
||||
* that turns the whole list into a loose list.
|
||||
* When turning markdown into HTML,
|
||||
* paragraphs in tight lists are not wrapped in `<p>` tags.
|
||||
*
|
||||
* Historically, how indentation of lists works in markdown has been a mess,
|
||||
* How indentation of lists works in markdown has historically been a mess,
|
||||
* especially with how they interact with indented code.
|
||||
* CommonMark made that a *lot* better, but there remain (documented but
|
||||
* complex) edge cases and some behavior intuitive.
|
||||
* CommonMark made that a *lot* better,
|
||||
* but there remain (documented but complex) edge cases and some behavior
|
||||
* intuitive.
|
||||
* Due to this, the default of this list is `'tab-size'`, which worked the best
|
||||
* in most markdown parsers.
|
||||
* Currently, the situation between markdown parsers is better, so choosing
|
||||
* `'space'` (which seems to be the most common style used by authors) should
|
||||
* be okay.
|
||||
* in most markdown parsers *and* in CommonMark.
|
||||
* Currently the situation between markdown parsers is better,
|
||||
* so choosing `'space'`, which seems to be the most common style used by
|
||||
* authors,
|
||||
* is okay.
|
||||
*
|
||||
* ## Fix
|
||||
*
|
||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
* uses `'tab-size'` (named `'tab'` there) by default.
|
||||
* [`listItemIndent: '1'` (for `'space'`) or `listItemIndent: 'mixed'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionslistitemindent)
|
||||
* is supported.
|
||||
* [`remark-stringify`][github-remark-stringify] uses `listItemIndent: 'one'`,
|
||||
* for `'space'`,
|
||||
* by default.
|
||||
* `listItemIndent: 'mixed'` or `listItemIndent: 'tab'` (for `'tab-size'`) is
|
||||
* also supported.
|
||||
*
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-list-item-indent]: #unifieduseremarklintlistitemindent-options
|
||||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module list-item-indent
|
||||
* @summary
|
||||
* remark-lint rule to warn when spacing between list item markers and
|
||||
* content is inconsistent.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
* @example
|
||||
* {"name": "ok.md"}
|
||||
*
|
||||
* *···List
|
||||
* ····item.
|
||||
* *␠␠␠List
|
||||
* ␠␠␠␠item.
|
||||
*
|
||||
* Paragraph.
|
||||
*
|
||||
* 11.·List
|
||||
* ····item.
|
||||
* 11.␠List
|
||||
* ␠␠␠␠item.
|
||||
*
|
||||
* Paragraph.
|
||||
*
|
||||
* *···List
|
||||
* ····item.
|
||||
* *␠␠␠List
|
||||
* ␠␠␠␠item.
|
||||
*
|
||||
* *···List
|
||||
* ····item.
|
||||
* *␠␠␠List
|
||||
* ␠␠␠␠item.
|
||||
*
|
||||
* @example
|
||||
* {"name": "ok.md", "config": "mixed"}
|
||||
*
|
||||
* *·List item.
|
||||
* *␠List item.
|
||||
*
|
||||
* Paragraph.
|
||||
*
|
||||
* 11.·List item
|
||||
* 11.␠List item
|
||||
*
|
||||
* Paragraph.
|
||||
*
|
||||
* *···List
|
||||
* ····item.
|
||||
* *␠␠␠List
|
||||
* ␠␠␠␠item.
|
||||
*
|
||||
* *···List
|
||||
* ····item.
|
||||
* *␠␠␠List
|
||||
* ␠␠␠␠item.
|
||||
*
|
||||
* @example
|
||||
* {"name": "ok.md", "config": "space"}
|
||||
*
|
||||
* *·List item.
|
||||
* *␠List item.
|
||||
*
|
||||
* Paragraph.
|
||||
*
|
||||
* 11.·List item
|
||||
* 11.␠List item
|
||||
*
|
||||
* Paragraph.
|
||||
*
|
||||
* *·List
|
||||
* ··item.
|
||||
* *␠List
|
||||
* ␠␠item.
|
||||
*
|
||||
* *·List
|
||||
* ··item.
|
||||
* *␠List
|
||||
* ␠␠item.
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "config": "space", "label": "input"}
|
||||
*
|
||||
* *···List
|
||||
* ····item.
|
||||
* *␠␠␠List
|
||||
* ␠␠␠␠item.
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "config": "space", "label": "output"}
|
||||
@ -126,8 +161,8 @@
|
||||
* @example
|
||||
* {"name": "not-ok.md", "config": "tab-size", "label": "input"}
|
||||
*
|
||||
* *·List
|
||||
* ··item.
|
||||
* *␠List
|
||||
* ␠␠item.
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "config": "tab-size", "label": "output"}
|
||||
@ -137,7 +172,7 @@
|
||||
* @example
|
||||
* {"name": "not-ok.md", "config": "mixed", "label": "input"}
|
||||
*
|
||||
* *···List item.
|
||||
* *␠␠␠List item.
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok.md", "config": "mixed", "label": "output"}
|
||||
|
@ -13,11 +13,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-list-item-indent"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-indent",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -25,7 +21,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,16 +2,16 @@
|
||||
|
||||
# remark-lint-list-item-indent
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when spacing between list item markers and
|
||||
content is inconsistent.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when the whitespace after list item markers violate
|
||||
a given style.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -21,7 +21,8 @@ content is inconsistent.
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintListItemIndent[, config])`](#unifieduseremarklintlistitemindent-config)
|
||||
* [`unified().use(remarkLintListItemIndent[, options])`](#unifieduseremarklintlistitemindent-options)
|
||||
* [`Options`](#options)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Fix](#fix)
|
||||
* [Examples](#examples)
|
||||
@ -31,40 +32,39 @@ content is inconsistent.
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the style of whitespace after list item markers.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that the spacing between list item markers
|
||||
and content is inconsistent.
|
||||
You can use this package to check that the style of whitespace after list
|
||||
item markers and before content is consistent.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'mixed'` |
|
||||
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | `'tab-size'` |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-list-item-indent
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintListItemIndent from 'https://esm.sh/remark-lint-list-item-indent@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -77,17 +77,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintListItemIndent from 'remark-lint-list-item-indent'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintListItemIndent)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -96,7 +100,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-list-item-indent example.md
|
||||
remark --frail --use remark-lint --use remark-lint-list-item-indent .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -117,14 +121,27 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintListItemIndent`.
|
||||
It exports the [TypeScript][typescript] type
|
||||
[`Options`][api-options].
|
||||
The default export is
|
||||
[`remarkLintListItemIndent`][api-remark-lint-list-item-indent].
|
||||
|
||||
### `unified().use(remarkLintListItemIndent[, config])`
|
||||
### `unified().use(remarkLintListItemIndent[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when the whitespace after list item markers violate a given style.
|
||||
|
||||
The following options (default: `'tab-size'`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `options` ([`Options`][api-options], default: `'tab-size'`)
|
||||
— preferred style
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
* `'space'`
|
||||
— prefer a single space
|
||||
@ -133,42 +150,53 @@ The following options (default: `'tab-size'`) are accepted:
|
||||
* `'mixed'`
|
||||
— prefer `'space'` for tight lists and `'tab-size'` for loose lists
|
||||
|
||||
###### Type
|
||||
|
||||
```ts
|
||||
type Options = 'mixed' | 'space' | 'tab-size'
|
||||
```
|
||||
|
||||
## Recommendation
|
||||
|
||||
First, some background.
|
||||
First some background.
|
||||
The number of spaces that occur after list markers (`*`, `-`, and `+` for
|
||||
unordered lists, or `.` and `)` for unordered lists) and before the content
|
||||
on the first line, defines how much indentation can be used for further
|
||||
lines.
|
||||
At least one space is required and up to 4 spaces are allowed (if there is no
|
||||
further content after the marker then it’s a blank line which is handled as
|
||||
if there was one space; if there are 5 or more spaces and then content, it’s
|
||||
also seen as one space and the rest is seen as indented code).
|
||||
unordered lists and `.` and `)` for unordered lists) and before the content
|
||||
on the first line,
|
||||
defines how much indentation can be used for further lines.
|
||||
At least one space is required and up to 4 spaces are allowed.
|
||||
If there is no further content after the marker then it’s a blank line which
|
||||
is handled as if there was one space.
|
||||
If there are 5 or more spaces and then content then it’s also seen as one
|
||||
space and the rest is seen as indented code.
|
||||
|
||||
There are two types of lists in markdown (other than ordered and unordered):
|
||||
tight and loose lists.
|
||||
Regardless of ordered and unordered,
|
||||
there are two kinds of lists in markdown,
|
||||
tight and loose.
|
||||
Lists are tight by default but if there is a blank line between two list
|
||||
items or between two blocks inside an item, that turns the whole list into a
|
||||
loose list.
|
||||
When turning markdown into HTML, paragraphs in tight lists are not wrapped
|
||||
in `<p>` tags.
|
||||
items or between two blocks inside an item,
|
||||
that turns the whole list into a loose list.
|
||||
When turning markdown into HTML,
|
||||
paragraphs in tight lists are not wrapped in `<p>` tags.
|
||||
|
||||
Historically, how indentation of lists works in markdown has been a mess,
|
||||
How indentation of lists works in markdown has historically been a mess,
|
||||
especially with how they interact with indented code.
|
||||
CommonMark made that a *lot* better, but there remain (documented but
|
||||
complex) edge cases and some behavior intuitive.
|
||||
CommonMark made that a *lot* better,
|
||||
but there remain (documented but complex) edge cases and some behavior
|
||||
intuitive.
|
||||
Due to this, the default of this list is `'tab-size'`, which worked the best
|
||||
in most markdown parsers.
|
||||
Currently, the situation between markdown parsers is better, so choosing
|
||||
`'space'` (which seems to be the most common style used by authors) should
|
||||
be okay.
|
||||
in most markdown parsers *and* in CommonMark.
|
||||
Currently the situation between markdown parsers is better,
|
||||
so choosing `'space'`, which seems to be the most common style used by
|
||||
authors,
|
||||
is okay.
|
||||
|
||||
## Fix
|
||||
|
||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||
uses `'tab-size'` (named `'tab'` there) by default.
|
||||
[`listItemIndent: '1'` (for `'space'`) or `listItemIndent: 'mixed'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionslistitemindent)
|
||||
is supported.
|
||||
[`remark-stringify`][github-remark-stringify] uses `listItemIndent: 'one'`,
|
||||
for `'space'`,
|
||||
by default.
|
||||
`listItemIndent: 'mixed'` or `listItemIndent: 'tab'` (for `'tab-size'`) is
|
||||
also supported.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -176,24 +204,22 @@ is supported.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
|
||||
```markdown
|
||||
*···List
|
||||
····item.
|
||||
*␠␠␠List
|
||||
␠␠␠␠item.
|
||||
|
||||
Paragraph.
|
||||
|
||||
11.·List
|
||||
····item.
|
||||
11.␠List
|
||||
␠␠␠␠item.
|
||||
|
||||
Paragraph.
|
||||
|
||||
*···List
|
||||
····item.
|
||||
*␠␠␠List
|
||||
␠␠␠␠item.
|
||||
|
||||
*···List
|
||||
····item.
|
||||
*␠␠␠List
|
||||
␠␠␠␠item.
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -206,22 +232,20 @@ When configured with `'mixed'`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
|
||||
```markdown
|
||||
*·List item.
|
||||
*␠List item.
|
||||
|
||||
Paragraph.
|
||||
|
||||
11.·List item
|
||||
11.␠List item
|
||||
|
||||
Paragraph.
|
||||
|
||||
*···List
|
||||
····item.
|
||||
*␠␠␠List
|
||||
␠␠␠␠item.
|
||||
|
||||
*···List
|
||||
····item.
|
||||
*␠␠␠List
|
||||
␠␠␠␠item.
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -234,22 +258,20 @@ When configured with `'space'`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
|
||||
```markdown
|
||||
*·List item.
|
||||
*␠List item.
|
||||
|
||||
Paragraph.
|
||||
|
||||
11.·List item
|
||||
11.␠List item
|
||||
|
||||
Paragraph.
|
||||
|
||||
*·List
|
||||
··item.
|
||||
*␠List
|
||||
␠␠item.
|
||||
|
||||
*·List
|
||||
··item.
|
||||
*␠List
|
||||
␠␠item.
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -262,11 +284,9 @@ When configured with `'space'`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
|
||||
```markdown
|
||||
*···List
|
||||
····item.
|
||||
*␠␠␠List
|
||||
␠␠␠␠item.
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -281,11 +301,9 @@ When configured with `'tab-size'`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
|
||||
```markdown
|
||||
*·List
|
||||
··item.
|
||||
*␠List
|
||||
␠␠item.
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -300,10 +318,8 @@ When configured with `'mixed'`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `·` represents a space.
|
||||
|
||||
```markdown
|
||||
*···List item.
|
||||
*␠␠␠List item.
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -324,71 +340,81 @@ When configured with `'💩'`.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-list-item-indent@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-options]: #options
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-list-item-indent.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-list-item-indent
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-list-item-indent.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-list-item-indent
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-list-item-indent]: #unifieduseremarklintlistitemindent-options
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-list-item-indent.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-list-item-indent
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-list-item-indent
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-list-item-indent
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-list-item-spacing/.npmrc
Normal file
2
packages/remark-lint-list-item-spacing/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,40 +1,66 @@
|
||||
/**
|
||||
* remark-lint rule to warn when lists violate a given style.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the style of lists.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that lists are loose or tight when
|
||||
* they should be.
|
||||
* they should be is.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `undefined`) are accepted:
|
||||
* ### `unified().use(remarkLintListItemSpacing[, options])`
|
||||
*
|
||||
* * `Object` with the following fields:
|
||||
* * `checkBlanks` (`boolean`, default: `false`)
|
||||
* — adhere to CommonMark looseness instead of markdown-style-guide
|
||||
* preference
|
||||
* Warn when lists violate a given style.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` ([`Options`][api-options], optional)
|
||||
* — configuration
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ### `Options`
|
||||
*
|
||||
* Configuration (TypeScript type).
|
||||
*
|
||||
* ###### Fields
|
||||
*
|
||||
* * `checkBlanks` (`boolean`, default: `false`)
|
||||
* — whether to follow CommonMark looseness instead of `markdown-style-guide`
|
||||
* preference
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* First, some background.
|
||||
* There are two types of lists in markdown (other than ordered and unordered):
|
||||
* tight and loose lists.
|
||||
* First some background.
|
||||
* Regardless of ordered and unordered,
|
||||
* there are two kinds of lists in markdown,
|
||||
* tight and loose.
|
||||
* Lists are tight by default but if there is a blank line between two list
|
||||
* items or between two blocks inside an item, that turns the whole list into a
|
||||
* loose list.
|
||||
* When turning markdown into HTML, paragraphs in tight lists are not wrapped
|
||||
* in `<p>` tags.
|
||||
* items or between two blocks inside an item,
|
||||
* that turns the whole list into a loose list.
|
||||
* When turning markdown into HTML,
|
||||
* paragraphs in tight lists are not wrapped in `<p>` tags.
|
||||
*
|
||||
* This rule defaults to the
|
||||
* [`markdown style guide`](https://cirosantilli.com/markdown-style-guide/)
|
||||
* preference for which lists should be loose or not: loose when at least one
|
||||
* item spans more than one line, tight otherwise.
|
||||
* With `{checkBlanks: true}`, this rule dictates that when at least one item is
|
||||
* loose, all items must be loose.
|
||||
* This rule defaults to the [`markdown-style-guide`][markdown-style-guide]
|
||||
* preference for which lists should be loose or not:
|
||||
* loose when at least one item spans more than one line and tight otherwise.
|
||||
* With `{checkBlanks: true}`,
|
||||
* this rule follows whether a list is loose or not according to Commonmark,
|
||||
* and when one item is loose,
|
||||
* all items must be loose.
|
||||
*
|
||||
* [api-options]: #options
|
||||
* [api-remark-lint-list-item-spacing]: #unifieduseremarklintlistitemspacing-options
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
* [markdown-style-guide]: https://cirosantilli.com/markdown-style-guide/
|
||||
*
|
||||
* @module list-item-spacing
|
||||
* @summary
|
||||
* remark-lint rule to warn when lists are loose when they should be tight,
|
||||
* or vice versa.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
@ -140,8 +166,8 @@
|
||||
* @typedef Options
|
||||
* Configuration.
|
||||
* @property {boolean | null | undefined} [checkBlanks=false]
|
||||
* Follow CommonMark looseness instead of markdown-style-guide preference
|
||||
* (default: `false`).
|
||||
* Whether to follow CommonMark looseness instead of `markdown-style-guide`
|
||||
* preference (default: `false`).
|
||||
*/
|
||||
|
||||
import {lintRule} from 'unified-lint-rule'
|
||||
|
@ -14,11 +14,7 @@
|
||||
"rule",
|
||||
"tight"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-list-item-spacing"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-spacing",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -26,7 +22,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,16 +2,15 @@
|
||||
|
||||
# remark-lint-list-item-spacing
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when lists are loose when they should be tight,
|
||||
or vice versa.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when lists violate a given style.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -21,7 +20,8 @@ or vice versa.
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintListItemSpacing[, config])`](#unifieduseremarklintlistitemspacing-config)
|
||||
* [`unified().use(remarkLintListItemSpacing[, options])`](#unifieduseremarklintlistitemspacing-options)
|
||||
* [`Options`](#options)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -30,39 +30,38 @@ or vice versa.
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the style of lists.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that lists are loose or tight when
|
||||
they should be.
|
||||
they should be is.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-list-item-spacing
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintListItemSpacing from 'https://esm.sh/remark-lint-list-item-spacing@4'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -75,17 +74,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintListItemSpacing from 'remark-lint-list-item-spacing'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintListItemSpacing)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -94,7 +97,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-list-item-spacing example.md
|
||||
remark --frail --use remark-lint --use remark-lint-list-item-spacing .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -115,37 +118,53 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintListItemSpacing`.
|
||||
It exports the [TypeScript][typescript] type
|
||||
[`Options`][api-options].
|
||||
The default export is
|
||||
[`remarkLintListItemSpacing`][api-remark-lint-list-item-spacing].
|
||||
|
||||
### `unified().use(remarkLintListItemSpacing[, config])`
|
||||
### `unified().use(remarkLintListItemSpacing[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when lists violate a given style.
|
||||
|
||||
The following options (default: `undefined`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `Object` with the following fields:
|
||||
* `checkBlanks` (`boolean`, default: `false`)
|
||||
— adhere to CommonMark looseness instead of markdown-style-guide
|
||||
preference
|
||||
* `options` ([`Options`][api-options], optional)
|
||||
— configuration
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
### `Options`
|
||||
|
||||
Configuration (TypeScript type).
|
||||
|
||||
###### Fields
|
||||
|
||||
* `checkBlanks` (`boolean`, default: `false`)
|
||||
— whether to follow CommonMark looseness instead of `markdown-style-guide`
|
||||
preference
|
||||
|
||||
## Recommendation
|
||||
|
||||
First, some background.
|
||||
There are two types of lists in markdown (other than ordered and unordered):
|
||||
tight and loose lists.
|
||||
First some background.
|
||||
Regardless of ordered and unordered,
|
||||
there are two kinds of lists in markdown,
|
||||
tight and loose.
|
||||
Lists are tight by default but if there is a blank line between two list
|
||||
items or between two blocks inside an item, that turns the whole list into a
|
||||
loose list.
|
||||
When turning markdown into HTML, paragraphs in tight lists are not wrapped
|
||||
in `<p>` tags.
|
||||
items or between two blocks inside an item,
|
||||
that turns the whole list into a loose list.
|
||||
When turning markdown into HTML,
|
||||
paragraphs in tight lists are not wrapped in `<p>` tags.
|
||||
|
||||
This rule defaults to the
|
||||
[`markdown style guide`](https://cirosantilli.com/markdown-style-guide/)
|
||||
preference for which lists should be loose or not: loose when at least one
|
||||
item spans more than one line, tight otherwise.
|
||||
With `{checkBlanks: true}`, this rule dictates that when at least one item is
|
||||
loose, all items must be loose.
|
||||
This rule defaults to the [`markdown-style-guide`][markdown-style-guide]
|
||||
preference for which lists should be loose or not:
|
||||
loose when at least one item spans more than one line and tight otherwise.
|
||||
With `{checkBlanks: true}`,
|
||||
this rule follows whether a list is loose or not according to Commonmark,
|
||||
and when one item is loose,
|
||||
all items must be loose.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -269,71 +288,81 @@ A loose list:
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-list-item-spacing@4`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
[api-options]: #options
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-list-item-spacing.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-list-item-spacing
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-list-item-spacing.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-list-item-spacing
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-list-item-spacing]: #unifieduseremarklintlistitemspacing-options
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-list-item-spacing.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-list-item-spacing
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-list-item-spacing
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-list-item-spacing
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[markdown-style-guide]: https://cirosantilli.com/markdown-style-guide/
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-maximum-heading-length/.npmrc
Normal file
2
packages/remark-lint-maximum-heading-length/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,28 +1,42 @@
|
||||
/**
|
||||
* remark-lint rule to warn when headings are too long.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the length of heading text.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that heading text is within reason.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `60`) are accepted:
|
||||
* ### `unified().use(remarkLintMaximumHeadingLength[, options])`
|
||||
*
|
||||
* * `number` (example: `72`)
|
||||
* — max number of characters to accept in heading text
|
||||
* Warn when headings are too long.
|
||||
*
|
||||
* Ignores syntax, only checks the plain text content.
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` (`number`, default: `60`)
|
||||
* — preferred max size
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* While this rule is sometimes annoying, reasonable size headings
|
||||
* do help SEO purposes (bots prefer reasonable headings), visual users
|
||||
* (headings are typically displayed quite large), and users of screen readers
|
||||
* (who typically use “jump to heading” features to navigate within a page,
|
||||
* which reads every heading out loud).
|
||||
* While this rule is sometimes annoying,
|
||||
* reasonable size headings do help SEO purposes (bots prefer reasonable
|
||||
* headings),
|
||||
* visual users (headings are typically displayed quite large),
|
||||
* and users of screen readers (who use “jump to heading” features that read
|
||||
* every heading out loud to navigate within a page).
|
||||
*
|
||||
* [api-remark-lint-maximum-heading-length]: #unifieduseremarklintmaximumheadinglength-options
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module maximum-heading-length
|
||||
* @summary
|
||||
* remark-lint rule to warn when headings are too long.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
|
@ -12,11 +12,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-maximum-heading-length"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-maximum-heading-length",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -24,7 +20,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-maximum-heading-length
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when headings are too long.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when headings are too long.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintMaximumHeadingLength[, config])`](#unifieduseremarklintmaximumheadinglength-config)
|
||||
* [`unified().use(remarkLintMaximumHeadingLength[, options])`](#unifieduseremarklintmaximumheadinglength-options)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -29,9 +29,7 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the length of heading text.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
@ -39,28 +37,29 @@ You can use this package to check that heading text is within reason.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-maximum-heading-length
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintMaximumHeadingLength from 'https://esm.sh/remark-lint-maximum-heading-length@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -73,17 +72,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintMaximumHeadingLength from 'remark-lint-maximum-heading-length'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintMaximumHeadingLength)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -92,7 +95,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-maximum-heading-length example.md
|
||||
remark --frail --use remark-lint --use remark-lint-maximum-heading-length .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -113,27 +116,31 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintMaximumHeadingLength`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintMaximumHeadingLength`][api-remark-lint-maximum-heading-length].
|
||||
|
||||
### `unified().use(remarkLintMaximumHeadingLength[, config])`
|
||||
### `unified().use(remarkLintMaximumHeadingLength[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when headings are too long.
|
||||
|
||||
The following options (default: `60`) are accepted:
|
||||
###### Parameters
|
||||
|
||||
* `number` (example: `72`)
|
||||
— max number of characters to accept in heading text
|
||||
* `options` (`number`, default: `60`)
|
||||
— preferred max size
|
||||
|
||||
Ignores syntax, only checks the plain text content.
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
While this rule is sometimes annoying, reasonable size headings
|
||||
do help SEO purposes (bots prefer reasonable headings), visual users
|
||||
(headings are typically displayed quite large), and users of screen readers
|
||||
(who typically use “jump to heading” features to navigate within a page,
|
||||
which reads every heading out loud).
|
||||
While this rule is sometimes annoying,
|
||||
reasonable size headings do help SEO purposes (bots prefer reasonable
|
||||
headings),
|
||||
visual users (headings are typically displayed quite large),
|
||||
and users of screen readers (who use “jump to heading” features that read
|
||||
every heading out loud to navigate within a page).
|
||||
|
||||
## Examples
|
||||
|
||||
@ -169,71 +176,77 @@ When configured with `40`.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-maximum-heading-length@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-maximum-heading-length.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-maximum-heading-length
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-maximum-heading-length.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-maximum-heading-length
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-maximum-heading-length]: #unifieduseremarklintmaximumheadinglength-options
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-maximum-heading-length.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-maximum-heading-length
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-maximum-heading-length
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-maximum-heading-length
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
2
packages/remark-lint-maximum-line-length/.npmrc
Normal file
2
packages/remark-lint-maximum-line-length/.npmrc
Normal file
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,27 +1,45 @@
|
||||
/**
|
||||
* remark-lint rule to warn when lines are too long.
|
||||
*
|
||||
* ## What is this?
|
||||
*
|
||||
* This package checks the length of lines.
|
||||
*
|
||||
* ## When should I use this?
|
||||
*
|
||||
* You can use this package to check that lines do not exceed a certain size.
|
||||
* You can use this package to check that lines are within reason.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* The following options (default: `80`) are accepted:
|
||||
* ### `unified().use(remarkLintMaximumLineLength[, options])`
|
||||
*
|
||||
* * `number` (example: `72`)
|
||||
* — max number of characters to accept in heading text
|
||||
* Warn when lines are too long.
|
||||
*
|
||||
* Ignores nodes that cannot be wrapped, such as headings, tables, code,
|
||||
* definitions, HTML, and JSX.
|
||||
* Ignores images, links, and code (inline) if they start before the wrap, end
|
||||
* after the wrap, and there’s no white space after them.
|
||||
* Nodes that cannot be wrapped are ignored, such as JSX, HTML, code (flow),
|
||||
* definitions, headings, and tables.
|
||||
*
|
||||
* When code (phrasing), images, and links start before the wrap,
|
||||
* end after the wrap,
|
||||
* and contain no whitespace,
|
||||
* they are also ignored.
|
||||
*
|
||||
* ###### Parameters
|
||||
*
|
||||
* * `options` (`number`, default: `80`)
|
||||
* — preferred max size
|
||||
*
|
||||
* ###### Returns
|
||||
*
|
||||
* Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
*
|
||||
* ## Recommendation
|
||||
*
|
||||
* Whether to wrap prose or not is a stylistic choice.
|
||||
*
|
||||
* [api-remark-lint-maximum-line-length]: #unifieduseremarklintmaximumlinelength-options
|
||||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
*
|
||||
* @module maximum-line-length
|
||||
* @summary
|
||||
* remark-lint rule to warn when lines are too long.
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
@ -85,18 +103,12 @@
|
||||
* @example
|
||||
* {"name": "ok-mixed-line-endings.md", "config": 10, "positionless": true}
|
||||
*
|
||||
* 0123456789␍␊
|
||||
* 0123456789␊
|
||||
* 01234␍␊
|
||||
* 01234␊
|
||||
* 0123456789␍␊0123456789␊01234␍␊01234␊
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok-mixed-line-endings.md", "config": 10, "label": "input", "positionless": true}
|
||||
*
|
||||
* 012345678901␍␊
|
||||
* 012345678901␊
|
||||
* 01234567890␍␊
|
||||
* 01234567890␊
|
||||
* 012345678901␍␊012345678901␊01234567890␍␊01234567890␊
|
||||
*
|
||||
* @example
|
||||
* {"name": "not-ok-mixed-line-endings.md", "config": 10, "label": "output", "positionless": true}
|
||||
|
@ -12,11 +12,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-maximum-line-length"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-maximum-line-length",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -24,7 +20,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
@ -2,15 +2,15 @@
|
||||
|
||||
# remark-lint-maximum-line-length
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
[![Build][badge-build-image]][badge-build-url]
|
||||
[![Coverage][badge-coverage-image]][badge-coverage-url]
|
||||
[![Downloads][badge-downloads-image]][badge-downloads-url]
|
||||
[![Size][badge-size-image]][badge-size-url]
|
||||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url]
|
||||
[![Backers][badge-funding-backers-image]][badge-funding-url]
|
||||
[![Chat][badge-chat-image]][badge-chat-url]
|
||||
|
||||
[`remark-lint`][mono] rule to warn when lines are too long.
|
||||
[`remark-lint`][github-remark-lint] rule to warn when lines are too long.
|
||||
|
||||
## Contents
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* [Install](#install)
|
||||
* [Use](#use)
|
||||
* [API](#api)
|
||||
* [`unified().use(remarkLintMaximumLineLength[, config])`](#unifieduseremarklintmaximumlinelength-config)
|
||||
* [`unified().use(remarkLintMaximumLineLength[, options])`](#unifieduseremarklintmaximumlinelength-options)
|
||||
* [Recommendation](#recommendation)
|
||||
* [Examples](#examples)
|
||||
* [Compatibility](#compatibility)
|
||||
@ -29,38 +29,37 @@
|
||||
|
||||
## What is this?
|
||||
|
||||
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||
rule.
|
||||
Lint rules check markdown code style.
|
||||
This package checks the length of lines.
|
||||
|
||||
## When should I use this?
|
||||
|
||||
You can use this package to check that lines do not exceed a certain size.
|
||||
You can use this package to check that lines are within reason.
|
||||
|
||||
## Presets
|
||||
|
||||
This rule is included in the following presets:
|
||||
This plugin is included in the following presets:
|
||||
|
||||
| Preset | Setting |
|
||||
| Preset | Options |
|
||||
| - | - |
|
||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `80` |
|
||||
|
||||
## Install
|
||||
|
||||
This package is [ESM only][esm].
|
||||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||
This package is [ESM only][github-gist-esm].
|
||||
In Node.js (version 16+),
|
||||
install with [npm][npm-install]:
|
||||
|
||||
```sh
|
||||
npm install remark-lint-maximum-line-length
|
||||
```
|
||||
|
||||
In Deno with [`esm.sh`][esmsh]:
|
||||
In Deno with [`esm.sh`][esm-sh]:
|
||||
|
||||
```js
|
||||
import remarkLintMaximumLineLength from 'https://esm.sh/remark-lint-maximum-line-length@3'
|
||||
```
|
||||
|
||||
In browsers with [`esm.sh`][esmsh]:
|
||||
In browsers with [`esm.sh`][esm-sh]:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
@ -73,17 +72,21 @@ In browsers with [`esm.sh`][esmsh]:
|
||||
On the API:
|
||||
|
||||
```js
|
||||
import {remark} from 'remark'
|
||||
import remarkLint from 'remark-lint'
|
||||
import remarkLintMaximumLineLength from 'remark-lint-maximum-line-length'
|
||||
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 remark()
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLint)
|
||||
.use(remarkLintMaximumLineLength)
|
||||
.use(remarkStringify)
|
||||
.process(file)
|
||||
|
||||
console.error(reporter(file))
|
||||
@ -92,7 +95,7 @@ console.error(reporter(file))
|
||||
On the CLI:
|
||||
|
||||
```sh
|
||||
remark --use remark-lint --use remark-lint-maximum-line-length example.md
|
||||
remark --frail --use remark-lint --use remark-lint-maximum-line-length .
|
||||
```
|
||||
|
||||
On the CLI in a config file (here a `package.json`):
|
||||
@ -113,22 +116,30 @@ On the CLI in a config file (here a `package.json`):
|
||||
## API
|
||||
|
||||
This package exports no identifiers.
|
||||
The default export is `remarkLintMaximumLineLength`.
|
||||
It exports no additional [TypeScript][typescript] types.
|
||||
The default export is
|
||||
[`remarkLintMaximumLineLength`][api-remark-lint-maximum-line-length].
|
||||
|
||||
### `unified().use(remarkLintMaximumLineLength[, config])`
|
||||
### `unified().use(remarkLintMaximumLineLength[, options])`
|
||||
|
||||
This rule supports standard configuration that all remark lint rules accept
|
||||
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||
Warn when lines are too long.
|
||||
|
||||
The following options (default: `80`) are accepted:
|
||||
Nodes that cannot be wrapped are ignored, such as JSX, HTML, code (flow),
|
||||
definitions, headings, and tables.
|
||||
|
||||
* `number` (example: `72`)
|
||||
— max number of characters to accept in heading text
|
||||
When code (phrasing), images, and links start before the wrap,
|
||||
end after the wrap,
|
||||
and contain no whitespace,
|
||||
they are also ignored.
|
||||
|
||||
Ignores nodes that cannot be wrapped, such as headings, tables, code,
|
||||
definitions, HTML, and JSX.
|
||||
Ignores images, links, and code (inline) if they start before the wrap, end
|
||||
after the wrap, and there’s no white space after them.
|
||||
###### Parameters
|
||||
|
||||
* `options` (`number`, default: `80`)
|
||||
— preferred max size
|
||||
|
||||
###### Returns
|
||||
|
||||
Transform ([`Transformer` from `unified`][github-unified-transformer]).
|
||||
|
||||
## Recommendation
|
||||
|
||||
@ -140,7 +151,7 @@ Whether to wrap prose or not is a stylistic choice.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||
> 👉 **Note**: this example uses GFM ([`remark-gfm`][github-remark-gfm]).
|
||||
|
||||
```markdown
|
||||
This line is simply not toooooooooooooooooooooooooooooooooooooooooooo
|
||||
@ -214,15 +225,8 @@ When configured with `10`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `␍␊` represents a carriage return and a line feed.
|
||||
|
||||
> 👉 **Note**: `␊` represents a line feed.
|
||||
|
||||
```markdown
|
||||
0123456789␍␊
|
||||
0123456789␊
|
||||
01234␍␊
|
||||
01234␊
|
||||
0123456789␍␊0123456789␊01234␍␊01234␊
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -235,15 +239,8 @@ When configured with `10`.
|
||||
|
||||
###### In
|
||||
|
||||
> 👉 **Note**: `␍␊` represents a carriage return and a line feed.
|
||||
|
||||
> 👉 **Note**: `␊` represents a line feed.
|
||||
|
||||
```markdown
|
||||
012345678901␍␊
|
||||
012345678901␊
|
||||
01234567890␍␊
|
||||
01234567890␊
|
||||
012345678901␍␊012345678901␊01234567890␍␊01234567890␊
|
||||
```
|
||||
|
||||
###### Out
|
||||
@ -257,73 +254,79 @@ When configured with `10`.
|
||||
|
||||
## Compatibility
|
||||
|
||||
Projects maintained by the unified collective are compatible with all maintained
|
||||
Projects maintained by the unified collective are compatible with maintained
|
||||
versions of Node.js.
|
||||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||
|
||||
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-maximum-line-length@3`,
|
||||
compatible with Node.js 12.
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
||||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways
|
||||
to get started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
See [`support.md`][github-dotfiles-support] for ways to get help.
|
||||
|
||||
This project has a [code of conduct][coc].
|
||||
This project has a [code of conduct][github-dotfiles-coc].
|
||||
By interacting with this repository, organization, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
[MIT][file-license] © [Titus Wormer][author]
|
||||
|
||||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[build]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-maximum-line-length.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/remark-lint-maximum-line-length
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-maximum-line-length.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=remark-lint-maximum-line-length
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[chat]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[unified]: https://github.com/unifiedjs/unified
|
||||
|
||||
[remark]: https://github.com/remarkjs/remark
|
||||
|
||||
[mono]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[esmsh]: https://esm.sh
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[health]: https://github.com/remarkjs/.github
|
||||
|
||||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
[api-remark-lint-maximum-line-length]: #unifieduseremarklintmaximumlinelength-options
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[gfm]: https://github.com/remarkjs/remark-gfm
|
||||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
|
||||
|
||||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions
|
||||
|
||||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg
|
||||
|
||||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions
|
||||
|
||||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg
|
||||
|
||||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint
|
||||
|
||||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-maximum-line-length.svg
|
||||
|
||||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-maximum-line-length
|
||||
|
||||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[badge-funding-url]: https://opencollective.com/unified
|
||||
|
||||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-maximum-line-length
|
||||
|
||||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-maximum-line-length
|
||||
|
||||
[esm-sh]: https://esm.sh
|
||||
|
||||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||
|
||||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||
|
||||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||
|
||||
[github-dotfiles-health]: https://github.com/remarkjs/.github
|
||||
|
||||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||
|
||||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||
|
||||
[github-remark-gfm]: https://github.com/remarkjs/remark-gfm
|
||||
|
||||
[github-remark-lint]: https://github.com/remarkjs/remark-lint
|
||||
|
||||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer
|
||||
|
||||
[npm-install]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[typescript]: https://www.typescriptlang.org
|
||||
|
@ -0,0 +1,2 @@
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
@ -1,8 +1,16 @@
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* ## API
|
||||
*
|
||||
* to do: remove.
|
||||
*
|
||||
* [api-remark-lint-no-auto-link-without-protocol]: #api
|
||||
*
|
||||
* @module no-auto-link-without-protocol
|
||||
* @author Titus Wormer
|
||||
* @copyright 2015 Titus Wormer
|
||||
* @license MIT
|
||||
* @module no-auto-link-without-protocol
|
||||
* @deprecated
|
||||
* **Stability: Legacy**.
|
||||
* This rule is no longer recommended for use.
|
||||
|
@ -13,11 +13,7 @@
|
||||
"remark-lint-rule",
|
||||
"rule"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/remarkjs/remark-lint",
|
||||
"directory": "packages/remark-lint-no-auto-link-without-protocol"
|
||||
},
|
||||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-auto-link-without-protocol",
|
||||
"bugs": "https://github.com/remarkjs/remark-lint/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
@ -25,7 +21,7 @@
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
"Titus Wormer <tituswormer@gmail.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user