mirror of https://github.com/nodejs/node.git
src,tools: use template literals
Convert string concatenation to template literals. Enforce with lint rule. PR-URL: https://github.com/nodejs/node/pull/5778 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu>pull/5778/merge
parent
e5f8a6a2fa
commit
f158a8662d
|
@ -1,3 +1,6 @@
|
||||||
rules:
|
rules:
|
||||||
|
# ECMAScript-6
|
||||||
|
# http://eslint.org/docs/rules/#ecmascript-6
|
||||||
|
prefer-template: 2
|
||||||
# Custom rules in tools/eslint-rules
|
# Custom rules in tools/eslint-rules
|
||||||
buffer-constructor: 2
|
buffer-constructor: 2
|
||||||
|
|
16
src/node.js
16
src/node.js
|
@ -566,19 +566,19 @@
|
||||||
module.paths = Module._nodeModulePaths(cwd);
|
module.paths = Module._nodeModulePaths(cwd);
|
||||||
var script = process._eval;
|
var script = process._eval;
|
||||||
var body = script;
|
var body = script;
|
||||||
script = 'global.__filename = ' + JSON.stringify(name) + ';\n' +
|
script = `global.__filename = ${JSON.stringify(name)};\n` +
|
||||||
'global.exports = exports;\n' +
|
'global.exports = exports;\n' +
|
||||||
'global.module = module;\n' +
|
'global.module = module;\n' +
|
||||||
'global.__dirname = __dirname;\n' +
|
'global.__dirname = __dirname;\n' +
|
||||||
'global.require = require;\n' +
|
'global.require = require;\n' +
|
||||||
'return require("vm").runInThisContext(' +
|
'return require("vm").runInThisContext(' +
|
||||||
JSON.stringify(body) + ', { filename: ' +
|
`${JSON.stringify(body)}, { filename: ` +
|
||||||
JSON.stringify(name) + ', displayErrors: true });\n';
|
`${JSON.stringify(name)}, displayErrors: true });\n`;
|
||||||
// Defer evaluation for a tick. This is a workaround for deferred
|
// Defer evaluation for a tick. This is a workaround for deferred
|
||||||
// events not firing when evaluating scripts from the command line,
|
// events not firing when evaluating scripts from the command line,
|
||||||
// see https://github.com/nodejs/node/issues/1600.
|
// see https://github.com/nodejs/node/issues/1600.
|
||||||
process.nextTick(function() {
|
process.nextTick(function() {
|
||||||
var result = module._compile(script, name + '-wrapper');
|
var result = module._compile(script, `${name}-wrapper`);
|
||||||
if (process._print_eval) console.log(result);
|
if (process._print_eval) console.log(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -770,7 +770,7 @@
|
||||||
sig.slice(0, 3) === 'SIG') {
|
sig.slice(0, 3) === 'SIG') {
|
||||||
err = process._kill(pid, startup.lazyConstants()[sig]);
|
err = process._kill(pid, startup.lazyConstants()[sig]);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Unknown signal: ' + sig);
|
throw new Error(`Unknown signal: ${sig}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,7 +875,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function NativeModule(id) {
|
function NativeModule(id) {
|
||||||
this.filename = id + '.js';
|
this.filename = `${id}.js`;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.exports = {};
|
this.exports = {};
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
|
@ -895,10 +895,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NativeModule.exists(id)) {
|
if (!NativeModule.exists(id)) {
|
||||||
throw new Error('No such native module ' + id);
|
throw new Error(`No such native module ${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.moduleLoadList.push('NativeModule ' + id);
|
process.moduleLoadList.push(`NativeModule ${id}`);
|
||||||
|
|
||||||
var nativeModule = new NativeModule(id);
|
var nativeModule = new NativeModule(id);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue