Skip to content

Commit

Permalink
Add eslint no-var check. Closes #11.
Browse files Browse the repository at this point in the history
  • Loading branch information
chambrid committed Sep 6, 2016
1 parent a2944c6 commit 2d92bb7
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 42 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"single"
],
"max-len": 0,
"no-var": "error",
"semi": [
"error",
"always"
Expand Down
4 changes: 2 additions & 2 deletions src/lib/virtualservers.entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const nlcconfig = require('hubot-ibmcloud-cognitive-lib').nlcconfig;
const NAMESPACE = 'IBMcloudVirtualservers';
const PARAM_VSNAME = 'vsname';

var functionsRegistered = false;
let functionsRegistered = false;


function buildGlobalName(parameterName) {
Expand All @@ -32,7 +32,7 @@ function registerEntityFunctions() {
function getVirtualServerNames(robot, res, parameterName, parameters) {
return new Promise(function(resolve, reject) {
vs.getServers().then((result) => {
var vsNames = result.map(function(virtualserver){
let vsNames = result.map(function(virtualserver){
return virtualserver.name;
});
nlcconfig.updateGlobalParameterValues(buildGlobalName(PARAM_VSNAME), vsNames);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/vs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'use strict';
const pkgcloud = require('pkgcloud');

var env = {
const env = {
username: process.env.HUBOT_BLUEMIX_USER,
password: process.env.HUBOT_BLUEMIX_PASSWORD,
provider: process.env.HUBOT_VIRTUAL_SERVER_PROVIDER || 'openstack',
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/virtualservers.destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
'use strict';

var path = require('path');
var TAG = path.basename(__filename);
const path = require('path');
const TAG = path.basename(__filename);

const vs = require('../lib/vs');
const utils = require('hubot-ibmcloud-utils').utils;
Expand All @@ -30,7 +30,7 @@ const entities = require('../lib/virtualservers.entities');
// It will read from a peer messages.json file. Later, these
// messages can be referenced throughout the module.
// --------------------------------------------------------------
var i18n = new (require('i18n-2'))({
const i18n = new (require('i18n-2'))({
locales: ['en'],
extension: '.json',
// Add more languages to the list of locales when the files are created.
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/virtualservers.help.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
*/
'use strict';

var path = require('path');
var TAG = path.basename(__filename);
const path = require('path');
const TAG = path.basename(__filename);

// --------------------------------------------------------------
// i18n (internationalization)
// It will read from a peer messages.json file. Later, these
// messages can be referenced throughout the module.
// --------------------------------------------------------------
var i18n = new (require('i18n-2'))({
const i18n = new (require('i18n-2'))({
locales: ['en'],
extension: '.json',
// Add more languages to the list of locales when the files are created.
Expand Down
8 changes: 4 additions & 4 deletions src/scripts/virtualservers.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
'use strict';

var path = require('path');
var TAG = path.basename(__filename);
const path = require('path');
const TAG = path.basename(__filename);

const vs = require('../lib/vs');
const palette = require('hubot-ibmcloud-utils').palette;
Expand All @@ -28,7 +28,7 @@ const activity = require('hubot-ibmcloud-activity-emitter');
// It will read from a peer messages.json file. Later, these
// messages can be referenced throughout the module.
// --------------------------------------------------------------
var i18n = new (require('i18n-2'))({
const i18n = new (require('i18n-2'))({
locales: ['en'],
extension: '.json',
// Add more languages to the list of locales when the files are created.
Expand Down Expand Up @@ -81,7 +81,7 @@ module.exports = (robot) => {
return attachment;
});

var vsNames = servers.map(function(server){
let vsNames = servers.map(function(server){
return server.name;
});
nlcconfig.updateGlobalParameterValues('IBMcloudVirtualservers_vsname', vsNames);
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/virtualservers.reboot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
'use strict';

var path = require('path');
var TAG = path.basename(__filename);
const path = require('path');
const TAG = path.basename(__filename);

const vs = require('../lib/vs');
const utils = require('hubot-ibmcloud-utils').utils;
Expand All @@ -30,7 +30,7 @@ const entities = require('../lib/virtualservers.entities');
// It will read from a peer messages.json file. Later, these
// messages can be referenced throughout the module.
// --------------------------------------------------------------
var i18n = new (require('i18n-2'))({
const i18n = new (require('i18n-2'))({
locales: ['en'],
extension: '.json',
// Add more languages to the list of locales when the files are created.
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/virtualservers.start.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
'use strict';

var path = require('path');
var TAG = path.basename(__filename);
const path = require('path');
const TAG = path.basename(__filename);

const vs = require('../lib/vs');
const activity = require('hubot-ibmcloud-activity-emitter');
Expand All @@ -28,7 +28,7 @@ const entities = require('../lib/virtualservers.entities');
// It will read from a peer messages.json file. Later, these
// messages can be referenced throughout the module.
// --------------------------------------------------------------
var i18n = new (require('i18n-2'))({
const i18n = new (require('i18n-2'))({
locales: ['en'],
extension: '.json',
// Add more languages to the list of locales when the files are created.
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/virtualservers.stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
'use strict';

var path = require('path');
var TAG = path.basename(__filename);
const path = require('path');
const TAG = path.basename(__filename);

const vs = require('../lib/vs');
const utils = require('hubot-ibmcloud-utils').utils;
Expand All @@ -30,7 +30,7 @@ const entities = require('../lib/virtualservers.entities');
// It will read from a peer messages.json file. Later, these
// messages can be referenced throughout the module.
// --------------------------------------------------------------
var i18n = new (require('i18n-2'))({
const i18n = new (require('i18n-2'))({
locales: ['en'],
extension: '.json',
// Add more languages to the list of locales when the files are created.
Expand Down
38 changes: 19 additions & 19 deletions test/bluemix.vs.cognitive.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const helper = new Helper('../src/scripts');
const expect = require('chai').expect;
const mockUtils = require('./mock.utils.vs.js');

var i18n = new (require('i18n-2'))({
const i18n = new (require('i18n-2'))({
locales: ['en'],
extension: '.json',
// Add more languages to the list of locales when the files are created.
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
}
});

var res = { message: {text: 'list my virtual servers', user: {id: 'mimiron'}}, response: room };
let res = { message: {text: 'list my virtual servers', user: {id: 'mimiron'}}, response: room };
room.robot.emit('bluemix.vs.list', res, {});
});
});
Expand All @@ -64,7 +64,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
done();
});

var res = { message: {text: 'Start virtual server unknownServer', user: {id: 'mimiron'}}, response: room };
let res = { message: {text: 'Start virtual server unknownServer', user: {id: 'mimiron'}}, response: room };
room.robot.emit('bluemix.vs.start', res, {vsname: 'unknownServer'});
});

Expand All @@ -78,7 +78,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
done();
});

var res = { message: {text: 'Start my virtual server new-server-test2', user: {id: 'mimiron'}}, response: room };
let res = { message: {text: 'Start my virtual server new-server-test2', user: {id: 'mimiron'}}, response: room };
room.robot.emit('bluemix.vs.start', res, {vsname: 'new-server-test2'});
});

Expand All @@ -91,13 +91,13 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
}
});

var res = { message: {text: 'start virtual server', user: {id: 'mimiron'}}, response: room };
let res = { message: {text: 'start virtual server', user: {id: 'mimiron'}}, response: room };
room.robot.emit('bluemix.vs.start', res, {});
});
});

context('user calls `virtual server stop`', function() {
var replyFn = function(msg){
let replyFn = function(msg){
if (msg.indexOf('Are you sure that you want to stop') >= 0) {
return room.user.say('mimiron', 'yes');
}
Expand All @@ -113,7 +113,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
done();
});

var res = { message: {text: 'Stop virtual server unknownServer', user: {id: 'mimiron'}}, response: room, reply: replyFn };
let res = { message: {text: 'Stop virtual server unknownServer', user: {id: 'mimiron'}}, response: room, reply: replyFn };
room.robot.emit('bluemix.vs.stop', res, {vsname: 'unknownServer'});
});

Expand All @@ -127,7 +127,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
done();
});

var res = { message: {text: 'Stop virtual server new-server-test', user: {id: 'mimiron'}}, response: room, reply: replyFn };
let res = { message: {text: 'Stop virtual server new-server-test', user: {id: 'mimiron'}}, response: room, reply: replyFn };
room.robot.emit('bluemix.vs.stop', res, {vsname: 'new-server-test'});
});

Expand All @@ -140,13 +140,13 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
}
});

var res = { message: {text: 'stop virtual server', user: {id: 'mimiron'}}, response: room };
let res = { message: {text: 'stop virtual server', user: {id: 'mimiron'}}, response: room };
room.robot.emit('bluemix.vs.stop', res, {});
});
});

context('user calls `virtual server destroy`', function() {
var replyFn = function(msg){
let replyFn = function(msg){
if (msg.indexOf('Are you sure that you want to destroy') >= 0) {
return room.user.say('mimiron', 'yes');
}
Expand All @@ -159,7 +159,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
done();
});

var res = { message: {text: 'Destroy virtual server unknownServer', user: {id: 'mimiron'}}, response: room, reply: replyFn };
let res = { message: {text: 'Destroy virtual server unknownServer', user: {id: 'mimiron'}}, response: room, reply: replyFn };
room.robot.emit('bluemix.vs.destroy', res, {vsname: 'unknownServer'});
});

Expand All @@ -170,7 +170,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
done();
});

var res = { message: {text: 'Destroy virtual server new-server-test', user: {id: 'mimiron'}}, response: room, reply: replyFn };
let res = { message: {text: 'Destroy virtual server new-server-test', user: {id: 'mimiron'}}, response: room, reply: replyFn };
room.robot.emit('bluemix.vs.destroy', res, {vsname: 'new-server-test'});
});

Expand All @@ -183,13 +183,13 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
}
});

var res = { message: {text: 'destroy virtual server', user: {id: 'mimiron'}}, response: room };
let res = { message: {text: 'destroy virtual server', user: {id: 'mimiron'}}, response: room };
room.robot.emit('bluemix.vs.destroy', res, {});
});
});

