Skip to content

Commit 038608d

Browse files
committed
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 <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 6986fa0 commit 038608d

File tree

7 files changed

+22
-32
lines changed

7 files changed

+22
-32
lines changed

Diff for: .eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ module.exports = {
141141
code: 80,
142142
ignorePattern: '^// Flags:',
143143
ignoreRegExpLiterals: true,
144+
ignoreTemplateLiterals: true,
144145
ignoreUrls: true,
145146
tabWidth: 2,
146147
}],

Diff for: lib/internal/util/inspect.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1551,8 +1551,9 @@ function formatMap(value, ctx, ignored, recurseTimes) {
15511551
const output = [];
15521552
ctx.indentationLvl += 2;
15531553
for (const { 0: k, 1: v } of value) {
1554-
output.push(`${formatValue(ctx, k, recurseTimes)} => ` +
1555-
formatValue(ctx, v, recurseTimes));
1554+
output.push(
1555+
`${formatValue(ctx, k, recurseTimes)} => ${formatValue(ctx, v, recurseTimes)}`
1556+
);
15561557
}
15571558
ctx.indentationLvl -= 2;
15581559
return output;
@@ -1593,8 +1594,8 @@ function formatMapIterInner(ctx, recurseTimes, entries, state) {
15931594
if (state === kWeak) {
15941595
for (; i < maxLength; i++) {
15951596
const pos = i * 2;
1596-
output[i] = `${formatValue(ctx, entries[pos], recurseTimes)}` +
1597-
` => ${formatValue(ctx, entries[pos + 1], recurseTimes)}`;
1597+
output[i] =
1598+
`${formatValue(ctx, entries[pos], recurseTimes)} => ${formatValue(ctx, entries[pos + 1], recurseTimes)}`;
15981599
}
15991600
// Sort all entries to have a halfway reliable output (if more entries than
16001601
// retrieved ones exist, we can not reliably return the same output) if the

Diff for: tools/doc/apilinks.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ inputs.forEach((file) => {
6262
const program = ast.body;
6363

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

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

Diff for: tools/doc/checkLinks.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ function checkFile(path) {
6363
if (previousDefinitionLabel &&
6464
previousDefinitionLabel > node.label) {
6565
const { line, column } = node.position.start;
66-
console.error((process.env.GITHUB_ACTIONS ?
67-
`::error file=${path},line=${line},col=${column}::` : '') +
68-
`Unordered reference at ${path}:${line}:${column} (` +
69-
`"${node.label}" should be before "${previousDefinitionLabel}")`
66+
console.error(
67+
(process.env.GITHUB_ACTIONS ? `::error file=${path},line=${line},col=${column}::` : '') +
68+
`Unordered reference at ${path}:${line}:${column} ("${node.label}" should be before "${previousDefinitionLabel}")`
7069
);
7170
process.exitCode = 1;
7271
}

Diff for: tools/doc/html.js

+10-18
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,10 @@ function linkManPages(text) {
169169
const displayAs = `<code>${name}(${number}${optionalCharacter})</code>`;
170170

171171
if (BSD_ONLY_SYSCALLS.has(name)) {
172-
return `${beginning}<a href="https://www.freebsd.org/cgi/man.cgi` +
173-
`?query=${name}&sektion=${number}">${displayAs}</a>`;
172+
return `${beginning}<a href="https://www.freebsd.org/cgi/man.cgi?query=${name}&sektion=${number}">${displayAs}</a>`;
174173
}
175174

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

@@ -212,17 +210,14 @@ function preprocessElements({ filename }) {
212210
} else if (node.type === 'code') {
213211
if (!node.lang) {
214212
console.warn(
215-
`No language set in ${filename}, ` +
216-
`line ${node.position.start.line}`);
213+
`No language set in ${filename}, line ${node.position.start.line}`
214+
);
217215
}
218216
const className = isJSFlavorSnippet(node) ?
219217
`language-js ${node.lang}` :
220218
`language-${node.lang}`;
221219
const highlighted =
222-
`<code class='${className}'>` +
223-
(getLanguage(node.lang || '') ?
224-
highlight(node.lang, node.value) : node).value +
225-
'</code>';
220+
`<code class='${className}'>${(getLanguage(node.lang || '') ? highlight(node.lang, node.value) : node).value}</code>`;
226221
node.type = 'html';
227222

228223
if (isJSFlavorSnippet(node)) {
@@ -356,8 +351,7 @@ function parseYAML(text) {
356351

357352
result += '</table>\n</details>\n';
358353
} else {
359-
result += `${added.description}${deprecated.description}` +
360-
`${removed.description}\n`;
354+
result += `${added.description}${deprecated.description}${removed.description}\n`;
361355
}
362356

363357
if (meta.napiVersion) {
@@ -420,15 +414,14 @@ function buildToc({ filename, apilinks }) {
420414
const hasStability = node.stability !== undefined;
421415
toc += ' '.repeat((depth - 1) * 2) +
422416
(hasStability ? `* <span class="stability_${node.stability}">` : '* ') +
423-
`<a href="#${isDeprecationHeading ? node.data.hProperties.id : id}">` +
424-
`${headingText}</a>${hasStability ? '</span>' : ''}\n`;
417+
`<a href="#${isDeprecationHeading ? node.data.hProperties.id : id}">${headingText}</a>${hasStability ? '</span>' : ''}\n`;
425418

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

429422
if (realFilename === 'errors' && headingText.startsWith('ERR_')) {
430-
anchor += `<span><a class="mark" href="#${headingText}" ` +
431-
`id="${headingText}">#</a></span>`;
423+
anchor +=
424+
`<span><a class="mark" href="#${headingText}" id="${headingText}">#</a></span>`;
432425
}
433426

434427
const api = headingText.replace(/^.*:\s+/, '').replace(/\(.*/, '');
@@ -478,8 +471,7 @@ function altDocs(filename, docCreated, versions) {
478471
`${host}/docs/latest-v${versionNum}/api/${filename}.html`;
479472

480473
const wrapInListItem = (version) =>
481-
`<li><a href="${getHref(version.num)}">${version.num}` +
482-
`${version.lts ? ' <b>LTS</b>' : ''}</a></li>`;
474+
`<li><a href="${getHref(version.num)}">${version.num}${version.lts ? ' <b>LTS</b>' : ''}</a></li>`;
483475

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

Diff for: tools/doc/json.js

-2
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ const callWithParams = r`\([^)]*\)`;
458458

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

461-
/* eslint-disable max-len */
462461
const headingExpressions = [
463462
{ type: 'event', re: RegExp(
464463
`${eventPrefix}${maybeBacktick}${maybeQuote}(${notQuotes})${maybeQuote}${maybeBacktick}$`, 'i') },
@@ -478,7 +477,6 @@ const headingExpressions = [
478477
{ type: 'property', re: RegExp(
479478
`^${maybeClassPropertyPrefix}${maybeBacktick}${ancestors}(${id})${maybeBacktick}$`, 'i') },
480479
];
481-
/* eslint-enable max-len */
482480

483481
function newSection(header, file) {
484482
const text = textJoin(header.children, file);

Diff for: tools/lint-sh.js

+1-2
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)