mirror of
https://github.com/remarkjs/remark-lint.git
synced 2024-08-16 15:20:38 +03:00
Add improved docs
Closes GH-276.
This commit is contained in:
parent
96e8c4f543
commit
014fca79e0
@ -11,7 +11,7 @@ import listOfRules from './script/plugin/list-of-rules.js'
|
|||||||
const plugins = [
|
const plugins = [
|
||||||
remarkPresetLintRecommended,
|
remarkPresetLintRecommended,
|
||||||
remarkPresetLintConsistent,
|
remarkPresetLintConsistent,
|
||||||
[remarkToc, {tight: true, maxDepth: 2, heading: 'contents'}],
|
[remarkToc, {tight: true, maxDepth: 3, heading: 'contents'}],
|
||||||
remarkCommentConfig,
|
remarkCommentConfig,
|
||||||
[remarkGfm, {tablePipeAlign: false}],
|
[remarkGfm, {tablePipeAlign: false}],
|
||||||
remarkGithub,
|
remarkGithub,
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
# [markdownlint](https://github.com/mivok/markdownlint)
|
# [markdownlint](https://github.com/markdownlint/markdownlint)
|
||||||
|
|
||||||
|
> ⚠️ **Important**: this comparison hasn’t been updated in years.
|
||||||
|
|
||||||
This table documents the similarity and difference between
|
This table documents the similarity and difference between
|
||||||
[**markdownlint**](https://github.com/mivok/markdownlint/blob/HEAD/docs/RULES.md)
|
[**markdownlint**](https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md)
|
||||||
rules and **remark-lint**’s rules.
|
rules and **remark-lint**’s rules.
|
||||||
|
|
||||||
| markdownlint | remark | note |
|
| markdownlint | remark | note |
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# Create a custom `remark-lint` rule
|
# Create a custom `remark-lint` rule
|
||||||
|
|
||||||
This guide is part of [a step-by-step tutorial](https://dev.to/floroz/how-to-create-a-custom-lint-rule-for-markdown-and-mdx-using-remark-and-eslint-2jim), and will help you getting started to create your first linting plugin for `remark`.
|
This guide is part of [a step-by-step tutorial][tutorial], and will help you
|
||||||
|
getting started to create your first linting plugin for `remark`.
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
@ -31,8 +32,10 @@ Now we can start installing our dependencies:
|
|||||||
npm install remark-lint remark-cli
|
npm install remark-lint remark-cli
|
||||||
```
|
```
|
||||||
|
|
||||||
* [`remark-lint`](https://github.com/remarkjs/remark-lint): Core lint plugin
|
* [`remark-lint`][remark-lint]
|
||||||
* [`remark-cli`](https://github.com/remarkjs/remark/tree/main/packages/remark-cli): Command-line interface
|
— core lint plugin
|
||||||
|
* [`remark-cli`][remark-cli]
|
||||||
|
— command line interface
|
||||||
|
|
||||||
We will also use some utilities:
|
We will also use some utilities:
|
||||||
|
|
||||||
@ -42,13 +45,12 @@ npm install unified-lint-rule unist-util-generated unist-util-visit
|
|||||||
|
|
||||||
These will help us creating and managing our custom rules.
|
These will help us creating and managing our custom rules.
|
||||||
|
|
||||||
[Back to Top](#contents)
|
|
||||||
|
|
||||||
## Set up remark
|
## Set up remark
|
||||||
|
|
||||||
With everything installed, we can now create a `.remarkrc.js` that will contain the plugins we’ll use.
|
With everything installed, we can now create a `.remarkrc.js` that will contain
|
||||||
|
the plugins we’ll use.
|
||||||
|
|
||||||
For more info on configuration, see [Configuring `remark-lint`](https://github.com/remarkjs/remark-lint#configuring-remark-lint).
|
For more info on configuration, see [Examples in `remark-lint`][examples].
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
touch .remarkrc.js
|
touch .remarkrc.js
|
||||||
@ -61,7 +63,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, in our `package.json`, add the following script to process all the markdown files in our project:
|
Then, in our `package.json`, add the following script to process all the
|
||||||
|
markdown files in our project:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -87,7 +90,8 @@ Some funny images of our favorite pets
|
|||||||
![a lovely dog](lovely-dog.png)
|
![a lovely dog](lovely-dog.png)
|
||||||
```
|
```
|
||||||
|
|
||||||
At this point, we have a working `remark` configuration and a markdown file in the project.
|
At this point, we have a working `remark` configuration and a markdown file in
|
||||||
|
the project.
|
||||||
|
|
||||||
If we run `npm run lint` we should expect to see in our terminal:
|
If we run `npm run lint` we should expect to see in our terminal:
|
||||||
|
|
||||||
@ -95,14 +99,15 @@ If we run `npm run lint` we should expect to see in our terminal:
|
|||||||
doc.md: no issues found
|
doc.md: no issues found
|
||||||
```
|
```
|
||||||
|
|
||||||
All good, the file has been processed, and because we haven’t specified any plugins nor lint rules, no issues are found.
|
All good, the file has been processed, and because we haven’t specified any
|
||||||
|
plugins nor lint rules, no issues are found.
|
||||||
[Back to Top](#contents)
|
|
||||||
|
|
||||||
## The `no-invalid-gif` rule
|
## The `no-invalid-gif` rule
|
||||||
|
|
||||||
Let’s imagine we want to write a rule that checks whether a `.gif` file is used as an image.
|
Let’s imagine we want to write a rule that checks whether a `.gif` file is used
|
||||||
Given the content of our `doc.md` file declared above, we would expect an *error* or *warning* pointing to:
|
as an image.
|
||||||
|
Given the content of our `doc.md` file declared above, we would expect an
|
||||||
|
*error* or *warning* pointing to:
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
![a funny cat](funny-cat.gif)
|
![a funny cat](funny-cat.gif)
|
||||||
@ -110,11 +115,10 @@ Given the content of our `doc.md` file declared above, we would expect an *error
|
|||||||
|
|
||||||
Because the file extension `.gif` in the image violates our rule.
|
Because the file extension `.gif` in the image violates our rule.
|
||||||
|
|
||||||
[Back to Top](#contents)
|
|
||||||
|
|
||||||
## Create the custom rule
|
## Create the custom rule
|
||||||
|
|
||||||
Let’s create a new folder `rules` under the root directory, where we will place all of our custom rules, and create a new file in it named `no-gif-allowed.js`.
|
Let’s create a new folder `rules` under the root directory, where we will place
|
||||||
|
all of our custom rules, and create a new file in it named `no-gif-allowed.js`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkdir rules
|
mkdir rules
|
||||||
@ -123,11 +127,14 @@ touch no-gif-allowed.js
|
|||||||
cd .. # return to project root
|
cd .. # return to project root
|
||||||
```
|
```
|
||||||
|
|
||||||
*Note*: the name of folders and files, and where to place them within your project, is up to you.
|
*Note*: the name of folders and files, and where to place them within your
|
||||||
|
project, is up to you.
|
||||||
|
|
||||||
In `./rules/no-gif-allowed.js`, let’s import `unified-lint-rule`.
|
In `./rules/no-gif-allowed.js`, let’s import `unified-lint-rule`.
|
||||||
|
|
||||||
We then export the result of calling `rule` by providing the *namespace and rule name* (`remark-lint:no-gif-allowed`) as the first argument, and our implementation of the rule (`noGifAllowed`) as the second argument.
|
We then export the result of calling `rule` by providing the *namespace and rule
|
||||||
|
name* (`remark-lint:no-gif-allowed`) as the first argument, and our
|
||||||
|
implementation of the rule (`noGifAllowed`) as the second argument.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// rules/no-gif-allowed.js
|
// rules/no-gif-allowed.js
|
||||||
@ -143,7 +150,8 @@ const remarkLintNoGifAllowed = lintRule(
|
|||||||
export default remarkLintNoGifAllowed
|
export default remarkLintNoGifAllowed
|
||||||
```
|
```
|
||||||
|
|
||||||
Let’s say you want all your custom rules to be defined as part of your project namespace.
|
Let’s say you want all your custom rules to be defined as part of your project
|
||||||
|
namespace.
|
||||||
If your project was named `my-project`, then you can export your rule as:
|
If your project was named `my-project`, then you can export your rule as:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@ -152,9 +160,8 @@ const remarkLintNoGifAllowed = lintRule('my-project-name:no-gif-allowed', () =>
|
|||||||
const remarkLintNoGifAllowed = lintRule('my-npm-published-package:no-gif-allowed', () => {})
|
const remarkLintNoGifAllowed = lintRule('my-npm-published-package:no-gif-allowed', () => {})
|
||||||
```
|
```
|
||||||
|
|
||||||
This can help you when wanting to create a group of rules under the same *namespace*.
|
This can help you when wanting to create a group of rules under the same
|
||||||
|
*namespace*.
|
||||||
[Back to Top](#contents)
|
|
||||||
|
|
||||||
## Rule arguments
|
## Rule arguments
|
||||||
|
|
||||||
@ -164,17 +171,20 @@ Your rule function will receive three arguments:
|
|||||||
(tree, file, options) => {}
|
(tree, file, options) => {}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `tree` (*required*): [mdast](https://github.com/syntax-tree/mdast)
|
* `tree` (*required*): [mdast][]
|
||||||
* `file` (*required*): [virtual file](https://github.com/vfile/vfile)
|
* `file` (*required*): [virtual file][vfile]
|
||||||
* `options` (*optional*): additional information passed to the rule by users
|
* `options` (*optional*): additional info passed to the rule by users
|
||||||
|
|
||||||
[Back to Top](#contents)
|
|
||||||
|
|
||||||
## Rule implementation
|
## Rule implementation
|
||||||
|
|
||||||
Because we will be inspecting [mdast](https://github.com/syntax-tree/mdast), which is a markdown abstract syntax tree built upon [unist](https://github.com/syntax-tree/unist), we can take advantage of the many existing [unist utilities](https://github.com/syntax-tree/unist#utilities) to inspect our tree’s nodes.
|
Because we will be inspecting [mdast][], which is a markdown abstract syntax
|
||||||
|
tree built upon [unist][], we can take advantage of the many existing
|
||||||
|
[unist utilities][unist-util] to inspect our tree’s nodes.
|
||||||
|
|
||||||
For this example, we will use [`unist-util-visit`](https://github.com/syntax-tree/unist-util-visit) to recursively inspect all the image nodes, and [`unist-util-generated`](https://github.com/syntax-tree/unist-util-generated) to ensure we are not inspecting nodes that we have generated ourselves and do not belong to the `doc.md`.
|
For this example, we will use [`unist-util-visit`][unist-util-visit] to
|
||||||
|
recursively inspect all the image nodes, and
|
||||||
|
[`unist-util-generated`][unist-util-generated] to ensure we are not inspecting
|
||||||
|
nodes that we have generated ourselves and do not belong to the `doc.md`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import {lintRule} from 'unified-lint-rule'
|
import {lintRule} from 'unified-lint-rule'
|
||||||
@ -205,7 +215,7 @@ const remarkLintNoGifAllowed = lintRule(
|
|||||||
// Remember to provide the node as second argument to the message,
|
// Remember to provide the node as second argument to the message,
|
||||||
// in order to obtain the position and column where the violation occurred.
|
// in order to obtain the position and column where the violation occurred.
|
||||||
file.message(
|
file.message(
|
||||||
'Invalid image file extentions. Please do not use gifs',
|
'Invalid image file extensions. Please do not use gifs',
|
||||||
node
|
node
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -217,11 +227,10 @@ const remarkLintNoGifAllowed = lintRule(
|
|||||||
export default remarkLintNoGifAllowed
|
export default remarkLintNoGifAllowed
|
||||||
```
|
```
|
||||||
|
|
||||||
[Back to Top](#contents)
|
|
||||||
|
|
||||||
## Import the rule in your remark config
|
## Import the rule in your remark config
|
||||||
|
|
||||||
Now that our custom rule is defined and ready to be used we need to add it to our `remark` configuration.
|
Now that our custom rule is defined and ready to be used we need to add it to
|
||||||
|
our `remark` configuration.
|
||||||
|
|
||||||
You can do that by importing your rule and adding it in `plugins` array:
|
You can do that by importing your rule and adding it in `plugins` array:
|
||||||
|
|
||||||
@ -238,16 +247,33 @@ const preset = {plugins}
|
|||||||
export default preset
|
export default preset
|
||||||
```
|
```
|
||||||
|
|
||||||
[Back to Top](#contents)
|
|
||||||
|
|
||||||
## Apply the rule on the Markdown file
|
## Apply the rule on the Markdown file
|
||||||
|
|
||||||
If you run `npm run lint`, you should see the following message in the terminal:
|
If you run `npm run lint`, you should see the following message in the terminal:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
5:1-5:30 warning Invalid image file extentions. Please do not use gifs no-gif-allowed remark-lint
|
5:1-5:30 warning Invalid image file extensions. Please do not use gifs no-gif-allowed remark-lint
|
||||||
```
|
```
|
||||||
|
|
||||||
**Congratulations! The rule works!**
|
**Congratulations!
|
||||||
|
The rule works!**
|
||||||
|
|
||||||
[Back to Top](#contents)
|
[tutorial]: https://dev.to/floroz/how-to-create-a-custom-lint-rule-for-markdown-and-mdx-using-remark-and-eslint-2jim
|
||||||
|
|
||||||
|
[remark-lint]: https://github.com/remarkjs/remark-lint
|
||||||
|
|
||||||
|
[remark-cli]: https://github.com/remarkjs/remark/tree/main/packages/remark-cli
|
||||||
|
|
||||||
|
[examples]: https://github.com/remarkjs/remark-lint#examples
|
||||||
|
|
||||||
|
[mdast]: https://github.com/syntax-tree/mdast
|
||||||
|
|
||||||
|
[vfile]: https://github.com/vfile/vfile
|
||||||
|
|
||||||
|
[unist]: https://github.com/syntax-tree/unist
|
||||||
|
|
||||||
|
[unist-util]: https://github.com/syntax-tree/unist#utilities
|
||||||
|
|
||||||
|
[unist-util-visit]: https://github.com/syntax-tree/unist-util-visit
|
||||||
|
|
||||||
|
[unist-util-generated]: https://github.com/syntax-tree/unist-util-generated
|
||||||
|
150
doc/rules.md
150
doc/rules.md
@ -1,155 +1,13 @@
|
|||||||
# Rules
|
# Rules
|
||||||
|
|
||||||
This document describes how to configure rules and lists all available official
|
|
||||||
rules. Each rule is a separate package. See their readme’s for more
|
|
||||||
information.
|
|
||||||
|
|
||||||
## Contents
|
|
||||||
|
|
||||||
* [Configuration](#configuration)
|
|
||||||
* [List of rules](#list-of-rules)
|
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
`false` turns rules off — the code no longer runs:
|
See the monorepo readme for [configuring rules][config].
|
||||||
|
|
||||||
```js
|
|
||||||
import remarkLintFinalNewline from 'remark-lint-final-newline'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLintFinalNewline, false)
|
|
||||||
// …
|
|
||||||
```
|
|
||||||
|
|
||||||
`true` turns a rule on again:
|
|
||||||
|
|
||||||
```js
|
|
||||||
import remarkLintFinalNewline from 'remark-lint-final-newline'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLintFinalNewline, true)
|
|
||||||
// …
|
|
||||||
```
|
|
||||||
|
|
||||||
Rules can be configured with a severity too. The following ignores all
|
|
||||||
messages from the plugin:
|
|
||||||
|
|
||||||
```js
|
|
||||||
import remarkLintFinalNewline from 'remark-lint-final-newline'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLintFinalNewline, [0])
|
|
||||||
// …
|
|
||||||
```
|
|
||||||
|
|
||||||
…and passing `[1]` explicitly sets the normal behavior (warn for problems).
|
|
||||||
To trigger an error instead of a warning, pass `2`:
|
|
||||||
|
|
||||||
```js
|
|
||||||
import remarkLintFinalNewline from 'remark-lint-final-newline'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLintFinalNewline, [2])
|
|
||||||
// …
|
|
||||||
```
|
|
||||||
|
|
||||||
It’s also possible to pass both a severity and configuration:
|
|
||||||
|
|
||||||
```js
|
|
||||||
import remarkLintMaximumLineLength from 'remark-lint-maximum-line-length'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLintMaximumLineLength, [2, 70])
|
|
||||||
// …
|
|
||||||
```
|
|
||||||
|
|
||||||
Lastly, strings can also be passed, instead of numbers:
|
|
||||||
`off` instead of `0`, `warn` or `on` instead of `1`, and
|
|
||||||
`error` instead of `2`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
import remarkLintMaximumLineLength from 'remark-lint-maximum-line-length'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLintMaximumLineLength, ['error', 70])
|
|
||||||
// …
|
|
||||||
```
|
|
||||||
|
|
||||||
## List of rules
|
## List of rules
|
||||||
|
|
||||||
This lists contains all “official” rules, developed in this repository.
|
See the monorepo readme for the [rules][].
|
||||||
For rules developed outside of this repo, view the [List of External
|
|
||||||
Rules][external].
|
|
||||||
|
|
||||||
<!--rules start-->
|
[config]: https://github.com/remarkjs/remark-lint#configure
|
||||||
|
|
||||||
* [`blockquote-indentation`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-blockquote-indentation) — warn when block quotes are either indented too much or too little
|
[rules]: https://github.com/remarkjs/remark-lint#rules
|
||||||
* [`checkbox-character-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-checkbox-character-style) — warn when list item checkboxes violate a given style
|
|
||||||
* [`checkbox-content-indent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-checkbox-content-indent) — warn when list item checkboxes are followed by too much whitespace
|
|
||||||
* [`code-block-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-code-block-style) — warn when code blocks do not adhere to a given style
|
|
||||||
* [`definition-case`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-definition-case) — warn when definition labels are not lowercase
|
|
||||||
* [`definition-spacing`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-definition-spacing) — warn when consecutive whitespace is used in a definition
|
|
||||||
* [`emphasis-marker`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-emphasis-marker) — warn when emphasis markers violate the given style
|
|
||||||
* [`fenced-code-flag`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-flag) — warn when fenced code blocks occur without language flag
|
|
||||||
* [`fenced-code-marker`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-marker) — warn when fenced code markers violate the given style
|
|
||||||
* [`file-extension`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-file-extension) — warn when the file’s extension violates the given style
|
|
||||||
* [`final-definition`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-final-definition) — warn when definitions are not placed at the end of the file
|
|
||||||
* [`final-newline`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-final-newline) — warn when a newline at the end of a file is missing
|
|
||||||
* [`first-heading-level`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-first-heading-level) — warn when the first heading has a level other than a specified value
|
|
||||||
* [`hard-break-spaces`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-hard-break-spaces) — warn when too many spaces are used to create a hard break
|
|
||||||
* [`heading-increment`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-heading-increment) — warn when headings increment with more than 1 level at a time
|
|
||||||
* [`heading-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-heading-style) — warn when heading style violates the given style
|
|
||||||
* [`linebreak-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-linebreak-style) — warn when linebreaks violate a given or detected style
|
|
||||||
* [`link-title-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-link-title-style) — warn when link and definition titles occur with incorrect quotes
|
|
||||||
* [`list-item-bullet-indent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-bullet-indent) — warn when list item bullets are indented
|
|
||||||
* [`list-item-content-indent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-content-indent) — warn when the content of a list item has mixed indentation
|
|
||||||
* [`list-item-indent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-indent) — warn when the spacing between a list item’s bullet and its content violates a given style
|
|
||||||
* [`list-item-spacing`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-spacing) — warn when list looseness is incorrect
|
|
||||||
* [`maximum-heading-length`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-maximum-heading-length) — warn when headings are too long
|
|
||||||
* [`maximum-line-length`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-maximum-line-length) — warn when lines are too long
|
|
||||||
* [`no-blockquote-without-marker`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-blockquote-without-marker) — warn when blank lines without markers (\`>\`) are found in a block quote
|
|
||||||
* [`no-consecutive-blank-lines`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-consecutive-blank-lines) — warn for too many consecutive blank lines
|
|
||||||
* [`no-duplicate-defined-urls`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-duplicate-defined-urls) — warn on definitions that define the same urls
|
|
||||||
* [`no-duplicate-definitions`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-duplicate-definitions) — warn on duplicate definitions
|
|
||||||
* [`no-duplicate-headings`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-duplicate-headings) — warn on duplicate headings
|
|
||||||
* [`no-duplicate-headings-in-section`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-duplicate-headings-in-section) — warn on duplicate headings in a section
|
|
||||||
* [`no-emphasis-as-heading`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-emphasis-as-heading) — warn when emphasis or importance is used instead of a heading
|
|
||||||
* [`no-empty-url`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-empty-url) — warn on empty URLs in links and images
|
|
||||||
* [`no-file-name-articles`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-articles) — warn when file name start with an article
|
|
||||||
* [`no-file-name-consecutive-dashes`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-consecutive-dashes) — warn when file names contain consecutive dashes
|
|
||||||
* [`no-file-name-irregular-characters`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-irregular-characters) — warn when file names contain irregular characters
|
|
||||||
* [`no-file-name-mixed-case`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-mixed-case) — warn when file names use mixed case
|
|
||||||
* [`no-file-name-outer-dashes`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-outer-dashes) — warn when file names contain initial or final dashes
|
|
||||||
* [`no-heading-content-indent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-heading-content-indent) — warn when heading content is indented
|
|
||||||
* [`no-heading-indent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-heading-indent) — warn when headings are indented
|
|
||||||
* [`no-heading-like-paragraph`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-heading-like-paragraph) — for too many hashes (h7+ “headings”)
|
|
||||||
* [`no-heading-punctuation`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-heading-punctuation) — warn when headings end in illegal characters
|
|
||||||
* [`no-html`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-html) — warn when HTML nodes are used
|
|
||||||
* [`no-inline-padding`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-inline-padding) — warn when inline nodes are padded with spaces
|
|
||||||
* [`no-literal-urls`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-literal-urls) — warn when URLs without angle brackets are used
|
|
||||||
* [`no-missing-blank-lines`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-missing-blank-lines) — warn when missing blank lines
|
|
||||||
* [`no-multiple-toplevel-headings`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-multiple-toplevel-headings) — warn when multiple top level headings are used
|
|
||||||
* [`no-paragraph-content-indent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-paragraph-content-indent) — warn when the content in paragraphs are indented
|
|
||||||
* [`no-reference-like-url`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-reference-like-url) — warn when URLs are also defined identifiers
|
|
||||||
* [`no-shell-dollars`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-shell-dollars) — warn when shell code is prefixed by dollars
|
|
||||||
* [`no-shortcut-reference-image`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-shortcut-reference-image) — warn when shortcut reference images are used
|
|
||||||
* [`no-shortcut-reference-link`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-shortcut-reference-link) — warn when shortcut reference links are used
|
|
||||||
* [`no-table-indentation`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-table-indentation) — warn when tables are indented
|
|
||||||
* [`no-tabs`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-tabs) — warn when hard tabs are used instead of spaces
|
|
||||||
* [`no-undefined-references`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-undefined-references) — warn when references to undefined definitions are found
|
|
||||||
* [`no-unneeded-full-reference-image`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-unneeded-full-reference-image) — warn when full reference images are used if they can be collapsed
|
|
||||||
* [`no-unneeded-full-reference-link`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-unneeded-full-reference-link) — warn when full reference links are used if they can be collapsed
|
|
||||||
* [`no-unused-definitions`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-unused-definitions) — warn when unused definitions are found
|
|
||||||
* [`ordered-list-marker-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-ordered-list-marker-style) — warn when the markers of ordered lists violate a given style
|
|
||||||
* [`ordered-list-marker-value`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-ordered-list-marker-value) — warn when the marker value of ordered lists violates a given style
|
|
||||||
* [`rule-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-rule-style) — warn when horizontal rules violate a given style
|
|
||||||
* [`strikethrough-marker`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-strikethrough-marker) — warn when strikethrough markers violate the given style
|
|
||||||
* [`strong-marker`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-strong-marker) — warn when importance (strong) markers violate the given style
|
|
||||||
* [`table-cell-padding`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-cell-padding) — warn when table cells are incorrectly padded
|
|
||||||
* [`table-pipe-alignment`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-pipe-alignment) — warn when table pipes are not aligned
|
|
||||||
* [`table-pipes`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-pipes) — warn when table rows are not fenced with pipes
|
|
||||||
* [`unordered-list-marker-style`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-unordered-list-marker-style) — warn when markers of unordered lists violate a given style
|
|
||||||
|
|
||||||
<!--rules end-->
|
|
||||||
|
|
||||||
[external]: https://github.com/remarkjs/remark-lint#list-of-external-rules
|
|
||||||
|
17
logo.svg
17
logo.svg
@ -1,5 +1,14 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" viewBox="0 0 410 210">
|
<svg xmlns="http://www.w3.org/2000/svg" width="1012" height="300" viewBox="0 0 1012 300">
|
||||||
<path fill="#d80303" d="M6.57 126L14.01 126L14.01 98.03C14.01 91.93 16.50 86.94 24.49 86.94C25.87 86.94 27.33 86.98 28.10 87.11L28.10 80.37C27.20 80.24 26.25 80.15 25.31 80.15C18.91 80.15 15.51 83.68 14.18 86.38L13.96 86.38L13.96 80.84L6.57 80.84ZM53.50 126.73C63.46 126.73 69.44 121.19 71.16 113.71L63.81 113.71C62.35 117.92 58.91 120.54 53.67 120.54C46.32 120.54 41.94 114.66 41.94 106.06L41.94 105.25L71.76 105.25L71.76 101.04C71.76 88.62 64.97 80.11 53.15 80.11C41.29 80.11 34.55 88.62 34.55 100.52L34.55 105.59C34.55 118.44 41.72 126.73 53.50 126.73ZM41.94 99.27L41.94 99.14C41.94 92.01 46.32 86.30 53.20 86.30C59.94 86.30 64.37 91.97 64.37 99.14L64.37 99.27Z"/>
|
<style>
|
||||||
<path d="M82.93 126L90.32 126L90.32 97.38C90.32 90.55 94.66 86.77 100.20 86.77C106.35 86.77 110.04 90.55 110.04 97.47L110.04 126L117.39 126L117.39 97.47C117.39 91.20 120.96 86.77 127.36 86.77C133.80 86.77 137.11 91.02 137.11 96.78L137.11 126L144.46 126L144.46 95.28C144.46 86.00 138.83 80.11 129.29 80.11C121.95 80.11 117.18 83.50 115.46 87.37L115.11 87.37C113.35 82.95 109.14 80.11 102.09 80.11C96.12 80.11 92.13 83.29 90.66 86.38L90.28 86.38L90.28 80.84L82.93 80.84ZM182.66 120.37L182.88 120.37L182.88 126L189.96 126L189.96 94.85C189.96 85.35 182.96 80.11 173.34 80.11C162.42 80.11 157.05 85.87 156.58 93.77L163.54 93.77C163.97 89.26 167.28 86.30 173.08 86.30C179.18 86.30 182.62 89.56 182.62 95.49L182.62 100.09L170.71 100.09C160.36 100.13 154.86 105.12 154.86 113.02C154.86 121.32 160.88 126.73 169.60 126.73C176.26 126.73 180.38 124.02 182.66 120.37ZM171.57 120.59C166.85 120.59 162.42 118.09 162.42 112.77C162.42 108.68 165.09 105.76 171.27 105.76L182.62 105.76L182.62 111.00C182.62 116.63 177.89 120.59 171.57 120.59ZM202.73 126L210.16 126L210.16 98.03C210.16 91.93 212.65 86.94 220.64 86.94C222.02 86.94 223.48 86.98 224.25 87.11L224.25 80.37C223.35 80.24 222.41 80.15 221.46 80.15C215.06 80.15 211.66 83.68 210.33 86.38L210.12 86.38L210.12 80.84L202.73 80.84ZM240.02 109.71L244.19 105.16L259.53 126L268.60 126L249.65 100.48L267.48 80.84L258.33 80.84L240.32 100.82L240.02 100.82L240.02 64.25L232.63 64.25L232.63 126L240.02 126Z"/>
|
.b {fill: #0d1117}
|
||||||
<path fill="#d80303" d="M274.57 126L281.92 126L281.92 64.25L274.57 64.25ZM295.80 126L303.19 126L303.19 80.84L295.80 80.84ZM294.77 69.97C294.77 72.59 296.87 74.65 299.49 74.65C302.11 74.65 304.26 72.59 304.26 69.97C304.26 67.30 302.11 65.24 299.49 65.24C296.87 65.24 294.77 67.30 294.77 69.97ZM316.81 126L324.20 126L324.20 98.50C324.20 92.31 327.55 86.81 335.33 86.81C341.90 86.81 346.37 90.68 346.37 98.29L346.37 126L353.76 126L353.76 97.04C353.76 86.04 346.84 80.11 337.56 80.11C330.21 80.11 326.05 83.93 324.37 86.81L324.16 86.81L324.16 80.84L316.81 80.84ZM369.06 80.84L362.96 80.84L362.96 87.03L369.02 87.03L369.02 113.37C369.02 122.26 371.21 126.39 381.91 126.39C383.45 126.39 385 126.21 385.64 126.09L385.64 120.16C385.04 120.24 384.48 120.24 383.75 120.24C378.21 120.24 376.41 118.87 376.41 113.45L376.41 87.03L385.34 87.03L385.34 80.84L376.41 80.84L376.41 69.58L369.06 69.58Z"/>
|
.l {fill: #fff}
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
.b {fill: #fff}
|
||||||
|
.l {fill: #0d1117}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<rect class="b" x="0" y="0" width="1012" height="300" />
|
||||||
|
<path fill="#d80303" d="M336.61 173.50L336.61 159.32Q336.61 152.84 339.62 149.00Q342.64 145.17 347.74 145.17L347.74 145.17Q349.03 145.17 350.43 145.40Q351.84 145.63 352.92 146.04L352.92 146.04L352.92 141.86Q352.19 141.53 350.95 141.34Q349.70 141.15 348.32 141.15L348.32 141.15Q343.72 141.15 340.74 143.45Q337.75 145.75 336.93 149.97L336.93 149.97L336.52 149.97L336.52 141.94L325.62 141.94L325.62 145.05L332.77 145.05L332.77 173.50L336.61 173.50ZM326.26 173.50L346.63 173.50L346.63 170.39L326.26 170.39L326.26 173.50ZM375.51 144.81L375.51 144.81Q379.70 144.81 382.06 147.67Q384.42 150.53 384.42 155.57L384.42 155.57L366.37 155.57Q366.37 150.50 368.80 147.66Q371.23 144.81 375.51 144.81ZM388.17 165.70L384.36 165.70Q383.63 168.02 381.40 169.31Q379.17 170.60 375.95 170.60L375.95 170.60Q371.56 170.60 368.96 167.68Q366.37 164.77 366.37 159.81L366.37 159.81L366.37 158.73L388.31 158.73L388.31 156.24Q388.31 151.52 386.81 148.21Q385.30 144.90 382.44 143.16Q379.58 141.42 375.51 141.42L375.51 141.42Q371.62 141.42 368.69 143.13Q365.76 144.84 364.14 147.93Q362.53 151.03 362.53 155.19L362.53 155.19L362.53 159.79Q362.53 166.52 366.06 170.27Q369.59 174.02 375.95 174.02L375.95 174.02Q379.14 174.02 381.71 173.00Q384.27 171.97 385.96 170.10Q387.64 168.22 388.17 165.70L388.17 165.70Z"/>
|
||||||
|
<path class="l" d="M427.87 173.50L427.87 150.85Q427.87 146.16 426.12 143.79Q424.38 141.42 420.92 141.42L420.92 141.42Q418.49 141.42 416.64 142.71Q414.80 143.99 414.15 146.16L414.15 146.16L413.74 146.16Q413.25 143.91 411.71 142.66Q410.17 141.42 407.91 141.42L407.91 141.42Q405.75 141.42 404.12 142.69Q402.49 143.96 401.88 146.16L401.88 146.16L401.47 146.16L401.47 141.94L397.98 141.94L397.98 173.50L401.59 173.50L401.59 152.37Q401.59 148.89 402.95 146.88Q404.31 144.87 406.68 144.87L406.68 144.87Q408.94 144.87 410.07 146.59Q411.20 148.30 411.20 151.70L411.20 151.70L411.20 173.50L414.80 173.50L414.80 152.37Q414.80 148.86 416.13 146.87Q417.46 144.87 419.78 144.87L419.78 144.87Q422.01 144.87 423.13 146.60Q424.26 148.33 424.26 151.73L424.26 151.73L424.26 173.50L427.87 173.50ZM447.23 174.05L447.23 174.05Q450.80 174.05 453.34 172.63Q455.87 171.21 456.99 168.54L456.99 168.54L457.40 168.54L457.40 173.53L461.09 173.53L461.09 151.85Q461.09 147.04 458.11 144.36Q455.14 141.68 449.78 141.68L449.78 141.68Q446.73 141.68 444.26 142.72Q441.78 143.76 440.21 145.58Q438.65 147.39 438.35 149.77L438.35 149.77L442.16 149.77Q442.84 147.48 444.81 146.25Q446.79 145.02 449.78 145.02L449.78 145.02Q453.41 145.02 455.32 146.82Q457.22 148.62 457.22 152.02L457.22 152.02L457.22 155.01L448.08 155.42Q442.87 155.65 440.01 158.04Q437.15 160.43 437.15 164.59L437.15 164.59Q437.15 168.87 439.92 171.46Q442.69 174.05 447.23 174.05ZM448.17 170.65L448.17 170.65Q444.89 170.65 443.00 169.03Q441.11 167.40 441.11 164.59L441.11 164.59Q441.11 158.91 448.34 158.58L448.34 158.58L457.22 158.20L457.22 162.60Q457.22 164.85 456.02 166.68Q454.82 168.52 452.77 169.58Q450.72 170.65 448.17 170.65ZM485.61 173.50L485.61 159.32Q485.61 152.84 488.63 149.00Q491.64 145.17 496.74 145.17L496.74 145.17Q498.03 145.17 499.44 145.40Q500.84 145.63 501.93 146.04L501.93 146.04L501.93 141.86Q501.20 141.53 499.95 141.34Q498.71 141.15 497.33 141.15L497.33 141.15Q492.73 141.15 489.74 143.45Q486.75 145.75 485.93 149.97L485.93 149.97L485.52 149.97L485.52 141.94L474.62 141.94L474.62 145.05L481.77 145.05L481.77 173.50L485.61 173.50ZM475.27 173.50L495.63 173.50L495.63 170.39L475.27 170.39L475.27 173.50ZM533.30 141.94L518.48 156.80L518.13 156.80L518.13 129.38L514.29 129.38L514.29 173.50L518.13 173.50L518.13 161.54L523.72 156.09L524.66 155.19L538.17 141.94L533.30 141.94ZM525.19 153.43L522.41 155.92L534.42 173.50L539.05 173.50L525.19 153.43Z"/>
|
||||||
|
<path fill="#d80303" d="M551 173.50L576.75 173.50L576.75 170.39L565.94 170.39L565.94 129.38L550.94 129.38L550.94 132.48L562.10 132.48L562.10 170.39L551 170.39L551 173.50ZM600.69 133.59L600.69 133.59Q602.18 133.59 603.25 132.52Q604.32 131.46 604.32 129.96L604.32 129.96Q604.32 128.47 603.25 127.40Q602.18 126.33 600.69 126.33L600.69 126.33Q599.19 126.33 598.12 127.40Q597.05 128.47 597.05 129.96L597.05 129.96Q597.05 131.46 598.12 132.52Q599.19 133.59 600.69 133.59ZM588.09 173.50L613.84 173.50L613.84 170.39L603.03 170.39L603.03 141.94L588.03 141.94L588.03 145.05L599.19 145.05L599.19 170.39L588.09 170.39L588.09 173.50ZM624.71 141.94L624.71 173.50L628.55 173.50L628.55 154.75Q628.55 150.35 631.17 147.61Q633.79 144.87 638.04 144.87L638.04 144.87Q642.03 144.87 643.93 147.10Q645.83 149.33 645.83 153.96L645.83 153.96L645.83 173.50L649.67 173.50L649.67 152.99Q649.67 147.36 646.95 144.39Q644.22 141.42 639.07 141.42L639.07 141.42Q635.40 141.42 632.72 143.03Q630.04 144.64 628.75 147.63L628.75 147.63L628.37 147.63L628.37 141.94L624.71 141.94ZM673.17 133.74L669.33 133.74L669.33 141.94L660.83 141.94L660.83 145.20L669.33 145.20L669.33 164.38Q669.33 167.49 670.59 169.56Q671.85 171.62 674.37 172.65Q676.89 173.67 680.67 173.67L680.67 173.67Q682.04 173.67 683.86 173.55Q685.68 173.44 686.38 173.32L686.38 173.32L686.38 170.04Q685.62 170.16 684.07 170.21Q682.51 170.27 680.87 170.27L680.87 170.27Q677.12 170.27 675.15 168.74Q673.17 167.20 673.17 164.27L673.17 164.27L673.17 145.20L686.38 145.20L686.38 141.94L673.17 141.94L673.17 133.74Z"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 5.4 KiB |
@ -1,16 +1,46 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## 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.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* The following options (default: `'consistent'`) are accepted:
|
||||||
|
*
|
||||||
|
* * `number` (example: `2`)
|
||||||
|
* — preferred indent of `>` and spaces before content
|
||||||
|
* * `'consistent'`
|
||||||
|
* — detect the first used style and warn when further block quotes differ
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* CommonMark specifies that when block quotes are used the `>` markers can be
|
||||||
|
* followed by an optional space.
|
||||||
|
* No space at all arguably looks rather ugly:
|
||||||
|
*
|
||||||
|
* ```markdown
|
||||||
|
* >Mars and
|
||||||
|
* >Venus.
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* There is no specific handling of more that one space, so if 5 spaces were
|
||||||
|
* used after `>`, then indented code kicks in:
|
||||||
|
*
|
||||||
|
* ```markdown
|
||||||
|
* > neptune()
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Due to this, it’s recommended to configure this rule with `2`.
|
||||||
|
*
|
||||||
|
* @module blockquote-indentation
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when block quotes are indented too much or
|
||||||
|
* too little.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module blockquote-indentation
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when block quotes are indented too much or too little.
|
|
||||||
*
|
|
||||||
* Options: `number` or `'consistent'`, default: `'consistent'`.
|
|
||||||
*
|
|
||||||
* `'consistent'` detects the first used indentation and will warn when
|
|
||||||
* other block quotes use a different indentation.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md", "setting": 4}
|
* {"name": "ok.md", "setting": 4}
|
||||||
*
|
*
|
||||||
|
@ -10,12 +10,35 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when block quotes are indented too much or too little.
|
[`remark-lint`][mono] rule to warn when block quotes are indented too much or
|
||||||
|
too little.
|
||||||
|
|
||||||
Options: `number` or `'consistent'`, default: `'consistent'`.
|
## Contents
|
||||||
|
|
||||||
`'consistent'` detects the first used indentation and will warn when
|
* [What is this?](#what-is-this)
|
||||||
other block quotes use a different indentation.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintBlockquoteIndentation[, config])`](#unifieduseremarklintblockquoteindentation-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -26,7 +49,111 @@ This rule is included in the following presets:
|
|||||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
| [`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` |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `2` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-blockquote-indentation
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintBlockquoteIndentation from 'https://cdn.skypack.dev/remark-lint-blockquote-indentation@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintBlockquoteIndentation from 'https://cdn.skypack.dev/remark-lint-blockquote-indentation@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintBlockquoteIndentation from 'remark-lint-blockquote-indentation'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintBlockquoteIndentation)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-blockquote-indentation example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-blockquote-indentation",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintBlockquoteIndentation`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintBlockquoteIndentation[, config])`
|
||||||
|
|
||||||
|
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: `'consistent'`) are accepted:
|
||||||
|
|
||||||
|
* `number` (example: `2`)
|
||||||
|
— preferred indent of `>` and spaces before content
|
||||||
|
* `'consistent'`
|
||||||
|
— detect the first used style and warn when further block quotes differ
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
CommonMark specifies that when block quotes are used the `>` markers can be
|
||||||
|
followed by an optional space.
|
||||||
|
No space at all arguably looks rather ugly:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
>Mars and
|
||||||
|
>Venus.
|
||||||
|
```
|
||||||
|
|
||||||
|
There is no specific handling of more that one space, so if 5 spaces were
|
||||||
|
used after `>`, then indented code kicks in:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
> neptune()
|
||||||
|
```
|
||||||
|
|
||||||
|
Due to this, it’s recommended to configure this rule with `2`.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -87,59 +214,12 @@ Paragraph.
|
|||||||
9:3: Add 1 space between block quote and content
|
9:3: Add 1 space between block quote and content
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-blockquote-indentation
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintBlockquoteIndentation`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-blockquote-indentation",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-blockquote-indentation readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintBlockquoteIndentation from 'remark-lint-blockquote-indentation'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintBlockquoteIndentation)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -181,17 +261,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,31 +1,41 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
|
||||||
* @license MIT
|
|
||||||
* @module checkbox-character-style
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when list item checkboxes violate a given style.
|
|
||||||
*
|
*
|
||||||
* Options: `Object` or `'consistent'`, default: `'consistent'`.
|
* You can use this package to check that the style of GFM tasklists is
|
||||||
|
* consistent.
|
||||||
*
|
*
|
||||||
* `'consistent'` detects the first used checked and unchecked checkbox
|
* ## API
|
||||||
* styles and warns when subsequent checkboxes use different styles.
|
|
||||||
*
|
*
|
||||||
* Styles can also be passed in like so:
|
* The following options (default: `'consistent'`) are accepted:
|
||||||
*
|
*
|
||||||
* ```js
|
* * `Object` with the following fields:
|
||||||
* {checked: 'x', unchecked: ' '}
|
* * `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
|
||||||
|
*
|
||||||
|
* ## 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)
|
||||||
|
* to make all checkboxes align.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* formats checked checkboxes using `x` (lowercase X) and unchecked checkboxes
|
* formats checked checkboxes using `'x'` (lowercase X) and unchecked checkboxes
|
||||||
* as `·` (a single space).
|
* using `'·'` (a space).
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @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
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md", "setting": {"checked": "x"}, "gfm": true}
|
* {"name": "ok.md", "setting": {"checked": "x"}, "gfm": true}
|
||||||
*
|
*
|
||||||
|
@ -10,27 +10,35 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when list item checkboxes violate a given style.
|
[`remark-lint`][mono] rule to warn when list item checkboxes violate a given
|
||||||
|
style.
|
||||||
|
|
||||||
Options: `Object` or `'consistent'`, default: `'consistent'`.
|
## Contents
|
||||||
|
|
||||||
`'consistent'` detects the first used checked and unchecked checkbox
|
* [What is this?](#what-is-this)
|
||||||
styles and warns when subsequent checkboxes use different styles.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintCheckboxCharacterStyle[, config])`](#unifieduseremarklintcheckboxcharacterstyle-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
Styles can also be passed in like so:
|
## What is this?
|
||||||
|
|
||||||
```js
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
{checked: 'x', unchecked: ' '}
|
rule.
|
||||||
```
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
## Fix
|
## When should I use this?
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
You can use this package to check that the style of GFM tasklists is
|
||||||
formats checked checkboxes using `x` (lowercase X) and unchecked checkboxes
|
consistent.
|
||||||
as `·` (a single space).
|
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -40,7 +48,107 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-checkbox-character-style
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintCheckboxCharacterStyle from 'https://cdn.skypack.dev/remark-lint-checkbox-character-style@4?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintCheckboxCharacterStyle from 'https://cdn.skypack.dev/remark-lint-checkbox-character-style@4?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintCheckboxCharacterStyle from 'remark-lint-checkbox-character-style'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintCheckboxCharacterStyle)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-checkbox-character-style example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-checkbox-character-style",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintCheckboxCharacterStyle`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintCheckboxCharacterStyle[, config])`
|
||||||
|
|
||||||
|
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: `'consistent'`) are accepted:
|
||||||
|
|
||||||
|
* `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
|
||||||
|
|
||||||
|
## 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)
|
||||||
|
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).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -48,7 +156,7 @@ When configured with `{ checked: 'x' }`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: this example uses [GFM][].
|
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
- [x] List item
|
- [x] List item
|
||||||
@ -65,7 +173,7 @@ When configured with `{ checked: 'X' }`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: this example uses [GFM][].
|
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
- [X] List item
|
- [X] List item
|
||||||
@ -82,9 +190,9 @@ When configured with `{ unchecked: ' ' }`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: this example uses [GFM][].
|
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
- [ ] List item
|
- [ ] List item
|
||||||
@ -103,9 +211,9 @@ When configured with `{ unchecked: '\t' }`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: this example uses [GFM][].
|
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||||
|
|
||||||
Note: `»` represents a tab.
|
> 👉 **Note**: `»` represents a tab.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
- [»] List item
|
- [»] List item
|
||||||
@ -120,9 +228,9 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: this example uses [GFM][].
|
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||||
|
|
||||||
Note: `»` represents a tab.
|
> 👉 **Note**: `»` represents a tab.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
- [x] List item
|
- [x] List item
|
||||||
@ -158,59 +266,12 @@ When configured with `{ checked: '💩' }`.
|
|||||||
1:1: Incorrect checked checkbox marker `💩`: use either `'x'`, or `'X'`
|
1:1: Incorrect checked checkbox marker `💩`: use either `'x'`, or `'X'`
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-checkbox-character-style
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintCheckboxCharacterStyle`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-checkbox-character-style",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-checkbox-character-style readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintCheckboxCharacterStyle from 'remark-lint-checkbox-character-style'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintCheckboxCharacterStyle)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -252,17 +313,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,42 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that the “indent” after a GFM tasklist
|
||||||
|
* checkbox is a single space.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no accepted options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* GFM allows zero or more spaces and tabs after checkboxes.
|
||||||
|
* No space at all arguably looks rather ugly:
|
||||||
|
*
|
||||||
|
* ```markdown
|
||||||
|
* * [x]Pluto
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* More that one space is superfluous:
|
||||||
|
*
|
||||||
|
* ```markdown
|
||||||
|
* * [x] Jupiter
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @module checkbox-content-indent
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when GFM tasklist checkboxes are followed by
|
||||||
|
* more than one space.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module checkbox-content-indent
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when list item checkboxes are followed by too much whitespace.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md", "gfm": true}
|
* {"name": "ok.md", "gfm": true}
|
||||||
*
|
*
|
||||||
|
@ -10,19 +10,148 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when list item checkboxes are followed by too much whitespace.
|
[`remark-lint`][mono] rule to warn when GFM tasklist checkboxes are followed by
|
||||||
|
more than one space.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintCheckboxContentIndent[, config])`](#unifieduseremarklintcheckboxcontentindent-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that the “indent” after a GFM tasklist
|
||||||
|
checkbox is a single space.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
This rule is not included in any default preset
|
This rule is not included in a preset maintained here.
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-checkbox-content-indent
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintCheckboxContentIndent from 'https://cdn.skypack.dev/remark-lint-checkbox-content-indent@4?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintCheckboxContentIndent from 'https://cdn.skypack.dev/remark-lint-checkbox-content-indent@4?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintCheckboxContentIndent from 'remark-lint-checkbox-content-indent'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintCheckboxContentIndent)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-checkbox-content-indent example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-checkbox-content-indent",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintCheckboxContentIndent`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintCheckboxContentIndent[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no accepted options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
GFM allows zero or more spaces and tabs after checkboxes.
|
||||||
|
No space at all arguably looks rather ugly:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
* [x]Pluto
|
||||||
|
```
|
||||||
|
|
||||||
|
More that one space is superfluous:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
* [x] Jupiter
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: this example uses [GFM][].
|
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
- [ ] List item
|
- [ ] List item
|
||||||
@ -39,7 +168,7 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: this example uses [GFM][].
|
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
- [ ] List item
|
- [ ] List item
|
||||||
@ -56,59 +185,12 @@ Note: this example uses [GFM][].
|
|||||||
4:7-4:10: Checkboxes should be followed by a single character
|
4:7-4:10: Checkboxes should be followed by a single character
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-checkbox-content-indent
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintCheckboxContentIndent`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-checkbox-content-indent",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-checkbox-content-indent readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintCheckboxContentIndent from 'remark-lint-checkbox-content-indent'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintCheckboxContentIndent)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -150,17 +232,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,27 +1,52 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
|
||||||
* @license MIT
|
|
||||||
* @module code-block-style
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when code blocks do not adhere to a given style.
|
|
||||||
*
|
*
|
||||||
* Options: `'consistent'`, `'fenced'`, or `'indented'`, default: `'consistent'`.
|
* You can use this package to check that code blocks are consistent.
|
||||||
*
|
*
|
||||||
* `'consistent'` detects the first used code block style and warns when
|
* ## API
|
||||||
* subsequent code blocks uses different styles.
|
*
|
||||||
|
* The following options (default: `'consistent'`) are accepted:
|
||||||
|
*
|
||||||
|
* * `'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
|
||||||
|
*
|
||||||
|
* ## 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
|
||||||
|
* programming language.
|
||||||
|
* 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
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* formats code blocks using a fence if they have a language flag and
|
* formats code blocks as fenced code when they have a language flag and as
|
||||||
* indentation if not.
|
* indented code otherwise.
|
||||||
* Pass
|
* Pass
|
||||||
* [`fences: true`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionsfences)
|
* [`fences: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsfences)
|
||||||
* to always use fences for code blocks.
|
* to always use fenced code.
|
||||||
*
|
*
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
* @module code-block-style
|
||||||
* on how to automatically fix warnings for this rule.
|
* @summary
|
||||||
|
* remark-lint rule to warn when code blocks violate a given style.
|
||||||
|
* @author Titus Wormer
|
||||||
|
* @copyright 2015 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* {"setting": "indented", "name": "ok.md"}
|
* {"setting": "indented", "name": "ok.md"}
|
||||||
|
@ -10,24 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when code blocks do not adhere to a given style.
|
[`remark-lint`][mono] rule to warn when code blocks violate a given style.
|
||||||
|
|
||||||
Options: `'consistent'`, `'fenced'`, or `'indented'`, default: `'consistent'`.
|
## Contents
|
||||||
|
|
||||||
`'consistent'` detects the first used code block style and warns when
|
* [What is this?](#what-is-this)
|
||||||
subsequent code blocks uses different styles.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintCodeBlockStyle[, config])`](#unifieduseremarklintcodeblockstyle-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
## Fix
|
## What is this?
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
formats code blocks using a fence if they have a language flag and
|
rule.
|
||||||
indentation if not.
|
Lint rules check markdown code style.
|
||||||
Pass
|
|
||||||
[`fences: true`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionsfences)
|
|
||||||
to always use fences for code blocks.
|
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
## When should I use this?
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
You can use this package to check that code blocks are consistent.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -38,7 +47,120 @@ This rule is included in the following presets:
|
|||||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
| [`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'` |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'fenced'` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-code-block-style
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintCodeBlockStyle from 'https://cdn.skypack.dev/remark-lint-code-block-style@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintCodeBlockStyle from 'https://cdn.skypack.dev/remark-lint-code-block-style@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintCodeBlockStyle from 'remark-lint-code-block-style'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintCodeBlockStyle)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-code-block-style example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-code-block-style",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintCodeBlockStyle`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintCodeBlockStyle[, config])`
|
||||||
|
|
||||||
|
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: `'consistent'`) are accepted:
|
||||||
|
|
||||||
|
* `'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
|
||||||
|
|
||||||
|
## 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
|
||||||
|
programming language.
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -156,59 +278,12 @@ When configured with `'💩'`.
|
|||||||
1:1: Incorrect code block style `💩`: use either `'consistent'`, `'fenced'`, or `'indented'`
|
1:1: Incorrect code block style `💩`: use either `'consistent'`, `'fenced'`, or `'indented'`
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-code-block-style
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintCodeBlockStyle`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-code-block-style",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-code-block-style readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintCodeBlockStyle from 'remark-lint-code-block-style'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintCodeBlockStyle)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -250,17 +325,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,26 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that the labels used in definitions
|
||||||
|
* are lowercase.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* Definitions and references are matched together regardless of casing.
|
||||||
|
* Using uppercase in labels might incorrectly indicate that casing is of
|
||||||
|
* importance.
|
||||||
|
* Due to this, it’s recommended to use lowercase and turn this rule on.
|
||||||
|
*
|
||||||
|
* @module definition-case
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when definition labels are not lowercase.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module definition-case
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when definition labels are not lowercase.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when definition labels are not lowercase.
|
[`remark-lint`][mono] rule to warn when definition labels are not lowercase.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintDefinitionCase[, config])`](#unifieduseremarklintdefinitioncase-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that the labels used in definitions
|
||||||
|
are lowercase.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -20,7 +46,93 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-definition-case
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintDefinitionCase from 'https://cdn.skypack.dev/remark-lint-definition-case@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintDefinitionCase from 'https://cdn.skypack.dev/remark-lint-definition-case@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintDefinitionCase from 'remark-lint-definition-case'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintDefinitionCase)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-definition-case example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-definition-case",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintDefinitionCase`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintDefinitionCase[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
Definitions and references are matched together regardless of casing.
|
||||||
|
Using uppercase in labels might incorrectly indicate that casing is of
|
||||||
|
importance.
|
||||||
|
Due to this, it’s recommended to use lowercase and turn this rule on.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -48,59 +160,12 @@ No messages.
|
|||||||
1:1-1:47: Do not use uppercase characters in definition labels
|
1:1-1:47: Do not use uppercase characters in definition labels
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-definition-case
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintDefinitionCase`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-definition-case",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-definition-case readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintDefinitionCase from 'remark-lint-definition-case'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintDefinitionCase)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -142,17 +207,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,28 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that the labels used in definitions
|
||||||
|
* do not use meaningless white space.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* Definitions and references are matched together by collapsing white space.
|
||||||
|
* Using more white space 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.
|
||||||
|
*
|
||||||
|
* @module definition-spacing
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when consecutive whitespace is used in
|
||||||
|
* a definition label.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module definition-spacing
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when consecutive whitespace is used in a definition.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,34 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when consecutive whitespace is used in a definition.
|
[`remark-lint`][mono] rule to warn when consecutive whitespace is used in
|
||||||
|
a definition label.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintDefinitionSpacing[, config])`](#unifieduseremarklintdefinitionspacing-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that the labels used in definitions
|
||||||
|
do not use meaningless white space.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -20,7 +47,94 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-definition-spacing
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintDefinitionSpacing from 'https://cdn.skypack.dev/remark-lint-definition-spacing@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintDefinitionSpacing from 'https://cdn.skypack.dev/remark-lint-definition-spacing@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintDefinitionSpacing from 'remark-lint-definition-spacing'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintDefinitionSpacing)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-definition-spacing example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-definition-spacing",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintDefinitionSpacing`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintDefinitionSpacing[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
Definitions and references are matched together by collapsing white space.
|
||||||
|
Using more white space 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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -38,7 +152,7 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
[example····domain]: http://example.com "Example Domain"
|
[example····domain]: http://example.com "Example Domain"
|
||||||
@ -50,59 +164,12 @@ Note: `·` represents a space.
|
|||||||
1:1-1:57: Do not use consecutive whitespace in definition labels
|
1:1-1:57: Do not use consecutive whitespace in definition labels
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-definition-spacing
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintDefinitionSpacing`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-definition-spacing",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-definition-spacing readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintDefinitionSpacing from 'remark-lint-definition-spacing'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintDefinitionSpacing)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -144,17 +211,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,27 +1,44 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
|
||||||
* @license MIT
|
|
||||||
* @module emphasis-marker
|
|
||||||
* @fileoverview
|
|
||||||
* Warn for violating emphasis markers.
|
|
||||||
*
|
*
|
||||||
* Options: `'consistent'`, `'*'`, or `'_'`, default: `'consistent'`.
|
* You can use this package to check that emphasis markers are consistent.
|
||||||
*
|
*
|
||||||
* `'consistent'` detects the first used emphasis style and warns when
|
* ## API
|
||||||
* subsequent emphasis use different styles.
|
*
|
||||||
|
* The following options (default: `'consistent'`) are accepted:
|
||||||
|
*
|
||||||
|
* * `'*'`
|
||||||
|
* — prefer asterisks
|
||||||
|
* * `'_'`
|
||||||
|
* — prefer underscores
|
||||||
|
* * `'consistent'`
|
||||||
|
* — detect the first used style and warn when further emphasis differs
|
||||||
|
*
|
||||||
|
* ## 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.
|
||||||
|
* 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.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* formats emphasis using `_` (underscore) by default.
|
* formats emphasis with asterisks by default.
|
||||||
* Pass
|
* Pass
|
||||||
* [`emphasis: '*'`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionsemphasis)
|
* [`emphasis: '_'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsemphasis)
|
||||||
* to use `*` (asterisk) instead.
|
* to always use underscores.
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @module emphasis-marker
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when emphasis markers are inconsistent.
|
||||||
|
* @author Titus Wormer
|
||||||
|
* @copyright 2015 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
* @example
|
* @example
|
||||||
* {"setting": "*", "name": "ok.md"}
|
* {"setting": "*", "name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,23 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn for violating emphasis markers.
|
[`remark-lint`][mono] rule to warn when emphasis markers are inconsistent.
|
||||||
|
|
||||||
Options: `'consistent'`, `'*'`, or `'_'`, default: `'consistent'`.
|
## Contents
|
||||||
|
|
||||||
`'consistent'` detects the first used emphasis style and warns when
|
* [What is this?](#what-is-this)
|
||||||
subsequent emphasis use different styles.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintEmphasisMarker[, config])`](#unifieduseremarklintemphasismarker-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
## Fix
|
## What is this?
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
formats emphasis using `_` (underscore) by default.
|
rule.
|
||||||
Pass
|
Lint rules check markdown code style.
|
||||||
[`emphasis: '*'`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionsemphasis)
|
|
||||||
to use `*` (asterisk) instead.
|
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
## When should I use this?
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
You can use this package to check that emphasis markers are consistent.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -37,7 +47,112 @@ This rule is included in the following presets:
|
|||||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
| [`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) | `'*'` |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'*'` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-emphasis-marker
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintEmphasisMarker from 'https://cdn.skypack.dev/remark-lint-emphasis-marker@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintEmphasisMarker from 'https://cdn.skypack.dev/remark-lint-emphasis-marker@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintEmphasisMarker from 'remark-lint-emphasis-marker'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintEmphasisMarker)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-emphasis-marker example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-emphasis-marker",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintEmphasisMarker`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintEmphasisMarker[, config])`
|
||||||
|
|
||||||
|
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: `'consistent'`) are accepted:
|
||||||
|
|
||||||
|
* `'*'`
|
||||||
|
— prefer asterisks
|
||||||
|
* `'_'`
|
||||||
|
— prefer underscores
|
||||||
|
* `'consistent'`
|
||||||
|
— detect the first used style and warn when further emphasis differs
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
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.
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -124,59 +239,12 @@ When configured with `'💩'`.
|
|||||||
1:1: Incorrect emphasis marker `💩`: use either `'consistent'`, `'*'`, or `'_'`
|
1:1: Incorrect emphasis marker `💩`: use either `'consistent'`, `'*'`, or `'_'`
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-emphasis-marker
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintEmphasisMarker`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-emphasis-marker",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-emphasis-marker readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintEmphasisMarker from 'remark-lint-emphasis-marker'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintEmphasisMarker)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -218,17 +286,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,19 +1,34 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that language flags of fenced code
|
||||||
|
* are used and consistent.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* The following options (default: `undefined`) are accepted:
|
||||||
|
*
|
||||||
|
* * `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)
|
||||||
|
*
|
||||||
|
* ## 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.
|
||||||
|
*
|
||||||
|
* @module fenced-code-flag
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to check that language flags of fenced code are used.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module fenced-code-flag
|
|
||||||
* @fileoverview
|
|
||||||
* Check fenced code block flags.
|
|
||||||
*
|
|
||||||
* Options: `Array<string>` or `Object`, optional.
|
|
||||||
*
|
|
||||||
* Providing an array is as passing `{flags: Array}`.
|
|
||||||
*
|
|
||||||
* The object can have an array of `'flags'` which are allowed: other flags
|
|
||||||
* will not be allowed.
|
|
||||||
* An `allowEmpty` field (`boolean`, default: `false`) can be set to allow
|
|
||||||
* code blocks without language flags.
|
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
|
@ -10,16 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Check fenced code block flags.
|
[`remark-lint`][mono] rule to check that language flags of fenced code are used.
|
||||||
|
|
||||||
Options: `Array<string>` or `Object`, optional.
|
## Contents
|
||||||
|
|
||||||
Providing an array is as passing `{flags: Array}`.
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintFencedCodeFlag[, config])`](#unifieduseremarklintfencedcodeflag-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
The object can have an array of `'flags'` which are allowed: other flags
|
## What is this?
|
||||||
will not be allowed.
|
|
||||||
An `allowEmpty` field (`boolean`, default: `false`) can be set to allow
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
code blocks without language flags.
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that language flags of fenced code
|
||||||
|
are used and consistent.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -29,7 +46,101 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `{ allowEmpty: false }` |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `{ allowEmpty: false }` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-fenced-code-flag
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintFencedCodeFlag from 'https://cdn.skypack.dev/remark-lint-fenced-code-flag@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintFencedCodeFlag from 'https://cdn.skypack.dev/remark-lint-fenced-code-flag@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintFencedCodeFlag from 'remark-lint-fenced-code-flag'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintFencedCodeFlag)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-fenced-code-flag example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-fenced-code-flag",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintFencedCodeFlag`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintFencedCodeFlag[, config])`
|
||||||
|
|
||||||
|
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: `undefined`) are accepted:
|
||||||
|
|
||||||
|
* `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)
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -145,59 +256,12 @@ bravo()
|
|||||||
1:1-3:4: Incorrect code language flag
|
1:1-3:4: Incorrect code language flag
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-fenced-code-flag
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintFencedCodeFlag`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-fenced-code-flag",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-fenced-code-flag readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintFencedCodeFlag from 'remark-lint-fenced-code-flag'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintFencedCodeFlag)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -239,17 +303,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,27 +1,38 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
|
||||||
* @license MIT
|
|
||||||
* @module fenced-code-marker
|
|
||||||
* @fileoverview
|
|
||||||
* Warn for violating fenced code markers.
|
|
||||||
*
|
*
|
||||||
* Options: `` '`' ``, `'~'`, or `'consistent'`, default: `'consistent'`.
|
* You can use this package to check that fenced code markers are consistent.
|
||||||
*
|
*
|
||||||
* `'consistent'` detects the first used fenced code marker style and warns
|
* ## API
|
||||||
* when subsequent fenced code blocks use different styles.
|
*
|
||||||
|
* The following options (default: `'consistent'`) are accepted:
|
||||||
|
*
|
||||||
|
* * ``'`'``
|
||||||
|
* — prefer grave accents
|
||||||
|
* * `'~'`
|
||||||
|
* — prefer tildes
|
||||||
|
* * `'consistent'`
|
||||||
|
* — detect the first used style and warn when further fenced code differs
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* Tildes are extremely uncommon.
|
||||||
|
* Due to this, it’s recommended to configure this rule with ``'`'``.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* formats fences using ``'`'`` (grave accent) by default.
|
* formats fenced code with grave accents by default.
|
||||||
* Pass
|
* Pass
|
||||||
* [`fence: '~'`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionsfence)
|
* [`fence: '~'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsfence)
|
||||||
* to use `~` (tilde) instead.
|
* to always use tildes.
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @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
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,23 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn for violating fenced code markers.
|
[`remark-lint`][mono] rule to warn when fenced code markers are inconsistent.
|
||||||
|
|
||||||
Options: ``'`'``, `'~'`, or `'consistent'`, default: `'consistent'`.
|
## Contents
|
||||||
|
|
||||||
`'consistent'` detects the first used fenced code marker style and warns
|
* [What is this?](#what-is-this)
|
||||||
when subsequent fenced code blocks use different styles.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintFencedCodeMarker[, config])`](#unifieduseremarklintfencedcodemarker-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
## Fix
|
## What is this?
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
formats fences using ``'`'`` (grave accent) by default.
|
rule.
|
||||||
Pass
|
Lint rules check markdown code style.
|
||||||
[`fence: '~'`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionsfence)
|
|
||||||
to use `~` (tilde) instead.
|
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
## When should I use this?
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
You can use this package to check that fenced code markers are consistent.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -37,7 +47,106 @@ This rule is included in the following presets:
|
|||||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
| [`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) | ``'`'`` |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | ``'`'`` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-fenced-code-marker
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintFencedCodeMarker from 'https://cdn.skypack.dev/remark-lint-fenced-code-marker@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintFencedCodeMarker from 'https://cdn.skypack.dev/remark-lint-fenced-code-marker@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintFencedCodeMarker from 'remark-lint-fenced-code-marker'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintFencedCodeMarker)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-fenced-code-marker example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-fenced-code-marker",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintFencedCodeMarker`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintFencedCodeMarker[, config])`
|
||||||
|
|
||||||
|
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: `'consistent'`) are accepted:
|
||||||
|
|
||||||
|
* ``'`'``
|
||||||
|
— prefer grave accents
|
||||||
|
* `'~'`
|
||||||
|
— prefer tildes
|
||||||
|
* `'consistent'`
|
||||||
|
— detect the first used style and warn when further fenced code differs
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
Tildes are extremely uncommon.
|
||||||
|
Due to this, 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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -143,59 +252,12 @@ When configured with `'💩'`.
|
|||||||
1:1: Incorrect fenced code marker `💩`: use either `'consistent'`, `` '`' ``, or `'~'`
|
1:1: Incorrect fenced code marker `💩`: use either `'consistent'`, `` '`' ``, or `'~'`
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-fenced-code-marker
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintFencedCodeMarker`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-fenced-code-marker",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-fenced-code-marker readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintFencedCodeMarker from 'remark-lint-fenced-code-marker'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintFencedCodeMarker)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -237,17 +299,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,16 +1,31 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that file extensions are `md`.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* The following options (default: `'md'`) are accepted:
|
||||||
|
*
|
||||||
|
* * `string` (example `'markdown'`)
|
||||||
|
* — preferred file extension (no dot)
|
||||||
|
*
|
||||||
|
* > 👉 **Note**: does not warn when files have no file extensions (such as
|
||||||
|
* > `AUTHORS` or `LICENSE`).
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* Use `md` as it’s the most common.
|
||||||
|
* Also use `md` when your markdown contains common syntax extensions (such as
|
||||||
|
* GFM, frontmatter, or math).
|
||||||
|
* Do not use `md` for MDX: use `mdx` instead.
|
||||||
|
*
|
||||||
|
* @module file-extension
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to check the file extension.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module file-extension
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when the file extension differ from the preferred extension.
|
|
||||||
*
|
|
||||||
* Does not warn when given documents have no file extensions (such as
|
|
||||||
* `AUTHORS` or `LICENSE`).
|
|
||||||
*
|
|
||||||
* Options: `string`, default: `'md'` — Expected file extension.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "readme.md"}
|
* {"name": "readme.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,12 +10,32 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when the file extension differ from the preferred extension.
|
[`remark-lint`][mono] rule to check the file extension.
|
||||||
|
|
||||||
Does not warn when given documents have no file extensions (such as
|
## Contents
|
||||||
`AUTHORS` or `LICENSE`).
|
|
||||||
|
|
||||||
Options: `string`, default: `'md'` — Expected file extension.
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintFileExtension[, config])`](#unifieduseremarklintfileextension-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that file extensions are `md`.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -25,7 +45,99 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'md'` |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'md'` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-file-extension
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintFileExtension from 'https://cdn.skypack.dev/remark-lint-file-extension@2?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintFileExtension from 'https://cdn.skypack.dev/remark-lint-file-extension@2?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintFileExtension from 'remark-lint-file-extension'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintFileExtension)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-file-extension example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-file-extension",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintFileExtension`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintFileExtension[, config])`
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
> 👉 **Note**: does not warn when files have no file extensions (such as
|
||||||
|
> `AUTHORS` or `LICENSE`).
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
Use `md` as it’s the most common.
|
||||||
|
Also use `md` when your markdown contains common syntax extensions (such as
|
||||||
|
GFM, frontmatter, or math).
|
||||||
|
Do not use `md` for MDX: use `mdx` instead.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `readme.md`
|
##### `readme.md`
|
||||||
|
|
||||||
@ -55,59 +167,12 @@ When configured with `'mkd'`.
|
|||||||
|
|
||||||
No messages.
|
No messages.
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-file-extension
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintFileExtension`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-file-extension",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-file-extension readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintFileExtension from 'remark-lint-file-extension'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintFileExtension)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -149,17 +214,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,12 +1,26 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that definitions are placed at the end of
|
||||||
|
* the document.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## 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.
|
||||||
|
*
|
||||||
|
* @module final-definition
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when definitions are used *in* the document
|
||||||
|
* instead of at the end.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module final-definition
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when definitions are placed somewhere other than at the end of
|
|
||||||
* the file.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,8 +10,34 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when definitions are placed somewhere other than at the end of
|
[`remark-lint`][mono] rule to warn when definitions are used *in* the document
|
||||||
the file.
|
instead of at the end.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintFinalDefinition[, config])`](#unifieduseremarklintfinaldefinition-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that definitions are placed at the end of
|
||||||
|
the document.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -21,7 +47,92 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-final-definition
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintFinalDefinition from 'https://cdn.skypack.dev/remark-lint-final-definition@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintFinalDefinition from 'https://cdn.skypack.dev/remark-lint-final-definition@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintFinalDefinition from 'remark-lint-final-definition'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintFinalDefinition)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-final-definition example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-final-definition",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintFinalDefinition`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintFinalDefinition[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -73,59 +184,12 @@ Paragraph.
|
|||||||
|
|
||||||
No messages.
|
No messages.
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-final-definition
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintFinalDefinition`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-final-definition",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-final-definition readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintFinalDefinition from 'remark-lint-final-definition'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintFinalDefinition)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -167,17 +231,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
|
||||||
* @license MIT
|
|
||||||
* @module final-newline
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when a line feed at the end of a file is missing.
|
|
||||||
* Empty files are allowed.
|
|
||||||
*
|
*
|
||||||
* See [StackExchange](https://unix.stackexchange.com/questions/18743) for why.
|
* You can use this package to check that fenced code markers are consistent.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* Turn this rule on.
|
||||||
|
* See [StackExchange](https://unix.stackexchange.com/questions/18743) for more
|
||||||
|
* info.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* always adds a final line feed to files.
|
* always adds final line endings.
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
* ## Example
|
* ## Example
|
||||||
*
|
*
|
||||||
@ -23,7 +24,7 @@
|
|||||||
*
|
*
|
||||||
* ###### In
|
* ###### In
|
||||||
*
|
*
|
||||||
* Note: `␊` represents LF.
|
* > 👉 **Note**: `␊` represents a line feed (`\n`).
|
||||||
*
|
*
|
||||||
* ```markdown
|
* ```markdown
|
||||||
* Alpha␊
|
* Alpha␊
|
||||||
@ -37,10 +38,10 @@
|
|||||||
*
|
*
|
||||||
* ###### In
|
* ###### In
|
||||||
*
|
*
|
||||||
* Note: The below file does not have a final newline.
|
* > 👉 **Note**: `␀` represents the end of the file.
|
||||||
*
|
*
|
||||||
* ```markdown
|
* ```markdown
|
||||||
* Bravo
|
* Bravo␀
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* ###### Out
|
* ###### Out
|
||||||
@ -48,6 +49,13 @@
|
|||||||
* ```text
|
* ```text
|
||||||
* 1:1: Missing newline character at end of file
|
* 1:1: Missing newline character at end of file
|
||||||
* ```
|
* ```
|
||||||
|
*
|
||||||
|
* @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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,18 +10,131 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when a line feed at the end of a file is missing.
|
[`remark-lint`][mono] rule to warn when files don’t end in a newline.
|
||||||
Empty files are allowed.
|
|
||||||
|
|
||||||
See [StackExchange](https://unix.stackexchange.com/questions/18743) for why.
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintFinalNewline[, config])`](#unifieduseremarklintfinalnewline-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Example](#example)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that fenced code markers are consistent.
|
||||||
|
|
||||||
|
## Presets
|
||||||
|
|
||||||
|
This rule is included in the following presets:
|
||||||
|
|
||||||
|
| Preset | Setting |
|
||||||
|
| - | - |
|
||||||
|
| [`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][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-final-newline
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintFinalNewline from 'https://cdn.skypack.dev/remark-lint-final-newline@2?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintFinalNewline from 'https://cdn.skypack.dev/remark-lint-final-newline@2?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintFinalNewline from 'remark-lint-final-newline'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintFinalNewline)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-final-newline example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-final-newline",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintFinalNewline`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintFinalNewline[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
Turn this rule on.
|
||||||
|
See [StackExchange](https://unix.stackexchange.com/questions/18743) for more
|
||||||
|
info.
|
||||||
|
|
||||||
## Fix
|
## Fix
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
always adds a final line feed to files.
|
always adds final line endings.
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
@ -29,7 +142,7 @@ on how to automatically fix warnings for this rule.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `␊` represents LF.
|
> 👉 **Note**: `␊` represents a line feed (`\n`).
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Alpha␊
|
Alpha␊
|
||||||
@ -43,10 +156,10 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: The below file does not have a final newline.
|
> 👉 **Note**: `␀` represents the end of the file.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Bravo
|
Bravo␀
|
||||||
```
|
```
|
||||||
|
|
||||||
###### Out
|
###### Out
|
||||||
@ -55,67 +168,12 @@ Bravo
|
|||||||
1:1: Missing newline character at end of file
|
1:1: Missing newline character at end of file
|
||||||
```
|
```
|
||||||
|
|
||||||
## Presets
|
## Compatibility
|
||||||
|
|
||||||
This rule is included in the following presets:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
|
versions of Node.js.
|
||||||
| Preset | Setting |
|
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.
|
||||||
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
|
||||||
|
|
||||||
[npm][]:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-final-newline
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintFinalNewline`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-final-newline",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-final-newline readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintFinalNewline from 'remark-lint-final-newline'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintFinalNewline)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -157,17 +215,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,13 +1,29 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check the heading rank of the first heading.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* The following options (default: `1`) are accepted:
|
||||||
|
*
|
||||||
|
* * `number` (example `1`)
|
||||||
|
* — expected rank of first heading
|
||||||
|
*
|
||||||
|
* ## 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.
|
||||||
|
*
|
||||||
|
* @module first-heading-level
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when the first heading has an unexpected rank.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module first-heading-level
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when the first heading has a level other than a specified value.
|
|
||||||
*
|
|
||||||
* Options: `number`, default: `1`.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,15 +10,128 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when the first heading has a level other than a specified value.
|
[`remark-lint`][mono] rule to warn when the first heading has an unexpected rank.
|
||||||
|
|
||||||
Options: `number`, default: `1`.
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintFirstHeadingLevel[, config])`](#unifieduseremarklintfirstheadinglevel-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check the heading rank of the first heading.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
This rule is not included in any default preset
|
This rule is not included in a preset maintained here.
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-first-heading-level
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintFirstHeadingLevel from 'https://cdn.skypack.dev/remark-lint-first-heading-level@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintFirstHeadingLevel from 'https://cdn.skypack.dev/remark-lint-first-heading-level@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintFirstHeadingLevel from 'remark-lint-first-heading-level'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintFirstHeadingLevel)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-first-heading-level example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-first-heading-level",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintFirstHeadingLevel`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintFirstHeadingLevel[, config])`
|
||||||
|
|
||||||
|
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: `1`) are accepted:
|
||||||
|
|
||||||
|
* `number` (example `1`)
|
||||||
|
— expected rank of first heading
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -160,59 +273,12 @@ Paragraph.
|
|||||||
1:1-1:17: First heading level should be `1`
|
1:1-1:17: First heading level should be `1`
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-first-heading-level
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintFirstHeadingLevel`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-first-heading-level",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-first-heading-level readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintFirstHeadingLevel from 'remark-lint-first-heading-level'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintFirstHeadingLevel)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -254,17 +320,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,26 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that hard breaks use two spaces and
|
||||||
|
* not more.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## 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.
|
||||||
|
*
|
||||||
|
* @module hard-break-spaces
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when more spaces are used than needed
|
||||||
|
* for hard breaks.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module hard-break-spaces
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when too many spaces are used to create a hard break.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,34 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when too many spaces are used to create a hard break.
|
[`remark-lint`][mono] rule to warn when more spaces are used than needed
|
||||||
|
for hard breaks.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintHardBreakSpaces[, config])`](#unifieduseremarklinthardbreakspaces-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that hard breaks use two spaces and
|
||||||
|
not more.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -21,13 +48,98 @@ This rule is included in the following presets:
|
|||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`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) | |
|
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-hard-break-spaces
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintHardBreakSpaces from 'https://cdn.skypack.dev/remark-lint-hard-break-spaces@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintHardBreakSpaces from 'https://cdn.skypack.dev/remark-lint-hard-break-spaces@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintHardBreakSpaces)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-hard-break-spaces example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-hard-break-spaces",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintHardBreakSpaces`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintHardBreakSpaces[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Lorem ipsum··
|
Lorem ipsum··
|
||||||
@ -42,7 +154,7 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Lorem ipsum···
|
Lorem ipsum···
|
||||||
@ -55,59 +167,12 @@ dolor sit amet.
|
|||||||
1:12-2:1: Use two spaces for hard line breaks
|
1:12-2:1: Use two spaces for hard line breaks
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-hard-break-spaces
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintHardBreakSpaces`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-hard-break-spaces",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-hard-break-spaces readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintHardBreakSpaces from 'remark-lint-hard-break-spaces'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintHardBreakSpaces)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -149,17 +214,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,30 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that heading ranks increment with one
|
||||||
|
* at a time.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## 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.
|
||||||
|
*
|
||||||
|
* @module heading-increment
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when heading ranks increment with more than
|
||||||
|
* 1 at a time.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module heading-increment
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when headings increment with more than 1 level at a time.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,34 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when headings increment with more than 1 level at a time.
|
[`remark-lint`][mono] rule to warn when heading ranks increment with more than
|
||||||
|
1 at a time.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintHeadingIncrement[, config])`](#unifieduseremarklintheadingincrement-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that heading ranks increment with one
|
||||||
|
at a time.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -20,7 +47,96 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-heading-increment
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintHeadingIncrement from 'https://cdn.skypack.dev/remark-lint-heading-increment@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintHeadingIncrement from 'https://cdn.skypack.dev/remark-lint-heading-increment@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintHeadingIncrement from 'remark-lint-heading-increment'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintHeadingIncrement)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-heading-increment example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-heading-increment",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintHeadingIncrement`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintHeadingIncrement[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -52,59 +168,12 @@ No messages.
|
|||||||
3:1-3:10: Heading levels should increment by one level at a time
|
3:1-3:10: Heading levels should increment by one level at a time
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-heading-increment
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintHeadingIncrement`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-heading-increment",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-heading-increment readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintHeadingIncrement from 'remark-lint-heading-increment'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintHeadingIncrement)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -146,17 +215,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,30 +1,66 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
|
||||||
* @license MIT
|
|
||||||
* @module heading-style
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when a heading does not conform to a given style.
|
|
||||||
*
|
*
|
||||||
* Options: `'consistent'`, `'atx'`, `'atx-closed'`, or `'setext'`,
|
* You can use this package to check that headings are consistent.
|
||||||
* default: `'consistent'`.
|
|
||||||
*
|
*
|
||||||
* `'consistent'` detects the first used heading style and warns when
|
* ## API
|
||||||
* subsequent headings use different styles.
|
*
|
||||||
|
* The following options (default: `'consistent'`) are accepted:
|
||||||
|
*
|
||||||
|
* * `'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
|
||||||
|
*
|
||||||
|
* ## 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:
|
||||||
|
*
|
||||||
|
* * 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
|
||||||
|
*
|
||||||
|
* Setext headings are also rather 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.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* formats headings as ATX by default.
|
* formats headings as ATX by default.
|
||||||
* This can be configured with the
|
* The other styles can be configured with
|
||||||
* [`setext`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionssetext)
|
* [`setext: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionssetext)
|
||||||
* and
|
* or
|
||||||
* [`closeAtx`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionscloseatx)
|
* [`closeAtx: true`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionscloseatx).
|
||||||
* options.
|
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @module heading-style
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when headings violate a given style.
|
||||||
|
* @author Titus Wormer
|
||||||
|
* @copyright 2015 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md", "setting": "atx"}
|
* {"name": "ok.md", "setting": "atx"}
|
||||||
*
|
*
|
||||||
|
@ -10,26 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when a heading does not conform to a given style.
|
[`remark-lint`][mono] rule to warn when headings violate a given style.
|
||||||
|
|
||||||
Options: `'consistent'`, `'atx'`, `'atx-closed'`, or `'setext'`,
|
## Contents
|
||||||
default: `'consistent'`.
|
|
||||||
|
|
||||||
`'consistent'` detects the first used heading style and warns when
|
* [What is this?](#what-is-this)
|
||||||
subsequent headings use different styles.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintHeadingStyle[, config])`](#unifieduseremarklintheadingstyle-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
## Fix
|
## What is this?
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
formats headings as ATX by default.
|
rule.
|
||||||
This can be configured with the
|
Lint rules check markdown code style.
|
||||||
[`setext`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionssetext)
|
|
||||||
and
|
|
||||||
[`closeAtx`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionscloseatx)
|
|
||||||
options.
|
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
## When should I use this?
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
You can use this package to check that headings are consistent.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -40,7 +47,134 @@ This rule is included in the following presets:
|
|||||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
| [`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'` |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'atx'` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-heading-style
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintHeadingStyle from 'https://cdn.skypack.dev/remark-lint-heading-style@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintHeadingStyle from 'https://cdn.skypack.dev/remark-lint-heading-style@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintHeadingStyle from 'remark-lint-heading-style'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintHeadingStyle)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-heading-style example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-heading-style",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintHeadingStyle`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintHeadingStyle[, config])`
|
||||||
|
|
||||||
|
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: `'consistent'`) are accepted:
|
||||||
|
|
||||||
|
* `'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
|
||||||
|
|
||||||
|
## 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:
|
||||||
|
|
||||||
|
* 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
|
||||||
|
|
||||||
|
Setext headings are also rather 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.
|
||||||
|
|
||||||
|
## 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).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -128,59 +262,12 @@ When configured with `'💩'`.
|
|||||||
1:1: Incorrect heading style type `💩`: use either `'consistent'`, `'atx'`, `'atx-closed'`, or `'setext'`
|
1:1: Incorrect heading style type `💩`: use either `'consistent'`, `'atx'`, `'atx-closed'`, or `'setext'`
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-heading-style
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintHeadingStyle`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-heading-style",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-heading-style readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintHeadingStyle from 'remark-lint-heading-style'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintHeadingStyle)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -222,17 +309,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,23 +1,37 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2017 Titus Wormer
|
|
||||||
* @license MIT
|
|
||||||
* @module linebreak-style
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when linebreaks violate a given or detected style.
|
|
||||||
*
|
*
|
||||||
* Options: either `'unix'` (for `\n`, denoted as `␊`), `'windows'` (for `\r\n`,
|
* You can use this package to check that line endings are consistent.
|
||||||
* denoted as `␍␊`), or `'consistent'` (to detect the first used linebreak in
|
*
|
||||||
* a file). Default: `'consistent'`.
|
* ## API
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* The following options (default: `'consistent'`) are accepted:
|
||||||
|
*
|
||||||
|
* * `'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
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* In Git projects, you can configure it 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.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* always uses unix linebreaks.
|
* always uses Unix linebreaks.
|
||||||
*
|
* @module linebreak-style
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
* @summary
|
||||||
* on how to automatically fix warnings for this rule.
|
* remark-lint rule to warn when line endings don’t match a given style.
|
||||||
*
|
* @author Titus Wormer
|
||||||
|
* @copyright 2017 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok-consistent-as-windows.md"}
|
* {"name": "ok-consistent-as-windows.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,31 +10,143 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when linebreaks violate a given or detected style.
|
[`remark-lint`][mono] rule to warn when line endings don’t match a given style.
|
||||||
|
|
||||||
Options: either `'unix'` (for `\n`, denoted as `␊`), `'windows'` (for `\r\n`,
|
## Contents
|
||||||
denoted as `␍␊`), or `'consistent'` (to detect the first used linebreak in
|
|
||||||
a file). Default: `'consistent'`.
|
|
||||||
|
|
||||||
## Fix
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintLinebreakStyle[, config])`](#unifieduseremarklintlinebreakstyle-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
## What is this?
|
||||||
always uses unix linebreaks.
|
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
on how to automatically fix warnings for this rule.
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that line endings are consistent.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
This rule is not included in any default preset
|
This rule is not included in a preset maintained here.
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-linebreak-style
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintLinebreakStyle from 'https://cdn.skypack.dev/remark-lint-linebreak-style@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintLinebreakStyle from 'https://cdn.skypack.dev/remark-lint-linebreak-style@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintLinebreakStyle from 'remark-lint-linebreak-style'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintLinebreakStyle)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-linebreak-style example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-linebreak-style",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintLinebreakStyle`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintLinebreakStyle[, config])`
|
||||||
|
|
||||||
|
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: `'consistent'`) are accepted:
|
||||||
|
|
||||||
|
* `'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
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
In Git projects, you can configure it 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.
|
||||||
|
|
||||||
|
## Fix
|
||||||
|
|
||||||
|
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
|
always uses Unix linebreaks.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok-consistent-as-windows.md`
|
##### `ok-consistent-as-windows.md`
|
||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `␍␊` represents a carriage return and a line feed.
|
> 👉 **Note**: `␍␊` represents a carriage return and a line feed.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Alpha␍␊
|
Alpha␍␊
|
||||||
@ -49,7 +161,7 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `␊` represents a line feed.
|
> 👉 **Note**: `␊` represents a line feed.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Alpha␊
|
Alpha␊
|
||||||
@ -66,7 +178,7 @@ When configured with `'unix'`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `␍␊` represents a carriage return and a line feed.
|
> 👉 **Note**: `␍␊` represents a carriage return and a line feed.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Alpha␍␊
|
Alpha␍␊
|
||||||
@ -84,7 +196,7 @@ When configured with `'windows'`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `␊` represents a line feed.
|
> 👉 **Note**: `␊` represents a line feed.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Alpha␊
|
Alpha␊
|
||||||
@ -96,59 +208,12 @@ Alpha␊
|
|||||||
1:6: Expected linebreaks to be windows (`\r\n`), not unix (`\n`)
|
1:6: Expected linebreaks to be windows (`\r\n`), not unix (`\n`)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-linebreak-style
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintLinebreakStyle`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-linebreak-style",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-linebreak-style readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintLinebreakStyle from 'remark-lint-linebreak-style'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintLinebreakStyle)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -190,17 +255,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,25 +1,48 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
|
||||||
* @license MIT
|
|
||||||
* @module link-title-style
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when link and definition titles occur with incorrect quotes.
|
|
||||||
*
|
*
|
||||||
* Options: `'consistent'`, `'"'`, `'\''`, or `'()'`, default: `'consistent'`.
|
* You can use this package to check that title markers are consistent.
|
||||||
*
|
*
|
||||||
* `'consistent'` detects the first used quote style and warns when subsequent
|
* ## API
|
||||||
* titles use different styles.
|
*
|
||||||
|
* The following options (default: `'consistent'`) are accepted:
|
||||||
|
*
|
||||||
|
* * `'"'`
|
||||||
|
* — prefer double quotes
|
||||||
|
* * `"'"`
|
||||||
|
* — prefer single quotes
|
||||||
|
* * `'()'`
|
||||||
|
* — prefer parens
|
||||||
|
* * `'consistent'`
|
||||||
|
* — detect the first used style and warn when further titles differ
|
||||||
|
*
|
||||||
|
* ## 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))`.
|
||||||
|
*
|
||||||
|
* In HTML, attributes are commonly written with double quotes.
|
||||||
|
* Due to this, titles are almost exclusively wrapped in double quotes in
|
||||||
|
* markdown, so it’s recommended to configure this rule with `'"'`.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* uses `'` (single quote) for titles if they contain a double quote, and `"`
|
* formats titles with double quotes by default.
|
||||||
* (double quotes) otherwise.
|
* Pass
|
||||||
*
|
* [`quote: "'"`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionsquote)
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
* to use single quotes.
|
||||||
* on how to automatically fix warnings for this rule.
|
* There is no option to use parens.
|
||||||
*
|
*
|
||||||
|
* @module link-title-style
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when title markers are inconsistent.
|
||||||
|
* @author Titus Wormer
|
||||||
|
* @copyright 2015 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md", "setting": "\""}
|
* {"name": "ok.md", "setting": "\""}
|
||||||
*
|
*
|
||||||
|
@ -10,21 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when link and definition titles occur with incorrect quotes.
|
[`remark-lint`][mono] rule to warn when title markers are inconsistent.
|
||||||
|
|
||||||
Options: `'consistent'`, `'"'`, `'\''`, or `'()'`, default: `'consistent'`.
|
## Contents
|
||||||
|
|
||||||
`'consistent'` detects the first used quote style and warns when subsequent
|
* [What is this?](#what-is-this)
|
||||||
titles use different styles.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintLinkTitleStyle[, config])`](#unifieduseremarklintlinktitlestyle-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
## Fix
|
## What is this?
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
uses `'` (single quote) for titles if they contain a double quote, and `"`
|
rule.
|
||||||
(double quotes) otherwise.
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
## When should I use this?
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
You can use this package to check that title markers are consistent.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -35,7 +47,116 @@ This rule is included in the following presets:
|
|||||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | `'consistent'` |
|
| [`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) | `'"'` |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `'"'` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-link-title-style
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintLinkTitleStyle from 'https://cdn.skypack.dev/remark-lint-link-title-style@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintLinkTitleStyle from 'https://cdn.skypack.dev/remark-lint-link-title-style@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintLinkTitleStyle from 'remark-lint-link-title-style'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintLinkTitleStyle)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-link-title-style example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-link-title-style",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintLinkTitleStyle`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintLinkTitleStyle[, config])`
|
||||||
|
|
||||||
|
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: `'consistent'`) are accepted:
|
||||||
|
|
||||||
|
* `'"'`
|
||||||
|
— prefer double quotes
|
||||||
|
* `"'"`
|
||||||
|
— prefer single quotes
|
||||||
|
* `'()'`
|
||||||
|
— prefer parens
|
||||||
|
* `'consistent'`
|
||||||
|
— detect the first used style and warn when further titles differ
|
||||||
|
|
||||||
|
## 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))`.
|
||||||
|
|
||||||
|
In HTML, attributes are commonly written with double quotes.
|
||||||
|
Due to this, titles are almost exclusively wrapped in double quotes in
|
||||||
|
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.
|
||||||
|
There is no option to use parens.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -168,59 +289,12 @@ When configured with `'💩'`.
|
|||||||
1:1: Incorrect link title style marker `💩`: use either `'consistent'`, `'"'`, `'\''`, or `'()'`
|
1:1: Incorrect link title style marker `💩`: use either `'consistent'`, `'"'`, `'\''`, or `'()'`
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-link-title-style
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintLinkTitleStyle`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-link-title-style",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-link-title-style readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintLinkTitleStyle from 'remark-lint-link-title-style'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintLinkTitleStyle)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -262,17 +336,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,19 +1,40 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
*
|
||||||
* @license MIT
|
* You can use this package to check that list items are not indented.
|
||||||
* @module list-item-bullet-indent
|
*
|
||||||
* @fileoverview
|
* ## API
|
||||||
* Warn when list item bullets are indented.
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* There is no specific handling of indented list items (or anything else) in
|
||||||
|
* markdown.
|
||||||
|
* While it is possible to use an indent to align ordered lists on their marker:
|
||||||
|
*
|
||||||
|
* ```markdown
|
||||||
|
* 1. One
|
||||||
|
* 10. Ten
|
||||||
|
* 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
|
||||||
|
* the 100th item).
|
||||||
|
* Hence, it’s recommended to not indent items and to turn this rule on.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* removes all indentation before bullets.
|
* formats all items without indent.
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @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
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,15 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when list item bullets are indented.
|
[`remark-lint`][mono] rule to warn when list items are indented.
|
||||||
|
|
||||||
## Fix
|
## Contents
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [What is this?](#what-is-this)
|
||||||
removes all indentation before bullets.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintListItemBulletIndent[, config])`](#unifieduseremarklintlistitembulletindent-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
## What is this?
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that list items are not indented.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -28,7 +46,108 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-list-item-bullet-indent
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintListItemBulletIndent from 'https://cdn.skypack.dev/remark-lint-list-item-bullet-indent@4?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintListItemBulletIndent from 'https://cdn.skypack.dev/remark-lint-list-item-bullet-indent@4?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintListItemBulletIndent from 'remark-lint-list-item-bullet-indent'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintListItemBulletIndent)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-list-item-bullet-indent example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-list-item-bullet-indent",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintListItemBulletIndent`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintListItemBulletIndent[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
There is no specific handling of indented list items (or anything else) in
|
||||||
|
markdown.
|
||||||
|
While it is possible to use an indent to align ordered lists on their marker:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
1. One
|
||||||
|
10. Ten
|
||||||
|
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
|
||||||
|
the 100th item).
|
||||||
|
Hence, it’s 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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -49,7 +168,7 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Paragraph.
|
Paragraph.
|
||||||
@ -65,59 +184,12 @@ Paragraph.
|
|||||||
4:2: Incorrect indentation before bullet: remove 1 space
|
4:2: Incorrect indentation before bullet: remove 1 space
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-list-item-bullet-indent
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintListItemBulletIndent`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-list-item-bullet-indent",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-list-item-bullet-indent readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintListItemBulletIndent from 'remark-lint-list-item-bullet-indent'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintListItemBulletIndent)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -159,17 +231,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,28 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that list item content is aligned.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* The position of the first child in a list item matters.
|
||||||
|
* Further children should align with it.
|
||||||
|
*
|
||||||
|
* ## Fix
|
||||||
|
*
|
||||||
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
|
* aligns the content of items.
|
||||||
|
*
|
||||||
|
* @module list-item-content-indent
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when list item content is not aligned.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module list-item-content-indent
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when the content of a list item has mixed indentation.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md", "gfm": true}
|
* {"name": "ok.md", "gfm": true}
|
||||||
*
|
*
|
||||||
@ -59,11 +76,12 @@ const remarkLintListItemContentIndent = lintRule(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get indentation for the first child. Only the first item can have a
|
// Get indentation for the first child.
|
||||||
// checkbox, so here we remove that from the column.
|
// Only the first item can have a checkbox, so here we remove that from
|
||||||
|
// the column.
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
// If there’s a checkbox before the content, look backwards to find the
|
// If there’s a checkbox before the content, look backwards to find
|
||||||
// start of that checkbox.
|
// the start of that checkbox.
|
||||||
if (typeof node.checked === 'boolean') {
|
if (typeof node.checked === 'boolean') {
|
||||||
let char = begin.offset - 1
|
let char = begin.offset - 1
|
||||||
|
|
||||||
|
@ -10,7 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when the content of a list item has mixed indentation.
|
[`remark-lint`][mono] rule to warn when list item content is not aligned.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintListItemContentIndent[, config])`](#unifieduseremarklintlistitemcontentindent-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that list item content is aligned.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -21,15 +47,104 @@ This rule is included in the following presets:
|
|||||||
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-consistent) | |
|
| [`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) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-list-item-content-indent
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintListItemContentIndent from 'https://cdn.skypack.dev/remark-lint-list-item-content-indent@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintListItemContentIndent from 'https://cdn.skypack.dev/remark-lint-list-item-content-indent@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintListItemContentIndent from 'remark-lint-list-item-content-indent'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintListItemContentIndent)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-list-item-content-indent example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-list-item-content-indent",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintListItemContentIndent`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintListItemContentIndent[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
The position of the first child in a list item matters.
|
||||||
|
Further children should align with it.
|
||||||
|
|
||||||
|
## Fix
|
||||||
|
|
||||||
|
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
|
aligns the content of items.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: this example uses [GFM][].
|
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
1.·[x] Alpha
|
1.·[x] Alpha
|
||||||
@ -44,9 +159,9 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: this example uses [GFM][].
|
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
1.·[x] Charlie
|
1.·[x] Charlie
|
||||||
@ -59,59 +174,12 @@ Note: `·` represents a space.
|
|||||||
2:5: Don’t use mixed indentation for children, remove 1 space
|
2:5: Don’t use mixed indentation for children, remove 1 space
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-list-item-content-indent
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintListItemContentIndent`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-list-item-content-indent",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-list-item-content-indent readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintListItemContentIndent from 'remark-lint-list-item-content-indent'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintListItemContentIndent)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -153,17 +221,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,27 +1,64 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
|
||||||
* @license MIT
|
|
||||||
* @module list-item-indent
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when the spacing between a list item’s bullet and its content violates
|
|
||||||
* a given style.
|
|
||||||
*
|
*
|
||||||
* Options: `'tab-size'`, `'mixed'`, or `'space'`, default: `'tab-size'`.
|
* You can use this package to check that the spacing between list item markers
|
||||||
|
* and content is inconsistent.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* The following options (default: `'tab-size'`) are accepted:
|
||||||
|
*
|
||||||
|
* * `'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
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* 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).
|
||||||
|
*
|
||||||
|
* There are two types of lists in markdown (other than ordered and unordered):
|
||||||
|
* tight and loose lists.
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Historically, how indentation of lists works in markdown has 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.
|
||||||
|
* 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.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* uses `'tab-size'` (named `'tab'` there) by default to ensure Markdown is
|
* uses `'tab-size'` (named `'tab'` there) by default.
|
||||||
* seen the same way across vendors.
|
* [`listItemIndent: '1'` (for `'space'`) or `listItemIndent: 'mixed'`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#optionslistitemindent)
|
||||||
* This can be configured with the
|
* is supported.
|
||||||
* [`listItemIndent`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionslistitemindent)
|
|
||||||
* option.
|
|
||||||
* This rule’s `'space'` option is named `'1'` there.
|
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @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
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,23 +10,35 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when the spacing between a list item’s bullet and its content violates
|
[`remark-lint`][mono] rule to warn when spacing between list item markers and
|
||||||
a given style.
|
content is inconsistent.
|
||||||
|
|
||||||
Options: `'tab-size'`, `'mixed'`, or `'space'`, default: `'tab-size'`.
|
## Contents
|
||||||
|
|
||||||
## Fix
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintListItemIndent[, config])`](#unifieduseremarklintlistitemindent-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
## What is this?
|
||||||
uses `'tab-size'` (named `'tab'` there) by default to ensure Markdown is
|
|
||||||
seen the same way across vendors.
|
|
||||||
This can be configured with the
|
|
||||||
[`listItemIndent`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#optionslistitemindent)
|
|
||||||
option.
|
|
||||||
This rule’s `'space'` option is named `'1'` there.
|
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
on how to automatically fix warnings for this rule.
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that the spacing between list item markers
|
||||||
|
and content is inconsistent.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -37,13 +49,136 @@ This rule is included in the following presets:
|
|||||||
| [`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-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'` |
|
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | `'tab-size'` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-list-item-indent
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintListItemIndent from 'https://cdn.skypack.dev/remark-lint-list-item-indent@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintListItemIndent from 'https://cdn.skypack.dev/remark-lint-list-item-indent@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintListItemIndent from 'remark-lint-list-item-indent'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintListItemIndent)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-list-item-indent example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-list-item-indent",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintListItemIndent`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintListItemIndent[, config])`
|
||||||
|
|
||||||
|
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: `'tab-size'`) are accepted:
|
||||||
|
|
||||||
|
* `'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
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
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).
|
||||||
|
|
||||||
|
There are two types of lists in markdown (other than ordered and unordered):
|
||||||
|
tight and loose lists.
|
||||||
|
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.
|
||||||
|
|
||||||
|
Historically, how indentation of lists works in markdown has 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.
|
||||||
|
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.
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
*···List
|
*···List
|
||||||
@ -73,7 +208,7 @@ When configured with `'mixed'`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
*·List item.
|
*·List item.
|
||||||
@ -101,7 +236,7 @@ When configured with `'mixed'`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
*···List item.
|
*···List item.
|
||||||
@ -119,7 +254,7 @@ When configured with `'space'`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
*·List item.
|
*·List item.
|
||||||
@ -147,7 +282,7 @@ When configured with `'space'`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
*···List
|
*···List
|
||||||
@ -166,7 +301,7 @@ When configured with `'tab-size'`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
*·List
|
*·List
|
||||||
@ -189,59 +324,12 @@ When configured with `'💩'`.
|
|||||||
1:1: Incorrect list-item indent style `💩`: use either `'tab-size'`, `'space'`, or `'mixed'`
|
1:1: Incorrect list-item indent style `💩`: use either `'tab-size'`, `'space'`, or `'mixed'`
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-list-item-indent
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintListItemIndent`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-list-item-indent",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-list-item-indent readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintListItemIndent from 'remark-lint-list-item-indent'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintListItemIndent)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -283,17 +371,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,25 +1,43 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that lists are loose or tight when
|
||||||
|
* they should be.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* The following options (default: `undefined`) are accepted:
|
||||||
|
*
|
||||||
|
* * `Object` with the following fields:
|
||||||
|
* * `checkBlanks` (`boolean`, default: `false`)
|
||||||
|
* — adhere to 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.
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @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
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module list-item-spacing
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when list looseness is incorrect, such as being tight when it should
|
|
||||||
* be loose, and vice versa.
|
|
||||||
*
|
|
||||||
* According to the [`markdown-style-guide`](http://www.cirosantilli.com/markdown-style-guide/),
|
|
||||||
* if one or more list items in a list spans more than one line, the list is
|
|
||||||
* required to have blank lines between each item.
|
|
||||||
* And otherwise, there should not be blank lines between items.
|
|
||||||
*
|
|
||||||
* By default, all items must be spread out (a blank line must be between
|
|
||||||
* them) if one or more items are multiline (span more than one line).
|
|
||||||
* Otherwise, the list must be tight (no blank line must be between items).
|
|
||||||
*
|
|
||||||
* If you pass `{checkBlanks: true}`, all items must be spread out if one or
|
|
||||||
* more items contain blank lines.
|
|
||||||
* Otherwise, the list must be tight.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,21 +10,34 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when list looseness is incorrect, such as being tight when it should
|
[`remark-lint`][mono] rule to warn when lists are loose when they should be tight,
|
||||||
be loose, and vice versa.
|
or vice versa.
|
||||||
|
|
||||||
According to the [`markdown-style-guide`](http://www.cirosantilli.com/markdown-style-guide/),
|
## Contents
|
||||||
if one or more list items in a list spans more than one line, the list is
|
|
||||||
required to have blank lines between each item.
|
|
||||||
And otherwise, there should not be blank lines between items.
|
|
||||||
|
|
||||||
By default, all items must be spread out (a blank line must be between
|
* [What is this?](#what-is-this)
|
||||||
them) if one or more items are multiline (span more than one line).
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
Otherwise, the list must be tight (no blank line must be between items).
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintListItemSpacing[, config])`](#unifieduseremarklintlistitemspacing-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
If you pass `{checkBlanks: true}`, all items must be spread out if one or
|
## What is this?
|
||||||
more items contain blank lines.
|
|
||||||
Otherwise, the list must be tight.
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that lists are loose or tight when
|
||||||
|
they should be.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -34,7 +47,109 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-list-item-spacing
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintListItemSpacing from 'https://cdn.skypack.dev/remark-lint-list-item-spacing@4?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintListItemSpacing from 'https://cdn.skypack.dev/remark-lint-list-item-spacing@4?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintListItemSpacing from 'remark-lint-list-item-spacing'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintListItemSpacing)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-list-item-spacing example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-list-item-spacing",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintListItemSpacing`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintListItemSpacing[, config])`
|
||||||
|
|
||||||
|
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: `undefined`) are accepted:
|
||||||
|
|
||||||
|
* `Object` with the following fields:
|
||||||
|
* `checkBlanks` (`boolean`, default: `false`)
|
||||||
|
— adhere to 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.
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -154,59 +269,12 @@ A loose list:
|
|||||||
14:15-16:1: Extraneous new line after list item
|
14:15-16:1: Extraneous new line after list item
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-list-item-spacing
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintListItemSpacing`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-list-item-spacing",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-list-item-spacing readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintListItemSpacing from 'remark-lint-list-item-spacing'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintListItemSpacing)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -248,17 +316,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,15 +1,31 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## 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:
|
||||||
|
*
|
||||||
|
* * `number` (example: `72`)
|
||||||
|
* — max number of characters to accept in heading text
|
||||||
|
*
|
||||||
|
* Ignores syntax, only checks the plain text content.
|
||||||
|
*
|
||||||
|
* ## 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).
|
||||||
|
*
|
||||||
|
* @module maximum-heading-length
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when headings are too long.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module maximum-heading-length
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when headings are too long.
|
|
||||||
*
|
|
||||||
* Options: `number`, default: `60`.
|
|
||||||
*
|
|
||||||
* Ignores Markdown syntax, only checks the plain text content.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,11 +10,32 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when headings are too long.
|
[`remark-lint`][mono] rule to warn when headings are too long.
|
||||||
|
|
||||||
Options: `number`, default: `60`.
|
## Contents
|
||||||
|
|
||||||
Ignores Markdown syntax, only checks the plain text content.
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintMaximumHeadingLength[, config])`](#unifieduseremarklintmaximumheadinglength-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that heading text is within reason.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -24,7 +45,99 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-maximum-heading-length
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintMaximumHeadingLength from 'https://cdn.skypack.dev/remark-lint-maximum-heading-length@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintMaximumHeadingLength from 'https://cdn.skypack.dev/remark-lint-maximum-heading-length@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintMaximumHeadingLength from 'remark-lint-maximum-heading-length'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintMaximumHeadingLength)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-maximum-heading-length example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-maximum-heading-length",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintMaximumHeadingLength`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintMaximumHeadingLength[, config])`
|
||||||
|
|
||||||
|
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: `60`) are accepted:
|
||||||
|
|
||||||
|
* `number` (example: `72`)
|
||||||
|
— max number of characters to accept in heading text
|
||||||
|
|
||||||
|
Ignores syntax, only checks the plain text content.
|
||||||
|
|
||||||
|
## 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).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `not-ok.md`
|
##### `not-ok.md`
|
||||||
|
|
||||||
@ -56,59 +169,12 @@ When configured with `40`.
|
|||||||
|
|
||||||
No messages.
|
No messages.
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-maximum-heading-length
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintMaximumHeadingLength`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-maximum-heading-length",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-maximum-heading-length readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintMaximumHeadingLength from 'remark-lint-maximum-heading-length'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintMaximumHeadingLength)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -150,17 +216,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,19 +1,30 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
|
||||||
* @license MIT
|
|
||||||
* @module maximum-line-length
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when lines are too long.
|
|
||||||
*
|
*
|
||||||
* Options: `number`, default: `80`.
|
* You can use this package to check that lines do not exceed a certain size.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* The following options (default: `80`) are accepted:
|
||||||
|
*
|
||||||
|
* * `number` (example: `72`)
|
||||||
|
* — max number of characters to accept in heading text
|
||||||
*
|
*
|
||||||
* Ignores nodes that cannot be wrapped, such as headings, tables, code,
|
* Ignores nodes that cannot be wrapped, such as headings, tables, code,
|
||||||
* definitions, HTML, and JSX.
|
* 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.
|
||||||
*
|
*
|
||||||
* Ignores images, links, and inline code if they start before the wrap, end
|
* ## Recommendation
|
||||||
* after the wrap, and there’s no whitespace after them.
|
|
||||||
*
|
*
|
||||||
|
* Whether to wrap prose or not is a stylistic choice.
|
||||||
|
*
|
||||||
|
* @module maximum-line-length
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when lines are too long.
|
||||||
|
* @author Titus Wormer
|
||||||
|
* @copyright 2015 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md", "positionless": true, "gfm": true}
|
* {"name": "ok.md", "positionless": true, "gfm": true}
|
||||||
*
|
*
|
||||||
@ -38,7 +49,7 @@
|
|||||||
*
|
*
|
||||||
* <a><b><i><p><q><s><u>alpha bravo charlie delta echo foxtrot golf</u></s></q></p></i></b></a>
|
* <a><b><i><p><q><s><u>alpha bravo charlie delta echo foxtrot golf</u></s></q></p></i></b></a>
|
||||||
*
|
*
|
||||||
* The following is also fine, because there is no whitespace.
|
* The following is also fine (note the `.`), because there is no whitespace.
|
||||||
*
|
*
|
||||||
* <http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables>.
|
* <http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables>.
|
||||||
*
|
*
|
||||||
|
@ -10,15 +10,32 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when lines are too long.
|
[`remark-lint`][mono] rule to warn when lines are too long.
|
||||||
|
|
||||||
Options: `number`, default: `80`.
|
## Contents
|
||||||
|
|
||||||
Ignores nodes that cannot be wrapped, such as headings, tables, code,
|
* [What is this?](#what-is-this)
|
||||||
definitions, HTML, and JSX.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintMaximumLineLength[, config])`](#unifieduseremarklintmaximumlinelength-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
Ignores images, links, and inline code if they start before the wrap, end
|
## What is this?
|
||||||
after the wrap, and there’s no whitespace after them.
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that lines do not exceed a certain size.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -28,7 +45,98 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `80` |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `80` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-maximum-line-length
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintMaximumLineLength from 'https://cdn.skypack.dev/remark-lint-maximum-line-length@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintMaximumLineLength from 'https://cdn.skypack.dev/remark-lint-maximum-line-length@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintMaximumLineLength from 'remark-lint-maximum-line-length'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintMaximumLineLength)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-maximum-line-length example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-maximum-line-length",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintMaximumLineLength`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintMaximumLineLength[, config])`
|
||||||
|
|
||||||
|
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: `80`) are accepted:
|
||||||
|
|
||||||
|
* `number` (example: `72`)
|
||||||
|
— max number of characters to accept in heading text
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
Whether to wrap prose or not is a stylistic choice.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok-mixed-line-endings.md`
|
##### `ok-mixed-line-endings.md`
|
||||||
|
|
||||||
@ -36,9 +144,9 @@ When configured with `10`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `␍␊` represents a carriage return and a line feed.
|
> 👉 **Note**: `␍␊` represents a carriage return and a line feed.
|
||||||
|
|
||||||
Note: `␊` represents a line feed.
|
> 👉 **Note**: `␊` represents a line feed.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
0123456789␍␊
|
0123456789␍␊
|
||||||
@ -57,9 +165,9 @@ When configured with `10`.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `␍␊` represents a carriage return and a line feed.
|
> 👉 **Note**: `␍␊` represents a carriage return and a line feed.
|
||||||
|
|
||||||
Note: `␊` represents a line feed.
|
> 👉 **Note**: `␊` represents a line feed.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
012345678901␍␊
|
012345678901␍␊
|
||||||
@ -112,7 +220,7 @@ And this one is also very wrong: because the code starts aaaaaaafter the column:
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: this example uses [GFM][].
|
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
This line is simply not toooooooooooooooooooooooooooooooooooooooooooo
|
This line is simply not toooooooooooooooooooooooooooooooooooooooooooo
|
||||||
@ -136,7 +244,7 @@ This is also fine: <http://this-long-url-with-a-long-domain.co.uk/a-long-path?qu
|
|||||||
|
|
||||||
<a><b><i><p><q><s><u>alpha bravo charlie delta echo foxtrot golf</u></s></q></p></i></b></a>
|
<a><b><i><p><q><s><u>alpha bravo charlie delta echo foxtrot golf</u></s></q></p></i></b></a>
|
||||||
|
|
||||||
The following is also fine, because there is no whitespace.
|
The following is also fine (note the `.`), because there is no whitespace.
|
||||||
|
|
||||||
<http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables>.
|
<http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables>.
|
||||||
|
|
||||||
@ -149,59 +257,12 @@ In addition, definitions are also fine:
|
|||||||
|
|
||||||
No messages.
|
No messages.
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-maximum-line-length
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintMaximumLineLength`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-maximum-line-length",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-maximum-line-length readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintMaximumLineLength from 'remark-lint-maximum-line-length'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintMaximumLineLength)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -243,17 +304,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-auto-link-without-protocol
|
* @module no-auto-link-without-protocol
|
||||||
* @deprecated
|
* @deprecated
|
||||||
|
* **Stability: Legacy**.
|
||||||
* This rule is no longer recommended for use.
|
* This rule is no longer recommended for use.
|
||||||
* With CommonMark, all autolinks (except for emails) are required to have a
|
* With CommonMark, all autolinks (except for emails) are required to have a
|
||||||
* protocol.
|
* protocol.
|
||||||
|
@ -2,68 +2,17 @@
|
|||||||
|
|
||||||
# remark-lint-no-auto-link-without-protocol
|
# remark-lint-no-auto-link-without-protocol
|
||||||
|
|
||||||
[![Build][build-badge]][build]
|
**Stability: Legacy**.
|
||||||
[![Coverage][coverage-badge]][coverage]
|
|
||||||
[![Downloads][downloads-badge]][downloads]
|
|
||||||
[![Size][size-badge]][size]
|
|
||||||
[![Sponsors][sponsors-badge]][collective]
|
|
||||||
[![Backers][backers-badge]][collective]
|
|
||||||
[![Chat][chat-badge]][chat]
|
|
||||||
|
|
||||||
This rule is no longer recommended for use.
|
This rule is no longer recommended for use.
|
||||||
With CommonMark, all autolinks (except for emails) are required to have a
|
With CommonMark, all autolinks (except for emails) are required to have a
|
||||||
protocol.
|
protocol.
|
||||||
Otherwise they don’t parse.
|
Otherwise they don’t parse.
|
||||||
The previous suggestion to add a protocol to email autolinks was wrong.
|
The previous suggestion to add a protocol to email autolinks was wrong.
|
||||||
|
|
||||||
## Contribute
|
|
||||||
|
|
||||||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
|
|
||||||
to get started.
|
|
||||||
See [`support.md`][support] for ways to get help.
|
|
||||||
|
|
||||||
This project has a [code of conduct][coc].
|
|
||||||
By interacting with this repository, organization, or community you agree to
|
|
||||||
abide by its terms.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[MIT][license] © [Titus Wormer][author]
|
[MIT][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-no-auto-link-without-protocol.svg
|
|
||||||
|
|
||||||
[downloads]: https://www.npmjs.com/package/remark-lint-no-auto-link-without-protocol
|
|
||||||
|
|
||||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-no-auto-link-without-protocol.svg
|
|
||||||
|
|
||||||
[size]: https://bundlephobia.com/result?p=remark-lint-no-auto-link-without-protocol
|
|
||||||
|
|
||||||
[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
|
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
[author]: https://wooorm.com
|
[author]: https://wooorm.com
|
||||||
|
@ -1,20 +1,28 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
*
|
||||||
* @license MIT
|
* You can use this package to check that lines in block quotes start with `>`.
|
||||||
* @module no-blockquote-without-marker
|
*
|
||||||
* @fileoverview
|
* ## API
|
||||||
* Warn when blank lines without `>` (greater than) markers are found in a
|
*
|
||||||
* block quote.
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* Rules around “lazy” lines are not straightforward and visually confusing,
|
||||||
|
* so it’s recommended to start each line with a `>`.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* adds markers to every line in a block quote.
|
* adds `>` markers to every line in a block quote.
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @module no-blockquote-without-marker
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when lines in block quotes start without `>`.
|
||||||
|
* @author Titus Wormer
|
||||||
|
* @copyright 2015 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,16 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when blank lines without `>` (greater than) markers are found in a
|
[`remark-lint`][mono] rule to warn when lines in block quotes start without `>`.
|
||||||
block quote.
|
|
||||||
|
|
||||||
## Fix
|
## Contents
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [What is this?](#what-is-this)
|
||||||
adds markers to every line in a block quote.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoBlockquoteWithoutMarker[, config])`](#unifieduseremarklintnoblockquotewithoutmarker-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
## What is this?
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that lines in block quotes start with `>`.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -30,7 +47,96 @@ This rule is included in the following presets:
|
|||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`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) | |
|
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-blockquote-without-marker
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoBlockquoteWithoutMarker from 'https://cdn.skypack.dev/remark-lint-no-blockquote-without-marker@5?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoBlockquoteWithoutMarker from 'https://cdn.skypack.dev/remark-lint-no-blockquote-without-marker@5?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoBlockquoteWithoutMarker from 'remark-lint-no-blockquote-without-marker'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoBlockquoteWithoutMarker)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-blockquote-without-marker example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-blockquote-without-marker",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoBlockquoteWithoutMarker`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoBlockquoteWithoutMarker[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
Rules around “lazy” lines are not straightforward and visually confusing,
|
||||||
|
so it’s recommended to start each line with a `>`.
|
||||||
|
|
||||||
|
## Fix
|
||||||
|
|
||||||
|
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
|
adds `>` markers to every line in a block quote.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -50,7 +156,7 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `»` represents a tab.
|
> 👉 **Note**: `»` represents a tab.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
>»Foo…
|
>»Foo…
|
||||||
@ -82,7 +188,7 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `»` represents a tab.
|
> 👉 **Note**: `»` represents a tab.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
>»Foo…
|
>»Foo…
|
||||||
@ -97,59 +203,12 @@ Note: `»` represents a tab.
|
|||||||
3:1: Missing marker in block quote
|
3:1: Missing marker in block quote
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-blockquote-without-marker
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoBlockquoteWithoutMarker`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-blockquote-without-marker",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-blockquote-without-marker readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoBlockquoteWithoutMarker from 'remark-lint-no-blockquote-without-marker'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoBlockquoteWithoutMarker)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -191,17 +250,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,22 +1,29 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
*
|
||||||
* @license MIT
|
* You can use this package to check that no more blank lines than needed
|
||||||
* @module no-consecutive-blank-lines
|
* are used between blocks.
|
||||||
* @fileoverview
|
*
|
||||||
* Warn for too many consecutive blank lines.
|
* ## API
|
||||||
* Knows about the extra line needed between a list and indented code, and two
|
*
|
||||||
* lists.
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* More than one blank line has no effect between blocks.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* always uses one blank line between blocks if possible, or two lines when
|
* adds exactly one blank line between any block.
|
||||||
* needed.
|
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @module no-consecutive-blank-lines
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when more blank lines that needed are used
|
||||||
|
* between blocks.
|
||||||
|
* @author Titus Wormer
|
||||||
|
* @copyright 2015 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,18 +10,35 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn for too many consecutive blank lines.
|
[`remark-lint`][mono] rule to warn when more blank lines that needed are used
|
||||||
Knows about the extra line needed between a list and indented code, and two
|
between blocks.
|
||||||
lists.
|
|
||||||
|
|
||||||
## Fix
|
## Contents
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [What is this?](#what-is-this)
|
||||||
always uses one blank line between blocks if possible, or two lines when
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
needed.
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoConsecutiveBlankLines[, config])`](#unifieduseremarklintnoconsecutiveblanklines-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
## What is this?
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that no more blank lines than needed
|
||||||
|
are used between blocks.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -31,13 +48,101 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-consecutive-blank-lines
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoConsecutiveBlankLines from 'https://cdn.skypack.dev/remark-lint-no-consecutive-blank-lines@4?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoConsecutiveBlankLines from 'https://cdn.skypack.dev/remark-lint-no-consecutive-blank-lines@4?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoConsecutiveBlankLines from 'remark-lint-no-consecutive-blank-lines'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoConsecutiveBlankLines)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-consecutive-blank-lines example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-consecutive-blank-lines",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoConsecutiveBlankLines`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoConsecutiveBlankLines[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
More than one blank line has no effect between blocks.
|
||||||
|
|
||||||
|
## Fix
|
||||||
|
|
||||||
|
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
|
adds exactly one blank line between any block.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `␊` represents a line feed.
|
> 👉 **Note**: `␊` represents a line feed.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Foo…
|
Foo…
|
||||||
@ -59,7 +164,7 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `␊` represents a line feed.
|
> 👉 **Note**: `␊` represents a line feed.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
Foo…
|
Foo…
|
||||||
@ -77,59 +182,12 @@ Foo…
|
|||||||
4:5: Remove 2 lines after node
|
4:5: Remove 2 lines after node
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-consecutive-blank-lines
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoConsecutiveBlankLines`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-consecutive-blank-lines",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-consecutive-blank-lines readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoConsecutiveBlankLines from 'remark-lint-no-consecutive-blank-lines'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoConsecutiveBlankLines)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -171,17 +229,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,23 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that URLs are defined once.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* It’s likely a mistake when the same URL is defined with different
|
||||||
|
* identifiers.
|
||||||
|
*
|
||||||
|
* @module no-duplicate-defined-urls
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when URLs are defined multiple times.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2020 Titus Wormer
|
* @copyright 2020 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-duplicate-defined-urls
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when definitions define the same URL.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,13 +10,122 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when definitions define the same URL.
|
[`remark-lint`][mono] rule to warn when URLs are defined multiple times.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoDuplicateDefinedUrls[, config])`](#unifieduseremarklintnoduplicatedefinedurls-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that URLs are defined once.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
This rule is not included in any default preset
|
This rule is not included in a preset maintained here.
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-duplicate-defined-urls
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoDuplicateDefinedUrls from 'https://cdn.skypack.dev/remark-lint-no-duplicate-defined-urls@2?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoDuplicateDefinedUrls from 'https://cdn.skypack.dev/remark-lint-no-duplicate-defined-urls@2?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoDuplicateDefinedUrls from 'remark-lint-no-duplicate-defined-urls'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoDuplicateDefinedUrls)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-duplicate-defined-urls example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-duplicate-defined-urls",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoDuplicateDefinedUrls`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoDuplicateDefinedUrls[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
It’s likely a mistake when the same URL is defined with different
|
||||||
|
identifiers.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -46,59 +155,12 @@ No messages.
|
|||||||
2:1-2:19: Do not use different definitions with the same URL (1:1)
|
2:1-2:19: Do not use different definitions with the same URL (1:1)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-duplicate-defined-urls
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoDuplicateDefinedUrls`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-duplicate-defined-urls",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-duplicate-defined-urls readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoDuplicateDefinedUrls from 'remark-lint-no-duplicate-defined-urls'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoDuplicateDefinedUrls)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -140,17 +202,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that identifiers are defined once.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* It’s a mistake when the same identifier is defined multiple times.
|
||||||
|
*
|
||||||
|
* @module no-duplicate-definitions
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when identifiers are defined multiple times.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-duplicate-definitions
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when duplicate definitions are found.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,32 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when duplicate definitions are found.
|
[`remark-lint`][mono] rule to warn when identifiers are defined multiple times.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoDuplicateDefinitions[, config])`](#unifieduseremarklintnoduplicatedefinitions-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that identifiers are defined once.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -20,7 +45,90 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-duplicate-definitions
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoDuplicateDefinitions from 'https://cdn.skypack.dev/remark-lint-no-duplicate-definitions@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoDuplicateDefinitions from 'https://cdn.skypack.dev/remark-lint-no-duplicate-definitions@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoDuplicateDefinitions)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-duplicate-definitions example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-duplicate-definitions",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoDuplicateDefinitions`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoDuplicateDefinitions[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
It’s a mistake when the same identifier is defined multiple times.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -50,59 +158,12 @@ No messages.
|
|||||||
2:1-2:11: Do not use definitions with the same identifier (1:1)
|
2:1-2:11: Do not use definitions with the same identifier (1:1)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-duplicate-definitions
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoDuplicateDefinitions`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-duplicate-definitions",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-duplicate-definitions readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoDuplicateDefinitions from 'remark-lint-no-duplicate-definitions'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoDuplicateDefinitions)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -144,17 +205,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,12 +1,25 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that headings with the same text are
|
||||||
|
* used once per section.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* It’s likely a mistake that the same heading text is used in the same
|
||||||
|
* section.
|
||||||
|
*
|
||||||
|
* @module no-duplicate-headings-in-section
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when headings with the same text are used
|
||||||
|
* multiple times per section.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-duplicate-headings-in-section
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when duplicate headings are found, but only when on the same level,
|
|
||||||
* “in” the same section.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,14 +10,124 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when duplicate headings are found, but only when on the same level,
|
[`remark-lint`][mono] rule to warn when headings with the same text are used
|
||||||
“in” the same section.
|
multiple times per section.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoDuplicateHeadingsInSection[, config])`](#unifieduseremarklintnoduplicateheadingsinsection-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that headings with the same text are
|
||||||
|
used once per section.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
This rule is not included in any default preset
|
This rule is not included in a preset maintained here.
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-duplicate-headings-in-section
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoDuplicateHeadingsInSection from 'https://cdn.skypack.dev/remark-lint-no-duplicate-headings-in-section@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoDuplicateHeadingsInSection from 'https://cdn.skypack.dev/remark-lint-no-duplicate-headings-in-section@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoDuplicateHeadingsInSection from 'remark-lint-no-duplicate-headings-in-section'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoDuplicateHeadingsInSection)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-duplicate-headings-in-section example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-duplicate-headings-in-section",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoDuplicateHeadingsInSection`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoDuplicateHeadingsInSection[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
It’s likely a mistake that the same heading text is used in the same
|
||||||
|
section.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -85,59 +195,12 @@ No messages.
|
|||||||
7:1-7:11: Do not use headings with similar content per section (3:1)
|
7:1-7:11: Do not use headings with similar content per section (3:1)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-duplicate-headings-in-section
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoDuplicateHeadingsInSection`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-duplicate-headings-in-section",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-duplicate-headings-in-section readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoDuplicateHeadingsInSection from 'remark-lint-no-duplicate-headings-in-section'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoDuplicateHeadingsInSection)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -179,17 +242,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,29 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that headings with the same text are
|
||||||
|
* used once.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* Headings having unique text helps screen reader users (who typically use
|
||||||
|
* “jump to heading” features to navigate within a page, which reads headings
|
||||||
|
* out loud).
|
||||||
|
* It also helps because often headings receive automatic unique IDs, and when
|
||||||
|
* the same heading text is used, they are suffixed with a number based on where
|
||||||
|
* they are positioned in the document, which makes linking to them prone to
|
||||||
|
* changes.
|
||||||
|
*
|
||||||
|
* @module no-duplicate-headings
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when headings with the same text are found.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-duplicate-headings
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when duplicate headings are found.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when duplicate headings are found.
|
[`remark-lint`][mono] rule to warn when headings with the same text are found.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoDuplicateHeadings[, config])`](#unifieduseremarklintnoduplicateheadings-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that headings with the same text are
|
||||||
|
used once.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -20,7 +46,96 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-duplicate-headings
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoDuplicateHeadings from 'https://cdn.skypack.dev/remark-lint-no-duplicate-headings@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoDuplicateHeadings from 'https://cdn.skypack.dev/remark-lint-no-duplicate-headings@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoDuplicateHeadings from 'remark-lint-no-duplicate-headings'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoDuplicateHeadings)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-duplicate-headings example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-duplicate-headings",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoDuplicateHeadings`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoDuplicateHeadings[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
Headings having unique text helps screen reader users (who typically use
|
||||||
|
“jump to heading” features to navigate within a page, which reads headings
|
||||||
|
out loud).
|
||||||
|
It also helps because often headings receive automatic unique IDs, and when
|
||||||
|
the same heading text is used, they are suffixed with a number based on where
|
||||||
|
they are positioned in the document, which makes linking to them prone to
|
||||||
|
changes.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -55,59 +170,12 @@ No messages.
|
|||||||
5:1-5:29: Do not use headings with similar content (3:1)
|
5:1-5:29: Do not use headings with similar content (3:1)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-duplicate-headings
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoDuplicateHeadings`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-duplicate-headings",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-duplicate-headings readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoDuplicateHeadings from 'remark-lint-no-duplicate-headings'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoDuplicateHeadings)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -149,17 +217,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,12 +1,26 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that headings are used to introduce
|
||||||
|
* paragraphs instead of “fake” headings made with emphasis or strong.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* While not always the case, typically emphasis or strong around the text
|
||||||
|
* in a paragraph is used as a “faux” heading.
|
||||||
|
* It’s recommended to use actual headings instead.
|
||||||
|
*
|
||||||
|
* @module no-emphasis-as-heading
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when emphasis or strong are used to introduce
|
||||||
|
* a paragraph.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-emphasis-as-heading
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when emphasis (including strong), instead of a heading, introduces
|
|
||||||
* a paragraph.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,9 +10,35 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when emphasis (including strong), instead of a heading, introduces
|
[`remark-lint`][mono] rule to warn when emphasis or strong are used to introduce
|
||||||
a paragraph.
|
a paragraph.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoEmphasisAsHeading[, config])`](#unifieduseremarklintnoemphasisasheading-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that headings are used to introduce
|
||||||
|
paragraphs instead of “fake” headings made with emphasis or strong.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
This rule is included in the following presets:
|
This rule is included in the following presets:
|
||||||
@ -21,7 +47,92 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-emphasis-as-heading
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoEmphasisAsHeading from 'https://cdn.skypack.dev/remark-lint-no-emphasis-as-heading@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoEmphasisAsHeading from 'https://cdn.skypack.dev/remark-lint-no-emphasis-as-heading@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoEmphasisAsHeading from 'remark-lint-no-emphasis-as-heading'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoEmphasisAsHeading)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-emphasis-as-heading example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-emphasis-as-heading",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoEmphasisAsHeading`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoEmphasisAsHeading[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
While not always the case, typically emphasis or strong around the text
|
||||||
|
in a paragraph is used as a “faux” heading.
|
||||||
|
It’s recommended to use actual headings instead.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -58,59 +169,12 @@ Quux.
|
|||||||
5:1-5:8: Don’t use emphasis to introduce a section, use a heading
|
5:1-5:8: Don’t use emphasis to introduce a section, use a heading
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-emphasis-as-heading
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoEmphasisAsHeading`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-emphasis-as-heading",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-emphasis-as-heading readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoEmphasisAsHeading from 'remark-lint-no-emphasis-as-heading'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoEmphasisAsHeading)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -152,17 +216,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,24 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that links and images have URLs.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* While it is possible to omit URLs in links and images, that typically
|
||||||
|
* indicates a “placeholder” or todo that has to be filled out later.
|
||||||
|
* It’s recommended to fill them out.
|
||||||
|
*
|
||||||
|
* @module no-empty-url
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn for empty URLs in links and images.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-empty-url
|
|
||||||
* @fileoverview
|
|
||||||
* Warn for empty URLs in links and images.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,13 +10,123 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn for empty URLs in links and images.
|
[`remark-lint`][mono] rule to warn for empty URLs in links and images.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoEmptyUrl[, config])`](#unifieduseremarklintnoemptyurl-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that links and images have URLs.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
This rule is not included in any default preset
|
This rule is not included in a preset maintained here.
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-empty-url
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoEmptyUrl from 'https://cdn.skypack.dev/remark-lint-no-empty-url@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoEmptyUrl from 'https://cdn.skypack.dev/remark-lint-no-empty-url@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoEmptyUrl from 'remark-lint-no-empty-url'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoEmptyUrl)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-empty-url example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-empty-url",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoEmptyUrl`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoEmptyUrl[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
While it is possible to omit URLs in links and images, that typically
|
||||||
|
indicates a “placeholder” or todo that has to be filled out later.
|
||||||
|
It’s recommended to fill them out.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -49,59 +159,12 @@ No messages.
|
|||||||
3:1-3:11: Don’t use images without URL
|
3:1-3:11: Don’t use images without URL
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-empty-url
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoEmptyUrl`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-empty-url",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-empty-url readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoEmptyUrl from 'remark-lint-no-empty-url'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoEmptyUrl)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -143,17 +206,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that file names do not start with
|
||||||
|
* articles (`a`, `the`, etc).
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* @module no-file-name-articles
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when file names start with articles.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-file-name-articles
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when file names start with an article.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "title.md"}
|
* {"name": "title.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,32 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when file names start with an article.
|
[`remark-lint`][mono] rule to warn when file names start with articles.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoFileNameArticles[, config])`](#unifieduseremarklintnofilenamearticles-config)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that file names do not start with
|
||||||
|
articles (`a`, `the`, etc).
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -20,7 +45,86 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-file-name-articles
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoFileNameArticles from 'https://cdn.skypack.dev/remark-lint-no-file-name-articles@2?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoFileNameArticles from 'https://cdn.skypack.dev/remark-lint-no-file-name-articles@2?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoFileNameArticles from 'remark-lint-no-file-name-articles'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoFileNameArticles)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-file-name-articles example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-file-name-articles",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoFileNameArticles`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoFileNameArticles[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `title.md`
|
##### `title.md`
|
||||||
|
|
||||||
@ -60,59 +164,12 @@ No messages.
|
|||||||
1:1: Do not start file names with `an`
|
1:1: Do not start file names with `an`
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-file-name-articles
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoFileNameArticles`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-file-name-articles",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-file-name-articles readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoFileNameArticles from 'remark-lint-no-file-name-articles'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoFileNameArticles)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -154,17 +211,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that no consecutive dashes appear in
|
||||||
|
* file names.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* @module no-file-name-consecutive-dashes
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when consecutive dashes appear in file names.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-file-name-consecutive-dashes
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when file names contain consecutive dashes.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "plug-ins.md"}
|
* {"name": "plug-ins.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,32 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when file names contain consecutive dashes.
|
[`remark-lint`][mono] rule to warn when consecutive dashes appear in file names.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoFileNameConsecutiveDashes[, config])`](#unifieduseremarklintnofilenameconsecutivedashes-config)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that no consecutive dashes appear in
|
||||||
|
file names.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -20,7 +45,86 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-file-name-consecutive-dashes
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoFileNameConsecutiveDashes from 'https://cdn.skypack.dev/remark-lint-no-file-name-consecutive-dashes@2?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoFileNameConsecutiveDashes from 'https://cdn.skypack.dev/remark-lint-no-file-name-consecutive-dashes@2?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoFileNameConsecutiveDashes from 'remark-lint-no-file-name-consecutive-dashes'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoFileNameConsecutiveDashes)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-file-name-consecutive-dashes example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-file-name-consecutive-dashes",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoFileNameConsecutiveDashes`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoFileNameConsecutiveDashes[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `plug-ins.md`
|
##### `plug-ins.md`
|
||||||
|
|
||||||
@ -36,59 +140,12 @@ No messages.
|
|||||||
1:1: Do not use consecutive dashes in a file name
|
1:1: Do not use consecutive dashes in a file name
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-file-name-consecutive-dashes
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoFileNameConsecutiveDashes`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-file-name-consecutive-dashes",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-file-name-consecutive-dashes readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoFileNameConsecutiveDashes from 'remark-lint-no-file-name-consecutive-dashes'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoFileNameConsecutiveDashes)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -130,17 +187,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,20 +1,24 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that file names contain regular characters.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* The following options (default: `'\\.a-zA-Z0-9-'`) are accepted:
|
||||||
|
*
|
||||||
|
* * `string` (example `'\w\\.'`)
|
||||||
|
* — allowed characters, wrapped in `new RegExp('[^' + x + ']')`, make sure
|
||||||
|
* to double escape regexp characters
|
||||||
|
* * `RegExp` (example `/[^\.a-zA-Z0-9-]/`)
|
||||||
|
* — disallowed pattern
|
||||||
|
*
|
||||||
|
* @module no-file-name-irregular-characters
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when file names contain irregular characters.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-file-name-irregular-characters
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when file names contain irregular characters: characters other than
|
|
||||||
* alphanumericals (`a-zA-Z0-9`), hyphen-minus (`-`), and dots (`.`, full
|
|
||||||
* stops).
|
|
||||||
*
|
|
||||||
* Options: `RegExp` or `string`, default: `'\\.a-zA-Z0-9-'`.
|
|
||||||
*
|
|
||||||
* If a string is given, it will be wrapped in
|
|
||||||
* `new RegExp('[^' + preferred + ']')`.
|
|
||||||
*
|
|
||||||
* Any match by the wrapped or given expressions creates a message.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "plug-ins.md"}
|
* {"name": "plug-ins.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,16 +10,31 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when file names contain irregular characters: characters other than
|
[`remark-lint`][mono] rule to warn when file names contain irregular characters.
|
||||||
alphanumericals (`a-zA-Z0-9`), hyphen-minus (`-`), and dots (`.`, full
|
|
||||||
stops).
|
|
||||||
|
|
||||||
Options: `RegExp` or `string`, default: `'\\.a-zA-Z0-9-'`.
|
## Contents
|
||||||
|
|
||||||
If a string is given, it will be wrapped in
|
* [What is this?](#what-is-this)
|
||||||
`new RegExp('[^' + preferred + ']')`.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoFileNameIrregularCharacters[, config])`](#unifieduseremarklintnofilenameirregularcharacters-config)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
Any match by the wrapped or given expressions creates a message.
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that file names contain regular characters.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -29,7 +44,92 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-file-name-irregular-characters
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoFileNameIrregularCharacters from 'https://cdn.skypack.dev/remark-lint-no-file-name-irregular-characters@2?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoFileNameIrregularCharacters from 'https://cdn.skypack.dev/remark-lint-no-file-name-irregular-characters@2?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoFileNameIrregularCharacters from 'remark-lint-no-file-name-irregular-characters'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoFileNameIrregularCharacters)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-file-name-irregular-characters example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-file-name-irregular-characters",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoFileNameIrregularCharacters`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoFileNameIrregularCharacters[, config])`
|
||||||
|
|
||||||
|
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: `'\\.a-zA-Z0-9-'`) are accepted:
|
||||||
|
|
||||||
|
* `string` (example `'\w\\.'`)
|
||||||
|
— allowed characters, wrapped in `new RegExp('[^' + x + ']')`, make sure
|
||||||
|
to double escape regexp characters
|
||||||
|
* `RegExp` (example `/[^\.a-zA-Z0-9-]/`)
|
||||||
|
— disallowed pattern
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `plug-ins.md`
|
##### `plug-ins.md`
|
||||||
|
|
||||||
@ -69,59 +169,12 @@ When configured with `'\\.a-z0-9'`.
|
|||||||
1:1: Do not use `R` in a file name
|
1:1: Do not use `R` in a file name
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-file-name-irregular-characters
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoFileNameIrregularCharacters`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-file-name-irregular-characters",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-file-name-irregular-characters readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoFileNameIrregularCharacters from 'remark-lint-no-file-name-irregular-characters'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoFileNameIrregularCharacters)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -163,17 +216,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that file name casing is consistent
|
||||||
|
* (either lowercase or uppercase).
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* @module no-file-name-mixed-case
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when file name casing is inconsistent.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-file-name-mixed-case
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when file names use mixed case: both upper- and lowercase characters.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "README.md"}
|
* {"name": "README.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,32 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when file names use mixed case: both upper- and lowercase characters.
|
[`remark-lint`][mono] rule to warn when file name casing is inconsistent.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoFileNameMixedCase[, config])`](#unifieduseremarklintnofilenamemixedcase-config)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that file name casing is consistent
|
||||||
|
(either lowercase or uppercase).
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -20,7 +45,86 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-file-name-mixed-case
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoFileNameMixedCase from 'https://cdn.skypack.dev/remark-lint-no-file-name-mixed-case@2?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoFileNameMixedCase from 'https://cdn.skypack.dev/remark-lint-no-file-name-mixed-case@2?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoFileNameMixedCase from 'remark-lint-no-file-name-mixed-case'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoFileNameMixedCase)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-file-name-mixed-case example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-file-name-mixed-case",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoFileNameMixedCase`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoFileNameMixedCase[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `README.md`
|
##### `README.md`
|
||||||
|
|
||||||
@ -42,59 +146,12 @@ No messages.
|
|||||||
1:1: Do not mix casing in file names
|
1:1: Do not mix casing in file names
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-file-name-mixed-case
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoFileNameMixedCase`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-file-name-mixed-case",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-file-name-mixed-case readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoFileNameMixedCase from 'remark-lint-no-file-name-mixed-case'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoFileNameMixedCase)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -136,17 +193,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that no initial or final dashes appear in
|
||||||
|
* file names.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* @module no-file-name-outer-dashes
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when initial or final dashes appear in file names.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-file-name-outer-dashes
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when file names contain initial or final dashes (hyphen-minus, `-`).
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "readme.md"}
|
* {"name": "readme.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,7 +10,32 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when file names contain initial or final dashes (hyphen-minus, `-`).
|
[`remark-lint`][mono] rule to warn when initial or final dashes appear in file names.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoFileNameOuterDashes[, config])`](#unifieduseremarklintnofilenameouterdashes-config)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that no initial or final dashes appear in
|
||||||
|
file names.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -20,7 +45,86 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-file-name-outer-dashes
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoFileNameOuterDashes from 'https://cdn.skypack.dev/remark-lint-no-file-name-outer-dashes@2?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoFileNameOuterDashes from 'https://cdn.skypack.dev/remark-lint-no-file-name-outer-dashes@2?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoFileNameOuterDashes from 'remark-lint-no-file-name-outer-dashes'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoFileNameOuterDashes)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-file-name-outer-dashes example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-file-name-outer-dashes",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoFileNameOuterDashes`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoFileNameOuterDashes[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `readme.md`
|
##### `readme.md`
|
||||||
|
|
||||||
@ -44,59 +148,12 @@ No messages.
|
|||||||
1:1: Do not use initial or final dashes in a file name
|
1:1: Do not use initial or final dashes in a file name
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-file-name-outer-dashes
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoFileNameOuterDashes`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-file-name-outer-dashes",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-file-name-outer-dashes readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoFileNameOuterDashes from 'remark-lint-no-file-name-outer-dashes'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoFileNameOuterDashes)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -138,17 +195,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,19 +1,30 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
*
|
||||||
* @license MIT
|
* You can use this package to check that there is on space between `#`
|
||||||
* @module no-heading-content-indent
|
* characters and the content in headings.
|
||||||
* @fileoverview
|
*
|
||||||
* Warn when content of headings is indented.
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* One space is required and more than one space has no effect.
|
||||||
|
* Due to this, it’s recommended to turn this rule on.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* removes all unneeded padding around content in headings.
|
* formats headings with exactly one space.
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @module no-heading-content-indent
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when there are too many spaces between
|
||||||
|
* hashes and content in headings.
|
||||||
|
* @author Titus Wormer
|
||||||
|
* @copyright 2015 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,15 +10,35 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when content of headings is indented.
|
[`remark-lint`][mono] rule to warn when there are too many spaces between
|
||||||
|
hashes and content in headings.
|
||||||
|
|
||||||
## Fix
|
## Contents
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [What is this?](#what-is-this)
|
||||||
removes all unneeded padding around content in headings.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoHeadingContentIndent[, config])`](#unifieduseremarklintnoheadingcontentindent-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
## What is this?
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that there is on space between `#`
|
||||||
|
characters and the content in headings.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -28,13 +48,102 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-heading-content-indent
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoHeadingContentIndent from 'https://cdn.skypack.dev/remark-lint-no-heading-content-indent@4?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoHeadingContentIndent from 'https://cdn.skypack.dev/remark-lint-no-heading-content-indent@4?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoHeadingContentIndent from 'remark-lint-no-heading-content-indent'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoHeadingContentIndent)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-heading-content-indent example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-heading-content-indent",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoHeadingContentIndent`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoHeadingContentIndent[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
One space is required and more than one space has no effect.
|
||||||
|
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 headings with exactly one space.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
#·Foo
|
#·Foo
|
||||||
@ -57,7 +166,7 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
#··Foo
|
#··Foo
|
||||||
@ -79,7 +188,7 @@ Note: `·` represents a space.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
#··
|
#··
|
||||||
@ -89,59 +198,12 @@ Note: `·` represents a space.
|
|||||||
|
|
||||||
No messages.
|
No messages.
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-heading-content-indent
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoHeadingContentIndent`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-heading-content-indent",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-heading-content-indent readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoHeadingContentIndent from 'remark-lint-no-heading-content-indent'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoHeadingContentIndent)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -183,17 +245,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,19 +1,40 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
*
|
||||||
* @license MIT
|
* You can use this package to check that headings are not indented.
|
||||||
* @module no-heading-indent
|
*
|
||||||
* @fileoverview
|
* ## API
|
||||||
* Warn when a heading is indented.
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* There is no specific handling of indented headings (or anything else) in
|
||||||
|
* markdown.
|
||||||
|
* While it is possible to use an indent to headings on their text:
|
||||||
|
*
|
||||||
|
* ```markdown
|
||||||
|
* # One
|
||||||
|
* ## Two
|
||||||
|
* ### Three
|
||||||
|
* #### Four
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* …such style is uncommon, a bit hard to maintain, and it’s impossible to add a
|
||||||
|
* heading with a rank of 5 as it would form indented code instead.
|
||||||
|
* Hence, it’s recommended to not indent headings and to turn this rule on.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* removes all unneeded indentation before headings.
|
* formats all headings without indent.
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @module no-heading-indent
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when headings are indented.
|
||||||
|
* @author Titus Wormer
|
||||||
|
* @copyright 2015 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,27 +10,146 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when a heading is indented.
|
[`remark-lint`][mono] rule to warn when headings are indented.
|
||||||
|
|
||||||
## Fix
|
## Contents
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [What is this?](#what-is-this)
|
||||||
removes all unneeded indentation before headings.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoHeadingIndent[, config])`](#unifieduseremarklintnoheadingindent-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
## What is this?
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that headings are not indented.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
This rule is not included in any default preset
|
This rule is not included in a preset maintained here.
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-heading-indent
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoHeadingIndent from 'https://cdn.skypack.dev/remark-lint-no-heading-indent@4?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoHeadingIndent from 'https://cdn.skypack.dev/remark-lint-no-heading-indent@4?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoHeadingIndent from 'remark-lint-no-heading-indent'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoHeadingIndent)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-heading-indent example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-heading-indent",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoHeadingIndent`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoHeadingIndent[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
There is no specific handling of indented headings (or anything else) in
|
||||||
|
markdown.
|
||||||
|
While it is possible to use an indent to headings on their text:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
# One
|
||||||
|
## Two
|
||||||
|
### Three
|
||||||
|
#### Four
|
||||||
|
```
|
||||||
|
|
||||||
|
…such style is uncommon, a bit hard to maintain, and it’s impossible to add a
|
||||||
|
heading with a rank of 5 as it would form indented code instead.
|
||||||
|
Hence, it’s recommended to not indent headings and to turn this rule on.
|
||||||
|
|
||||||
|
## Fix
|
||||||
|
|
||||||
|
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
|
formats all headings without indent.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
#·Hello world
|
#·Hello world
|
||||||
@ -52,7 +171,7 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: `·` represents a space.
|
> 👉 **Note**: `·` represents a space.
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
···# Hello world
|
···# Hello world
|
||||||
@ -75,59 +194,12 @@ Note: `·` represents a space.
|
|||||||
8:4: Remove 3 spaces before this heading
|
8:4: Remove 3 spaces before this heading
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-heading-indent
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoHeadingIndent`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-heading-indent",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-heading-indent readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoHeadingIndent from 'remark-lint-no-heading-indent'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoHeadingIndent)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -169,17 +241,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to ensure that no heading-like constructs are
|
||||||
|
* created, which instead will result in paragraphs with the `#` characters
|
||||||
|
* shown.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* @module no-heading-like-paragraph
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when h7+ “headings” are used.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-heading-like-paragraph
|
|
||||||
* @fileoverview
|
|
||||||
* Warn for h7+ “headings”.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,13 +10,118 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn for h7+ “headings”.
|
[`remark-lint`][mono] rule to warn when h7+ “headings” are used.
|
||||||
|
|
||||||
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoHeadingLikeParagraph[, config])`](#unifieduseremarklintnoheadinglikeparagraph-config)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to ensure that no heading-like constructs are
|
||||||
|
created, which instead will result in paragraphs with the `#` characters
|
||||||
|
shown.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
This rule is not included in any default preset
|
This rule is not included in a preset maintained here.
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-heading-like-paragraph
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoHeadingLikeParagraph from 'https://cdn.skypack.dev/remark-lint-no-heading-like-paragraph@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoHeadingLikeParagraph from 'https://cdn.skypack.dev/remark-lint-no-heading-like-paragraph@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoHeadingLikeParagraph from 'remark-lint-no-heading-like-paragraph'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoHeadingLikeParagraph)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-heading-like-paragraph example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-heading-like-paragraph",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoHeadingLikeParagraph`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoHeadingLikeParagraph[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -48,59 +153,12 @@ Delta.
|
|||||||
1:1-1:16: This looks like a heading but has too many hashes
|
1:1-1:16: This looks like a heading but has too many hashes
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-heading-like-paragraph
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoHeadingLikeParagraph`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-heading-like-paragraph",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-heading-like-paragraph readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoHeadingLikeParagraph from 'remark-lint-no-heading-like-paragraph'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoHeadingLikeParagraph)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -142,17 +200,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,16 +1,24 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that headings don’t end in punctuation.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* The following options (default: `'\\.,;:!?'`) are accepted:
|
||||||
|
*
|
||||||
|
* * `string` (example `'\\.,;:'`)
|
||||||
|
* — disallowed characters, wrapped in `new RegExp('[' + x + ']')`, make sure
|
||||||
|
* to double escape regexp characters
|
||||||
|
* * `RegExp` (example `/\p{P}/u`)
|
||||||
|
* — disallowed pattern
|
||||||
|
*
|
||||||
|
* @module no-heading-punctuation
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn headings end in certain punctuation.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-heading-punctuation
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when a heading ends with a group of characters.
|
|
||||||
*
|
|
||||||
* Options: `string`, default: `'.,;:!?'`.
|
|
||||||
*
|
|
||||||
* Note: these are added to a regex, in a group (`'[' + char + ']'`), be
|
|
||||||
* careful to escape the string correctly.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,12 +10,31 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when a heading ends with a group of characters.
|
[`remark-lint`][mono] rule to warn headings end in certain punctuation.
|
||||||
|
|
||||||
Options: `string`, default: `'.,;:!?'`.
|
## Contents
|
||||||
|
|
||||||
Note: these are added to a regex, in a group (`'[' + char + ']'`), be
|
* [What is this?](#what-is-this)
|
||||||
careful to escape the string correctly.
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoHeadingPunctuation[, config])`](#unifieduseremarklintnoheadingpunctuation-config)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that headings don’t end in punctuation.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -25,7 +44,92 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `':.'` |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `':.'` |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-heading-punctuation
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoHeadingPunctuation from 'https://cdn.skypack.dev/remark-lint-no-heading-punctuation@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoHeadingPunctuation from 'https://cdn.skypack.dev/remark-lint-no-heading-punctuation@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoHeadingPunctuation from 'remark-lint-no-heading-punctuation'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoHeadingPunctuation)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-heading-punctuation example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-heading-punctuation",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoHeadingPunctuation`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoHeadingPunctuation[, config])`
|
||||||
|
|
||||||
|
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: `'\\.,;:!?'`) are accepted:
|
||||||
|
|
||||||
|
* `string` (example `'\\.,;:'`)
|
||||||
|
— disallowed characters, wrapped in `new RegExp('[' + x + ']')`, make sure
|
||||||
|
to double escape regexp characters
|
||||||
|
* `RegExp` (example `/\p{P}/u`)
|
||||||
|
— disallowed pattern
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -79,59 +183,12 @@ When configured with `',;:!?'`.
|
|||||||
|
|
||||||
No messages.
|
No messages.
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-heading-punctuation
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoHeadingPunctuation`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-heading-punctuation",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-heading-punctuation readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoHeadingPunctuation from 'remark-lint-no-heading-punctuation'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoHeadingPunctuation)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -173,17 +230,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that no HTML (other than comments) is used.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* @module no-html
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when HTML is used.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-html
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when HTML nodes are used.
|
|
||||||
*
|
|
||||||
* Ignores comments, because they are used by `remark`, `remark-lint`, other
|
|
||||||
* Markdown tools, and because Markdown doesn’t have native comments.
|
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
|
@ -10,16 +10,116 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when HTML nodes are used.
|
[`remark-lint`][mono] rule to warn when HTML is used.
|
||||||
|
|
||||||
Ignores comments, because they are used by `remark`, `remark-lint`, other
|
## Contents
|
||||||
Markdown tools, and because Markdown doesn’t have native comments.
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoHtml[, config])`](#unifieduseremarklintnohtml-config)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that no HTML (other than comments) is used.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
This rule is not included in any default preset
|
This rule is not included in a preset maintained here.
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-html
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoHtml from 'https://cdn.skypack.dev/remark-lint-no-html@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoHtml from 'https://cdn.skypack.dev/remark-lint-no-html@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoHtml from 'remark-lint-no-html'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoHtml)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-html example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-html",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoHtml`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoHtml[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -49,59 +149,12 @@ No messages.
|
|||||||
1:1-1:15: Do not use HTML in markdown
|
1:1-1:15: Do not use HTML in markdown
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-html
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoHtml`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-html",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-html readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoHtml from 'remark-lint-no-html'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoHtml)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -143,17 +196,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that inline constructs (links) are
|
||||||
|
* not padded.
|
||||||
|
* Historically, it was possible to pad emphasis, strong, and strikethrough
|
||||||
|
* too, but this was removed in CommonMark, making this rule much less useful.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* @module no-inline-padding
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when inline constructs are padded.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-inline-padding
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when phrasing content is padded with spaces between their markers and
|
|
||||||
* content.
|
|
||||||
*
|
|
||||||
* Warns for emphasis, strong, delete, image, and link.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,10 +10,34 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when phrasing content is padded with spaces between their markers and
|
[`remark-lint`][mono] rule to warn when inline constructs are padded.
|
||||||
content.
|
|
||||||
|
|
||||||
Warns for emphasis, strong, delete, image, and link.
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoInlinePadding[, config])`](#unifieduseremarklintnoinlinepadding-config)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that inline constructs (links) are
|
||||||
|
not padded.
|
||||||
|
Historically, it was possible to pad emphasis, strong, and strikethrough
|
||||||
|
too, but this was removed in CommonMark, making this rule much less useful.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -24,7 +48,86 @@ This rule is included in the following presets:
|
|||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`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) | |
|
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-inline-padding
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoInlinePadding from 'https://cdn.skypack.dev/remark-lint-no-inline-padding@4?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoInlinePadding from 'https://cdn.skypack.dev/remark-lint-no-inline-padding@4?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoInlinePadding from 'remark-lint-no-inline-padding'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoInlinePadding)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-inline-padding example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-inline-padding",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoInlinePadding`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoInlinePadding[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -52,59 +155,12 @@ Alpha [ bravo ](http://echo.fox/trot)
|
|||||||
1:7-1:38: Don’t pad `link` with inner spaces
|
1:7-1:38: Don’t pad `link` with inner spaces
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-inline-padding
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoInlinePadding`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-inline-padding",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-inline-padding readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoInlinePadding from 'remark-lint-no-inline-padding'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoInlinePadding)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -146,17 +202,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,23 +1,30 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
*
|
||||||
* @license MIT
|
* You can use this package to check that autolink literal URLs are not used.
|
||||||
* @module no-literal-urls
|
*
|
||||||
* @fileoverview
|
* ## API
|
||||||
* Warn for literal URLs in text.
|
*
|
||||||
* URLs are treated as links in some Markdown vendors, but not in others.
|
* There are no options.
|
||||||
* To make sure they are always linked, wrap them in `<` (less than) and `>`
|
*
|
||||||
* (greater than).
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* Autolink literal URLs (just a URL) are a feature enabled by GFM.
|
||||||
|
* They don’t work everywhere.
|
||||||
|
* Due to this, it’s recommended to instead use normal autolinks
|
||||||
|
* (`<https://url>`) or links (`[text](url)`).
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* never creates literal URLs and always uses `<` (less than) and `>`
|
* never creates autolink literals and always uses normal autolinks (`<url>`).
|
||||||
* (greater than).
|
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @module no-literal-urls
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn for autolink literals.
|
||||||
|
* @author Titus Wormer
|
||||||
|
* @copyright 2015 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,19 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn for literal URLs in text.
|
[`remark-lint`][mono] rule to warn for autolink literals.
|
||||||
URLs are treated as links in some Markdown vendors, but not in others.
|
|
||||||
To make sure they are always linked, wrap them in `<` (less than) and `>`
|
|
||||||
(greater than).
|
|
||||||
|
|
||||||
## Fix
|
## Contents
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [What is this?](#what-is-this)
|
||||||
never creates literal URLs and always uses `<` (less than) and `>`
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
(greater than).
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoLiteralUrls[, config])`](#unifieduseremarklintnoliteralurls-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
## What is this?
|
||||||
on how to automatically fix warnings for this rule.
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that autolink literal URLs are not used.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -33,7 +47,98 @@ This rule is included in the following presets:
|
|||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`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) | |
|
| [`remark-preset-lint-recommended`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-recommended) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-literal-urls
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoLiteralUrls from 'https://cdn.skypack.dev/remark-lint-no-literal-urls@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoLiteralUrls from 'https://cdn.skypack.dev/remark-lint-no-literal-urls@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoLiteralUrls from 'remark-lint-no-literal-urls'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoLiteralUrls)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-literal-urls example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-literal-urls",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoLiteralUrls`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoLiteralUrls[, config])`
|
||||||
|
|
||||||
|
This rule supports standard configuration that all remark lint rules accept
|
||||||
|
(such as `false` to turn it off or `[1, options]` to configure it).
|
||||||
|
|
||||||
|
There are no options.
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
Autolink literal URLs (just a URL) are a feature enabled by GFM.
|
||||||
|
They don’t work everywhere.
|
||||||
|
Due to this, it’s recommended to instead use normal autolinks
|
||||||
|
(`<https://url>`) or links (`[text](url)`).
|
||||||
|
|
||||||
|
## Fix
|
||||||
|
|
||||||
|
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
|
never creates autolink literals and always uses normal autolinks (`<url>`).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -51,7 +156,7 @@ No messages.
|
|||||||
|
|
||||||
###### In
|
###### In
|
||||||
|
|
||||||
Note: this example uses [GFM][].
|
> 👉 **Note**: this example uses GFM ([`remark-gfm`][gfm]).
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
http://foo.bar/baz
|
http://foo.bar/baz
|
||||||
@ -63,59 +168,12 @@ http://foo.bar/baz
|
|||||||
1:1-1:19: Don’t use literal URLs without angle brackets
|
1:1-1:19: Don’t use literal URLs without angle brackets
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-literal-urls
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoLiteralUrls`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-literal-urls",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-literal-urls readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoLiteralUrls from 'remark-lint-no-literal-urls'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoLiteralUrls)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -157,17 +215,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,26 +1,34 @@
|
|||||||
/**
|
/**
|
||||||
* @author Titus Wormer
|
* ## When should I use this?
|
||||||
* @copyright 2015 Titus Wormer
|
|
||||||
* @license MIT
|
|
||||||
* @module no-missing-blank-lines
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when missing blank lines before block content (and frontmatter
|
|
||||||
* content).
|
|
||||||
*
|
*
|
||||||
* This rule can be configured to allow tight list items without blank lines
|
* You can use this package to check that blank lines are used between blocks.
|
||||||
* between their contents by passing `{exceptTightLists: true}` (default:
|
*
|
||||||
* `false`).
|
* ## API
|
||||||
|
*
|
||||||
|
* The following options (default: `undefined`) are accepted:
|
||||||
|
*
|
||||||
|
* * `Object` with the following fields:
|
||||||
|
* * `exceptTightLists` (`boolean`, default: `false`)
|
||||||
|
* — allow tight list items
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* While not always required, blank lines are required in certain, sometimes
|
||||||
|
* confusing, cases.
|
||||||
|
* Due to this, it’s recommended to always use blank lines between blocks.
|
||||||
*
|
*
|
||||||
* ## Fix
|
* ## Fix
|
||||||
*
|
*
|
||||||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
* always uses one blank line between blocks if possible, or two lines when
|
* always uses blank lines between blocks.
|
||||||
* needed.
|
* It has a `join` function to customize such behavior.
|
||||||
* The style of the list items persists.
|
|
||||||
*
|
|
||||||
* See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
|
||||||
* on how to automatically fix warnings for this rule.
|
|
||||||
*
|
*
|
||||||
|
* @module no-missing-blank-lines
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when blank lines are missing.
|
||||||
|
* @author Titus Wormer
|
||||||
|
* @copyright 2015 Titus Wormer
|
||||||
|
* @license MIT
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
@ -10,28 +10,134 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when missing blank lines before block content (and frontmatter
|
[`remark-lint`][mono] rule to warn when blank lines are missing.
|
||||||
content).
|
|
||||||
|
|
||||||
This rule can be configured to allow tight list items without blank lines
|
## Contents
|
||||||
between their contents by passing `{exceptTightLists: true}` (default:
|
|
||||||
`false`).
|
|
||||||
|
|
||||||
## Fix
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoMissingBlankLines[, config])`](#unifieduseremarklintnomissingblanklines-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Fix](#fix)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify)
|
## What is this?
|
||||||
always uses one blank line between blocks if possible, or two lines when
|
|
||||||
needed.
|
|
||||||
The style of the list items persists.
|
|
||||||
|
|
||||||
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
on how to automatically fix warnings for this rule.
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that blank lines are used between blocks.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
This rule is not included in any default preset
|
This rule is not included in a preset maintained here.
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-missing-blank-lines
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoMissingBlankLines from 'https://cdn.skypack.dev/remark-lint-no-missing-blank-lines@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoMissingBlankLines from 'https://cdn.skypack.dev/remark-lint-no-missing-blank-lines@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoMissingBlankLines from 'remark-lint-no-missing-blank-lines'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoMissingBlankLines)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-missing-blank-lines example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-missing-blank-lines",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoMissingBlankLines`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoMissingBlankLines[, config])`
|
||||||
|
|
||||||
|
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: `undefined`) are accepted:
|
||||||
|
|
||||||
|
* `Object` with the following fields:
|
||||||
|
* `exceptTightLists` (`boolean`, default: `false`)
|
||||||
|
— allow tight list items
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
While not always required, blank lines are required in certain, sometimes
|
||||||
|
confusing, cases.
|
||||||
|
Due to this, it’s recommended to always use blank lines between blocks.
|
||||||
|
|
||||||
|
## Fix
|
||||||
|
|
||||||
|
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify)
|
||||||
|
always uses blank lines between blocks.
|
||||||
|
It has a `join` function to customize such behavior.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -96,59 +202,12 @@ Paragraph.
|
|||||||
2:1-2:7: Missing blank line before block node
|
2:1-2:7: Missing blank line before block node
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-missing-blank-lines
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoMissingBlankLines`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-missing-blank-lines",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-missing-blank-lines readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoMissingBlankLines from 'remark-lint-no-missing-blank-lines'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoMissingBlankLines)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -190,17 +249,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,13 +1,27 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that no more than one top level heading
|
||||||
|
* is used.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* The following options (default: `1`) are accepted:
|
||||||
|
*
|
||||||
|
* * `number` (example: `1`)
|
||||||
|
* — assumed top level heading rank
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* Documents should almost always have one main heading, which is typically a
|
||||||
|
* heading with a rank of `1`.
|
||||||
|
*
|
||||||
|
* @module no-multiple-toplevel-headings
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when more than one top level heading is used.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2015 Titus Wormer
|
* @copyright 2015 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-multiple-toplevel-headings
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when multiple top level headings are used.
|
|
||||||
*
|
|
||||||
* Options: `number`, default: `1`.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md", "setting": 1}
|
* {"name": "ok.md", "setting": 1}
|
||||||
*
|
*
|
||||||
|
@ -10,9 +10,33 @@
|
|||||||
[![Backers][backers-badge]][collective]
|
[![Backers][backers-badge]][collective]
|
||||||
[![Chat][chat-badge]][chat]
|
[![Chat][chat-badge]][chat]
|
||||||
|
|
||||||
Warn when multiple top level headings are used.
|
[`remark-lint`][mono] rule to warn when more than one top level heading is used.
|
||||||
|
|
||||||
Options: `number`, default: `1`.
|
## Contents
|
||||||
|
|
||||||
|
* [What is this?](#what-is-this)
|
||||||
|
* [When should I use this?](#when-should-i-use-this)
|
||||||
|
* [Presets](#presets)
|
||||||
|
* [Install](#install)
|
||||||
|
* [Use](#use)
|
||||||
|
* [API](#api)
|
||||||
|
* [`unified().use(remarkLintNoMultipleToplevelHeadings[, config])`](#unifieduseremarklintnomultipletoplevelheadings-config)
|
||||||
|
* [Recommendation](#recommendation)
|
||||||
|
* [Examples](#examples)
|
||||||
|
* [Compatibility](#compatibility)
|
||||||
|
* [Contribute](#contribute)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
## What is this?
|
||||||
|
|
||||||
|
This package is a [unified][] ([remark][]) plugin, specifically a `remark-lint`
|
||||||
|
rule.
|
||||||
|
Lint rules check markdown code style.
|
||||||
|
|
||||||
|
## When should I use this?
|
||||||
|
|
||||||
|
You can use this package to check that no more than one top level heading
|
||||||
|
is used.
|
||||||
|
|
||||||
## Presets
|
## Presets
|
||||||
|
|
||||||
@ -22,7 +46,94 @@ This rule is included in the following presets:
|
|||||||
| - | - |
|
| - | - |
|
||||||
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | |
|
||||||
|
|
||||||
## Example
|
## Install
|
||||||
|
|
||||||
|
This package is [ESM only][esm].
|
||||||
|
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install remark-lint-no-multiple-toplevel-headings
|
||||||
|
```
|
||||||
|
|
||||||
|
In Deno with [Skypack][]:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import remarkLintNoMultipleToplevelHeadings from 'https://cdn.skypack.dev/remark-lint-no-multiple-toplevel-headings@3?dts'
|
||||||
|
```
|
||||||
|
|
||||||
|
In browsers with [Skypack][]:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import remarkLintNoMultipleToplevelHeadings from 'https://cdn.skypack.dev/remark-lint-no-multiple-toplevel-headings@3?min'
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
On the API:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import {read} from 'to-vfile'
|
||||||
|
import {reporter} from 'vfile-reporter'
|
||||||
|
import {remark} from 'remark'
|
||||||
|
import remarkLint from 'remark-lint'
|
||||||
|
import remarkLintNoMultipleToplevelHeadings from 'remark-lint-no-multiple-toplevel-headings'
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const file = await remark()
|
||||||
|
.use(remarkLint)
|
||||||
|
.use(remarkLintNoMultipleToplevelHeadings)
|
||||||
|
.process(await read('example.md'))
|
||||||
|
|
||||||
|
console.error(reporter(file))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
remark --use remark-lint --use remark-lint-no-multiple-toplevel-headings example.md
|
||||||
|
```
|
||||||
|
|
||||||
|
On the CLI in a config file (here a `package.json`):
|
||||||
|
|
||||||
|
```diff
|
||||||
|
…
|
||||||
|
"remarkConfig": {
|
||||||
|
"plugins": [
|
||||||
|
…
|
||||||
|
"remark-lint",
|
||||||
|
+ "remark-lint-no-multiple-toplevel-headings",
|
||||||
|
…
|
||||||
|
]
|
||||||
|
}
|
||||||
|
…
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
This package exports no identifiers.
|
||||||
|
The default export is `remarkLintNoMultipleToplevelHeadings`.
|
||||||
|
|
||||||
|
### `unified().use(remarkLintNoMultipleToplevelHeadings[, config])`
|
||||||
|
|
||||||
|
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: `1`) are accepted:
|
||||||
|
|
||||||
|
* `number` (example: `1`)
|
||||||
|
— assumed top level heading rank
|
||||||
|
|
||||||
|
## Recommendation
|
||||||
|
|
||||||
|
Documents should almost always have one main heading, which is typically a
|
||||||
|
heading with a rank of `1`.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
##### `ok.md`
|
##### `ok.md`
|
||||||
|
|
||||||
@ -58,59 +169,12 @@ When configured with `1`.
|
|||||||
3:1-3:6: Don’t use multiple top level headings (1:1)
|
3:1-3:6: Don’t use multiple top level headings (1:1)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Compatibility
|
||||||
|
|
||||||
This package is [ESM only][esm]:
|
Projects maintained by the unified collective are compatible with all maintained
|
||||||
Node 12+ is needed to use it and it must be `imported`ed instead of `required`d.
|
versions of Node.js.
|
||||||
|
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
|
||||||
[npm][]:
|
Our projects sometimes work with older versions, but this is not guaranteed.
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install remark-lint-no-multiple-toplevel-headings
|
|
||||||
```
|
|
||||||
|
|
||||||
This package exports no identifiers.
|
|
||||||
The default export is `remarkLintNoMultipleToplevelHeadings`.
|
|
||||||
|
|
||||||
## Use
|
|
||||||
|
|
||||||
You probably want to use it on the CLI through a config file:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
…
|
|
||||||
"remarkConfig": {
|
|
||||||
"plugins": [
|
|
||||||
…
|
|
||||||
"lint",
|
|
||||||
+ "lint-no-multiple-toplevel-headings",
|
|
||||||
…
|
|
||||||
]
|
|
||||||
}
|
|
||||||
…
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use it on the CLI directly
|
|
||||||
|
|
||||||
```sh
|
|
||||||
remark -u lint -u lint-no-multiple-toplevel-headings readme.md
|
|
||||||
```
|
|
||||||
|
|
||||||
Or use this on the API:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
import {remark} from 'remark'
|
|
||||||
import {reporter} from 'vfile-reporter'
|
|
||||||
import remarkLint from 'remark-lint'
|
|
||||||
import remarkLintNoMultipleToplevelHeadings from 'remark-lint-no-multiple-toplevel-headings'
|
|
||||||
|
|
||||||
remark()
|
|
||||||
.use(remarkLint)
|
|
||||||
+ .use(remarkLintNoMultipleToplevelHeadings)
|
|
||||||
.process('_Emphasis_ and **importance**')
|
|
||||||
.then((file) => {
|
|
||||||
console.error(reporter(file))
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
@ -152,17 +216,25 @@ abide by its terms.
|
|||||||
|
|
||||||
[chat]: https://github.com/remarkjs/remark/discussions
|
[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
|
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
||||||
|
|
||||||
|
[skypack]: https://www.skypack.dev
|
||||||
|
|
||||||
[npm]: https://docs.npmjs.com/cli/install
|
[npm]: https://docs.npmjs.com/cli/install
|
||||||
|
|
||||||
[health]: https://github.com/remarkjs/.github
|
[health]: https://github.com/remarkjs/.github
|
||||||
|
|
||||||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
|
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
|
||||||
|
|
||||||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
|
[support]: https://github.com/remarkjs/.github/blob/main/support.md
|
||||||
|
|
||||||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
|
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
|
||||||
|
|
||||||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
[license]: https://github.com/remarkjs/remark-lint/blob/main/license
|
||||||
|
|
||||||
|
@ -1,11 +1,24 @@
|
|||||||
/**
|
/**
|
||||||
|
* ## When should I use this?
|
||||||
|
*
|
||||||
|
* You can use this package to check that content in paragraphs is not
|
||||||
|
* indented.
|
||||||
|
*
|
||||||
|
* ## API
|
||||||
|
*
|
||||||
|
* There are no options.
|
||||||
|
*
|
||||||
|
* ## Recommendation
|
||||||
|
*
|
||||||
|
* Indenting further lines in a paragraph has no effect.
|
||||||
|
* Due to this, it’s recommended to turn this rule on.
|
||||||
|
*
|
||||||
|
* @module no-paragraph-content-indent
|
||||||
|
* @summary
|
||||||
|
* remark-lint rule to warn when content in paragraphs is indented.
|
||||||
* @author Titus Wormer
|
* @author Titus Wormer
|
||||||
* @copyright 2017 Titus Wormer
|
* @copyright 2017 Titus Wormer
|
||||||
* @license MIT
|
* @license MIT
|
||||||
* @module no-paragraph-content-indent
|
|
||||||
* @fileoverview
|
|
||||||
* Warn when the content in paragraphs is indented.
|
|
||||||
*
|
|
||||||
* @example
|
* @example
|
||||||
* {"name": "ok.md"}
|
* {"name": "ok.md"}
|
||||||
*
|
*
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user