src,tools: use template literals
authorRich Trott <rtrott@gmail.com>
Fri, 18 Mar 2016 05:04:22 +0000 (22:04 -0700)
committerMyles Borins <mborins@us.ibm.com>
Mon, 4 Apr 2016 21:29:25 +0000 (14:29 -0700)
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>
src/.eslintrc [new file with mode: 0644]
src/node.js

diff --git a/src/.eslintrc b/src/.eslintrc
new file mode 100644 (file)
index 0000000..9ec5142
--- /dev/null
@@ -0,0 +1,3 @@
+# ECMAScript-6
+# http://eslint.org/docs/rules/#ecmascript-6
+prefer-template: 2
\ No newline at end of file
index 8914e85..7301d9d 100644 (file)
     module.paths = Module._nodeModulePaths(cwd);
     var script = process._eval;
     var body = script;
-    script = 'global.__filename = ' + JSON.stringify(name) + ';\n' +
+    script = `global.__filename = ${JSON.stringify(name)};\n` +
              'global.exports = exports;\n' +
              'global.module = module;\n' +
              'global.__dirname = __dirname;\n' +
              'global.require = require;\n' +
              'return require("vm").runInThisContext(' +
-             JSON.stringify(body) + ', { filename: ' +
-             JSON.stringify(name) + ' });\n';
+             `${JSON.stringify(body)}, { filename: ` +
+             `${JSON.stringify(name)} });\n`;
     // Defer evaluation for a tick.  This is a workaround for deferred
     // events not firing when evaluating scripts from the command line,
     // see https://github.com/nodejs/node/issues/1600.
     process.nextTick(function() {
-      var result = module._compile(script, name + '-wrapper');
+      var result = module._compile(script, `${name}-wrapper`);
       if (process._print_eval) console.log(result);
     });
   }
             sig.slice(0, 3) === 'SIG') {
           err = process._kill(pid, startup.lazyConstants()[sig]);
         } else {
-          throw new Error('Unknown signal: ' + sig);
+          throw new Error(`Unknown signal: ${sig}`);
         }
       }
 
   }
 
   function NativeModule(id) {
-    this.filename = id + '.js';
+    this.filename = `${id}.js`;
     this.id = id;
     this.exports = {};
     this.loaded = false;
     }
 
     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);