Skip to content

Commit 6fdc5d9

Browse files
TrottBridgeAR
authored andcommitted
tools: enable 80-char line length markdown linting
PR-URL: #24094 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 3ce71f7 commit 6fdc5d9

File tree

4 files changed

+164
-100
lines changed

4 files changed

+164
-100
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Select a Node.js version below to view the changelog history:
1818
Please use the following table to find the changelog for a specific Node.js
1919
release.
2020

21+
<!--lint disable maximum-line-length-->
2122
<table>
2223
<tr>
2324
<th title="Current"><a href="doc/changelogs/CHANGELOG_V11.md">11</a><sup>Current</sup></th>

tools/lint-md.js

+141-90
Original file line numberDiff line numberDiff line change
@@ -30293,96 +30293,69 @@ function stringify$7(options) {
3029330293

3029430294
var remark = unified_1().use(remarkParse).use(remarkStringify).freeze();
3029530295

30296-
const _args = [["remark@8.0.0","D:\\code\\prws\\tools\\node-lint-md-cli-rollup"]];
30297-
const _from = "remark@8.0.0";
30298-
const _id = "remark@8.0.0";
30299-
const _inBundle = false;
30300-
const _integrity = "sha512-K0PTsaZvJlXTl9DN6qYlvjTkqSZBFELhROZMrblm2rB+085flN84nz4g/BscKRMqDvhzlK1oQ/xnWQumdeNZYw==";
30301-
const _location = "/remark";
30302-
const _phantomChildren = {};
30303-
const _requested = {"type":"version","registry":true,"raw":"remark@8.0.0","name":"remark","escapedName":"remark","rawSpec":"8.0.0","saveSpec":null,"fetchSpec":"8.0.0"};
30304-
const _requiredBy = ["/"];
30305-
const _resolved = "https://registry.npmjs.org/remark/-/remark-8.0.0.tgz";
30306-
const _spec = "8.0.0";
30307-
const _where = "D:\\code\\prws\\tools\\node-lint-md-cli-rollup";
30308-
const author = {"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"http://wooorm.com"};
30309-
const bugs = {"url":"https://github.com/wooorm/remark/issues"};
30310-
const contributors = [{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"http://wooorm.com"}];
30311-
const dependencies = {"remark-parse":"^4.0.0","remark-stringify":"^4.0.0","unified":"^6.0.0"};
30296+
const name = "remark";
30297+
const version$1 = "8.0.0";
3031230298
const description = "Markdown processor powered by plugins";
30313-
const files = ["index.js"];
30314-
const homepage = "http://remark.js.org";
30315-
const keywords = ["markdown","abstract","syntax","tree","ast","parse","stringify","process"];
3031630299
const license = "MIT";
30317-
const name = "remark";
30318-
const repository = {"type":"git","url":"https://github.com/wooorm/remark/tree/master/packages/remark"};
30300+
const keywords = ["markdown","abstract","syntax","tree","ast","parse","stringify","process"];
30301+
const dependencies = {"remark-parse":"^4.0.0","remark-stringify":"^4.0.0","unified":"^6.0.0"};
30302+
const homepage = "http://remark.js.org";
30303+
const repository = "https://github.com/wooorm/remark/tree/master/packages/remark";
30304+
const bugs = "https://github.com/wooorm/remark/issues";
30305+
const author = "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)";
30306+
const contributors = ["Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"];
30307+
const files = ["index.js"];
3031930308
const scripts = {};
30320-
const version$1 = "8.0.0";
3032130309
const xo = false;
30310+
const _resolved = "https://registry.npmjs.org/remark/-/remark-8.0.0.tgz";
30311+
const _integrity = "sha512-K0PTsaZvJlXTl9DN6qYlvjTkqSZBFELhROZMrblm2rB+085flN84nz4g/BscKRMqDvhzlK1oQ/xnWQumdeNZYw==";
30312+
const _from = "remark@8.0.0";
3032230313
var _package = {
30323-
_args: _args,
30324-
_from: _from,
30325-
_id: _id,
30326-
_inBundle: _inBundle,
30327-
_integrity: _integrity,
30328-
_location: _location,
30329-
_phantomChildren: _phantomChildren,
30330-
_requested: _requested,
30331-
_requiredBy: _requiredBy,
30332-
_resolved: _resolved,
30333-
_spec: _spec,
30334-
_where: _where,
30335-
author: author,
30336-
bugs: bugs,
30337-
contributors: contributors,
30338-
dependencies: dependencies,
30314+
name: name,
30315+
version: version$1,
3033930316
description: description,
30340-
files: files,
30341-
homepage: homepage,
30342-
keywords: keywords,
3034330317
license: license,
30344-
name: name,
30318+
keywords: keywords,
30319+
dependencies: dependencies,
30320+
homepage: homepage,
3034530321
repository: repository,
30322+
bugs: bugs,
30323+
author: author,
30324+
contributors: contributors,
30325+
files: files,
3034630326
scripts: scripts,
30347-
version: version$1,
30348-
xo: xo
30327+
xo: xo,
30328+
_resolved: _resolved,
30329+
_integrity: _integrity,
30330+
_from: _from
3034930331
};
3035030332

3035130333
var _package$1 = Object.freeze({
30352-
_args: _args,
30353-
_from: _from,
30354-
_id: _id,
30355-
_inBundle: _inBundle,
30356-
_integrity: _integrity,
30357-
_location: _location,
30358-
_phantomChildren: _phantomChildren,
30359-
_requested: _requested,
30360-
_requiredBy: _requiredBy,
30361-
_resolved: _resolved,
30362-
_spec: _spec,
30363-
_where: _where,
30364-
author: author,
30365-
bugs: bugs,
30366-
contributors: contributors,
30367-
dependencies: dependencies,
30334+
name: name,
30335+
version: version$1,
3036830336
description: description,
30369-
files: files,
30370-
homepage: homepage,
30371-
keywords: keywords,
3037230337
license: license,
30373-
name: name,
30338+
keywords: keywords,
30339+
dependencies: dependencies,
30340+
homepage: homepage,
3037430341
repository: repository,
30342+
bugs: bugs,
30343+
author: author,
30344+
contributors: contributors,
30345+
files: files,
3037530346
scripts: scripts,
30376-
version: version$1,
3037730347
xo: xo,
30348+
_resolved: _resolved,
30349+
_integrity: _integrity,
30350+
_from: _from,
3037830351
default: _package
3037930352
});
3038030353

3038130354
const name$1 = "node-lint-md-cli-rollup";
3038230355
const description$1 = "remark packaged for node markdown linting";
3038330356
const version$2 = "1.0.0";
3038430357
const devDependencies = {"rollup":"^0.55.5","rollup-plugin-commonjs":"^8.0.2","rollup-plugin-json":"^2.3.1","rollup-plugin-node-resolve":"^3.4.0"};
30385-
const dependencies$1 = {"markdown-extensions":"^1.1.0","remark":"^8.0.0","remark-lint":"^6.0.2","remark-preset-lint-node":"^1.0.3","unified-args":"^6.0.0","unified-engine":"^5.1.0"};
30358+
const dependencies$1 = {"markdown-extensions":"^1.1.0","remark":"^8.0.0","remark-lint":"^6.0.2","remark-preset-lint-node":"^1.1.0","unified-args":"^6.0.0","unified-engine":"^5.1.0"};
3038630359
const scripts$1 = {"build":"rollup -c","build-node":"npm run build && cp dist/* .."};
3038730360
var _package$2 = {
3038830361
name: name$1,
@@ -32479,7 +32452,84 @@ function noInlinePadding(tree, file) {
3247932452
}
3248032453
}
3248132454

32455+
var remarkLintMaximumLineLength = unifiedLintRule('remark-lint:maximum-line-length', maximumLineLength);
32456+
3248232457
var start$6 = unistUtilPosition.start;
32458+
var end$4 = unistUtilPosition.end;
32459+
32460+
function maximumLineLength(tree, file, pref) {
32461+
var style = typeof pref === 'number' && !isNaN(pref) ? pref : 80;
32462+
var content = String(file);
32463+
var lines = content.split(/\r?\n/);
32464+
var length = lines.length;
32465+
var index = -1;
32466+
var lineLength;
32467+
32468+
unistUtilVisit(tree, ['heading', 'table', 'code', 'definition'], ignore);
32469+
unistUtilVisit(tree, ['link', 'image', 'inlineCode'], inline);
32470+
32471+
/* Iterate over every line, and warn for violating lines. */
32472+
while (++index < length) {
32473+
lineLength = lines[index].length;
32474+
32475+
if (lineLength > style) {
32476+
file.message('Line must be at most ' + style + ' characters', {
32477+
line: index + 1,
32478+
column: lineLength + 1
32479+
});
32480+
}
32481+
}
32482+
32483+
/* Finally, whitelist some inline spans, but only if they occur at or after
32484+
* the wrap. However, when they do, and there’s white-space after it, they
32485+
* are not whitelisted. */
32486+
function inline(node, pos, parent) {
32487+
var next = parent.children[pos + 1];
32488+
var initial;
32489+
var final;
32490+
32491+
/* istanbul ignore if - Nothing to whitelist when generated. */
32492+
if (unistUtilGenerated(node)) {
32493+
return
32494+
}
32495+
32496+
initial = start$6(node);
32497+
final = end$4(node);
32498+
32499+
/* No whitelisting when starting after the border, or ending before it. */
32500+
if (initial.column > style || final.column < style) {
32501+
return
32502+
}
32503+
32504+
/* No whitelisting when there’s white-space after
32505+
* the link. */
32506+
if (
32507+
next &&
32508+
start$6(next).line === initial.line &&
32509+
(!next.value || /^(.+?[ \t].+?)/.test(next.value))
32510+
) {
32511+
return
32512+
}
32513+
32514+
whitelist(initial.line - 1, final.line);
32515+
}
32516+
32517+
function ignore(node) {
32518+
/* istanbul ignore else - Hard to test, as we only run this case on `position: true` */
32519+
if (!unistUtilGenerated(node)) {
32520+
whitelist(start$6(node).line - 1, end$4(node).line);
32521+
}
32522+
}
32523+
32524+
/* Whitelist from `initial` to `final`, zero-based. */
32525+
function whitelist(initial, final) {
32526+
while (initial < final) {
32527+
lines[initial++] = '';
32528+
}
32529+
}
32530+
}
32531+
32532+
var start$7 = unistUtilPosition.start;
3248332533

3248432534

3248532535

@@ -32502,7 +32552,7 @@ function noMultipleToplevelHeadings(tree, file, pref) {
3250232552
node
3250332553
);
3250432554
} else {
32505-
duplicate = unistUtilStringifyPosition(start$6(node));
32555+
duplicate = unistUtilStringifyPosition(start$7(node));
3250632556
}
3250732557
}
3250832558
}
@@ -32664,8 +32714,8 @@ var rule$1 = unifiedLintRule;
3266432714

