remark-lint-no-consecutive-blank-lines
Advanced tools
Comparing version 4.1.3 to 5.0.0
@@ -1,8 +0,8 @@ | ||
export default remarkLintNoConsecutiveBlankLines | ||
export type Root = import('mdast').Root | ||
export type Point = import('unist').Point | ||
declare const remarkLintNoConsecutiveBlankLines: import('unified').Plugin< | ||
void[] | [unknown], | ||
import('mdast').Root, | ||
import('mdast').Root | ||
> | ||
export default remarkLintNoConsecutiveBlankLines; | ||
export type Nodes = import('mdast').Nodes; | ||
export type Root = import('mdast').Root; | ||
declare const remarkLintNoConsecutiveBlankLines: { | ||
(config?: unknown): ((tree: import("mdast").Root, file: import("vfile").VFile, next: import("unified").TransformCallback<import("mdast").Root>) => undefined) | undefined; | ||
readonly name: string; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
385
index.js
/** | ||
* remark-lint rule to warn when multiple blank lines are used. | ||
* | ||
* ## What is this? | ||
* | ||
* This package checks the number of blank lines. | ||
* | ||
* ## When should I use this? | ||
* | ||
* You can use this package to check that no more blank lines than needed | ||
* are used between blocks. | ||
* You can use this package to check that there are no unneeded blank lines. | ||
* | ||
* ## API | ||
* | ||
* ### `unified().use(remarkLintNoConsecutiveBlankLines)` | ||
* | ||
* Warn when multiple blank lines are used. | ||
* | ||
* ###### Parameters | ||
* | ||
* There are no options. | ||
* | ||
* ###### Returns | ||
* | ||
* Transform ([`Transformer` from `unified`][github-unified-transformer]). | ||
* | ||
* ## Recommendation | ||
@@ -17,52 +32,216 @@ * | ||
* | ||
* [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) | ||
* adds exactly one blank line between any block. | ||
* [`remark-stringify`][github-remark-stringify] adds exactly one blank line | ||
* between any block. | ||
* It has a `join` option to configure more complex cases. | ||
* | ||
* [api-remark-lint-no-consecutive-blank-lines]: #unifieduseremarklintnoconsecutiveblanklines | ||
* [github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify | ||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer | ||
* | ||
* @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 | ||
* {"name": "ok.md"} | ||
* | ||
* Foo… | ||
* ␊ | ||
* …Bar. | ||
* # Planets | ||
* | ||
* Mercury. | ||
* | ||
* Venus. | ||
* | ||
* @example | ||
* {"label": "input", "name": "not-ok.md"} | ||
* | ||
* # Planets | ||
* | ||
* | ||
* Mercury. | ||
* | ||
* | ||
* | ||
* Venus. | ||
* @example | ||
* {"label": "output", "name": "not-ok.md"} | ||
* | ||
* 4:1: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
* 8:1: Unexpected `3` blank lines before node, expected up to `1` blank line, remove `2` blank lines | ||
* | ||
* @example | ||
* {"label": "input", "name": "initial.md"} | ||
* | ||
* ␊Mercury. | ||
* @example | ||
* {"label": "output", "name": "initial.md"} | ||
* | ||
* 2:1: Unexpected `1` blank line before node, expected `0` blank lines, remove `1` blank line | ||
* | ||
* @example | ||
* {"name": "final-one.md"} | ||
* | ||
* Mercury.␊ | ||
* | ||
* @example | ||
* {"label": "input", "name": "final-more.md"} | ||
* | ||
* Mercury.␊␊ | ||
* @example | ||
* {"label": "output", "name": "final-more.md"} | ||
* | ||
* 1:9: Unexpected `1` blank line after node, expected `0` blank lines, remove `1` blank line | ||
* | ||
* @example | ||
* {"name": "empty-document.md"} | ||
* | ||
* @example | ||
* {"name": "not-ok.md", "label": "input"} | ||
* {"label": "input", "name": "block-quote.md"} | ||
* | ||
* Foo… | ||
* ␊ | ||
* ␊ | ||
* …Bar | ||
* ␊ | ||
* ␊ | ||
* > Mercury. | ||
* | ||
* Venus. | ||
* | ||
* > | ||
* > Earth. | ||
* > | ||
* @example | ||
* {"name": "not-ok.md", "label": "output"} | ||
* {"label": "output", "name": "block-quote.md"} | ||
* | ||
* 4:1: Remove 1 line before node | ||
* 4:5: Remove 2 lines after node | ||
* 6:3: Unexpected `1` blank line before node, expected `0` blank lines, remove `1` blank line | ||
* 6:9: Unexpected `1` blank line after node, expected `0` blank lines, remove `1` blank line | ||
* | ||
* @example | ||
* {"directive": true, "label": "input", "name": "directive.md"} | ||
* | ||
* :::mercury | ||
* Venus. | ||
* | ||
* | ||
* Earth. | ||
* ::: | ||
* @example | ||
* {"directive": true, "label": "output", "name": "directive.md"} | ||
* | ||
* 5:1: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
* | ||
* @example | ||
* {"gfm": true, "label": "input", "name": "footnote.md"} | ||
* | ||
* [^x]: | ||
* Mercury. | ||
* | ||
* Venus. | ||
* | ||
* [^y]: | ||
* | ||
* Earth. | ||
* | ||
* | ||
* Mars. | ||
* @example | ||
* {"gfm": true, "label": "output", "name": "footnote.md"} | ||
* | ||
* 8:5: Unexpected `1` blank line before node, expected `0` blank lines, remove `1` blank line | ||
* 11:5: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
* | ||
* @example | ||
* {"label": "input", "mdx": true, "name": "jsx.md"} | ||
* | ||
* <Mercury> | ||
* Venus. | ||
* | ||
* | ||
* Earth. | ||
* </Mercury> | ||
* @example | ||
* {"label": "output", "mdx": true, "name": "jsx.md"} | ||
* | ||
* 5:3: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
* | ||
* @example | ||
* {"label": "input", "name": "list.md"} | ||
* | ||
* * Mercury. | ||
* * Venus. | ||
* | ||
* *** | ||
* | ||
* * Mercury. | ||
* | ||
* * Venus. | ||
* | ||
* *** | ||
* | ||
* * Mercury. | ||
* | ||
* | ||
* * Venus. | ||
* @example | ||
* {"label": "output", "name": "list.md"} | ||
* | ||
* 15:1: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
* | ||
* @example | ||
* {"label": "input", "name": "list-item.md"} | ||
* | ||
* * Mercury. | ||
* Venus. | ||
* | ||
* *** | ||
* | ||
* * Mercury. | ||
* | ||
* Venus. | ||
* | ||
* *** | ||
* | ||
* * Mercury. | ||
* | ||
* | ||
* Venus. | ||
* | ||
* *** | ||
* | ||
* * | ||
* Mercury. | ||
* @example | ||
* {"label": "output", "name": "list-item.md"} | ||
* | ||
* 15:3: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
* 20:3: Unexpected `1` blank line before node, expected `0` blank lines, remove `1` blank line | ||
* | ||
* @example | ||
* {"label": "input", "name": "deep-block-quote.md"} | ||
* | ||
* * > * > # Venus␊␊ | ||
* @example | ||
* {"label": "output", "name": "deep-block-quote.md"} | ||
* | ||
* 1:16: Unexpected `1` blank line after node, expected `0` blank lines, remove `1` blank line | ||
* | ||
* @example | ||
* {"label": "input", "name": "deep-list-item.md"} | ||
* | ||
* > * > * # Venus␊␊ | ||
* @example | ||
* {"label": "output", "name": "deep-list-item.md"} | ||
* | ||
* 1:16: Unexpected `1` blank line after node, expected `0` blank lines, remove `1` blank line | ||
*/ | ||
/** | ||
* @typedef {import('mdast').Nodes} Nodes | ||
* @typedef {import('mdast').Root} Root | ||
* @typedef {import('unist').Point} Point | ||
*/ | ||
/// <reference types="mdast-util-directive" /> | ||
/// <reference types="mdast-util-mdx" /> | ||
import {phrasing} from 'mdast-util-phrasing' | ||
import pluralize from 'pluralize' | ||
import {lintRule} from 'unified-lint-rule' | ||
import plural from 'pluralize' | ||
import {visit} from 'unist-util-visit' | ||
import {pointStart, pointEnd} from 'unist-util-position' | ||
import {generated} from 'unist-util-generated' | ||
import {pointEnd, pointStart} from 'unist-util-position' | ||
import {SKIP, visitParents} from 'unist-util-visit-parents' | ||
const unknownContainerSize = new Set(['mdxJsxFlowElement', 'mdxJsxTextElement']) | ||
const remarkLintNoConsecutiveBlankLines = lintRule( | ||
@@ -73,65 +252,115 @@ { | ||
}, | ||
/** @type {import('unified-lint-rule').Rule<Root, void>} */ | ||
(tree, file) => { | ||
visit(tree, (node) => { | ||
if (!generated(node) && 'children' in node) { | ||
const head = node.children[0] | ||
/** | ||
* @param {Root} tree | ||
* Tree. | ||
* @returns {undefined} | ||
* Nothing. | ||
*/ | ||
function (tree, file) { | ||
visitParents(tree, function (node, parents) { | ||
const parent = parents.at(-1) | ||
if (head && !generated(head)) { | ||
if (!unknownContainerSize.has(node.type)) { | ||
// Compare parent and first child. | ||
compare(pointStart(node), pointStart(head), 0) | ||
} | ||
// Ignore phrasing nodes and non-parents. | ||
if (!parent) return | ||
// Compare between each child. | ||
let index = -1 | ||
// Do not walk into phrasing. | ||
if (phrasing(node)) { | ||
return SKIP | ||
} | ||
while (++index < node.children.length) { | ||
const previous = node.children[index - 1] | ||
const child = node.children[index] | ||
const siblings = /** @type {Array<Nodes>} */ (parent.children) | ||
const index = siblings.indexOf(node) | ||
if (previous && !generated(previous) && !generated(child)) { | ||
compare(pointEnd(previous), pointStart(child), 2) | ||
} | ||
} | ||
// Compare parent and first child. | ||
if ( | ||
index === 0 && | ||
// Container directives and JSX have arbitrary opening length. | ||
parent.type !== 'containerDirective' && | ||
parent.type !== 'mdxJsxFlowElement' | ||
) { | ||
const parentStart = pointStart(parent) | ||
const start = pointStart(node) | ||
const tail = node.children[node.children.length - 1] | ||
if (parentStart && start) { | ||
// For footnote definitions, the first line with the label can | ||
// otherwise be empty. | ||
const difference = | ||
start.line - | ||
parentStart.line - | ||
(parent.type === 'footnoteDefinition' ? 1 : 0) | ||
// Compare parent and last child. | ||
if ( | ||
tail !== head && | ||
!generated(tail) && | ||
!unknownContainerSize.has(node.type) | ||
) { | ||
compare(pointEnd(node), pointEnd(tail), 1) | ||
if (difference > 0) { | ||
file.message( | ||
'Unexpected `' + | ||
difference + | ||
'` blank ' + | ||
pluralize('line', difference) + | ||
' before node, expected `0` blank lines, remove `' + | ||
difference + | ||
'` blank ' + | ||
pluralize('line', difference), | ||
{ancestors: [...parents, node], place: start} | ||
) | ||
} | ||
} | ||
} | ||
}) | ||
/** | ||
* Compare the difference between `start` and `end`, and warn when that | ||
* difference exceeds `max`. | ||
* | ||
* @param {Point} start | ||
* @param {Point} end | ||
* @param {0 | 1 | 2} max | ||
*/ | ||
function compare(start, end, max) { | ||
const diff = end.line - start.line | ||
const lines = Math.abs(diff) - max | ||
const next = siblings[index + 1] | ||
const end = pointEnd(node) | ||
const nextStart = pointStart(next) | ||
if (lines > 0) { | ||
file.message( | ||
'Remove ' + | ||
lines + | ||
' ' + | ||
plural('line', Math.abs(lines)) + | ||
' ' + | ||
(diff > 0 ? 'before' : 'after') + | ||
' node', | ||
end | ||
) | ||
// Compare child and next sibling. | ||
if (end && nextStart) { | ||
// `2` for line ending after node and optional line ending of blank | ||
// line. | ||
const difference = nextStart.line - end.line - 2 | ||
if (difference > 0) { | ||
const actual = difference + 1 | ||
file.message( | ||
'Unexpected `' + | ||
actual + | ||
'` blank ' + | ||
pluralize('line', actual) + | ||
' before node, expected up to `1` blank line, remove `' + | ||
difference + | ||
'` blank ' + | ||
pluralize('line', difference), | ||
{ancestors: [...parents, next], place: nextStart} | ||
) | ||
} | ||
} | ||
} | ||
const parentEnd = pointEnd(parent) | ||
// Compare parent and last child. | ||
if ( | ||
!next && | ||
parentEnd && | ||
end && | ||
// Container directives and JSX have arbitrary closing length. | ||
parent.type !== 'containerDirective' && | ||
parent.type !== 'mdxJsxFlowElement' | ||
) { | ||
// Block quote can have extra blank lines in them if with `>`. | ||
// Other containers cannot. | ||
const difference = | ||
parentEnd.line - end.line - (parent.type === 'blockquote' ? 0 : 1) | ||
if (difference > 0) { | ||
file.message( | ||
'Unexpected `' + | ||
difference + | ||
'` blank ' + | ||
pluralize('line', difference) + | ||
' after node, expected `0` blank lines, remove `' + | ||
difference + | ||
'` blank ' + | ||
pluralize('line', difference), | ||
{ancestors: [...parents, node], place: end} | ||
) | ||
} | ||
} | ||
}) | ||
} | ||
@@ -138,0 +367,0 @@ ) |
{ | ||
"name": "remark-lint-no-consecutive-blank-lines", | ||
"version": "4.1.3", | ||
"version": "5.0.0", | ||
"description": "remark-lint rule to warn for too many consecutive blank lines", | ||
"license": "MIT", | ||
"keywords": [ | ||
"blank", | ||
"lines", | ||
"lint", | ||
"remark", | ||
"lint", | ||
"rule", | ||
"remark-lint", | ||
"remark-lint-rule", | ||
"blank", | ||
"lines" | ||
"rule" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/remarkjs/remark-lint", | ||
"directory": "packages/remark-lint-no-consecutive-blank-lines" | ||
}, | ||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-consecutive-blank-lines", | ||
"bugs": "https://github.com/remarkjs/remark-lint/issues", | ||
@@ -26,30 +23,37 @@ "funding": { | ||
"contributors": [ | ||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)" | ||
"Titus Wormer <tituswormer@gmail.com>" | ||
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"exports": "./index.js", | ||
"files": [ | ||
"index.d.ts", | ||
"index.d.ts.map", | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"@types/mdast": "^3.0.0", | ||
"@types/unist": "^2.0.0", | ||
"@types/mdast": "^4.0.0", | ||
"mdast-util-directive": "^3.0.0", | ||
"mdast-util-mdx": "^3.0.0", | ||
"mdast-util-phrasing": "^4.0.0", | ||
"pluralize": "^8.0.0", | ||
"unified": "^10.0.0", | ||
"unified-lint-rule": "^2.0.0", | ||
"unist-util-generated": "^2.0.0", | ||
"unist-util-position": "^4.0.0", | ||
"unist-util-visit": "^4.0.0" | ||
"unified-lint-rule": "^3.0.0", | ||
"unist-util-position": "^5.0.0", | ||
"unist-util-visit-parents": "^6.0.0" | ||
}, | ||
"scripts": {}, | ||
"xo": false, | ||
"typeCoverage": { | ||
"atLeast": 100, | ||
"detail": true, | ||
"strict": true, | ||
"ignoreCatch": true | ||
"ignoreCatch": true, | ||
"strict": true | ||
}, | ||
"xo": { | ||
"prettier": true, | ||
"rules": { | ||
"capitalized-comments": "off", | ||
"unicorn/prefer-at": "off", | ||
"unicorn/prefer-set-has": "off" | ||
} | ||
} | ||
} |
442
readme.md
@@ -5,45 +5,41 @@ <!--This file is generated--> | ||
[![Build][build-badge]][build] | ||
[![Coverage][coverage-badge]][coverage] | ||
[![Downloads][downloads-badge]][downloads] | ||
[![Size][size-badge]][size] | ||
[![Sponsors][sponsors-badge]][collective] | ||
[![Backers][backers-badge]][collective] | ||
[![Chat][chat-badge]][chat] | ||
[![Build][badge-build-image]][badge-build-url] | ||
[![Coverage][badge-coverage-image]][badge-coverage-url] | ||
[![Downloads][badge-downloads-image]][badge-downloads-url] | ||
[![Size][badge-size-image]][badge-size-url] | ||
[![Sponsors][badge-funding-sponsors-image]][badge-funding-url] | ||
[![Backers][badge-funding-backers-image]][badge-funding-url] | ||
[![Chat][badge-chat-image]][badge-chat-url] | ||
[`remark-lint`][mono] rule to warn when more blank lines that needed are used | ||
between blocks. | ||
[`remark-lint`][github-remark-lint] rule to warn when multiple blank lines 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(remarkLintNoConsecutiveBlankLines[, config])`](#unifieduseremarklintnoconsecutiveblanklines-config) | ||
* [Recommendation](#recommendation) | ||
* [Fix](#fix) | ||
* [Examples](#examples) | ||
* [Compatibility](#compatibility) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
* [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(remarkLintNoConsecutiveBlankLines)`](#unifieduseremarklintnoconsecutiveblanklines) | ||
* [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. | ||
This package checks the number of blank lines. | ||
## When should I use this? | ||
You can use this package to check that no more blank lines than needed | ||
are used between blocks. | ||
You can use this package to check that there are no unneeded blank lines. | ||
## Presets | ||
This rule is included in the following presets: | ||
This plugin is included in the following presets: | ||
| Preset | Setting | | ||
| Preset | Options | | ||
| - | - | | ||
@@ -54,4 +50,5 @@ | [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | | | ||
This package is [ESM only][esm]. | ||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]: | ||
This package is [ESM only][github-gist-esm]. | ||
In Node.js (version 16+), | ||
install with [npm][npm-install]: | ||
@@ -62,13 +59,13 @@ ```sh | ||
In Deno with [`esm.sh`][esmsh]: | ||
In Deno with [`esm.sh`][esm-sh]: | ||
```js | ||
import remarkLintNoConsecutiveBlankLines from 'https://esm.sh/remark-lint-no-consecutive-blank-lines@4' | ||
import remarkLintNoConsecutiveBlankLines from 'https://esm.sh/remark-lint-no-consecutive-blank-lines@5' | ||
``` | ||
In browsers with [`esm.sh`][esmsh]: | ||
In browsers with [`esm.sh`][esm-sh]: | ||
```html | ||
<script type="module"> | ||
import remarkLintNoConsecutiveBlankLines from 'https://esm.sh/remark-lint-no-consecutive-blank-lines@4?bundle' | ||
import remarkLintNoConsecutiveBlankLines from 'https://esm.sh/remark-lint-no-consecutive-blank-lines@5?bundle' | ||
</script> | ||
@@ -82,18 +79,20 @@ ``` | ||
```js | ||
import remarkLint from 'remark-lint' | ||
import remarkLintNoConsecutiveBlankLines from 'remark-lint-no-consecutive-blank-lines' | ||
import remarkParse from 'remark-parse' | ||
import remarkStringify from 'remark-stringify' | ||
import {read} from 'to-vfile' | ||
import {unified} from 'unified' | ||
import {reporter} from 'vfile-reporter' | ||
import {remark} from 'remark' | ||
import remarkLint from 'remark-lint' | ||
import remarkLintNoConsecutiveBlankLines from 'remark-lint-no-consecutive-blank-lines' | ||
main() | ||
const file = await read('example.md') | ||
async function main() { | ||
const file = await remark() | ||
.use(remarkLint) | ||
.use(remarkLintNoConsecutiveBlankLines) | ||
.process(await read('example.md')) | ||
await unified() | ||
.use(remarkParse) | ||
.use(remarkLint) | ||
.use(remarkLintNoConsecutiveBlankLines) | ||
.use(remarkStringify) | ||
.process(file) | ||
console.error(reporter(file)) | ||
} | ||
console.error(reporter(file)) | ||
``` | ||
@@ -104,3 +103,3 @@ | ||
```sh | ||
remark --use remark-lint --use remark-lint-no-consecutive-blank-lines example.md | ||
remark --frail --use remark-lint --use remark-lint-no-consecutive-blank-lines . | ||
``` | ||
@@ -126,11 +125,18 @@ | ||
This package exports no identifiers. | ||
The default export is `remarkLintNoConsecutiveBlankLines`. | ||
It exports no additional [TypeScript][typescript] types. | ||
The default export is | ||
[`remarkLintNoConsecutiveBlankLines`][api-remark-lint-no-consecutive-blank-lines]. | ||
### `unified().use(remarkLintNoConsecutiveBlankLines[, config])` | ||
### `unified().use(remarkLintNoConsecutiveBlankLines)` | ||
This rule supports standard configuration that all remark lint rules accept | ||
(such as `false` to turn it off or `[1, options]` to configure it). | ||
Warn when multiple blank lines are used. | ||
###### Parameters | ||
There are no options. | ||
###### Returns | ||
Transform ([`Transformer` from `unified`][github-unified-transformer]). | ||
## Recommendation | ||
@@ -142,4 +148,5 @@ | ||
[`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify) | ||
adds exactly one blank line between any block. | ||
[`remark-stringify`][github-remark-stringify] adds exactly one blank line | ||
between any block. | ||
It has a `join` option to configure more complex cases. | ||
@@ -152,8 +159,27 @@ ## Examples | ||
> 👉 **Note**: `␊` represents a line feed. | ||
```markdown | ||
# Planets | ||
Mercury. | ||
Venus. | ||
``` | ||
###### Out | ||
No messages. | ||
##### `not-ok.md` | ||
###### In | ||
```markdown | ||
Foo… | ||
␊ | ||
…Bar. | ||
# Planets | ||
Mercury. | ||
Venus. | ||
``` | ||
@@ -163,4 +189,47 @@ | ||
```text | ||
4:1: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
8:1: Unexpected `3` blank lines before node, expected up to `1` blank line, remove `2` blank lines | ||
``` | ||
##### `initial.md` | ||
###### In | ||
```markdown | ||
␊Mercury. | ||
``` | ||
###### Out | ||
```text | ||
2:1: Unexpected `1` blank line before node, expected `0` blank lines, remove `1` blank line | ||
``` | ||
##### `final-one.md` | ||
###### In | ||
```markdown | ||
Mercury.␊ | ||
``` | ||
###### Out | ||
No messages. | ||
##### `final-more.md` | ||
###### In | ||
```markdown | ||
Mercury.␊␊ | ||
``` | ||
###### Out | ||
```text | ||
1:9: Unexpected `1` blank line after node, expected `0` blank lines, remove `1` blank line | ||
``` | ||
##### `empty-document.md` | ||
@@ -172,15 +241,37 @@ | ||
##### `not-ok.md` | ||
##### `block-quote.md` | ||
###### In | ||
> 👉 **Note**: `␊` represents a line feed. | ||
```markdown | ||
> Mercury. | ||
Venus. | ||
> | ||
> Earth. | ||
> | ||
``` | ||
###### Out | ||
```text | ||
6:3: Unexpected `1` blank line before node, expected `0` blank lines, remove `1` blank line | ||
6:9: Unexpected `1` blank line after node, expected `0` blank lines, remove `1` blank line | ||
``` | ||
##### `directive.md` | ||
###### In | ||
> 👉 **Note**: this example uses | ||
> directives ([`remark-directive`][github-remark-directive]). | ||
```markdown | ||
Foo… | ||
␊ | ||
␊ | ||
…Bar | ||
␊ | ||
␊ | ||
:::mercury | ||
Venus. | ||
Earth. | ||
::: | ||
``` | ||
@@ -191,20 +282,163 @@ | ||
```text | ||
4:1: Remove 1 line before node | ||
4:5: Remove 2 lines after node | ||
5:1: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
``` | ||
##### `footnote.md` | ||
###### In | ||
> 👉 **Note**: this example uses | ||
> GFM ([`remark-gfm`][github-remark-gfm]). | ||
```markdown | ||
[^x]: | ||
Mercury. | ||
Venus. | ||
[^y]: | ||
Earth. | ||
Mars. | ||
``` | ||
###### Out | ||
```text | ||
8:5: Unexpected `1` blank line before node, expected `0` blank lines, remove `1` blank line | ||
11:5: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
``` | ||
##### `jsx.md` | ||
###### In | ||
> 👉 **Note**: this example uses | ||
> MDX ([`remark-mdx`][github-remark-mdx]). | ||
```mdx | ||
<Mercury> | ||
Venus. | ||
Earth. | ||
</Mercury> | ||
``` | ||
###### Out | ||
```text | ||
5:3: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
``` | ||
##### `list.md` | ||
###### In | ||
```markdown | ||
* Mercury. | ||
* Venus. | ||
*** | ||
* Mercury. | ||
* Venus. | ||
*** | ||
* Mercury. | ||
* Venus. | ||
``` | ||
###### Out | ||
```text | ||
15:1: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
``` | ||
##### `list-item.md` | ||
###### In | ||
```markdown | ||
* Mercury. | ||
Venus. | ||
*** | ||
* Mercury. | ||
Venus. | ||
*** | ||
* Mercury. | ||
Venus. | ||
*** | ||
* | ||
Mercury. | ||
``` | ||
###### Out | ||
```text | ||
15:3: Unexpected `2` blank lines before node, expected up to `1` blank line, remove `1` blank line | ||
20:3: Unexpected `1` blank line before node, expected `0` blank lines, remove `1` blank line | ||
``` | ||
##### `deep-block-quote.md` | ||
###### In | ||
```markdown | ||
* > * > # Venus␊␊ | ||
``` | ||
###### Out | ||
```text | ||
1:16: Unexpected `1` blank line after node, expected `0` blank lines, remove `1` blank line | ||
``` | ||
##### `deep-list-item.md` | ||
###### In | ||
```markdown | ||
> * > * # Venus␊␊ | ||
``` | ||
###### Out | ||
```text | ||
1:16: Unexpected `1` blank line after node, expected `0` blank lines, remove `1` blank line | ||
``` | ||
## Compatibility | ||
Projects maintained by the unified collective are compatible with all maintained | ||
Projects maintained by the unified collective are compatible with maintained | ||
versions of Node.js. | ||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+. | ||
Our projects sometimes work with older versions, but this is not guaranteed. | ||
When we cut a new major release, we drop support for unmaintained versions of | ||
Node. | ||
This means we try to keep the current release line, | ||
`remark-lint-no-consecutive-blank-lines@5`, | ||
compatible with Node.js 16. | ||
## Contribute | ||
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways | ||
See [`contributing.md`][github-dotfiles-contributing] in [`remarkjs/.github`][github-dotfiles-health] for ways | ||
to get started. | ||
See [`support.md`][support] for ways to get help. | ||
See [`support.md`][github-dotfiles-support] for ways to get help. | ||
This project has a [code of conduct][coc]. | ||
This project has a [code of conduct][github-dotfiles-coc]. | ||
By interacting with this repository, organization, or community you agree to | ||
@@ -215,52 +449,62 @@ abide by its terms. | ||
[MIT][license] © [Titus Wormer][author] | ||
[MIT][file-license] © [Titus Wormer][author] | ||
[build-badge]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg | ||
[api-remark-lint-no-consecutive-blank-lines]: #unifieduseremarklintnoconsecutiveblanklines | ||
[build]: https://github.com/remarkjs/remark-lint/actions | ||
[author]: https://wooorm.com | ||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg | ||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg | ||
[coverage]: https://codecov.io/github/remarkjs/remark-lint | ||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions | ||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-no-consecutive-blank-lines.svg | ||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg | ||
[downloads]: https://www.npmjs.com/package/remark-lint-no-consecutive-blank-lines | ||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions | ||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-no-consecutive-blank-lines.svg | ||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg | ||
[size]: https://bundlephobia.com/result?p=remark-lint-no-consecutive-blank-lines | ||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint | ||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg | ||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-no-consecutive-blank-lines.svg | ||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg | ||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-no-consecutive-blank-lines | ||
[collective]: https://opencollective.com/unified | ||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg | ||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg | ||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg | ||
[chat]: https://github.com/remarkjs/remark/discussions | ||
[badge-funding-url]: https://opencollective.com/unified | ||
[unified]: https://github.com/unifiedjs/unified | ||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-no-consecutive-blank-lines | ||
[remark]: https://github.com/remarkjs/remark | ||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-no-consecutive-blank-lines | ||
[mono]: https://github.com/remarkjs/remark-lint | ||
[esm-sh]: https://esm.sh | ||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license | ||
[esmsh]: https://esm.sh | ||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md | ||
[npm]: https://docs.npmjs.com/cli/install | ||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md | ||
[health]: https://github.com/remarkjs/.github | ||
[github-dotfiles-health]: https://github.com/remarkjs/.github | ||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md | ||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md | ||
[support]: https://github.com/remarkjs/.github/blob/main/support.md | ||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md | ||
[github-remark-directive]: https://github.com/remarkjs/remark-directive | ||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license | ||
[github-remark-gfm]: https://github.com/remarkjs/remark-gfm | ||
[author]: https://wooorm.com | ||
[github-remark-lint]: https://github.com/remarkjs/remark-lint | ||
[github-remark-mdx]: https://mdxjs.com/packages/remark-mdx/ | ||
[github-remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify | ||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer | ||
[npm-install]: https://docs.npmjs.com/cli/install | ||
[typescript]: https://www.typescriptlang.org |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20866
5
356
499
1
1
+ Addedmdast-util-directive@^3.0.0
+ Addedmdast-util-mdx@^3.0.0
+ Addedmdast-util-phrasing@^4.0.0
+ Added@types/debug@4.1.12(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Added@types/estree-jsx@1.0.5(transitive)
+ Added@types/hast@3.0.4(transitive)
+ Added@types/mdast@4.0.4(transitive)
+ Added@types/ms@0.7.34(transitive)
+ Added@types/unist@3.0.3(transitive)
+ Addedccount@2.0.1(transitive)
+ Addedcharacter-entities@2.0.2(transitive)
+ Addedcharacter-entities-html4@2.1.0(transitive)
+ Addedcharacter-entities-legacy@3.0.0(transitive)
+ Addedcharacter-reference-invalid@2.0.1(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addeddecode-named-character-reference@1.0.2(transitive)
+ Addeddequal@2.0.3(transitive)
+ Addeddevlop@1.1.0(transitive)
+ Addedis-alphabetical@2.0.1(transitive)
+ Addedis-alphanumerical@2.0.1(transitive)
+ Addedis-decimal@2.0.1(transitive)
+ Addedis-hexadecimal@2.0.1(transitive)
+ Addedlongest-streak@3.1.0(transitive)
+ Addedmdast-util-directive@3.0.0(transitive)
+ Addedmdast-util-from-markdown@2.0.2(transitive)
+ Addedmdast-util-mdx@3.0.0(transitive)
+ Addedmdast-util-mdx-expression@2.0.1(transitive)
+ Addedmdast-util-mdx-jsx@3.1.3(transitive)
+ Addedmdast-util-mdxjs-esm@2.0.1(transitive)
+ Addedmdast-util-phrasing@4.1.0(transitive)
+ Addedmdast-util-to-markdown@2.1.2(transitive)
+ Addedmdast-util-to-string@4.0.0(transitive)
+ Addedmicromark@4.0.1(transitive)
+ Addedmicromark-core-commonmark@2.0.2(transitive)
+ Addedmicromark-factory-destination@2.0.1(transitive)
+ Addedmicromark-factory-label@2.0.1(transitive)
+ Addedmicromark-factory-space@2.0.1(transitive)
+ Addedmicromark-factory-title@2.0.1(transitive)
+ Addedmicromark-factory-whitespace@2.0.1(transitive)
+ Addedmicromark-util-character@2.1.1(transitive)
+ Addedmicromark-util-chunked@2.0.1(transitive)
+ Addedmicromark-util-classify-character@2.0.1(transitive)
+ Addedmicromark-util-combine-extensions@2.0.1(transitive)
+ Addedmicromark-util-decode-numeric-character-reference@2.0.2(transitive)
+ Addedmicromark-util-decode-string@2.0.1(transitive)
+ Addedmicromark-util-encode@2.0.1(transitive)
+ Addedmicromark-util-html-tag-name@2.0.1(transitive)
+ Addedmicromark-util-normalize-identifier@2.0.1(transitive)
+ Addedmicromark-util-resolve-all@2.0.1(transitive)
+ Addedmicromark-util-sanitize-uri@2.0.1(transitive)
+ Addedmicromark-util-subtokenize@2.0.2(transitive)
+ Addedmicromark-util-symbol@2.0.1(transitive)
+ Addedmicromark-util-types@2.0.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addedparse-entities@4.0.1(transitive)
+ Addedstringify-entities@4.0.4(transitive)
+ Addedunified@11.0.5(transitive)
+ Addedunified-lint-rule@3.0.0(transitive)
+ Addedunist-util-is@6.0.0(transitive)
+ Addedunist-util-position@5.0.0(transitive)
+ Addedunist-util-stringify-position@4.0.0(transitive)
+ Addedunist-util-visit@5.0.0(transitive)
+ Addedunist-util-visit-parents@6.0.1(transitive)
+ Addedvfile@6.0.3(transitive)
+ Addedvfile-message@4.0.2(transitive)
+ Addedzwitch@2.0.4(transitive)
- Removed@types/unist@^2.0.0
- Removedunified@^10.0.0
- Removedunist-util-generated@^2.0.0
- Removedunist-util-visit@^4.0.0
- Removed@types/mdast@3.0.15(transitive)
- Removedis-buffer@2.0.5(transitive)
- Removedunified@10.1.2(transitive)
- Removedunified-lint-rule@2.1.2(transitive)
- Removedunist-util-generated@2.0.1(transitive)
- Removedunist-util-is@5.2.1(transitive)
- Removedunist-util-position@4.0.4(transitive)
- Removedunist-util-stringify-position@3.0.3(transitive)
- Removedunist-util-visit@4.1.2(transitive)
- Removedunist-util-visit-parents@5.1.3(transitive)
- Removedvfile@5.3.7(transitive)
- Removedvfile-message@3.1.4(transitive)
Updated@types/mdast@^4.0.0
Updatedunified-lint-rule@^3.0.0
Updatedunist-util-position@^5.0.0