mirror of
https://github.com/remarkjs/remark-lint.git
synced 2024-09-11 19:57:15 +03:00
Fix list-item-indent
for non-incremented lists
Closes GH-40.
This commit is contained in:
parent
a95b422d8a
commit
e708a1c802
@ -93,19 +93,17 @@ function listItemIndent(ast, file, preferred, done) {
|
||||
|
||||
visit(ast, 'list', function (node) {
|
||||
var items = node.children;
|
||||
var isOrdered = node.ordered;
|
||||
var offset = node.start || 1;
|
||||
|
||||
if (position.generated(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
items.forEach(function (item, index) {
|
||||
items.forEach(function (item) {
|
||||
var head = item.children[0];
|
||||
var bulletSize = isOrdered ? String(offset + index).length + 1 : 1;
|
||||
var tab = Math.ceil(bulletSize / 4) * 4;
|
||||
var initial = start(item).offset;
|
||||
var final = start(head).offset;
|
||||
var bulletSize;
|
||||
var tab;
|
||||
var marker;
|
||||
var shouldBe;
|
||||
var diff;
|
||||
@ -119,6 +117,9 @@ function listItemIndent(ast, file, preferred, done) {
|
||||
|
||||
marker = marker.replace(/\[[x ]?\]\s*$/i, '');
|
||||
|
||||
bulletSize = marker.trimRight().length;
|
||||
tab = Math.ceil(bulletSize / 4) * 4;
|
||||
|
||||
if (preferred === 'tab-size') {
|
||||
shouldBe = tab;
|
||||
} else if (preferred === 'space') {
|
||||
|
13
test/fixtures/list-item-indent-space.md
vendored
13
test/fixtures/list-item-indent-space.md
vendored
@ -48,3 +48,16 @@ And an extra test for numbers:
|
||||
|
||||
11. baz
|
||||
3
|
||||
|
||||
And many items:
|
||||
|
||||
1. One
|
||||
1. Two
|
||||
1. Three
|
||||
1. Four
|
||||
1. Five
|
||||
1. Six
|
||||
1. Seven
|
||||
1. Eight
|
||||
1. Nine
|
||||
1. Ten
|
||||
|
@ -1297,7 +1297,17 @@ describe('Rules', function () {
|
||||
'list-item-indent-space.md:29:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:32:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:37:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:43:4: Incorrect list-item indent: add 1 space'
|
||||
'list-item-indent-space.md:43:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:54:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:55:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:56:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:57:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:58:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:59:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:60:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:61:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:62:4: Incorrect list-item indent: add 1 space',
|
||||
'list-item-indent-space.md:63:4: Incorrect list-item indent: add 1 space'
|
||||
]);
|
||||
|
||||
assertFile('list-item-indent-mixed.md', [
|
||||
|
Loading…
Reference in New Issue
Block a user