3266532715
var remarkLintRuleStyle = rule$1('remark-lint:rule-style', ruleStyle);
3266632716

32667-
var start$7 = unistUtilPosition.start;
32668-
var end$4 = unistUtilPosition.end;
32717+
var start$8 = unistUtilPosition.start;
32718+
var end$5 = unistUtilPosition.end;
3266932719

3267032720
function ruleStyle(tree, file, pref) {
3267132721
var contents = String(file);
@@ -32681,8 +32731,8 @@ function ruleStyle(tree, file, pref) {
3268132731
unistUtilVisit(tree, 'thematicBreak', visitor);
3268232732

3268332733
function visitor(node) {
32684-
var initial = start$7(node).offset;
32685-
var final = end$4(node).offset;
32734+
var initial = start$8(node).offset;
32735+
var final = end$5(node).offset;
3268632736
var rule;
3268732737

3268832738
if (!unistUtilGenerated(node)) {
@@ -32701,8 +32751,8 @@ function ruleStyle(tree, file, pref) {
3270132751

3270232752
var remarkLintTablePipes = unifiedLintRule('remark-lint:table-pipes', tablePipes);
3270332753

32704-
var start$8 = unistUtilPosition.start;
32705-
var end$5 = unistUtilPosition.end;
32754+
var start$9 = unistUtilPosition.start;
32755+
var end$6 = unistUtilPosition.end;
3270632756

3270732757
var reasonStart = 'Missing initial pipe in table fence';
3270832758
var reasonEnd = 'Missing final pipe in table fence';
@@ -32730,15 +32780,15 @@ function tablePipes(tree, file) {
3273032780
cells = row.children;
3273132781
head = cells[0];
3273232782
tail = cells[cells.length - 1];
32733-
initial = contents.slice(start$8(row).offset, start$8(head).offset);
32734-
final = contents.slice(end$5(tail).offset, end$5(row).offset);
32783+
initial = contents.slice(start$9(row).offset, start$9(head).offset);
32784+
final = contents.slice(end$6(tail).offset, end$6(row).offset);
3273532785

3273632786
if (initial.indexOf('|') === -1) {
32737-
file.message(reasonStart, start$8(row));
32787+
file.message(reasonStart, start$9(row));
3273832788
}
3273932789

3274032790
if (final.indexOf('|') === -1) {
32741-
file.message(reasonEnd, end$5(row));
32791+
file.message(reasonEnd, end$6(row));
3274232792
}
3274332793
}
3274432794
}
@@ -32800,8 +32850,8 @@ var remarkLintCheckboxCharacterStyle = unifiedLintRule(
3280032850
checkboxCharacterStyle
3280132851
);
3280232852

32803-
var start$9 = unistUtilPosition.start;
32804-
var end$6 = unistUtilPosition.end;
32853+
var start$10 = unistUtilPosition.start;
32854+
var end$7 = unistUtilPosition.end;
3280532855

3280632856
var checked = {x: true, X: true};
3280732857
var unchecked = {' ': true, '\t': true};
@@ -32846,8 +32896,8 @@ function checkboxCharacterStyle(tree, file, pref) {
3284632896
}
3284732897

3284832898
type = types[node.checked];
32849-
initial = start$9(node).offset;
32850-
final = (node.children.length ? start$9(node.children[0]) : end$6(node)).offset;
32899+
initial = start$10(node).offset;
32900+
final = (node.children.length ? start$10(node.children[0]) : end$7(node)).offset;
3285132901

3285232902
/* For a checkbox to be parsed, it must be followed by a white space. */
3285332903
value = contents
@@ -32881,8 +32931,8 @@ function checkboxCharacterStyle(tree, file, pref) {
3288132931

3288232932
var remarkLintCodeBlockStyle = unifiedLintRule('remark-lint:code-block-style', codeBlockStyle);
3288332933

32884-
var start$10 = unistUtilPosition.start;
32885-
var end$7 = unistUtilPosition.end;
32934+
var start$11 = unistUtilPosition.start;
32935+
var end$8 = unistUtilPosition.end;
3288632936

3288732937
var styles = {null: true, fenced: true, indented: true};
3288832938

@@ -32915,8 +32965,8 @@ function codeBlockStyle(tree, file, pref) {
3291532965

3291632966
/* Get the style of `node`. */
3291732967
function check(node) {
32918-
var initial = start$10(node).offset;
32919-
var final = end$7(node).offset;
32968+
var initial = start$11(node).offset;
32969+
var final = end$8(node).offset;
3292032970

3292132971
if (unistUtilGenerated(node)) {
3292232972
return null
@@ -33111,8 +33161,8 @@ function strongMarker(tree, file, pref) {
3311133161

3311233162
var remarkLintTableCellPadding = unifiedLintRule('remark-lint:table-cell-padding', tableCellPadding);
3311333163

33114-
var start$11 = unistUtilPosition.start;
33115-
var end$8 = unistUtilPosition.end;
33164+
var start$12 = unistUtilPosition.start;
33165+
var end$9 = unistUtilPosition.end;
3311633166

3311733167
var styles$1 = {null: true, padded: true, compact: true};
3311833168

@@ -33160,8 +33210,8 @@ function tableCellPadding(tree, file, pref) {
3316033210
next = cells[column + 1];
3316133211

3316233212
fence = contents.slice(
33163-
cell ? end$8(cell).offset : start$11(row).offset,
33164-
next ? start$11(next).offset : end$8(row).offset
33213+
cell ? end$9(cell).offset : start$12(row).offset,
33214+
next ? start$12(next).offset : end$9(row).offset
3316533215
);
3316633216

3316733217
pos = fence.indexOf('|');
@@ -33238,7 +33288,7 @@ function tableCellPadding(tree, file, pref) {
3323833288
}
3323933289

3324033290
function size(node) {
33241-
return end$8(node).offset - start$11(node).offset
33291+
return end$9(node).offset - start$12(node).offset
3324233292
}
3324333293

3324433294
var plugins$1 = [
@@ -33258,6 +33308,7 @@ var plugins$1 = [
3325833308
remarkLintNoHeadingContentIndent,
3325933309
remarkLintNoHeadingIndent,
3326033310
remarkLintNoInlinePadding,
33311+
remarkLintMaximumLineLength,
3326133312
remarkLintNoMultipleToplevelHeadings,
3326233313
remarkLintNoShellDollars,
3326333314
remarkLintNoShortcutReferenceImage,

0 commit comments

Comments
 (0)