Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add settings for enforced styles to presets #282

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/remark-preset-lint-consistent/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Preset of [`remark-lint`][mono] rules to warn for inconsistencies.
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Rules](#rules)
* [Settings](#settings)
* [Install](#install)
* [Use](#use)
* [API](#api)
Expand Down Expand Up @@ -54,6 +55,10 @@ This preset configures [`remark-lint`][mono] with the following rules:
| [`remark-lint-strong-marker`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-strong-marker) | `'consistent'` |
| [`remark-lint-table-cell-padding`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-cell-padding) | `'consistent'` |

## Settings

It doesn't set any remark [settings][configure].

## Install

This package is [ESM only][esm].
Expand Down Expand Up @@ -183,6 +188,8 @@ abide by its terms.

[mono]: https://github.com/remarkjs/remark-lint

[configure]: https://github.com/remarkjs/remark-lint#configure

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[skypack]: https://www.skypack.dev
Expand Down
15 changes: 14 additions & 1 deletion packages/remark-preset-lint-markdown-style-guide/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,20 @@ const remarkPresetLintMarkdownStyleGuide = {

// https://cirosantilli.com/markdown-style-guide/#email-automatic-links.
// Not checked.
]
],
settings: {
bullet: '-',
bulletOrdered: '.',
emphasis: '*',
fence: '`',
fences: true,
incrementListMarker: false,
listItemIndent: 'mixed',
quote: '"',
rule: '-',
setext: false,
strong: '*'
}
}

export default remarkPresetLintMarkdownStyleGuide
22 changes: 22 additions & 0 deletions packages/remark-preset-lint-markdown-style-guide/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Preset of [`remark-lint`][mono] rules that follow an opinionated style guide.
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Rules](#rules)
* [Settings](#settings)
* [Install](#install)
* [Use](#use)
* [API](#api)
Expand Down Expand Up @@ -175,6 +176,25 @@ This preset configures [`remark-lint`][mono] with the following rules:
| [`remark-lint-no-emphasis-as-heading`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-emphasis-as-heading) | |
| [`remark-lint-no-literal-urls`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-literal-urls) | |

## Settings

It sets the following remark [settings][configure].
Settings are shared among all plugins --- particularly [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options):

| Name | Value |
| - | - |
| `settings.bullet` | `'-'` |
| `settings.bulletOrdered` | `'.'` |
| `settings.emphasis` | `'*'` |
| `settings.fence` | ``'`'`` |
| `settings.fences` | `true` |
| `settings.incrementListMarker` | `false` |
| `settings.listItemIndent` | `'mixed'` |
| `settings.quote` | `'"'` |
| `settings.rule` | `'-'` |
| `settings.setext` | `false` |
| `settings.strong` | `'*'` |

## Install

This package is [ESM only][esm].
Expand Down Expand Up @@ -304,6 +324,8 @@ abide by its terms.

[mono]: https://github.com/remarkjs/remark-lint

[configure]: https://github.com/remarkjs/remark-lint#configure

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[skypack]: https://www.skypack.dev
Expand Down
6 changes: 5 additions & 1 deletion packages/remark-preset-lint-recommended/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const remarkPresetLintRecommended = {
remarkLintNoShortcutReferenceLink,
remarkLintNoUndefinedReferences,
remarkLintNoUnusedDefinitions
]
],
settings: {
bulletOrdered: '.',
listItemIndent: 'tab'
}
}

export default remarkPresetLintRecommended
13 changes: 13 additions & 0 deletions packages/remark-preset-lint-recommended/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Preset of [`remark-lint`][mono] rules to warn for some likely problems.
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Rules](#rules)
* [Settings](#settings)
* [Install](#install)
* [Use](#use)
* [API](#api)
Expand Down Expand Up @@ -56,6 +57,16 @@ This preset configures [`remark-lint`][mono] with the following rules:
| [`remark-lint-no-undefined-references`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-undefined-references) | |
| [`remark-lint-no-unused-definitions`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-unused-definitions) | |

## Settings

It sets the following remark [settings][configure].
Settings are shared among all plugins --- particularly [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options):

| Name | Value |
| - | - |
| `settings.bulletOrdered` | `'.'` |
| `settings.listItemIndent` | `'tab'` |

## Install

This package is [ESM only][esm].
Expand Down Expand Up @@ -185,6 +196,8 @@ abide by its terms.

[mono]: https://github.com/remarkjs/remark-lint

[configure]: https://github.com/remarkjs/remark-lint#configure

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[skypack]: https://www.skypack.dev
Expand Down
90 changes: 89 additions & 1 deletion script/build-presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ presets(root).then((presetObjects) => {
let index = -1

while (++index < presetObjects.length) {
const {name, packages} = presetObjects[index]
const {name, packages, settings} = presetObjects[index]
const base = path.resolve(root, name)
/** @type {PackageJson} */
const pack = JSON.parse(
Expand Down Expand Up @@ -311,6 +311,89 @@ presets(root).then((presetObjects) => {
]
},
{type: 'table', align: [], children: rows},
{
type: 'heading',
depth: 2,
children: [{type: 'text', value: 'Settings'}]
},
.../** @type {Array<BlockContent>} */ (
settings
? [
{
type: 'paragraph',
children: [
{type: 'text', value: 'It sets the following remark '},
{
type: 'linkReference',
identifier: 'configure',
referenceType: 'full',
children: [{type: 'text', value: 'settings'}]
},
{
type: 'text',
value:
'.\nSettings are shared among all plugins --- particularly '
},
{
type: 'link',
url: 'https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options',
title: null,
children: [{type: 'inlineCode', value: 'remark-stringify'}]
},
{type: 'text', value: ':'}
]
},
{
type: 'table',
align: [],
children: [
{
type: 'tableRow',
children: [
{
type: 'tableCell',
children: [{type: 'text', value: 'Name'}]
},
{
type: 'tableCell',
children: [{type: 'text', value: 'Value'}]
}
]
},
...Object.entries(settings).map(([name, value]) => ({
type: 'tableRow',
children: [
{
type: 'tableCell',
children: [
{type: 'inlineCode', value: `settings.${name}`}
]
},
{
type: 'tableCell',
children: [{type: 'inlineCode', value: inspect(value)}]
}
]
}))
]
}
]
: [
{
type: 'paragraph',
children: [
{type: 'text', value: "It doesn't set any remark "},
{
type: 'linkReference',
identifier: 'configure',
referenceType: 'full',
children: [{type: 'text', value: 'settings'}]
},
{type: 'text', value: '.'}
]
}
]
),
{
type: 'heading',
depth: 2,
Expand Down Expand Up @@ -664,6 +747,11 @@ presets(root).then((presetObjects) => {
identifier: 'mono',
url: 'https://github.com/' + slug
},
{
type: 'definition',
identifier: 'configure',
url: `https://github.com/${slug}#configure`
},
{
type: 'definition',
identifier: 'esm',
Expand Down
4 changes: 2 additions & 2 deletions script/util/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import url from 'node:url'

/**
* @param {string} base
* @returns {Promise<Array<{name: string, packages: Record<string, unknown>}>>}
* @returns {Promise<Array<{name: string, packages: Record<string, unknown>, settings: Record<string, unknown>|undefined}>>}
*/
export async function presets(base) {
const allFiles = await fs.readdir(base)
Expand Down Expand Up @@ -70,7 +70,7 @@ export async function presets(base) {
] = option
}

return {name, packages}
return {name, packages, settings: preset.settings}
})
)
}
Loading