Skip to content

Commit

Permalink
Add linter eqeqeq rule and some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
angiehjort committed Mar 8, 2017
1 parent e48aa3a commit aef369a
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Expand Up @@ -110,6 +110,7 @@
"error",
"never"
],
"eqeqeq": 0,
"no-floating-decimal": 1,
"no-trailing-spaces": 1,
"no-debugger": 1,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -7,7 +7,7 @@
"start": "webpack-dev-server",
"lint:diff": "shjs ./.githooks/pre-commit.js",
"lint:diff:fix": "cross-env FIX=1 npm run lint:diff",
"lint": "eslint -c .eslintrc --ignore-path .eslintignore",
"lint": "eslint -c .eslintrc --ignore-path .eslintignore src",
"build:prod": "cross-env NODE_ENV=production webpack",
"e2e:local": "./node_modules/protractor/bin/webdriver-manager update && ./node_modules/.bin/protractor .cicd/protractor.conf.js",
"build": "sh ./docker_run.sh"
Expand Down
4 changes: 2 additions & 2 deletions src/base/intervals.js
Expand Up @@ -30,8 +30,8 @@ const Intervals = Class.extend({
clearInterval(this.intervals[name]);
delete this.intervals[name];
}
} else {
this.clearAllIntervals();
} else {
this.clearAllIntervals();
}
},

