Skip to content

Commit

Permalink
list-item-indent: change default to one
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Dec 17, 2023
1 parent 07140bd commit ccea691
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"remark-validate-links",
[
"remark-lint-list-item-indent",
"space"
"one"
],
"./script/plugin/list-of-plugins.js",
"./script/plugin/list-of-presets.js"
Expand Down
55 changes: 37 additions & 18 deletions packages/remark-lint-list-item-indent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* ###### Parameters
*
* * `options` ([`Options`][api-options], default: `'tab'`)
* * `options` ([`Options`][api-options], default: `'one'`)
* — preferred style
*
* ###### Returns
Expand All @@ -30,12 +30,12 @@
*
* Configuration (TypeScript type).
*
* * `'one'`
* — prefer a single space
* * `'tab'`
* — prefer spaces the size of the next tab stop
* * `'mixed'`
* — prefer `'one'` for tight lists and `'tab'` for loose lists
* * `'one'`
* — prefer the size of the bullet and a single space
* * `'tab'`
* — prefer the size of the bullet and a single space to the next tab stop
*
* ###### Type
*
Expand Down Expand Up @@ -70,11 +70,11 @@
* 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'`, which worked the best
* in most markdown parsers *and* in CommonMark.
* Due to this, `'tab'` works the best in most markdown parsers *and* in
* CommonMark.
* Currently the situation between markdown parsers is better,
* so choosing `'one'`, which seems to be the most common style used by
* authors,
* so the default `'one'`,
* which seems to be the most common style used by authors,
* is okay.
*
* ## Fix
Expand All @@ -95,8 +95,8 @@
* @example
* {"name": "ok.md"}
*
* *␠␠␠List
* ␠␠␠␠item.
* *␠List
* ␠␠item.
*
* Paragraph.
*
Expand All @@ -105,11 +105,11 @@
*
* Paragraph.
*
* *␠␠␠List
* ␠␠␠␠item.
* *␠List
* ␠␠item.
*
* *␠␠␠List
* ␠␠␠␠item.
* *␠List
* ␠␠item.
*
* @example
* {"name": "ok.md", "config": "mixed"}
Expand Down Expand Up @@ -146,6 +146,25 @@
* ␠␠item.
*
* @example
* {"config": "tab", "name": "ok.md"}
*
* *␠␠␠List
* ␠␠␠␠item.
*
* Paragraph.
*
* 11.␠List
* ␠␠␠␠item.
*
* Paragraph.
*
* *␠␠␠List
* ␠␠␠␠item.
*
* *␠␠␠List
* ␠␠␠␠item.
*
* @example
* {"name": "not-ok.md", "config": "one", "label": "input"}
*
* *␠␠␠List
Expand Down Expand Up @@ -205,14 +224,14 @@ const remarkLintListItemIndent = lintRule(
/**
* @param {Root} tree
* Tree.
* @param {Options | null | undefined} [options='tab']
* Configuration (default: `'tab'`).
* @param {Options | null | undefined} [options='one']
* Configuration (default: `'one'`).
* @returns {undefined}
* Nothing.
*/
function (tree, file, options) {
const value = String(file)
const option = options || 'tab'
const option = options || 'one'

/* c8 ignore next 13 -- previous names. */
// @ts-expect-error: old name.
Expand Down
58 changes: 43 additions & 15 deletions packages/remark-lint-list-item-indent/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Warn when the whitespace after list item markers violate a given style.

###### Parameters

* `options` ([`Options`][api-options], default: `'tab'`)
* `options` ([`Options`][api-options], default: `'one'`)
— preferred style

###### Returns
Expand All @@ -143,12 +143,12 @@ Transform ([`Transformer` from `unified`][github-unified-transformer]).

Configuration (TypeScript type).

* `'one'`
— prefer a single space
* `'tab'`
— prefer spaces the size of the next tab stop
* `'mixed'`
— prefer `'one'` for tight lists and `'tab'` for loose lists
* `'one'`
— prefer the size of the bullet and a single space
* `'tab'`
— prefer the size of the bullet and a single space to the next tab stop

###### Type

Expand Down Expand Up @@ -183,11 +183,11 @@ 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'`, which worked the best
in most markdown parsers *and* in CommonMark.
Due to this, `'tab'` works the best in most markdown parsers *and* in
CommonMark.
Currently the situation between markdown parsers is better,
so choosing `'one'`, which seems to be the most common style used by
authors,
so the default `'one'`,
which seems to be the most common style used by authors,
is okay.
## Fix
Expand All @@ -203,8 +203,8 @@ by default.
###### In
```markdown
*␠␠␠List
␠␠␠␠item.
*␠List
␠␠item.

Paragraph.

Expand All @@ -213,11 +213,11 @@ Paragraph.

Paragraph.

*␠␠List
␠␠␠␠item.
*List
␠␠item.

*␠␠List
␠␠␠␠item.
*List
␠␠item.
```

###### Out
Expand Down Expand Up @@ -276,6 +276,34 @@ Paragraph.

No messages.

##### `ok.md`

When configured with `'tab'`.

###### In

```markdown
*␠␠␠List
␠␠␠␠item.

Paragraph.

11.␠List
␠␠␠␠item.

Paragraph.

*␠␠␠List
␠␠␠␠item.

*␠␠␠List
␠␠␠␠item.
```

###### Out

No messages.

##### `not-ok.md`

When configured with `'one'`.
Expand Down

0 comments on commit ccea691

Please sign in to comment.