context('user calls `virtual server reboot`', function() {
var replyFn = function(msg){
let replyFn = function(msg){
if (msg.indexOf('Are you sure that you want to reboot') >= 0) {
return room.user.say('mimiron', 'yes');
}
Expand All @@ -202,7 +202,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
done();
});

var res = { message: {text: 'Reboot virtual server unknownServer', user: {id: 'mimiron'}}, response: room, reply: replyFn };
let res = { message: {text: 'Reboot virtual server unknownServer', user: {id: 'mimiron'}}, response: room, reply: replyFn };
room.robot.emit('bluemix.vs.reboot', res, {vsname: 'unknownServer'});
});

Expand All @@ -213,7 +213,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
done();
});

var res = { message: {text: 'Reboot virtual server new-server-test', user: {id: 'mimiron'}}, response: room, reply: replyFn };
let res = { message: {text: 'Reboot virtual server new-server-test', user: {id: 'mimiron'}}, response: room, reply: replyFn };
room.robot.emit('bluemix.vs.reboot', res, {vsname: 'new-server-test'});
});

Expand All @@ -226,7 +226,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
}
});

var res = { message: {text: 'reboot virtual server', user: {id: 'mimiron'}}, response: room };
let res = { message: {text: 'reboot virtual server', user: {id: 'mimiron'}}, response: room };
room.robot.emit('bluemix.vs.reboot', res, {});
});
});
Expand All @@ -245,7 +245,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {
}
});

