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
This commit is contained in:
Miroslav Bajtoš 2017-01-27 11:29:39 +01:00
parent 450aa84ae8
commit be8dd0ded8
4 changed files with 11 additions and 10 deletions

View File

@ -1,8 +1,5 @@
{ {
"extends": "loopback", "extends": "loopback",
"parserOptions": {
"ecmaVersion": 5
},
"rules": { "rules": {
"max-len": ["error", 100, 4, { "max-len": ["error", 100, 4, {
"ignoreComments": true, "ignoreComments": true,

View File

@ -8,8 +8,8 @@
* loopback ~ public api * loopback ~ public api
*/ */
var loopback = module.exports = require('./lib/loopback'); const loopback = module.exports = require('./lib/loopback');
var datasourceJuggler = require('loopback-datasource-juggler'); const datasourceJuggler = require('loopback-datasource-juggler');
/** /**
* Connectors * Connectors

View File

@ -46,9 +46,9 @@
"ejs": "^2.3.1", "ejs": "^2.3.1",
"express": "^4.14.0", "express": "^4.14.0",
"inflection": "^1.6.0", "inflection": "^1.6.0",
"isemail": "^1.2.0",
"loopback-connector-remote": "^3.0.0", "loopback-connector-remote": "^3.0.0",
"loopback-datasource-juggler": "^3.0.0", "loopback-datasource-juggler": "^3.0.0",
"isemail": "^1.2.0",
"loopback-phase": "^1.2.0", "loopback-phase": "^1.2.0",
"nodemailer": "^2.5.0", "nodemailer": "^2.5.0",
"nodemailer-stub-transport": "^1.0.0", "nodemailer-stub-transport": "^1.0.0",
@ -60,11 +60,12 @@
"underscore.string": "^3.0.3" "underscore.string": "^3.0.3"
}, },
"devDependencies": { "devDependencies": {
"babel-preset-es2015": "^6.22.0",
"babelify": "^7.3.0",
"browserify": "^13.1.0", "browserify": "^13.1.0",
"chai": "^3.5.0", "chai": "^3.5.0",
"cookie-parser": "^1.3.4", "cookie-parser": "^1.3.4",
"dirty-chai": "^1.2.2", "dirty-chai": "^1.2.2",
"es5-shim": "^4.1.0",
"eslint-config-loopback": "^7.0.1", "eslint-config-loopback": "^7.0.1",
"express-session": "^1.14.0", "express-session": "^1.14.0",
"grunt": "^1.0.1", "grunt": "^1.0.1",
@ -78,6 +79,7 @@
"karma": "^1.1.2", "karma": "^1.1.2",
"karma-browserify": "^4.4.2", "karma-browserify": "^4.4.2",
"karma-chrome-launcher": "^1.0.1", "karma-chrome-launcher": "^1.0.1",
"karma-es6-shim": "^1.0.0",
"karma-firefox-launcher": "^1.0.0", "karma-firefox-launcher": "^1.0.0",
"karma-html2js-preprocessor": "^1.0.0", "karma-html2js-preprocessor": "^1.0.0",
"karma-junit-reporter": "~1.0.0", "karma-junit-reporter": "~1.0.0",

View File

@ -16,11 +16,10 @@ module.exports = function(config) {
basePath: '../', basePath: '../',
// testing framework to use (jasmine/mocha/qunit/...) // testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['mocha', 'browserify'], frameworks: ['es6-shim', 'browserify', 'mocha'],
// list of files / patterns to load in the browser // list of files / patterns to load in the browser
files: [ files: [
'node_modules/es5-shim/es5-shim.js',
'test/loopback.test.js', 'test/loopback.test.js',
'test/model.test.js', 'test/model.test.js',
// [rfeng] Browserified common/models/application.js // [rfeng] Browserified common/models/application.js
@ -63,6 +62,7 @@ module.exports = function(config) {
// Which plugins to enable // Which plugins to enable
plugins: [ plugins: [
'karma-browserify', 'karma-browserify',
'karma-es6-shim',
'karma-mocha', 'karma-mocha',
'karma-phantomjs-launcher', 'karma-phantomjs-launcher',
'karma-chrome-launcher', 'karma-chrome-launcher',
@ -104,7 +104,9 @@ module.exports = function(config) {
'superagent', 'superagent',
'supertest', 'supertest',
], ],
// transform: ['coffeeify'], transform: [
['babelify', {presets: 'es2015'}],
],
debug: true, debug: true,
// noParse: ['jquery'], // noParse: ['jquery'],
watch: true, watch: true,