Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: relax max-len lint rule for template strings #38097

Merged
merged 1 commit into from
Apr 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Trott committed Apr 7, 2021
commit 038608d40105db8447afdf8a1b823eafe98b8a75
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -141,6 +141,7 @@ module.exports = {
code: 80,
ignorePattern: '^// Flags:',
ignoreRegExpLiterals: true,
ignoreTemplateLiterals: true,
ignoreUrls: true,
tabWidth: 2,
}],
9 changes: 5 additions & 4 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
@@ -1551,8 +1551,9 @@ function formatMap(value, ctx, ignored, recurseTimes) {
const output = [];
ctx.indentationLvl += 2;
for (const { 0: k, 1: v } of value) {
output.push(`${formatValue(ctx, k, recurseTimes)} => ` +
formatValue(ctx, v, recurseTimes));
output.push(
`${formatValue(ctx, k, recurseTimes)} => ${formatValue(ctx, v, recurseTimes)}`
);
}
ctx.indentationLvl -= 2;
return output;
@@ -1593,8 +1594,8 @@ function formatMapIterInner(ctx, recurseTimes, entries, state) {
if (state === kWeak) {
for (; i < maxLength; i++) {
const pos = i * 2;
output[i] = `${formatValue(ctx, entries[pos], recurseTimes)}` +
` => ${formatValue(ctx, entries[pos + 1], recurseTimes)}`;
output[i] =
`${formatValue(ctx, entries[pos], recurseTimes)} => ${formatValue(ctx, entries[pos + 1], recurseTimes)}`;
}
// Sort all entries to have a halfway reliable output (if more entries than
// retrieved ones exist, we can not reliably return the same output) if the
4 changes: 2 additions & 2 deletions tools/doc/apilinks.js
Original file line number Diff line number Diff line change
@@ -62,8 +62,8 @@ inputs.forEach((file) => {
const program = ast.body;

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

// Scan for exports.
const exported = { constructors: [], identifiers: [] };
7 changes: 3 additions & 4 deletions tools/doc/checkLinks.js
Original file line number Diff line number Diff line change
@@ -63,10 +63,9 @@ function checkFile(path) {
if (previousDefinitionLabel &&
previousDefinitionLabel > node.label) {
const { line, column } = node.position.start;
console.error((process.env.GITHUB_ACTIONS ?
`::error file=${path},line=${line},col=${column}::` : '') +
`Unordered reference at ${path}:${line}:${column} (` +
`"${node.label}" should be before "${previousDefinitionLabel}")`
console.error(
(process.env.GITHUB_ACTIONS ? `::error file=${path},line=${line},col=${column}::` : '') +
`Unordered reference at ${path}:${line}:${column} ("${node.label}" should be before "${previousDefinitionLabel}")`
);
process.exitCode = 1;
}
28 changes: 10 additions & 18 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
@@ -169,12 +169,10 @@ function linkManPages(text) {
const displayAs = `<code>${name}(${number}${optionalCharacter})</code>`;

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

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

@@ -212,17 +210,14 @@ function preprocessElements({ filename }) {
} else if (node.type === 'code') {
if (!node.lang) {
console.warn(
`No language set in ${filename}, ` +
`line ${node.position.start.line}`);
`No language set in ${filename}, line ${node.position.start.line}`
);
}
const className = isJSFlavorSnippet(node) ?
`language-js ${node.lang}` :
`language-${node.lang}`;
const highlighted =
`<code class='${className}'>` +
(getLanguage(node.lang || '') ?
highlight(node.lang, node.value) : node).value +
'</code>';
`<code class='${className}'>${(getLanguage(node.lang || '') ? highlight(node.lang, node.value) : node).value}</code>`;
node.type = 'html';

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

result += '</table>\n</details>\n';
} else {
result += `${added.description}${deprecated.description}` +
`${removed.description}\n`;
result += `${added.description}${deprecated.description}${removed.description}\n`;
}

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

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

if (realFilename === 'errors' && headingText.startsWith('ERR_')) {
anchor += `<span><a class="mark" href="#${headingText}" ` +
`id="${headingText}">#</a></span>`;
anchor +=
`<span><a class="mark" href="#${headingText}" id="${headingText}">#</a></span>`;
}

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

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

function isDocInVersion(version) {
const [versionMajor, versionMinor] = version.num.split('.').map(Number);
2 changes: 0 additions & 2 deletions tools/doc/json.js
Original file line number Diff line number Diff line change
@@ -458,7 +458,6 @@ const callWithParams = r`\([^)]*\)`;

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

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

function newSection(header, file) {
const text = textJoin(header.children, file);
3 changes: 1 addition & 2 deletions tools/lint-sh.js
Original file line number Diff line number Diff line change
@@ -138,8 +138,7 @@ async function checkFiles(...files) {
const data = JSON.parse(stdout);
for (const { file, line, column, message } of data) {
console.error(
`::error file=${file},line=${line},col=${column}::` +
`${file}:${line}:${column}: ${message}`
`::error file=${file},line=${line},col=${column}::${file}:${line}:${column}: ${message}`
);
}
}