remark-lint-fenced-code-flag
Advanced tools
Comparing version
@@ -1,39 +0,21 @@ | ||
export default remarkLintFencedCodeFlag | ||
export type Root = import('mdast').Root | ||
export default remarkLintFencedCodeFlag; | ||
export type Root = import('mdast').Root; | ||
/** | ||
* Language flags. | ||
*/ | ||
export type Flags = Array<string> | ||
/** | ||
* Configuration. | ||
*/ | ||
export type FlagMap = { | ||
/** | ||
* Language flags. | ||
*/ | ||
flags?: Flags | ||
/** | ||
* Allow language flags to be omitted (default: `false`). | ||
*/ | ||
allowEmpty?: boolean | ||
} | ||
/** | ||
* Options. | ||
*/ | ||
export type Options = string[] | FlagMap | ||
declare const remarkLintFencedCodeFlag: import('unified').Plugin< | ||
| void[] | ||
| [ | ||
| Options | ||
| [ | ||
( | ||
| boolean | ||
| import('unified-lint-rule/lib/index.js').Label | ||
| import('unified-lint-rule/lib/index.js').Severity | ||
), | ||
(Options | undefined)? | ||
] | ||
], | ||
import('mdast').Root, | ||
import('mdast').Root | ||
> | ||
export type Options = { | ||
/** | ||
* Allow language flags to be omitted (default: `false`). | ||
*/ | ||
allowEmpty?: boolean | null | undefined; | ||
/** | ||
* Flags to allow, | ||
* other flags will result in a warning (optional). | ||
*/ | ||
flags?: ReadonlyArray<string> | null | undefined; | ||
}; | ||
declare const remarkLintFencedCodeFlag: { | ||
(config?: import("../../node_modules/unified-lint-rule/lib/index.js").Label | import("../../node_modules/unified-lint-rule/lib/index.js").Severity | readonly string[] | Readonly<Options> | [level: import("../../node_modules/unified-lint-rule/lib/index.js").Label | import("../../node_modules/unified-lint-rule/lib/index.js").Severity, option?: readonly string[] | Readonly<Options> | null | undefined] | null | undefined): ((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 |
240
index.js
/** | ||
* remark-lint rule to warn when language flags of fenced code | ||
* are not used. | ||
* | ||
* ## What is this? | ||
* | ||
* This package checks the language flags of fenced code blocks, | ||
* whether they exist, | ||
* and optionally what values they hold. | ||
* | ||
* ## When should I use this? | ||
* | ||
* You can use this package to check that language flags of fenced code | ||
* are used and consistent. | ||
* You can use this package to check that the style of language flags of fenced | ||
* code blocks is consistent. | ||
* | ||
* ## API | ||
* | ||
* The following options (default: `undefined`) are accepted: | ||
* ### `unified().use(remarkLintFencedCodeFlag[, options])` | ||
* | ||
* * `Array<string>` | ||
* — as if passing `{flags: options}` | ||
* * `Object` with the following fields: | ||
* * `allowEmpty` (`boolean`, default: `false`) | ||
* — allow language flags to be omitted | ||
* * `flags` (`Array<string>` default: `[]`) | ||
* — specific flags to allow (other flags will result in a warning) | ||
* Warn when language flags of fenced code are not used. | ||
* | ||
* ###### Parameters | ||
* | ||
* * `options` ([`Options`][api-options] or `Array<string>`, optional) | ||
* — configuration or flags to allow | ||
* | ||
* ###### Returns | ||
* | ||
* Transform ([`Transformer` from `unified`][github-unified-transformer]). | ||
* | ||
* ### `Options` | ||
* | ||
* Configuration (TypeScript type). | ||
* | ||
* ###### Fields | ||
* | ||
* * `allowEmpty` (`boolean`, default: `false`) | ||
* — allow language flags to be omitted | ||
* * `flags` (`Array<string>`, optional) | ||
* — flags to allow, | ||
* other flags will result in a warning | ||
* | ||
* ## Recommendation | ||
* | ||
* While omitting the language flag is perfectly fine to signal that the code is | ||
* plain text, it *could* point to a mistake. | ||
* It’s recommended to instead use a certain flag for plain text (such as `txt`) | ||
* and to turn this rule on. | ||
* While omitting language flags is fine to signal that code is plain text, | ||
* it *could* point to a mistake. | ||
* It’s recommended to instead use a certain flag for plain text (such as | ||
* `txt`) and to turn this rule on. | ||
* | ||
* [api-options]: #options | ||
* [api-remark-lint-fenced-code-flag]: #unifieduseremarklintfencedcodeflag-options | ||
* [github-unified-transformer]: https://github.com/unifiedjs/unified#transformer | ||
* | ||
* @module fenced-code-flag | ||
* @summary | ||
* remark-lint rule to check that language flags of fenced code are used. | ||
* @author Titus Wormer | ||
@@ -36,62 +62,77 @@ * @copyright 2015 Titus Wormer | ||
* | ||
* ```alpha | ||
* bravo() | ||
* Some markdown: | ||
* | ||
* ```markdown | ||
* # Mercury | ||
* ``` | ||
* | ||
* @example | ||
* {"name": "not-ok.md", "label": "input"} | ||
* {"label": "input", "name": "not-ok.md"} | ||
* | ||
* ``` | ||
* alpha() | ||
* mercury() | ||
* ``` | ||
* | ||
* @example | ||
* {"name": "not-ok.md", "label": "output"} | ||
* {"label": "output", "name": "not-ok.md"} | ||
* | ||
* 1:1-3:4: Missing code language flag | ||
* 1:1-3:4: Unexpected missing fenced code language flag in info string, expected keyword | ||
* | ||
* @example | ||
* {"name": "ok.md", "config": {"allowEmpty": true}} | ||
* {"config": {"allowEmpty": true}, "name": "ok-allow-empty.md"} | ||
* | ||
* ``` | ||
* alpha() | ||
* mercury() | ||
* ``` | ||
* | ||
* @example | ||
* {"name": "not-ok.md", "config": {"allowEmpty": false}, "label": "input"} | ||
* {"config": {"allowEmpty": false}, "label": "input", "name": "not-ok-allow-empty.md"} | ||
* | ||
* ``` | ||
* alpha() | ||
* mercury() | ||
* ``` | ||
* @example | ||
* {"config": {"allowEmpty": false}, "label": "output", "name": "not-ok-allow-empty.md"} | ||
* | ||
* 1:1-3:4: Unexpected missing fenced code language flag in info string, expected keyword | ||
* | ||
* @example | ||
* {"name": "not-ok.md", "config": {"allowEmpty": false}, "label": "output"} | ||
* {"config": ["markdown"], "name": "ok-array.md"} | ||
* | ||
* 1:1-3:4: Missing code language flag | ||
* ```markdown | ||
* # Mercury | ||
* ``` | ||
* | ||
* @example | ||
* {"name": "ok.md", "config": ["alpha"]} | ||
* {"config": {"flags":["markdown"]}, "name": "ok-options.md"} | ||
* | ||
* ```alpha | ||
* bravo() | ||
* ```markdown | ||
* # Mercury | ||
* ``` | ||
* | ||
* @example | ||
* {"name": "ok.md", "config": {"flags":["alpha"]}} | ||
* {"config": ["markdown"], "label": "input", "name": "not-ok-array.md"} | ||
* | ||
* ```alpha | ||
* bravo() | ||
* ```javascript | ||
* mercury() | ||
* ``` | ||
* @example | ||
* {"config": ["markdown"], "label": "output", "name": "not-ok-array.md"} | ||
* | ||
* 1:1-3:4: Unexpected fenced code language flag `javascript` in info string, expected `markdown` | ||
* | ||
* @example | ||
* {"name": "not-ok.md", "config": ["charlie"], "label": "input"} | ||
* {"config": ["javascript", "markdown", "mdx", "typescript"], "label": "input", "name": "not-ok-long-array.md"} | ||
* | ||
* ```alpha | ||
* bravo() | ||
* ```html | ||
* <h1>Mercury</h1> | ||
* ``` | ||
* @example | ||
* {"config": ["javascript", "markdown", "mdx", "typescript"], "label": "output", "name": "not-ok-long-array.md"} | ||
* | ||
* 1:1-3:4: Unexpected fenced code language flag `html` in info string, expected `javascript`, `markdown`, `mdx`, … | ||
* | ||
* @example | ||
* {"name": "not-ok.md", "config": ["charlie"], "label": "output"} | ||
* {"config": "🌍", "label": "output", "name": "not-ok-options.md", "positionless": true} | ||
* | ||
* 1:1-3:4: Incorrect code language flag | ||
* 1:1: Unexpected value `🌍` for `options`, expected array or object | ||
*/ | ||
@@ -104,23 +145,22 @@ | ||
/** | ||
* @typedef {Array<string>} Flags | ||
* Language flags. | ||
* | ||
* @typedef FlagMap | ||
* @typedef Options | ||
* Configuration. | ||
* @property {Flags} [flags] | ||
* Language flags. | ||
* @property {boolean} [allowEmpty=false] | ||
* @property {boolean | null | undefined} [allowEmpty=false] | ||
* Allow language flags to be omitted (default: `false`). | ||
* | ||
* @typedef {Flags | FlagMap} Options | ||
* Options. | ||
* @property {ReadonlyArray<string> | null | undefined} [flags] | ||
* Flags to allow, | ||
* other flags will result in a warning (optional). | ||
*/ | ||
import {quotation} from 'quotation' | ||
import {phrasing} from 'mdast-util-phrasing' | ||
import {lintRule} from 'unified-lint-rule' | ||
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 fence = /^ {0,3}([~`])\1{2,}/ | ||
const listFormat = new Intl.ListFormat('en', {type: 'disjunction'}) | ||
const listFormatUnit = new Intl.ListFormat('en', {type: 'unit'}) | ||
const remarkLintFencedCodeFlag = lintRule( | ||
@@ -131,35 +171,87 @@ { | ||
}, | ||
/** @type {import('unified-lint-rule').Rule<Root, Options>} */ | ||
(tree, file, option) => { | ||
/** | ||
* @param {Root} tree | ||
* Tree. | ||
* @param {Readonly<Options> | ReadonlyArray<string> | null | undefined} [options] | ||
* Configuration or flags to allow (optional). | ||
* @returns {undefined} | ||
* Nothing. | ||
*/ | ||
function (tree, file, options) { | ||
const value = String(file) | ||
let allowEmpty = false | ||
/** @type {Array<string>} */ | ||
let allowed = [] | ||
/** @type {ReadonlyArray<string> | undefined} */ | ||
let allowed | ||
if (typeof option === 'object') { | ||
if (Array.isArray(option)) { | ||
allowed = option | ||
if (options === null || options === undefined) { | ||
// Empty. | ||
} else if (typeof options === 'object') { | ||
// Note: casts because `isArray` and `readonly` don’t mix. | ||
if (Array.isArray(options)) { | ||
const flags = /** @type {ReadonlyArray<string>} */ (options) | ||
allowed = flags | ||
} else { | ||
allowEmpty = Boolean(option.allowEmpty) | ||
const settings = /** @type {Options} */ (options) | ||
allowEmpty = settings.allowEmpty === true | ||
if (option.flags) { | ||
allowed = option.flags | ||
if (settings.flags) { | ||
allowed = settings.flags | ||
} | ||
} | ||
} else { | ||
file.fail( | ||
'Unexpected value `' + | ||
options + | ||
'` for `options`, expected array or object' | ||
) | ||
} | ||
visit(tree, 'code', (node) => { | ||
if (!generated(node)) { | ||
/** @type {string} */ | ||
let allowedDisplay | ||
if (allowed) { | ||
allowedDisplay = | ||
allowed.length > 3 | ||
? listFormatUnit.format([...quotation(allowed.slice(0, 3), '`'), '…']) | ||
: listFormat.format(quotation(allowed, '`')) | ||
} else { | ||
allowedDisplay = 'keyword' | ||
} | ||
visitParents(tree, function (node, parents) { | ||
// Do not walk into phrasing. | ||
if (phrasing(node)) { | ||
return SKIP | ||
} | ||
if (node.type !== 'code') return | ||
const end = pointEnd(node) | ||
const start = pointStart(node) | ||
if ( | ||
end && | ||
start && | ||
typeof end.offset === 'number' && | ||
typeof start.offset === 'number' | ||
) { | ||
if (node.lang) { | ||
if (allowed.length > 0 && !allowed.includes(node.lang)) { | ||
file.message('Incorrect code language flag', node) | ||
if (allowed && !allowed.includes(node.lang)) { | ||
file.message( | ||
'Unexpected fenced code language flag `' + | ||
node.lang + | ||
'` in info string, expected ' + | ||
allowedDisplay, | ||
{ancestors: [...parents, node], place: node.position} | ||
) | ||
} | ||
} else { | ||
const slice = value.slice( | ||
pointStart(node).offset, | ||
pointEnd(node).offset | ||
) | ||
} else if (!allowEmpty) { | ||
const slice = value.slice(start.offset, end.offset) | ||
if (!allowEmpty && fence.test(slice)) { | ||
file.message('Missing code language flag', node) | ||
if (fence.test(slice)) { | ||
file.message( | ||
'Unexpected missing fenced code language flag in info string, expected ' + | ||
allowedDisplay, | ||
{ancestors: [...parents, node], place: node.position} | ||
) | ||
} | ||
@@ -166,0 +258,0 @@ } |
{ | ||
"name": "remark-lint-fenced-code-flag", | ||
"version": "3.1.2", | ||
"version": "4.0.0", | ||
"description": "remark-lint rule to warn when fenced code blocks occur without language flag", | ||
"license": "MIT", | ||
"keywords": [ | ||
"code", | ||
"fenced", | ||
"flag", | ||
"infostring", | ||
"lint", | ||
"remark", | ||
"lint", | ||
"rule", | ||
"remark-lint", | ||
"remark-lint-rule", | ||
"fenced", | ||
"code", | ||
"flag", | ||
"infostring" | ||
"rule" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/remarkjs/remark-lint", | ||
"directory": "packages/remark-lint-fenced-code-flag" | ||
}, | ||
"repository": "https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-flag", | ||
"bugs": "https://github.com/remarkjs/remark-lint/issues", | ||
@@ -28,28 +25,33 @@ "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", | ||
"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" | ||
"@types/mdast": "^4.0.0", | ||
"mdast-util-phrasing": "^4.0.0", | ||
"quotation": "^2.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" | ||
} | ||
} | ||
} |
286
readme.md
@@ -5,43 +5,45 @@ <!--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 check that language flags of fenced code are used. | ||
[`remark-lint`][github-remark-lint] rule to warn when language flags of fenced code | ||
are not used. | ||
## Contents | ||
* [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) | ||
* [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[, options])`](#unifieduseremarklintfencedcodeflag-options) | ||
* [`Options`](#options) | ||
* [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. | ||
This package checks the language flags of fenced code blocks, | ||
whether they exist, | ||
and optionally what values they hold. | ||
## When should I use this? | ||
You can use this package to check that language flags of fenced code | ||
are used and consistent. | ||
You can use this package to check that the style of language flags of fenced | ||
code blocks is consistent. | ||
## Presets | ||
This rule is included in the following presets: | ||
This plugin is included in the following presets: | ||
| Preset | Setting | | ||
| Preset | Options | | ||
| - | - | | ||
@@ -52,4 +54,5 @@ | [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-preset-lint-markdown-style-guide) | `{ allowEmpty: false }` | | ||
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]: | ||
@@ -60,13 +63,13 @@ ```sh | ||
In Deno with [`esm.sh`][esmsh]: | ||
In Deno with [`esm.sh`][esm-sh]: | ||
```js | ||
import remarkLintFencedCodeFlag from 'https://esm.sh/remark-lint-fenced-code-flag@3' | ||
import remarkLintFencedCodeFlag from 'https://esm.sh/remark-lint-fenced-code-flag@4' | ||
``` | ||
In browsers with [`esm.sh`][esmsh]: | ||
In browsers with [`esm.sh`][esm-sh]: | ||
```html | ||
<script type="module"> | ||
import remarkLintFencedCodeFlag from 'https://esm.sh/remark-lint-fenced-code-flag@3?bundle' | ||
import remarkLintFencedCodeFlag from 'https://esm.sh/remark-lint-fenced-code-flag@4?bundle' | ||
</script> | ||
@@ -80,18 +83,20 @@ ``` | ||
```js | ||
import remarkLint from 'remark-lint' | ||
import remarkLintFencedCodeFlag from 'remark-lint-fenced-code-flag' | ||
import remarkParse from 'remark-parse' | ||
import remarkStringify from 'remark-stringify' | ||
import {read} from 'to-vfile' | ||
import {unified} from 'unified' | ||
import {reporter} from 'vfile-reporter' | ||
import {remark} from 'remark' | ||
import remarkLint from 'remark-lint' | ||
import remarkLintFencedCodeFlag from 'remark-lint-fenced-code-flag' | ||
main() | ||
const file = await read('example.md') | ||
async function main() { | ||
const file = await remark() | ||
.use(remarkLint) | ||
.use(remarkLintFencedCodeFlag) | ||
.process(await read('example.md')) | ||
await unified() | ||
.use(remarkParse) | ||
.use(remarkLint) | ||
.use(remarkLintFencedCodeFlag) | ||
.use(remarkStringify) | ||
.process(file) | ||
console.error(reporter(file)) | ||
} | ||
console.error(reporter(file)) | ||
``` | ||
@@ -102,3 +107,3 @@ | ||
```sh | ||
remark --use remark-lint --use remark-lint-fenced-code-flag example.md | ||
remark --frail --use remark-lint --use remark-lint-fenced-code-flag . | ||
``` | ||
@@ -124,25 +129,38 @@ | ||
This package exports no identifiers. | ||
The default export is `remarkLintFencedCodeFlag`. | ||
It exports the [TypeScript][typescript] type | ||
[`Options`][api-options]. | ||
The default export is | ||
[`remarkLintFencedCodeFlag`][api-remark-lint-fenced-code-flag]. | ||
### `unified().use(remarkLintFencedCodeFlag[, config])` | ||
### `unified().use(remarkLintFencedCodeFlag[, options])` | ||
This rule supports standard configuration that all remark lint rules accept | ||
(such as `false` to turn it off or `[1, options]` to configure it). | ||
Warn when language flags of fenced code are not used. | ||
The following options (default: `undefined`) are accepted: | ||
###### Parameters | ||
* `Array<string>` | ||
— as if passing `{flags: options}` | ||
* `Object` with the following fields: | ||
* `allowEmpty` (`boolean`, default: `false`) | ||
— allow language flags to be omitted | ||
* `flags` (`Array<string>` default: `[]`) | ||
— specific flags to allow (other flags will result in a warning) | ||
* `options` ([`Options`][api-options] or `Array<string>`, optional) | ||
— configuration or flags to allow | ||
###### Returns | ||
Transform ([`Transformer` from `unified`][github-unified-transformer]). | ||
### `Options` | ||
Configuration (TypeScript type). | ||
###### Fields | ||
* `allowEmpty` (`boolean`, default: `false`) | ||
— allow language flags to be omitted | ||
* `flags` (`Array<string>`, optional) | ||
— flags to allow, | ||
other flags will result in a warning | ||
## Recommendation | ||
While omitting the language flag is perfectly fine to signal that the code is | ||
plain text, it *could* point to a mistake. | ||
It’s recommended to instead use a certain flag for plain text (such as `txt`) | ||
and to turn this rule on. | ||
While omitting language flags is fine to signal that code is plain text, | ||
it *could* point to a mistake. | ||
It’s recommended to instead use a certain flag for plain text (such as | ||
`txt`) and to turn this rule on. | ||
@@ -156,4 +174,6 @@ ## Examples | ||
````markdown | ||
```alpha | ||
bravo() | ||
Some markdown: | ||
```markdown | ||
# Mercury | ||
``` | ||
@@ -172,3 +192,3 @@ ```` | ||
``` | ||
alpha() | ||
mercury() | ||
``` | ||
@@ -180,6 +200,6 @@ ```` | ||
```text | ||
1:1-3:4: Missing code language flag | ||
1:1-3:4: Unexpected missing fenced code language flag in info string, expected keyword | ||
``` | ||
##### `ok.md` | ||
##### `ok-allow-empty.md` | ||
@@ -192,3 +212,3 @@ When configured with `{ allowEmpty: true }`. | ||
``` | ||
alpha() | ||
mercury() | ||
``` | ||
@@ -201,3 +221,3 @@ ```` | ||
##### `not-ok.md` | ||
##### `not-ok-allow-empty.md` | ||
@@ -210,3 +230,3 @@ When configured with `{ allowEmpty: false }`. | ||
``` | ||
alpha() | ||
mercury() | ||
``` | ||
@@ -218,8 +238,8 @@ ```` | ||
```text | ||
1:1-3:4: Missing code language flag | ||
1:1-3:4: Unexpected missing fenced code language flag in info string, expected keyword | ||
``` | ||
##### `ok.md` | ||
##### `ok-array.md` | ||
When configured with `[ 'alpha' ]`. | ||
When configured with `[ 'markdown' ]`. | ||
@@ -229,4 +249,4 @@ ###### In | ||
````markdown | ||
```alpha | ||
bravo() | ||
```markdown | ||
# Mercury | ||
``` | ||
@@ -239,5 +259,5 @@ ```` | ||
##### `ok.md` | ||
##### `ok-options.md` | ||
When configured with `{ flags: [ 'alpha' ] }`. | ||
When configured with `{ flags: [ 'markdown' ] }`. | ||
@@ -247,4 +267,4 @@ ###### In | ||
````markdown | ||
```alpha | ||
bravo() | ||
```markdown | ||
# Mercury | ||
``` | ||
@@ -257,5 +277,5 @@ ```` | ||
##### `not-ok.md` | ||
##### `not-ok-array.md` | ||
When configured with `[ 'charlie' ]`. | ||
When configured with `[ 'markdown' ]`. | ||
@@ -265,4 +285,4 @@ ###### In | ||
````markdown | ||
```alpha | ||
bravo() | ||
```javascript | ||
mercury() | ||
``` | ||
@@ -274,19 +294,51 @@ ```` | ||
```text | ||
1:1-3:4: Incorrect code language flag | ||
1:1-3:4: Unexpected fenced code language flag `javascript` in info string, expected `markdown` | ||
``` | ||
##### `not-ok-long-array.md` | ||
When configured with `[ 'javascript', 'markdown', 'mdx', 'typescript' ]`. | ||
###### In | ||
````markdown | ||
```html | ||
<h1>Mercury</h1> | ||
``` | ||
```` | ||
###### Out | ||
```text | ||
1:1-3:4: Unexpected fenced code language flag `html` in info string, expected `javascript`, `markdown`, `mdx`, … | ||
``` | ||
##### `not-ok-options.md` | ||
When configured with `'🌍'`. | ||
###### Out | ||
```text | ||
1:1: Unexpected value `🌍` for `options`, expected array or object | ||
``` | ||
## Compatibility | ||
Projects maintained by the unified collective are compatible with all maintained | ||
Projects maintained by the unified collective are compatible with maintained | ||
versions of Node.js. | ||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+. | ||
Our projects sometimes work with older versions, but this is not guaranteed. | ||
When we cut a new major release, we drop support for unmaintained versions of | ||
Node. | ||
This means we try to keep the current release line, | ||
`remark-lint-fenced-code-flag@4`, | ||
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 | ||
@@ -297,52 +349,56 @@ 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-options]: #options | ||
[build]: https://github.com/remarkjs/remark-lint/actions | ||
[api-remark-lint-fenced-code-flag]: #unifieduseremarklintfencedcodeflag-options | ||
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg | ||
[author]: https://wooorm.com | ||
[coverage]: https://codecov.io/github/remarkjs/remark-lint | ||
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg | ||
[downloads-badge]: https://img.shields.io/npm/dm/remark-lint-fenced-code-flag.svg | ||
[badge-build-url]: https://github.com/remarkjs/remark-lint/actions | ||
[downloads]: https://www.npmjs.com/package/remark-lint-fenced-code-flag | ||
[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg | ||
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-lint-fenced-code-flag.svg | ||
[badge-chat-url]: https://github.com/remarkjs/remark/discussions | ||
[size]: https://bundlephobia.com/result?p=remark-lint-fenced-code-flag | ||
[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/remark-lint.svg | ||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg | ||
[badge-coverage-url]: https://codecov.io/github/remarkjs/remark-lint | ||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg | ||
[badge-downloads-image]: https://img.shields.io/npm/dm/remark-lint-fenced-code-flag.svg | ||
[collective]: https://opencollective.com/unified | ||
[badge-downloads-url]: https://www.npmjs.com/package/remark-lint-fenced-code-flag | ||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg | ||
[badge-funding-backers-image]: https://opencollective.com/unified/backers/badge.svg | ||
[chat]: https://github.com/remarkjs/remark/discussions | ||
[badge-funding-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg | ||
[unified]: https://github.com/unifiedjs/unified | ||
[badge-funding-url]: https://opencollective.com/unified | ||
[remark]: https://github.com/remarkjs/remark | ||
[badge-size-image]: https://img.shields.io/bundlejs/size/remark-lint-fenced-code-flag | ||
[mono]: https://github.com/remarkjs/remark-lint | ||
[badge-size-url]: https://bundlejs.com/?q=remark-lint-fenced-code-flag | ||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[esm-sh]: https://esm.sh | ||
[esmsh]: https://esm.sh | ||
[file-license]: https://github.com/remarkjs/remark-lint/blob/main/license | ||
[npm]: https://docs.npmjs.com/cli/install | ||
[github-dotfiles-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md | ||
[health]: https://github.com/remarkjs/.github | ||
[github-dotfiles-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md | ||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md | ||
[github-dotfiles-health]: https://github.com/remarkjs/.github | ||
[support]: https://github.com/remarkjs/.github/blob/main/support.md | ||
[github-dotfiles-support]: https://github.com/remarkjs/.github/blob/main/support.md | ||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md | ||
[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[license]: https://github.com/remarkjs/remark-lint/blob/main/license | ||
[github-remark-lint]: https://github.com/remarkjs/remark-lint | ||
[author]: https://wooorm.com | ||
[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer | ||
[npm-install]: https://docs.npmjs.com/cli/install | ||
[typescript]: https://www.typescriptlang.org |
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
17957
41.62%5
25%267
34.85%385
17.02%2
100%1
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated