diff --git a/packages/remark-lint-blockquote-indentation/readme.md b/packages/remark-lint-blockquote-indentation/readme.md index 3dd7f90a..3b16288f 100644 --- a/packages/remark-lint-blockquote-indentation/readme.md +++ b/packages/remark-lint-blockquote-indentation/readme.md @@ -157,16 +157,16 @@ Due to this, it’s recommended to configure this rule with `2`. ##### `ok.md` -When configured with `2`. +When configured with `4`. ###### In ```markdown -> Hello +> Hello Paragraph. -> World +> World ``` ###### Out @@ -175,16 +175,16 @@ No messages. ##### `ok.md` -When configured with `4`. +When configured with `2`. ###### In ```markdown -> Hello +> Hello Paragraph. -> World +> World ``` ###### Out diff --git a/packages/remark-lint-emphasis-marker/index.js b/packages/remark-lint-emphasis-marker/index.js index 064d2289..b26d32f5 100644 --- a/packages/remark-lint-emphasis-marker/index.js +++ b/packages/remark-lint-emphasis-marker/index.js @@ -40,32 +40,32 @@ * @copyright 2015 Titus Wormer * @license MIT * @example - * {"setting": "*", "name": "ok.md"} + * {"settings": {"emphasis": "*"}, "name": "ok.md"} * * *foo* * * @example - * {"setting": "*", "name": "not-ok.md", "label": "input"} + * {"settings": {"emphasis": "*"}, "name": "not-ok.md", "label": "input"} * * _foo_ * * @example - * {"setting": "*", "name": "not-ok.md", "label": "output"} + * {"settings": {"emphasis": "*"}, "name": "not-ok.md", "label": "output"} * * 1:1-1:6: Emphasis should use `*` as a marker * * @example - * {"setting": "_", "name": "ok.md"} + * {"settings": {"emphasis": "_"}, "name": "ok.md"} * * _foo_ * * @example - * {"setting": "_", "name": "not-ok.md", "label": "input"} + * {"settings": {"emphasis": "_"}, "name": "not-ok.md", "label": "input"} * * *foo* * * @example - * {"setting": "_", "name": "not-ok.md", "label": "output"} + * {"settings": {"emphasis": "_"}, "name": "not-ok.md", "label": "output"} * * 1:1-1:6: Emphasis should use `_` as a marker * @@ -81,7 +81,7 @@ * 2:1-2:6: Emphasis should use `*` as a marker * * @example - * {"setting": "πŸ’©", "name": "not-ok.md", "label": "output", "positionless": true} + * {"settings": {"emphasis": "πŸ’©"}, "name": "not-ok.md", "label": "output", "positionless": true} * * 1:1: Incorrect emphasis marker `πŸ’©`: use either `'consistent'`, `'*'`, or `'_'` */ diff --git a/packages/remark-lint-emphasis-marker/readme.md b/packages/remark-lint-emphasis-marker/readme.md index 28ee7272..943ecaf6 100644 --- a/packages/remark-lint-emphasis-marker/readme.md +++ b/packages/remark-lint-emphasis-marker/readme.md @@ -156,7 +156,7 @@ to always use underscores. ##### `ok.md` -When configured with `'*'`. +When configured with `{ emphasis: '*' }`. ###### In @@ -170,7 +170,7 @@ No messages. ##### `not-ok.md` -When configured with `'*'`. +When configured with `{ emphasis: '*' }`. ###### In @@ -186,7 +186,7 @@ _foo_ ##### `ok.md` -When configured with `'_'`. +When configured with `{ emphasis: '_' }`. ###### In @@ -200,7 +200,7 @@ No messages. ##### `not-ok.md` -When configured with `'_'`. +When configured with `{ emphasis: '_' }`. ###### In @@ -231,7 +231,7 @@ _bar_ ##### `not-ok.md` -When configured with `'πŸ’©'`. +When configured with `{ emphasis: 'πŸ’©' }`. ###### Out diff --git a/packages/remark-lint-first-heading-level/readme.md b/packages/remark-lint-first-heading-level/readme.md index c660081e..a3e38bf2 100644 --- a/packages/remark-lint-first-heading-level/readme.md +++ b/packages/remark-lint-first-heading-level/readme.md @@ -135,14 +135,10 @@ a value of `2` can be defined here. ##### `ok.md` -When configured with `2`. - ###### In ```markdown -## Delta - -Paragraph. +# The default is to expect a level one heading ``` ###### Out @@ -151,14 +147,26 @@ No messages. ##### `ok-html.md` -When configured with `2`. +###### In + +```markdown +

An HTML heading is also seen by this rule.

+``` + +###### Out + +No messages. + +##### `ok-delayed.md` ###### In ```markdown -

Echo

+You can use markdown content before the heading. -Paragraph. +
Or non-heading HTML
+ +

So the first heading, be it HTML or markdown, is checked

``` ###### Out @@ -167,12 +175,10 @@ No messages. ##### `not-ok.md` -When configured with `2`. - ###### In ```markdown -# Foxtrot +## Bravo Paragraph. ``` @@ -180,17 +186,15 @@ Paragraph. ###### Out ```text -1:1-1:10: First heading level should be `2` +1:1-1:9: First heading level should be `1` ``` ##### `not-ok-html.md` -When configured with `2`. - ###### In ```markdown -

Golf

+

Charlie

Paragraph. ``` @@ -198,15 +202,19 @@ Paragraph. ###### Out ```text -1:1-1:14: First heading level should be `2` +1:1-1:17: First heading level should be `1` ``` ##### `ok.md` +When configured with `2`. + ###### In ```markdown -# The default is to expect a level one heading +## Delta + +Paragraph. ``` ###### Out @@ -215,26 +223,14 @@ No messages. ##### `ok-html.md` -###### In - -```markdown -

An HTML heading is also seen by this rule.

-``` - -###### Out - -No messages. - -##### `ok-delayed.md` +When configured with `2`. ###### In ```markdown -You can use markdown content before the heading. - -
Or non-heading HTML
+

Echo

-

So the first heading, be it HTML or markdown, is checked

+Paragraph. ``` ###### Out @@ -243,10 +239,12 @@ No messages. ##### `not-ok.md` +When configured with `2`. + ###### In ```markdown -## Bravo +# Foxtrot Paragraph. ``` @@ -254,15 +252,17 @@ Paragraph. ###### Out ```text -1:1-1:9: First heading level should be `1` +1:1-1:10: First heading level should be `2` ``` ##### `not-ok-html.md` +When configured with `2`. + ###### In ```markdown -

Charlie

+

Golf

Paragraph. ``` @@ -270,7 +270,7 @@ Paragraph. ###### Out ```text -1:1-1:17: First heading level should be `1` +1:1-1:14: First heading level should be `2` ``` ## Compatibility diff --git a/packages/remark-lint-maximum-heading-length/readme.md b/packages/remark-lint-maximum-heading-length/readme.md index 11044fdb..c62fdad2 100644 --- a/packages/remark-lint-maximum-heading-length/readme.md +++ b/packages/remark-lint-maximum-heading-length/readme.md @@ -139,35 +139,35 @@ which reads every heading out loud). ## Examples -##### `not-ok.md` - -When configured with `40`. +##### `ok.md` ###### In ```markdown # Alpha bravo charlie delta echo foxtrot golf hotel + +# ![Alpha bravo charlie delta echo foxtrot golf hotel](http://example.com/nato.png) ``` ###### Out -```text -1:1-1:52: Use headings shorter than `40` -``` +No messages. -##### `ok.md` +##### `not-ok.md` + +When configured with `40`. ###### In ```markdown # Alpha bravo charlie delta echo foxtrot golf hotel - -# ![Alpha bravo charlie delta echo foxtrot golf hotel](http://example.com/nato.png) ``` ###### Out -No messages. +```text +1:1-1:52: Use headings shorter than `40` +``` ## Compatibility diff --git a/packages/remark-lint-maximum-line-length/readme.md b/packages/remark-lint-maximum-line-length/readme.md index 48790f01..aec51ec5 100644 --- a/packages/remark-lint-maximum-line-length/readme.md +++ b/packages/remark-lint-maximum-line-length/readme.md @@ -138,52 +138,46 @@ Whether to wrap prose or not is a stylistic choice. ## Examples -##### `ok-mixed-line-endings.md` - -When configured with `10`. +##### `ok.md` ###### In -> πŸ‘‰ **Note**: `␍␊` represents a carriage return and a line feed. - -> πŸ‘‰ **Note**: `␊` represents a line feed. +> πŸ‘‰ **Note**: this example uses GFM ([`remark-gfm`][gfm]). ```markdown -0123456789␍␊ -0123456789␊ -01234␍␊ -01234␊ -``` +This line is simply not toooooooooooooooooooooooooooooooooooooooooooo +long. -###### Out +This is also fine: -No messages. + -##### `not-ok-mixed-line-endings.md` +`alphaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJuliettKiloLimaMikeNovemberOscarPapaQuebec.romeo()` -When configured with `10`. +[foo](http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables) -###### In + -> πŸ‘‰ **Note**: `␍␊` represents a carriage return and a line feed. +![foo](http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables) -> πŸ‘‰ **Note**: `␊` represents a line feed. +| An | exception | is | line | length | in | long | tables | because | those | can’t | just | +| -- | --------- | -- | ---- | ------ | -- | ---- | ------ | ------- | ----- | ----- | ---- | +| be | helped | | | | | | | | | | . | -```markdown -012345678901␍␊ -012345678901␊ -01234567890␍␊ -01234567890␊ +

alpha bravo charlie delta echo foxtrot golf

+ +The following is also fine (note the `.`), because there is no whitespace. + +. + +In addition, definitions are also fine: + +[foo]: ``` ###### Out -```text -1:13: Line must be at most 10 characters -2:13: Line must be at most 10 characters -3:12: Line must be at most 10 characters -4:12: Line must be at most 10 characters -``` +No messages. ##### `not-ok.md` @@ -216,46 +210,52 @@ And this one is also very wrong: because the code starts aaaaaaafter the column: 12:99: Line must be at most 80 characters ``` -##### `ok.md` - -###### In - -> πŸ‘‰ **Note**: this example uses GFM ([`remark-gfm`][gfm]). +##### `ok-mixed-line-endings.md` -```markdown -This line is simply not toooooooooooooooooooooooooooooooooooooooooooo -long. +When configured with `10`. -This is also fine: +###### In - +> πŸ‘‰ **Note**: `␍␊` represents a carriage return and a line feed. -`alphaBravoCharlieDeltaEchoFoxtrotGolfHotelIndiaJuliettKiloLimaMikeNovemberOscarPapaQuebec.romeo()` +> πŸ‘‰ **Note**: `␊` represents a line feed. -[foo](http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables) +```markdown +0123456789␍␊ +0123456789␊ +01234␍␊ +01234␊ +``` - +###### Out -![foo](http://this-long-url-with-a-long-domain-is-ok.co.uk/a-long-path?query=variables) +No messages. -| An | exception | is | line | length | in | long | tables | because | those | can’t | just | -| -- | --------- | -- | ---- | ------ | -- | ---- | ------ | ------- | ----- | ----- | ---- | -| be | helped | | | | | | | | | | . | +##### `not-ok-mixed-line-endings.md` -

alpha bravo charlie delta echo foxtrot golf

