From be8dd0ded8a8ea7f8609766ffe529abdfb81783a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Fri, 27 Jan 2017 11:29:39 +0100 Subject: [PATCH] Enable ES6/ES2015 goodness - Remove ES5 parser exception from .eslintrc - Configure Karma to use Babel to transpile ES6 sources to ES5, because PhantomJS does not support ES6 - Upgrade es5-shim to es6-shim --- .eslintrc | 3 --- index.js | 4 ++-- package.json | 6 ++++-- test/karma.conf.js | 8 +++++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.eslintrc b/.eslintrc index 8e2160a9..f3fa72da 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,8 +1,5 @@ { "extends": "loopback", - "parserOptions": { - "ecmaVersion": 5 - }, "rules": { "max-len": ["error", 100, 4, { "ignoreComments": true, diff --git a/index.js b/index.js index 35dd82f5..ec3d87e6 100644 --- a/index.js +++ b/index.js @@ -8,8 +8,8 @@ * loopback ~ public api */ -var loopback = module.exports = require('./lib/loopback'); -var datasourceJuggler = require('loopback-datasource-juggler'); +const loopback = module.exports = require('./lib/loopback'); +const datasourceJuggler = require('loopback-datasource-juggler'); /** * Connectors diff --git a/package.json b/package.json index 3b6f7d9b..fdf38684 100644 --- a/package.json +++ b/package.json @@ -46,9 +46,9 @@ "ejs": "^2.3.1", "express": "^4.14.0", "inflection": "^1.6.0", + "isemail": "^1.2.0", "loopback-connector-remote": "^3.0.0", "loopback-datasource-juggler": "^3.0.0", - "isemail": "^1.2.0", "loopback-phase": "^1.2.0", "nodemailer": "^2.5.0", "nodemailer-stub-transport": "^1.0.0", @@ -60,11 +60,12 @@ "underscore.string": "^3.0.3" }, "devDependencies": { + "babel-preset-es2015": "^6.22.0", + "babelify": "^7.3.0", "browserify": "^13.1.0", "chai": "^3.5.0", "cookie-parser": "^1.3.4", "dirty-chai": "^1.2.2", - "es5-shim": "^4.1.0", "eslint-config-loopback": "^7.0.1", "express-session": "^1.14.0", "grunt": "^1.0.1", @@ -78,6 +79,7 @@ "karma": "^1.1.2", "karma-browserify": "^4.4.2", "karma-chrome-launcher": "^1.0.1", + "karma-es6-shim": "^1.0.0", "karma-firefox-launcher": "^1.0.0", "karma-html2js-preprocessor": "^1.0.0", "karma-junit-reporter": "~1.0.0", diff --git a/test/karma.conf.js b/test/karma.conf.js index d9000f4c..16e5af0e 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -16,11 +16,10 @@ module.exports = function(config) { basePath: '../', // testing framework to use (jasmine/mocha/qunit/...) - frameworks: ['mocha', 'browserify'], + frameworks: ['es6-shim', 'browserify', 'mocha'], // list of files / patterns to load in the browser files: [ - 'node_modules/es5-shim/es5-shim.js', 'test/loopback.test.js', 'test/model.test.js', // [rfeng] Browserified common/models/application.js @@ -63,6 +62,7 @@ module.exports = function(config) { // Which plugins to enable plugins: [ 'karma-browserify', + 'karma-es6-shim', 'karma-mocha', 'karma-phantomjs-launcher', 'karma-chrome-launcher', @@ -104,7 +104,9 @@ module.exports = function(config) { 'superagent', 'supertest', ], - // transform: ['coffeeify'], + transform: [ + ['babelify', {presets: 'es2015'}], + ], debug: true, // noParse: ['jquery'], watch: true,