Skip to content

Commit 4f683ab

Browse files
TrottMyles Borins
authored andcommitted
src,tools: use template literals
Convert string concatenation to template literals. Enforce with lint rule. PR-URL: #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>
1 parent 200f763 commit 4f683ab

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎src/.eslintrc‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ECMAScript-6
2+
# http://eslint.org/docs/rules/#ecmascript-6
3+
prefer-template: 2

‎src/node.js‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -564,19 +564,19 @@
564564
module.paths=Module._nodeModulePaths(cwd);
565565
varscript=process._eval;
566566
varbody=script;
567-
script='global.__filename = '+JSON.stringify(name)+';\n'+
567+
script=`global.__filename = ${JSON.stringify(name)};\n`+
568568
'global.exports = exports;\n'+
569569
'global.module = module;\n'+
570570
'global.__dirname = __dirname;\n'+
571571
'global.require = require;\n'+
572572
'return require("vm").runInThisContext('+
573-
JSON.stringify(body)+', { filename: '+
574-
JSON.stringify(name)+' });\n';
573+
`${JSON.stringify(body)}, { filename: `+
574+
`${JSON.stringify(name)}});\n`;
575575
// Defer evaluation for a tick. This is a workaround for deferred
576576
// events not firing when evaluating scripts from the command line,
577577
// see https://github.com/nodejs/node/issues/1600.
578578
process.nextTick(function(){
579-
varresult=module._compile(script,name+'-wrapper');
579+
varresult=module._compile(script,`${name}-wrapper`);
580580
if(process._print_eval)console.log(result);
581581
});
582582
}
@@ -768,7 +768,7 @@
768768
sig.slice(0,3)==='SIG'){
769769
err=process._kill(pid,startup.lazyConstants()[sig]);
770770
}else{
771-
thrownewError('Unknown signal: '+sig);
771+
thrownewError(`Unknown signal: ${sig}`);
772772
}
773773
}
774774

@@ -873,7 +873,7 @@
873873
}
874874

875875
functionNativeModule(id){
876-
this.filename=id+'.js';
876+
this.filename=`${id}.js`;
877877
this.id=id;
878878
this.exports={};
879879
this.loaded=false;
@@ -893,10 +893,10 @@
893893
}
894894

895895
if(!NativeModule.exists(id)){
896-
thrownewError('No such native module '+id);
896+
thrownewError(`No such native module ${id}`);
897897
}
898898

899-
process.moduleLoadList.push('NativeModule '+id);
899+
process.moduleLoadList.push(`NativeModule ${id}`);
900900

901901
varnativeModule=newNativeModule(id);
902902

0 commit comments

Comments
 (0)