mirror of
https://github.com/remarkjs/remark-lint.git
synced 2024-10-26 19:31:42 +03:00
Fix hard-break-spaces in indented blocks
Closes GH-31.
This commit is contained in:
parent
d0264d2432
commit
a427c59a35
@ -43,12 +43,15 @@ function hardBreakSpaces(ast, file, preferred, done) {
|
||||
visit(ast, 'break', function (node) {
|
||||
var start = position.start(node).offset;
|
||||
var end = position.end(node).offset;
|
||||
var value;
|
||||
|
||||
if (position.generated(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (contents.slice(start, end).length > 3) {
|
||||
value = contents.slice(start, end).split('\n', 1)[0];
|
||||
|
||||
if (value.length > 2) {
|
||||
file.warn('Use two spaces for hard line breaks', node);
|
||||
}
|
||||
});
|
||||
|
3
test/fixtures/hard-break-spaces-invalid.md
vendored
3
test/fixtures/hard-break-spaces-invalid.md
vendored
@ -1,5 +1,8 @@
|
||||
Here’s one that uses too
|
||||
much white space.
|
||||
|
||||
- A bullet with three trailing spaces
|
||||
Next line.
|
||||
|
||||
And here’s a commonmark\
|
||||
break.
|
||||
|
3
test/fixtures/hard-break-spaces-valid.md
vendored
3
test/fixtures/hard-break-spaces-valid.md
vendored
@ -1,5 +1,8 @@
|
||||
Here’s one that uses too
|
||||
just enough white space.
|
||||
|
||||
- A bullet with two trailing spaces
|
||||
Next line.
|
||||
|
||||
And here’s another
|
||||
break.
|
||||
|
@ -1214,7 +1214,8 @@ describe('Rules', function () {
|
||||
describeRule('hard-break-spaces', function () {
|
||||
describeSetting(true, function () {
|
||||
assertFile('hard-break-spaces-invalid.md', [
|
||||
'hard-break-spaces-invalid.md:1:25-2:1: Use two spaces for hard line breaks'
|
||||
'hard-break-spaces-invalid.md:1:25-2:1: Use two spaces for hard line breaks',
|
||||
'hard-break-spaces-invalid.md:4:40-5:5: Use two spaces for hard line breaks'
|
||||
]);
|
||||
|
||||
assertFile('hard-break-spaces-valid.md', []);
|
||||
|
Loading…
Reference in New Issue
Block a user