Expand Down
4 changes: 2 additions & 2 deletions src/base/utils.js
Expand Up @@ -1443,7 +1443,7 @@ export function firstBy() {

function makeCompareFunction(f, opt) {
opt = typeof (opt) === "number" ? { direction: opt } : opt || {};
if (typeof (f) != "function") {
if (typeof (f) !== "function") {
const prop = f;
// make unary function
f = function(v1) {
Expand All @@ -1468,7 +1468,7 @@ export function firstBy() {
which is applied in case the first one returns 0 (equal)
returns a new compare function, which has a `thenBy` method as well */
function tb(func, opt) {
const x = typeof (this) == "function" ? this : false;
const x = typeof (this) === "function" ? this : false;
const y = makeCompareFunction(func, opt);
const f = x ? function(a, b) {
return x(a, b) || y(a, b);
Expand Down
6 changes: 3 additions & 3 deletions src/components/buttonlist/buttonlist.js
Expand Up @@ -503,7 +503,7 @@ const ButtonList = Component.extend({
const translator = this.model.locale.getTFunction();

btn.classed(class_unavailable, this.model.state.marker.select.length == 0 && !active);
if (typeof active == "undefined") {
if (typeof active === "undefined") {
btn.classed(class_hidden, this.model.state.marker.select.length == 0);
} else {
btn.classed(class_hidden, !active);
Expand All @@ -521,7 +521,7 @@ const ButtonList = Component.extend({
this.setInpercent();
},
setInpercent() {
if (typeof ((this.model.ui.chart || {}).inpercent) == "undefined") return;
if (typeof ((this.model.ui.chart || {}).inpercent) === "undefined") return;
const id = "inpercent";
const translator = this.model.locale.getTFunction();
const btn = this.element.selectAll(".vzb-buttonlist-btn[data-btn='" + id + "']");
Expand Down Expand Up @@ -565,7 +565,7 @@ const ButtonList = Component.extend({
exitFullscreen.call(this);
}
utils.classed(pholder, class_vzb_fullscreen, fs);
if (typeof container != "undefined") {
if (typeof container !== "undefined") {
utils.classed(container, class_container_fullscreen, fs);
}

Expand Down
6 changes: 3 additions & 3 deletions src/models/data.js
Expand Up @@ -221,7 +221,7 @@ const DataModel = Model.extend({
}

// if they want a certain processing of the data, see if it's already in cache
const id = (typeof whatId == "string") ? whatId : JSON.stringify(whatId);
const id = (typeof whatId === "string") ? whatId : JSON.stringify(whatId);
if (this._collection[dataId][what][id]) {
return this._collection[dataId][what][id];
}
Expand Down Expand Up @@ -465,7 +465,7 @@ const DataModel = Model.extend({

this.unMute = function() {
this.isActive = true;
if (typeof this.delayedAction == "function") {
if (typeof this.delayedAction === "function") {
this.delayedAction();
}
this.delayedAction = null;
Expand Down Expand Up @@ -555,7 +555,7 @@ const DataModel = Model.extend({
_context._muteAllQueues(this.whatId);
this.unMute();
if (typeof cb === "function") {
if (typeof this.callbacks[frameName] != "object") {
if (typeof this.callbacks[frameName] !== "object") {
this.callbacks[frameName] = [];
}
this.callbacks[frameName].push(cb);
Expand Down
2 changes: 1 addition & 1 deletion src/models/marker.js
Expand Up @@ -701,7 +701,7 @@ const Marker = Model.extend({

hook.dataSource.listenFrame(hook._dataId, steps, keys, (dataId, time) => {
const keyName = time.toString();
if (typeof preparedFrames[keyName] == "undefined") preparedFrames[keyName] = [];
if (typeof preparedFrames[keyName] === "undefined") preparedFrames[keyName] = [];
if (preparedFrames[keyName].indexOf(dataId) == -1) preparedFrames[keyName].push(dataId);
if (preparedFrames[keyName].length == dataIds.length) {
cb(time);
Expand Down
2 changes: 1 addition & 1 deletion src/models/time.js
Expand Up @@ -101,7 +101,7 @@ const TimeModel = DataConnected.extend({
this.formatters = formats[this.unit];
}
// specifically set formats overwrite unit defaults
if (typeof this.format == "string") {
if (typeof this.format === "string") {
this.formatters.data = this.formatters.ui = d3.time.format.utc(this.format);
} else {
if (this.format.data) {
Expand Down
8 changes: 4 additions & 4 deletions src/tools/bubblechart/bubblechart-component.js
Expand Up @@ -757,12 +757,12 @@ const BubbleChartComp = Component.extend({
const sizeA = _this.frame.size[a[KEY]];
const sizeB = _this.frame.size[b[KEY]];

if (typeof sizeA == "undefined" && typeof sizeB != "undefined") return -1;
if (typeof sizeA != "undefined" && typeof sizeB == "undefined") return 1;
if (typeof sizeA === "undefined" && typeof sizeB !== "undefined") return -1;
if (typeof sizeA !== "undefined" && typeof sizeB === "undefined") return 1;
if (sizeA != sizeB) return d3.descending(sizeA, sizeB);
if (a[KEY] != b[KEY]) return d3.ascending(a[KEY], b[KEY]);
if (typeof a.trailStartTime != "undefined" || typeof b.trailStartTime != "undefined") return typeof a.trailStartTime != "undefined" ? -1 : 1; // only lines has trailStartTime
if (typeof a.limits != "undefined" || typeof b.limits != "undefined") return typeof a.limits != "undefined" ? -1 : 1; // only trails has attribute limits
if (typeof a.trailStartTime !== "undefined" || typeof b.trailStartTime !== "undefined") return typeof a.trailStartTime !== "undefined" ? -1 : 1; // only lines has trailStartTime
if (typeof a.limits !== "undefined" || typeof b.limits !== "undefined") return typeof a.limits !== "undefined" ? -1 : 1; // only trails has attribute limits
return d3.descending(sizeA, sizeB);
});
},
Expand Down
6 changes: 3 additions & 3 deletions src/tools/bubblechart/bubblechart-trail.js
Expand Up @@ -180,7 +180,7 @@ export default Class.extend({
const _this = this;
const KEY = _context.KEY;
if (!this._isCreated || _context.model.time.splash) return;
if (typeof actions == "string") actions = [actions];
if (typeof actions === "string") actions = [actions];

this._isCreated.then(() => {
//quit if function is called accidentally
Expand Down Expand Up @@ -559,8 +559,8 @@ export default Class.extend({
_context.model.marker.getFrame(segment.t, frame => {
if (d.status != "reveal") return resolve();
if (!frame ||
(typeof frame.axis_x == "undefined") || frame.axis_x[d[KEY]] == null ||
(typeof frame.axis_y == "undefined") || frame.axis_y[d[KEY]] == null)
(typeof frame.axis_x === "undefined") || frame.axis_x[d[KEY]] == null ||
(typeof frame.axis_y === "undefined") || frame.axis_y[d[KEY]] == null)
{
utils.warn("Frame for trail missed: " + segment.t);
return resolve();
Expand Down

0 comments on commit aef369a

Please sign in to comment.