enable prefer const (#5113)

This commit is contained in:
Henry Zhu
2017-01-14 09:48:52 -05:00
committed by GitHub
parent 982850731e
commit 672adba9a1
177 changed files with 1862 additions and 1863 deletions

View File

@@ -11,7 +11,7 @@ import _ from "lodash";
import "babel-polyfill";
import register from "babel-register";
let program = new commander.Command("babel-node");
const program = new commander.Command("babel-node");
program.option("-e, --eval [script]", "Evaluate script");
program.option("-p, --print [code]", "Evaluate script and print result");
@@ -21,7 +21,7 @@ program.option("-x, --extensions [extensions]", "List of extensions to hook into
program.option("-w, --plugins [string]", "", util.list);
program.option("-b, --presets [string]", "", util.list);
let pkg = require("../package.json");
const pkg = require("../package.json");
program.version(pkg.version);
program.usage("[options] [ -e script | script.js ] [arguments]");
program.parse(process.argv);
@@ -38,7 +38,7 @@ register({
//
let replPlugin = ({ types: t }) => ({
const replPlugin = ({ types: t }) => ({
visitor: {
ModuleDeclaration(path) {
throw path.buildCodeFrameError("Modules aren't supported in the REPL");
@@ -62,7 +62,7 @@ let replPlugin = ({ types: t }) => ({
//
let _eval = function (code, filename) {
const _eval = function (code, filename) {
code = code.trim();
if (!code) return undefined;
@@ -84,7 +84,7 @@ if (program.eval || program.print) {
global.__filename = "[eval]";
global.__dirname = process.cwd();
let module = new Module(global.__filename);
const module = new Module(global.__filename);
module.filename = global.__filename;
module.paths = Module._nodeModulePaths(global.__dirname);
@@ -92,9 +92,9 @@ if (program.eval || program.print) {
global.module = module;
global.require = module.require.bind(module);
let result = _eval(code, global.__filename);
const result = _eval(code, global.__filename);
if (program.print) {
let output = _.isString(result) ? result : inspect(result);
const output = _.isString(result) ? result : inspect(result);
process.stdout.write(output + "\n");
}
} else {
@@ -111,7 +111,7 @@ if (program.eval || program.print) {
}
if (arg[0] === "-") {
let parsedArg = program[arg.slice(2)];
const parsedArg = program[arg.slice(2)];
if (parsedArg && parsedArg !== true) {
ignoreNext = true;
}
@@ -123,7 +123,7 @@ if (program.eval || program.print) {
args = args.slice(i);
// make the filename absolute
let filename = args[0];
const filename = args[0];
if (!pathIsAbsolute(filename)) args[0] = path.join(process.cwd(), filename);
// add back on node and concat the sliced args