Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Chore: First ES6 refactoring (refs #6407) (#6570)
First steps in taking advantage of ES6 features:

1. Remove es6-map dependency (no longer needed)
2. Use babelify to create browser bundle
3. Refactor a couple files into ES6 classes
  • Loading branch information
nzakas committed Jul 18, 2016
1 parent ec58bc7 commit c64b0c2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.yml
Expand Up @@ -2,6 +2,10 @@ root: true

env:
node: true
es6: true

parserOptions:
ecmaVersion: 6

extends:
"./packages/eslint-config-eslint/default.yml"
6 changes: 3 additions & 3 deletions Makefile.js
Expand Up @@ -688,13 +688,13 @@ target.browserify = function() {
generateRulesIndex(TEMP_DIR);

// 5. browserify the temp directory
nodeCLI.exec("browserify", "-x espree", TEMP_DIR + "eslint.js", "-o", BUILD_DIR + "eslint.js", "-s eslint");
nodeCLI.exec("browserify", "-x espree", TEMP_DIR + "eslint.js", "-o", BUILD_DIR + "eslint.js", "-s eslint", "-t [ babelify --presets [ es2015 ] ]");

// 6. Browserify espree
nodeCLI.exec("browserify", "-r espree", "-o", TEMP_DIR + "espree.js");

// 7. Concatenate the two files together
cat(TEMP_DIR + "espree.js", BUILD_DIR + "eslint.js").to(BUILD_DIR + "eslint.js");
// 7. Concatenate Babel polyfill, Espree, and ESLint files together
cat("./node_modules/babel-polyfill/dist/polyfill.js", TEMP_DIR + "espree.js", BUILD_DIR + "eslint.js").to(BUILD_DIR + "eslint.js");

// 8. remove temp directory
rm("-r", TEMP_DIR);
Expand Down
20 changes: 10 additions & 10 deletions lib/config/environments.js
Expand Up @@ -14,7 +14,7 @@ var envs = require("../../conf/environments");
// Private
//------------------------------------------------------------------------------

var environments = Object.create(null);
var environments = new Map();

/**
* Loads the default environments.
Expand All @@ -23,7 +23,7 @@ var environments = Object.create(null);
*/
function load() {
Object.keys(envs).forEach(function(envName) {
environments[envName] = envs[envName];
environments.set(envName, envs[envName]);
});
}

Expand All @@ -36,15 +36,15 @@ load();

module.exports = {

load: load,
load,

/**
* Gets the environment with the given name.
* @param {string} name The name of the environment to retrieve.
* @returns {Object?} The environment object or null if not found.
*/
get: function(name) {
return environments[name] || null;
get(name) {
return environments.get(name) || null;
},

/**
Expand All @@ -53,8 +53,8 @@ module.exports = {
* @param {Object} env The environment settings.
* @returns {void}
*/
define: function(name, env) {
environments[name] = env;
define(name, env) {
environments.set(name, env);
},

/**
Expand All @@ -63,7 +63,7 @@ module.exports = {
* @param {string} pluginName The name of the plugin.
* @returns {void}
*/
importPlugin: function(plugin, pluginName) {
importPlugin(plugin, pluginName) {
if (plugin.environments) {
Object.keys(plugin.environments).forEach(function(envName) {
this.define(pluginName + "/" + envName, plugin.environments[envName]);
Expand All @@ -75,8 +75,8 @@ module.exports = {
* Resets all environments. Only use for tests!
* @returns {void}
*/
testReset: function() {
environments = Object.create(null);
testReset() {
environments = new Map();
load();
}
};
3 changes: 1 addition & 2 deletions lib/rules/no-unmodified-loop-condition.js
Expand Up @@ -9,8 +9,7 @@
// Requirements
//------------------------------------------------------------------------------

var Map = require("es6-map"),
Traverser = require("../util/traverser"),
var Traverser = require("../util/traverser"),
astUtils = require("../ast-utils");

//------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion lib/rules/prefer-const.js
Expand Up @@ -9,7 +9,6 @@
// Requirements
//------------------------------------------------------------------------------

var Map = require("es6-map");
var lodash = require("lodash");

//------------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -40,7 +40,6 @@
"concat-stream": "^1.4.6",
"debug": "^2.1.1",
"doctrine": "^1.2.2",
"es6-map": "^0.1.3",
"escope": "^3.6.0",
"espree": "^3.1.6",
"estraverse": "^4.2.0",
Expand Down Expand Up @@ -71,6 +70,9 @@
"user-home": "^2.0.0"
},
"devDependencies": {
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babelify": "^7.3.0",
"beefy": "^2.0.0",
"brfs": "0.0.9",
"browserify": "^12.0.1",
Expand Down

0 comments on commit c64b0c2

Please sign in to comment.