var res = { message: {text: 'help virtual server', user: {id: 'mimiron'}}, response: room };
let res = { message: {text: 'help virtual server', user: {id: 'mimiron'}}, response: room };
room.robot.emit('bluemix.vs.help', res, {});
});
});
Expand All @@ -254,7 +254,7 @@ describe('Interacting with Virtual Servers via Natural Language -', function() {

it('should retrieve set of virtual server names', function(done) {
const entities = require('../src/lib/virtualservers.entities');
var res = { message: {text: '', user: {id: 'mimiron'}}, response: room };
let res = { message: {text: '', user: {id: 'mimiron'}}, response: room };
entities.getVirtualServerNames(room.robot, res, 'vsname', {}).then(function(vsNames) {
expect(vsNames.length).to.eql(2);
done();
Expand Down
2 changes: 1 addition & 1 deletion test/bluemix.vs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const sprinkles = require('mocha-sprinkles');
// It will read from a peer messages.json file. Later, these
// messages can be referenced throughout the module.
// --------------------------------------------------------------
var i18n = new (require('i18n-2'))({
const i18n = new (require('i18n-2'))({
locales: ['en'],
extension: '.json',
// Add more languages to the list of locales when the files are created.
Expand Down

0 comments on commit 2d92bb7

Please sign in to comment.