tools: replace concat with template literals

PR-URL: https://github.com/nodejs/node/pull/16046
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Lance Ball <lball@redhat.com>
This commit is contained in:
Minya Liang 2017-10-06 12:40:47 -05:00 committed by Ruben Bridgewater
parent be3ac440dc
commit 9f98989484
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762

View File

@ -32,7 +32,7 @@ const marked = require('marked');
// customized heading without id attribute // customized heading without id attribute
const renderer = new marked.Renderer(); const renderer = new marked.Renderer();
renderer.heading = function(text, level) { renderer.heading = function(text, level) {
return '<h' + level + '>' + text + '</h' + level + '>\n'; return `<h${level}>${text}</h${level}>\n`;
}; };
marked.setOptions({ marked.setOptions({
renderer: renderer renderer: renderer
@ -246,25 +246,25 @@ function processList(section) {
} else if (type === 'list_item_end') { } else if (type === 'list_item_end') {
if (!current) { if (!current) {
throw new Error('invalid list - end without current item\n' + throw new Error('invalid list - end without current item\n' +
JSON.stringify(tok) + '\n' + `${JSON.stringify(tok)}\n` +
JSON.stringify(list)); JSON.stringify(list));
} }
current = stack.pop(); current = stack.pop();
} else if (type === 'text') { } else if (type === 'text') {
if (!current) { if (!current) {
throw new Error('invalid list - text without current item\n' + throw new Error('invalid list - text without current item\n' +
JSON.stringify(tok) + '\n' + `${JSON.stringify(tok)}\n` +
JSON.stringify(list)); JSON.stringify(list));
} }
current.textRaw = current.textRaw || ''; current.textRaw = current.textRaw || '';
current.textRaw += tok.text + ' '; current.textRaw += `${tok.text} `;
} }
}); });
// shove the name in there for properties, since they are always // shove the name in there for properties, since they are always
// just going to be the value etc. // just going to be the value etc.
if (section.type === 'property' && values[0]) { if (section.type === 'property' && values[0]) {
values[0].textRaw = '`' + section.name + '` ' + values[0].textRaw; values[0].textRaw = `\`${section.name}\` ${values[0].textRaw}`;
} }
// now pull the actual values out of the text bits. // now pull the actual values out of the text bits.
@ -362,8 +362,8 @@ function parseSignature(text, sig) {
// at this point, the name should match. // at this point, the name should match.
if (p !== param.name) { if (p !== param.name) {
console.error('Warning: invalid param "%s"', p); console.error('Warning: invalid param "%s"', p);
console.error(' > ' + JSON.stringify(param)); console.error(` > ${JSON.stringify(param)}`);
console.error(' > ' + text); console.error(` > ${text}`);
} }
if (optional) param.optional = true; if (optional) param.optional = true;
if (def !== undefined) param.default = def; if (def !== undefined) param.default = def;
@ -428,7 +428,7 @@ function parseListItem(item) {
function finishSection(section, parent) { function finishSection(section, parent) {
if (!section || !parent) { if (!section || !parent) {
throw new Error('Invalid finishSection call\n' + throw new Error('Invalid finishSection call\n' +
JSON.stringify(section) + '\n' + `${JSON.stringify(section)}\n` +
JSON.stringify(parent)); JSON.stringify(parent));
} }
@ -488,11 +488,11 @@ function finishSection(section, parent) {
var plur; var plur;
if (section.type.slice(-1) === 's') { if (section.type.slice(-1) === 's') {
plur = section.type + 'es'; plur = `${section.type}es`;
} else if (section.type.slice(-1) === 'y') { } else if (section.type.slice(-1) === 'y') {
plur = section.type.replace(/y$/, 'ies'); plur = section.type.replace(/y$/, 'ies');
} else { } else {
plur = section.type + 's'; plur = `${section.type}s`;
} }
// if the parent's type is 'misc', then it's just a random // if the parent's type is 'misc', then it's just a random