From f7ddce30002587e1609e9acf1c8590697f6034b3 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Fri, 22 Jan 2016 10:53:16 -0400 Subject: [PATCH] Enable ES6 in JSHint - Also rename `Promise` to `Bluebird` since now JSHint complains that `Promise` is already defined. --- .jshintrc | 5 +++-- lib/src/dialog.js | 4 ++-- lib/src/drives.js | 4 ++-- lib/src/writer.js | 8 ++++---- tests/src/drives.spec.js | 10 +++++----- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.jshintrc b/.jshintrc index bce31b04..cf86db2c 100644 --- a/.jshintrc +++ b/.jshintrc @@ -19,6 +19,8 @@ // @author http://michael.haschke.biz/ // @license http://unlicense.org/ + "esversion" : 6, + // == Enforcing Options =============================================== // // These options tell JSHint to be more strict towards your code. Use @@ -53,8 +55,7 @@ "boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments. "debug" : false, // Allow debugger statements e.g. browser breakpoints. "eqnull" : false, // Tolerate use of `== null`. - "es5" : false, // Allow EcmaScript 5 syntax. - "esnext" : false, // Allow ES.next specific features such as `const` and `let`. + "esnext" : true, // Allow ES.next specific features such as `const` and `let`. "evil" : false, // Tolerate use of `eval`. "expr" : true, // Tolerate `ExpressionStatement` as Programs. "funcscope" : false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside. diff --git a/lib/src/dialog.js b/lib/src/dialog.js index 9ec73290..5b90a81e 100644 --- a/lib/src/dialog.js +++ b/lib/src/dialog.js @@ -15,7 +15,7 @@ */ var electron = require('electron'); -var Promise = require('bluebird'); +var Bluebird = require('bluebird'); var _ = require('lodash'); /** @@ -37,7 +37,7 @@ var _ = require('lodash'); exports.selectImage = function() { 'use strict'; - return new Promise(function(resolve) { + return new Bluebird(function(resolve) { electron.dialog.showOpenDialog({ properties: [ 'openFile' ], filters: [ diff --git a/lib/src/drives.js b/lib/src/drives.js index c7c75fb4..4750c33e 100644 --- a/lib/src/drives.js +++ b/lib/src/drives.js @@ -14,8 +14,8 @@ * limitations under the License. */ -var Promise = require('bluebird'); -var drivelist = Promise.promisifyAll(require('drivelist')); +var Bluebird = require('bluebird'); +var drivelist = Bluebird.promisifyAll(require('drivelist')); /** * @summary List all available removable drives diff --git a/lib/src/writer.js b/lib/src/writer.js index eef12289..288fa183 100644 --- a/lib/src/writer.js +++ b/lib/src/writer.js @@ -15,14 +15,14 @@ */ var imageWrite = require('resin-image-write'); -var Promise = require('bluebird'); -var umount = Promise.promisifyAll(require('umount')); +var Bluebird = require('bluebird'); +var umount = Bluebird.promisifyAll(require('umount')); var fs = require('fs'); var os = require('os'); var isWindows = os.platform() === 'win32'; if (isWindows) { - var removedrive = Promise.promisifyAll(require('removedrive')); + var removedrive = Bluebird.promisifyAll(require('removedrive')); } /** @@ -79,7 +79,7 @@ exports.writeImage = function(image, drive, onProgress) { var stream = exports.getImageStream(image); return imageWrite.write(drive.device, stream); }).then(function(writer) { - return new Promise(function(resolve, reject) { + return new Bluebird(function(resolve, reject) { writer.on('progress', onProgress); writer.on('error', reject); writer.on('done', resolve); diff --git a/tests/src/drives.spec.js b/tests/src/drives.spec.js index f089758f..f56c9c65 100644 --- a/tests/src/drives.spec.js +++ b/tests/src/drives.spec.js @@ -1,5 +1,5 @@ var m = require('mochainon'); -var Promise = require('bluebird'); +var Bluebird = require('bluebird'); var drivelist = require('drivelist'); var drives = require('../../lib/src/drives'); @@ -12,7 +12,7 @@ describe('Drives:', function() { beforeEach(function() { this.drivesListStub = m.sinon.stub(drivelist, 'listAsync'); - this.drivesListStub.returns(Promise.resolve([])); + this.drivesListStub.returns(Bluebird.resolve([])); }); afterEach(function() { @@ -40,7 +40,7 @@ describe('Drives:', function() { ]; this.drivesListStub = m.sinon.stub(drivelist, 'listAsync'); - this.drivesListStub.returns(Promise.resolve(this.drives)); + this.drivesListStub.returns(Bluebird.resolve(this.drives)); }); afterEach(function() { @@ -82,7 +82,7 @@ describe('Drives:', function() { ]; this.drivesListStub = m.sinon.stub(drivelist, 'listAsync'); - this.drivesListStub.returns(Promise.resolve(this.drives)); + this.drivesListStub.returns(Bluebird.resolve(this.drives)); }); afterEach(function() { @@ -115,7 +115,7 @@ describe('Drives:', function() { beforeEach(function() { this.drivesListStub = m.sinon.stub(drivelist, 'listAsync'); - this.drivesListStub.returns(Promise.reject(new Error('scan error'))); + this.drivesListStub.returns(Bluebird.reject(new Error('scan error'))); }); afterEach(function() {