Skip to content

Commit

Permalink
Merge pull request #703 from eapearson/develop
Browse files Browse the repository at this point in the history
tighten eslint rules, and resulting codebase changes
  • Loading branch information
eapearson committed Jun 21, 2018
2 parents f2d8462 + 655b313 commit cfc143b
Show file tree
Hide file tree
Showing 59 changed files with 556 additions and 542 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules/
/bower_components/
/build/
/deployment/
**/*.js
!/src/**/*.js
26 changes: 26 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,29 @@ rules:
- allow:
- warn
- error
# stylistic
no-trailing-spaces:
- error
space-before-function-paren:
- error
-
anonymous: always
named: never
asyncArrow: always
space-in-parens:
- error
- never
func-call-spacing:
- error
- never
keyword-spacing:
- error
-
before: true
after: true
no-fallthrough:
- error
-
commentPattern: fallthrough
prefer-const:
- error
2 changes: 1 addition & 1 deletion config/app/dev/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ plugins:
-
name: narrative-info
globalName: kbase-ui-plugin-narrative-info
version: 1.1.3
version: 1.1.4
cwd: src/plugin
source:
bower: {}
Expand Down
2 changes: 1 addition & 1 deletion config/app/prod/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ plugins:
-
name: narrative-info
globalName: kbase-ui-plugin-narrative-info
version: 1.1.3
version: 1.1.4
cwd: src/plugin
source:
bower: {}
Expand Down
2 changes: 1 addition & 1 deletion src/client/modules/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ define([
}

function checkCoreServices() {
let manager = new kbaseServiceManager.KBaseServiceManager({
const manager = new kbaseServiceManager.KBaseServiceManager({
runtime: api
});
return manager.check();
Expand Down
18 changes: 9 additions & 9 deletions src/client/modules/app/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define([
var messenger = config.messenger;
var serviceManager = config.serviceManager;

// Access to ui config.
// Access to ui config.
// This is simply a wrapping around the venerable Props module.
function getConfig(prop, defaultValue) {
return configProps.getItem(prop, defaultValue);
Expand All @@ -23,8 +23,8 @@ define([
}

// allow tag
// Returns true if the provided string 'tag' is found in
// the array of allowed tags, as defined in the config
// Returns true if the provided string 'tag' is found in
// the array of allowed tags, as defined in the config
// property 'ui.allow'.
function allow(tag) {
var allowed = configProps.getItem('ui.allow', []);
Expand All @@ -35,18 +35,18 @@ define([
}

var featureSwitches = {};
configProps.getItem('ui.featureSwitches.available').reduce((features, featureSwitch) => {
configProps.getItem('ui.featureSwitches.available', []).reduce((features, featureSwitch) => {
featureSwitches[featureSwitch.id] = featureSwitch;
});
}, {});

function featureEnabled(id) {
let featureSwitch = featureSwitches[id];
const featureSwitch = featureSwitches[id];
if (!featureSwitch) {
throw new Error('Feature switch "' + id + '" not defined');
}

// look for the feature switch in the.
let enabledFeatureSwitches = configProps.getItem('ui.featureSwitches.enabled');
const enabledFeatureSwitches = configProps.getItem('ui.featureSwitches.enabled');
// let disabledFeatureSwitches = configProps.getItem('ui.featureSwitches.disabled');

if (enabledFeatureSwitches.includes(id)) {
Expand All @@ -56,13 +56,13 @@ define([
}

function featureDisabled(id) {
let featureSwitch = featureSwitches[id];
const featureSwitch = featureSwitches[id];
if (!featureSwitch) {
throw new Error('Feature switch "' + id + '" not defined');
}

// look for the feature switch in the.
let disabledFeatureSwitches = configProps.getItem('ui.featureSwitches.disabled');
const disabledFeatureSwitches = configProps.getItem('ui.featureSwitches.disabled');

if (disabledFeatureSwitches.includes(id)) {
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/client/modules/app/services/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ define([

// // show the disconnected dialog
// // which starts listening back to home base to see if we are
// // connected yet. Allow the user to bail to a default "closer"
// // connected yet. Allow the user to bail to a default "closer"
// // page which is just a simple view which destroys the current view
// // and allows the user to just kill the tab.
// });
Expand All @@ -164,7 +164,7 @@ define([
if (checking) {
return;
}
var now = new Date().getTime();
const now = new Date().getTime();
if (now - lastCheckAt > interval) {
checking = true;
var httpClient = new HttpClient.HttpClient();
Expand Down
30 changes: 15 additions & 15 deletions src/client/modules/app/services/coreService.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ define([
) {
'use strict';

class CoreService {
constructor({moduleName, minimumVersion, url, versionMethod, versionPath}) {
this.moduleName = moduleName;
this.minimumVersion = minimumVersion;
this.url = url;
this.versionMethod = versionMethod;
this.versionPath = versionPath;
}
}
// class CoreService {
// constructor({moduleName, minimumVersion, url, versionMethod, versionPath}) {
// this.moduleName = moduleName;
// this.minimumVersion = minimumVersion;
// this.url = url;
// this.versionMethod = versionMethod;
// this.versionPath = versionPath;
// }
// }

class CoreServicesMonitor {
constructor({runtime}) {
Expand All @@ -22,22 +22,22 @@ define([
this.services = {};
}

start () {
start() {

}

stop () {
stop() {

}

pluginHandler(config) {
pluginHandler() {
// console.log('plugin handler', config);
}

addCoreServiceDepenency(dep) {
addCoreServiceDepenency() {

}
}
}


return {ServiceClass: CoreServicesMonitor};
Expand Down
5 changes: 2 additions & 3 deletions src/client/modules/app/services/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ define([
}

function getJson(arg) {
let url = '/data/' + arg.path + '/' + arg.file + '.json';
let http = new HttpClient.HttpClient();
const url = '/data/' + arg.path + '/' + arg.file + '.json';
const http = new HttpClient.HttpClient();
return http.request({
method: 'GET',
url: url
Expand All @@ -42,7 +42,6 @@ define([
throw new Error('Error fetching file: ' + result.status);
}
});

}
return {
start: start,
Expand Down
14 changes: 7 additions & 7 deletions src/client/modules/app/services/dynamic-service.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
define([
'kb_common/hotCache',
'kb_common/jsonRpc/genericClient',
'kb_common/jsonRpc/dynamicServiceClient'
'kb_common/hotCache'
// 'kb_common/jsonRpc/genericClient',
// 'kb_common/jsonRpc/dynamicServiceClient'
], function (
HotCache,
GenericClient,
DynamicServiceClient
HotCache
// GenericClient,
// DynamicServiceClient
) {
'use strict';

function factory(config) {
function factory() {
var cache = HotCache.make({
hardTtl: 3600000, // 1 min
hotTtl: 18000000, // 5 min
Expand Down
6 changes: 3 additions & 3 deletions src/client/modules/app/services/heartbeat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*global define */
/*jslint white: true, browser: true */
define([], function() {
define([], function () {
'use strict';

function factory(config) {
Expand All @@ -12,7 +12,7 @@ define([], function() {

function start() {
heartbeat = 0;
heartbeatTimer = window.setInterval(function() {
heartbeatTimer = window.setInterval(function () {
heartbeat += 1;
runtime.send('app', 'heartbeat', { heartbeat: heartbeat });
}, interval);
Expand All @@ -30,7 +30,7 @@ define([], function() {
}

return {
make: function(config) {
make: function (config) {
return factory(config);
}
};
Expand Down
7 changes: 3 additions & 4 deletions src/client/modules/app/services/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define([
'bluebird',
'kb_common/observed'
], function (
Promise,
Promise,
observed
) {
'use strict';
Expand Down Expand Up @@ -43,7 +43,7 @@ define([
* Add a defined menu item to a menu, according to a menu entry definition.
*/
function addToMenu(menuEntry, menuItemSpec) {
var menu, section, position,
var menu, section, position,
menuItems = state.getItem('menuItems'),
menuItemDef = menuItems[menuItemSpec.id];

Expand Down Expand Up @@ -78,7 +78,7 @@ define([
allowRoles: menuItemSpec.allowRoles || null,
authRequired: menuItemSpec.auth ? true : false
};

menu = menuEntry.menu;
section = menuEntry.section;
position = menuEntry.position || 'bottom';
Expand All @@ -97,7 +97,6 @@ define([
});
}

// Get the
function getCurrentMenu(menu) {
menu = menu || 'hamburger';
var menus = state.getItem('menu.' + menu);
Expand Down
2 changes: 1 addition & 1 deletion src/client/modules/app/services/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ define([
handler = {
params: {
title: 'Access Error',
error: 'One or more required roles not available in your account: ' + handler.route.rolesRequired.join(', ')
error: 'One or more required roles not available in your account: ' + handler.route.rolesRequired.join(', ')
},
route: {
authorization: false,
Expand Down
19 changes: 4 additions & 15 deletions src/client/modules/app/services/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define([
'bluebird',
'lib/rpc'
], function (
Promise,
Promise,
rpc
) {
'use strict';
Expand All @@ -27,31 +27,20 @@ define([
function stop() {
return true;
}
function pluginHandler(widgetsConfig, pluginConfig) {
function pluginHandler() {
return Promise.try(function () {
// widgetsConfig.forEach(function (widgetDef) {
// // If source modules are not specified, we are using module
// // paths. A full path will start with "plugins/" and a relative
// // path won't. Prefix a relative path with the plugin's module path.
// if (!pluginConfig.usingSourceModules) {
// if (!widgetDef.module.match(/^plugins\//)) {
// widgetDef.module = [pluginConfig.moduleRoot, widgetDef.module].join('/');
// }
// }
// widgetManager.addWidget(widgetDef);
// });
});
}

function makeClient(arg) {
let client = new rpc.RPCClient({
const client = new rpc.RPCClient({
runtime: runtime,
module: arg.module
});
return client;
}

return {start, stop, pluginHandler, makeClient};
return {start, stop, pluginHandler, makeClient};
}
return {
make: function (config) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/modules/app/services/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ define([
stop: stop,
// plugin interface
pluginHandler: pluginHandler,
makeWidget: function () {
makeWidget: function () {
return proxyMethod(widgetManager, 'makeWidget', arguments);
},
getWidget: function () {
Expand Down

0 comments on commit cfc143b

Please sign in to comment.