+When configured with `10`. -The following is also fine (note the `.`), because there is no whitespace. +###### In -. +> πŸ‘‰ **Note**: `␍␊` represents a carriage return and a line feed. -In addition, definitions are also fine: +> πŸ‘‰ **Note**: `␊` represents a line feed. -[foo]: +```markdown +012345678901␍␊ +012345678901␊ +01234567890␍␊ +01234567890␊ ``` ###### Out -No messages. +```text +1:13: Line must be at most 10 characters +2:13: Line must be at most 10 characters +3:12: Line must be at most 10 characters +4:12: Line must be at most 10 characters +``` ## Compatibility diff --git a/packages/remark-lint-strong-marker/index.js b/packages/remark-lint-strong-marker/index.js index bfd3b575..9fd03b30 100644 --- a/packages/remark-lint-strong-marker/index.js +++ b/packages/remark-lint-strong-marker/index.js @@ -50,12 +50,12 @@ * __foo__ and __bar__. * * @example - * {"name": "ok.md", "setting": "*"} + * {"name": "ok.md", "settings": {"strong": "*"}} * * **foo**. * * @example - * {"name": "ok.md", "setting": "_"} + * {"name": "ok.md", "settings": {"strong": "_"}} * * __foo__. * @@ -70,7 +70,7 @@ * 1:13-1:20: Strong should use `*` as a marker * * @example - * {"name": "not-ok.md", "label": "output", "setting": "πŸ’©", "positionless": true} + * {"name": "not-ok.md", "label": "output", "settings": {"strong": "πŸ’©"}, "positionless": true} * * 1:1: Incorrect strong marker `πŸ’©`: use either `'consistent'`, `'*'`, or `'_'` */ diff --git a/packages/remark-lint-strong-marker/readme.md b/packages/remark-lint-strong-marker/readme.md index ad5ea611..ed1af8d5 100644 --- a/packages/remark-lint-strong-marker/readme.md +++ b/packages/remark-lint-strong-marker/readme.md @@ -194,7 +194,7 @@ No messages. ##### `ok.md` -When configured with `'*'`. +When configured with `{ strong: '*' }`. ###### In @@ -208,7 +208,7 @@ No messages. ##### `ok.md` -When configured with `'_'`. +When configured with `{ strong: '_' }`. ###### In @@ -222,7 +222,7 @@ No messages. ##### `not-ok.md` -When configured with `'πŸ’©'`. +When configured with `{ strong: 'πŸ’©' }`. ###### Out diff --git a/script/build-rules.js b/script/build-rules.js index a48d569a..f332be64 100644 --- a/script/build-rules.js +++ b/script/build-rules.js @@ -588,7 +588,9 @@ presets(root).then((presetObjects) => { for (fileName in fixtures) { if (own.call(fixtures, fileName)) { const fixture = fixtures[fileName] - const label = inspect(JSON.parse(setting)) + /** @type {{settings: unknown, options: unknown}} */ + const {settings, options} = JSON.parse(setting) + const label = inspect(settings || options) let clean = fixture.input children.push({ diff --git a/script/util/rule.js b/script/util/rule.js index 8c9ed05b..c60041f0 100755 --- a/script/util/rule.js +++ b/script/util/rule.js @@ -77,7 +77,7 @@ export function rule(filePath) { while (++index < examples.length) { const lines = examples[index].split('\n') - /** @type {{name: string, label?: 'input'|'output', setting?: unknown, positionless?: boolean, gfm?: boolean}} */ + /** @type {{name: string, label?: 'input'|'output', settings?: unknown, setting?: unknown, positionless?: boolean, gfm?: boolean}} */ let info try { @@ -92,7 +92,10 @@ export function rule(filePath) { } const exampleValue = strip(lines.join('\n').replace(/^\r?\n/g, '')) - const setting = JSON.stringify(info.setting || true) + const setting = JSON.stringify({ + settings: info.settings, + options: info.setting || true + }) const name = info.name const context = setting in tests ? tests[setting] : (tests[setting] = {}) diff --git a/test.js b/test.js index bfb3622d..d4a6ec4e 100644 --- a/test.js +++ b/test.js @@ -301,8 +301,8 @@ function assertRule(t, rule, info) { for (setting in tests) { if (own.call(tests, setting)) { const checks = tests[setting] - /** @type {unknown} */ - const options = JSON.parse(setting) + /** @type {{settings: unknown, options: unknown}} */ + const {settings, options} = JSON.parse(setting) t.test(setting, (t) => { /** @type {string} */ @@ -314,7 +314,7 @@ function assertRule(t, rule, info) { const check = checks[name] t.test(name, (t) => { - assertFixture(t, rule, info, check, basename, options) + assertFixture(t, rule, info, check, basename, settings, options) }) } } @@ -332,14 +332,15 @@ function assertRule(t, rule, info) { * @param {Check} fixture * @param {string} basename * @param {unknown} settings + * @param {unknown} options */ /* eslint-disable-next-line max-params */ -function assertFixture(t, rule, info, fixture, basename, settings) { +function assertFixture(t, rule, info, fixture, basename, settings, options) { const ruleId = info.ruleId const file = toVFile(basename) const expected = fixture.output const positionless = fixture.positionless - let proc = remark().use(rule, settings) + let proc = remark().data('settings', settings).use(rule, options) if (fixture.gfm) proc.use(remarkGfm) @@ -392,7 +393,7 @@ function assertFixture(t, rule, info, fixture, basename, settings) { file.messages = [] proc = remark() .use(() => (tree) => removePosition(tree)) - .use(rule, settings) + .use(rule, options) if (fixture.gfm) proc.use(remarkGfm) proc.processSync(file)