Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format entire codebase with eslint config #1389

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 34 additions & 11 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
{
"parser": "babel-eslint",
"extends": [
],
"plugins": [
],
"env": {
"browser": true,
"amd": true,
"es6": true
"extends": "eslint-config-airbnb-es5",
"plugins": [],
"rules": {
"no-var": 0,
"no-console": 0,
"space-in-parens": ["error", "never"],
"object-shorthand": 0,
"indent": ["error", 4],
"max-len": ["error", 200, 4],
"no-unused-vars": [2, {"varsIgnorePattern": "profile"}],
"vars-on-top": 0,
"prefer-arrow-callback": 0,
"func-names": 0,
"valid-jsdoc": 0,
"no-param-reassign": 0,
"eqeqeq": 0,
"no-undefined": 0,
"no-nested-ternary": 0,
"one-var": 0,
"new-cap": 0,
"camelcase": 0
},
"globals": {
"$": true,
"window": true,
"console": true,
"dojo": true,
"dijit": true,
"define": true,
"require": true,
"describe": true,
"it": true
},
"rules": {
"no-underscore-dangle": 0,
"no-undef": "error"
"env": {
"browser": true,
"amd": true,
"es6": true
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
"electron-packager": "^12.0.1",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-config-airbnb-es5": "^1.2.0",
"eslint-plugin-import": "^2.10.0",
"eslint-plugin-react": "^7.14.2",
"extract-text-webpack-plugin": "^3.0.2",
"filesaver.js": "^0.2.0",
"http-range-fetcher": "^1.2.1",
Expand Down
120 changes: 59 additions & 61 deletions src/JBrowse/BehaviorManager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define([],
function() {
/**
function () {
/**
* Stores, applies, and removes a named set of behaviors. A behavior
* is a set of event handlers that need to be connected and then
* disconnected repeatedly as a group.
Expand Down Expand Up @@ -34,85 +34,83 @@ define([],
* called.
* @lends JBrowse.BehaviorManager
*/
function BehaviorManager( args ) {
this.context = args.context;
this.behaviors = args.behaviors;
};
function BehaviorManager(args) {
this.context = args.context;
this.behaviors = args.behaviors;
}

/**
/**
* Apply the behaviors that have <code>apply_on_init</code> true.
*/
BehaviorManager.prototype.initialize = function() {
this.removeAll();
for( var bname in this.behaviors ) {
var b = this.behaviors[bname];
if( b.apply_on_init ) {
this.applyBehaviors( bname );
}
}
};
BehaviorManager.prototype.initialize = function () {
this.removeAll();
for (var bname in this.behaviors) {
var b = this.behaviors[bname];
if (b.apply_on_init) {
this.applyBehaviors(bname);
}
}
};

/**
/**
* Apply each of the behaviors named as arguments to this function.
* @param {String} [...] Zero or more string behavior names to apply.
*/
BehaviorManager.prototype.applyBehaviors = function() {
dojo.forEach( arguments, function(name) {
var b = this._get(name);
if( !b.applied ) {
b.handles = b.handles || [];
b.handles = b.apply.call( this.context || this, this, b.handles );
b.applied = true;
}
}, this);
};
BehaviorManager.prototype.applyBehaviors = function () {
dojo.forEach(arguments, function (name) {
var b = this._get(name);
if (!b.applied) {
b.handles = b.handles || [];
b.handles = b.apply.call(this.context || this, this, b.handles);
b.applied = true;
}
}, this);
};

/**
/**
* Look up a behavior by name, throw an exception if it's not there.
* @private
*/
BehaviorManager.prototype._get = function( name ) {
var b = this.behaviors[name];
if( !b )
throw "no behavior registed with name '"+"'name";
return b;
};
BehaviorManager.prototype._get = function (name) {
var b = this.behaviors[name];
if (!b) {throw "no behavior registed with name '" + "'name";}
return b;
};

/**
/**
* Given two behavior names, remove the first one and apply the second
* one. For convenience.
*/
BehaviorManager.prototype.swapBehaviors = function( off, on ) {
this.removeBehaviors(off);
this.applyBehaviors(on);
};
BehaviorManager.prototype.swapBehaviors = function (off, on) {
this.removeBehaviors(off);
this.applyBehaviors(on);
};

/**
/**
* Remove each of the behaviors named as arguments to this function.
* @param {String} [...] Zero or more string behavior names to remove.
*/
BehaviorManager.prototype.removeBehaviors = function( ) {
dojo.forEach( arguments, function(name) {
var b = this._get(name);
if( b.applied ) {
var remove = b.remove || function( m, h ) {
dojo.forEach( h, dojo.disconnect, dojo );
};
remove.call( this.context || this, this, b.handles );
b.applied = false;
}
}, this);
};
BehaviorManager.prototype.removeBehaviors = function () {
dojo.forEach(arguments, function (name) {
var b = this._get(name);
if (b.applied) {
var remove = b.remove || function (m, h) {
dojo.forEach(h, dojo.disconnect, dojo);
};
remove.call(this.context || this, this, b.handles);
b.applied = false;
}
}, this);
};

/**
/**
* Remove all behaviors that are currently applied.
*/
BehaviorManager.prototype.removeAll = function( ) {
for( var bname in this.behaviors ) {
this.removeBehaviors( bname );
}
};

return BehaviorManager;
BehaviorManager.prototype.removeAll = function () {
for (var bname in this.behaviors) {
this.removeBehaviors(bname);
}
};

});
return BehaviorManager;
});
Loading