Skip to content

Commit

Permalink
Add eslint and fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwalton committed Jul 6, 2016
1 parent 5f84a64 commit fdcf54e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
45 changes: 45 additions & 0 deletions polyfill/.eslintrc
@@ -0,0 +1,45 @@
{
"env": {
"browser": true,
"node": true,
"mocha": true
},
"globals": {
"expect": false,
"sinon": false
},
"extends": [
"eslint:recommended"
],
"rules": {
// possible errors
"no-cond-assign": 0,
"no-empty": 0,
"valid-jsdoc": [2, {
"prefer": {"return": "return"},
"requireReturn": false
}],
// best practices
"no-extra-bind": 2,
// style
"comma-spacing": [2, {"before": false, "after": true}],
"eol-last": [0],
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
"linebreak-style": [2, "unix"],
"max-len": [2, 80, {"ignoreUrls": true}],
"no-multiple-empty-lines": [2, {"max": 2}],
"no-unused-vars": ["error", {"vars": "all"}],
"no-trailing-spaces": 2,
"object-curly-spacing": [2, "never"],
"quotes": [2, "single"],
"require-jsdoc": [2, {
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true
}
}],
"semi": [2, "always"],
"semi-spacing": [2, {"before": false, "after": true}],
}
}
8 changes: 3 additions & 5 deletions polyfill/intersection-observer.js
Expand Up @@ -45,7 +45,7 @@ function IntersectionObserverEntry(entry) {
var intersectionRect = this.intersectionRect;
var intersectionArea = intersectionRect.width * intersectionRect.height;
this.intersectionRatio = targetArea ? (intersectionArea / targetArea) : 0;
};
}


/**
Expand Down Expand Up @@ -85,7 +85,7 @@ function IntersectionObserver(callback, opt_options) {
this.rootMargin = this._rootMarginValues.map(function(margin) {
return margin.value + margin.unit;
}).join(' ');
};
}


/**
Expand Down Expand Up @@ -324,8 +324,6 @@ IntersectionObserver.prototype._checkForIntersections = function() {
};




/**
* Accepts a target and root rect computes the intersection between then
* following the algorithm in the spec.
Expand Down Expand Up @@ -607,7 +605,7 @@ function getBoundingClientRect(el) {
left: rect.left,
width: rect.right - rect.left,
height: rect.bottom - rect.top
}
};
}
return rect;
}
Expand Down

1 comment on commit fdcf54e

@funnyrule
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Please sign in to comment.