Skip to content

Commit d86d37b

Browse files
Trotttargos
authored andcommitted
tools: relax max-len lint rule for template strings
Splitting template strings across multiple lines can make them harder to read. PR-URL: #38097 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent f2e1c22 commit d86d37b

File tree

7 files changed

+22
-32
lines changed

7 files changed

+22
-32
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ module.exports = {
163163
code: 80,
164164
ignorePattern: '^// Flags:',
165165
ignoreRegExpLiterals: true,
166+
ignoreTemplateLiterals: true,
166167
ignoreUrls: true,
167168
tabWidth: 2,
168169
}],

lib/internal/util/inspect.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,8 +1537,9 @@ function formatMap(value, ctx, ignored, recurseTimes) {
15371537
const output = [];
15381538
ctx.indentationLvl += 2;
15391539
for (const { 0: k, 1: v } of value) {
1540-
output.push(`${formatValue(ctx, k, recurseTimes)} => ` +
1541-
formatValue(ctx, v, recurseTimes));
1540+
output.push(
1541+
`${formatValue(ctx, k, recurseTimes)} => ${formatValue(ctx, v, recurseTimes)}`
1542+
);
15421543
}
15431544
ctx.indentationLvl -= 2;
15441545
return output;
@@ -1578,8 +1579,8 @@ function formatMapIterInner(ctx, recurseTimes, entries, state) {
15781579
if (state === kWeak) {
15791580
for (; i < maxLength; i++) {
15801581
const pos = i * 2;
1581-
output[i] = `${formatValue(ctx, entries[pos], recurseTimes)}` +
1582-
` => ${formatValue(ctx, entries[pos + 1], recurseTimes)}`;
1582+
output[i] =
1583+
`${formatValue(ctx, entries[pos], recurseTimes)} => ${formatValue(ctx, entries[pos + 1], recurseTimes)}`;
15831584
}
15841585
// Sort all entries to have a halfway reliable output (if more entries than
15851586
// retrieved ones exist, we can not reliably return the same output) if the

tools/doc/apilinks.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ inputs.forEach((file) => {
6161
const program = ast.body;
6262

6363
// Build link
64-
const link = `https://github.com/${repo}/blob/${tag}/` +
65-
path.relative('.', file).replace(/\\/g, '/');
64+
const link =
65+
`https://github.com/${repo}/blob/${tag}/${path.relative('.', file).replace(/\\/g, '/')}`;
6666

6767
// Scan for exports.
6868
const exported = { constructors: [], identifiers: [] };

tools/doc/checkLinks.mjs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ function checkFile(path) {
6565
if (previousDefinitionLabel &&
6666
previousDefinitionLabel > node.label) {
6767
const { line, column } = node.position.start;
68-
console.error((process.env.GITHUB_ACTIONS ?
69-
`::error file=${path},line=${line},col=${column}::` : '') +
70-
`Unordered reference at ${path}:${line}:${column} (` +
71-
`"${node.label}" should be before "${previousDefinitionLabel}")`
68+
console.error(
69+
(process.env.GITHUB_ACTIONS ? `::error file=${path},line=${line},col=${column}::` : '') +
70+
`Unordered reference at ${path}:${line}:${column} ("${node.label}" should be before "${previousDefinitionLabel}")`
7271
);
7372
process.exitCode = 1;
7473
}

tools/doc/html.mjs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,10 @@ function linkManPages(text) {
167167
const displayAs = `<code>${name}(${number}${optionalCharacter})</code>`;
168168

169169
if (BSD_ONLY_SYSCALLS.has(name)) {
170-
return `${beginning}<a href="https://www.freebsd.org/cgi/man.cgi` +
171-
`?query=${name}&sektion=${number}">${displayAs}</a>`;
170+
return `${beginning}<a href="https://www.freebsd.org/cgi/man.cgi?query=${name}&sektion=${number}">${displayAs}</a>`;
172171
}
173172

174-
return `${beginning}<a href="http://man7.org/linux/man-pages/man${number}` +
175-
`/${name}.${number}${optionalCharacter}.html">${displayAs}</a>`;
173+
return `${beginning}<a href="http://man7.org/linux/man-pages/man${number}/${name}.${number}${optionalCharacter}.html">${displayAs}</a>`;
176174
});
177175
}
178176

@@ -210,17 +208,14 @@ export function preprocessElements({ filename }) {
210208
} else if (node.type === 'code') {
211209
if (!node.lang) {
212210
console.warn(
213-
`No language set in ${filename}, ` +
214-
`line ${node.position.start.line}`);
211+
`No language set in ${filename}, line ${node.position.start.line}`
212+
);
215213
}
216214
const className = isJSFlavorSnippet(node) ?
217215
`language-js ${node.lang}` :
218216
`language-${node.lang}`;
219217
const highlighted =
220-
`<code class='${className}'>` +
221-
(getLanguage(node.lang || '') ?
222-
highlight(node.value, { language: node.lang }) : node).value +
223-
'</code>';
218+
`<code class='${className}'>${(getLanguage(node.lang || '') ? highlight(node.value, { language: node.lang }) : node).value}</code>`;
224219
node.type = 'html';
225220

226221
if (isJSFlavorSnippet(node)) {
@@ -354,8 +349,7 @@ function parseYAML(text) {
354349

355350
result += '</table>\n</details>\n';
356351
} else {
357-
result += `${added.description}${deprecated.description}` +
358-
`${removed.description}\n`;
352+
result += `${added.description}${deprecated.description}${removed.description}\n`;
359353
}
360354

361355
if (meta.napiVersion) {
@@ -418,15 +412,14 @@ export function buildToc({ filename, apilinks }) {
418412
const hasStability = node.stability !== undefined;
419413
toc += ' '.repeat((depth - 1) * 2) +
420414
(hasStability ? `* <span class="stability_${node.stability}">` : '* ') +
421-
`<a href="#${isDeprecationHeading ? node.data.hProperties.id : id}">` +
422-
`${headingText}</a>${hasStability ? '</span>' : ''}\n`;
415+
`<a href="#${isDeprecationHeading ? node.data.hProperties.id : id}">${headingText}</a>${hasStability ? '</span>' : ''}\n`;
423416

424417
let anchor =
425418
`<span><a class="mark" href="#${id}" id="${id}">#</a></span>`;
426419

427420
if (realFilename === 'errors' && headingText.startsWith('ERR_')) {
428-
anchor += `<span><a class="mark" href="#${headingText}" ` +
429-
`id="${headingText}">#</a></span>`;
421+
anchor +=
422+
`<span><a class="mark" href="#${headingText}" id="${headingText}">#</a></span>`;
430423
}
431424

432425
const api = headingText.replace(/^.*:\s+/, '').replace(/\(.*/, '');
@@ -476,8 +469,7 @@ function altDocs(filename, docCreated, versions) {
476469
`${host}/docs/latest-v${versionNum}/api/${filename}.html`;
477470

478471
const wrapInListItem = (version) =>
479-
`<li><a href="${getHref(version.num)}">${version.num}` +
480-
`${version.lts ? ' <b>LTS</b>' : ''}</a></li>`;
472+
`<li><a href="${getHref(version.num)}">${version.num}${version.lts ? ' <b>LTS</b>' : ''}</a></li>`;
481473

482474
function isDocInVersion(version) {
483475
const [versionMajor, versionMinor] = version.num.split('.').map(Number);

tools/doc/json.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ const callWithParams = r`\([^)]*\)`;
455455

456456
const maybeExtends = `(?: +extends +${maybeAncestors}${classId})?`;
457457

458-
/* eslint-disable max-len */
459458
const headingExpressions = [
460459
{ type: 'event', re: RegExp(
461460
`${eventPrefix}${maybeBacktick}${maybeQuote}(${notQuotes})${maybeQuote}${maybeBacktick}$`, 'i') },
@@ -475,7 +474,6 @@ const headingExpressions = [
475474
{ type: 'property', re: RegExp(
476475
`^${maybeClassPropertyPrefix}${maybeBacktick}${ancestors}(${id})${maybeBacktick}$`, 'i') },
477476
];
478-
/* eslint-enable max-len */
479477

480478
function newSection(header, file) {
481479
const text = textJoin(header.children, file);

tools/lint-sh.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ async function checkFiles(...files) {
138138
const data = JSON.parse(stdout);
139139
for (const { file, line, column, message } of data) {
140140
console.error(
141-
`::error file=${file},line=${line},col=${column}::` +
142-
`${file}:${line}:${column}: ${message}`
141+
`::error file=${file},line=${line},col=${column}::${file}:${line}:${column}: ${message}`
143142
);
144143
}
145144
}

0 commit comments

Comments
 (0)