Skip to content

Commit

Permalink
Merge pull request #415 from adroitwhiz/eslint
Browse files Browse the repository at this point in the history
Enable ESLint
  • Loading branch information
jonobr1 authored Dec 7, 2019
2 parents 1800df6 + f7a4b71 commit eacba1a
Show file tree
Hide file tree
Showing 25 changed files with 113 additions and 74 deletions.
36 changes: 36 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"extends": "eslint:recommended",
"env": {
"browser": true,
"commonjs": true,
"amd": true
},
"globals": {
"global": "writable"
},
"rules": {
"semi": ["error", "always"],
"no-unused-vars": "off"
},
"overrides": [
{
"files": ["utils/**"],
"env": {
"node": true
}
},
{
"files": ["tests/**"],
"globals": {
"QUnit": "writable",
"resemble": "writable",
"Two": "writable",
"_": "writable"
},
"rules": {
"no-redeclare": "off"
}
}
],
"ignorePatterns": ["build/", "utils/start-comment.js", "utils/end-comment.js", "utils/exports.js"]
}
2 changes: 1 addition & 1 deletion extras/zui.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

addLimits: function(min, max, type) {

var type = type || 'scale';
type = type || 'scale';

if (!_.isUndefined(min)) {
if (this.limits[type].min) {
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"extras",
"src"
],
"scripts": {
"lint": "eslint ."
},
"directories": {
"doc": "documentation",
"test": "tests",
Expand Down Expand Up @@ -50,6 +53,7 @@
"devDependencies": {
"animation-frame": "^0.1.7",
"blueimp-canvas-to-blob": "^2.1.0",
"eslint": "^6.7.2",
"jsdoc": "~3.5.5",
"jsdoc-to-markdown": "^4.0.1",
"moment": "^2.22.2",
Expand Down
2 changes: 1 addition & 1 deletion src/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

// Append the `controls` object only if control points are specified,
// keeping the Two.Anchor inline with a Two.Vector until it needs to
// evolve beyond those functions — e.g: a simple 2 component vector.
// evolve beyond those functions - e.g: a simple 2 component vector.
if (ilx || ily || irx || iry) {
Two.Anchor.AppendCurveProperties(this);
}
Expand Down
2 changes: 1 addition & 1 deletion src/effects/image-sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
clone: function(parent) {

var clone = new ImageSequence(this.textures, this.translation.x,
this.translation.y, this.frameRate)
this.translation.y, this.frameRate);

clone._loop = this._loop;

Expand Down
2 changes: 1 addition & 1 deletion src/effects/sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

}

})
});

_.extend(Sprite.prototype, Rectangle.prototype, {

Expand Down
3 changes: 1 addition & 2 deletions src/effects/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@

if (Two.Utils.isHeadless) {
throw new Two.Utils.Error('video textures are not implemented in headless environments.');
return;
}

texture.image.setAttribute('two-src', texture.src);
Expand Down Expand Up @@ -529,7 +528,7 @@
repeat: this.repeat,
origin: this.origin.toObject(),
scale: _.isNumber(this.scale) ? this.scale : this.scale.toObject()
}
};
},

/**
Expand Down
2 changes: 1 addition & 1 deletion src/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@
for (var i = 0; i < objects.length; i++) {
var child = objects[i];
if (!(child && child.id)) {
continue
continue;
}
var index = _.indexOf(this.children, child);
if (index >= 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
var e = elements[4];
var f = elements[5];

if (!!fullMatrix) {
if (fullMatrix) {

var g = elements[6];
var h = elements[7];
Expand Down Expand Up @@ -533,7 +533,7 @@
var e = elements[4];
var f = elements[5];

if (!!fullMatrix) {
if (fullMatrix) {

var g = elements[6];
var h = elements[7];
Expand Down
4 changes: 2 additions & 2 deletions src/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,13 +832,13 @@
// TODO: Update this to not __always__ update. Just when it needs to.
this._update(true);

matrix = !!shallow ? this._matrix : getComputedMatrix(this);
matrix = shallow ? this._matrix : getComputedMatrix(this);

border = this.linewidth / 2;
l = this._renderer.vertices.length;

if (l <= 0) {
v = matrix.multiply(0, 0, 1);
var v = matrix.multiply(0, 0, 1);
return {
top: v.y,
left: v.x,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@

if (!clip && !parentClipped) {
if (!canvas.isHidden.test(fill)) {
isOffset = fill._renderer && fill._renderer.offset
isOffset = fill._renderer && fill._renderer.offset;
if (isOffset) {
ctx.save();
ctx.translate(
Expand Down
11 changes: 6 additions & 5 deletions src/renderer/webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@
this._renderer.opacity = this._opacity
* (parent && parent._renderer ? parent._renderer.opacity : 1);

var i;
if (this._flagSubtractions) {
for (var i = 0; i < this.subtractions.length; i++) {
for (i = 0; i < this.subtractions.length; i++) {
webgl.group.removeChild(this.subtractions[i], gl);
}
}

for (var i = 0; i < this.children.length; i++) {
for (i = 0; i < this.children.length; i++) {
var child = this.children[i];
webgl[child._renderer.type].render.call(child, gl, program);
}
Expand Down Expand Up @@ -226,7 +227,7 @@
var largeArcFlag = b.largeArcFlag;
var sweepFlag = b.sweepFlag;

prev = closed ? mod(i - 1, length) : max(i - 1, 0);
prev = closed ? mod(i - 1, length) : Math.max(i - 1, 0);
a = commands[prev];

var ax = a.x;
Expand Down Expand Up @@ -315,7 +316,7 @@
}

if (!webgl.isHidden.test(fill)) {
isOffset = fill._renderer && fill._renderer.offset
isOffset = fill._renderer && fill._renderer.offset;
if (isOffset) {
ctx.save();
ctx.translate(
Expand Down Expand Up @@ -1075,7 +1076,7 @@
*/
var Renderer = Two[Two.Types.webgl] = function(params) {

var params, gl, vs, fs;
var gl, vs, fs;

/**
* @name Two.WebGLRenderer#domElement
Expand Down
4 changes: 2 additions & 2 deletions src/shapes/arc-segment.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
this.translation.y = oy;
}

}
};

_.extend(ArcSegment, {

Expand Down Expand Up @@ -353,7 +353,7 @@
var object = Path.prototype.toObject.call(this);

_.each(ArcSegment.Properties, function(property) {
object[property] = this[property]
object[property] = this[property];
}, this);

return object;
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
var object = Path.prototype.toObject.call(this);

_.each(Circle.Properties, function(property) {
object[property] = this[property]
object[property] = this[property];
}, this);

return object;
Expand Down
6 changes: 3 additions & 3 deletions src/shapes/ellipse.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@
var lx = i === 0 ? 0 : rx * c * cos(theta - HALF_PI);
var ly = i === 0 ? 0 : ry * c * sin(theta - HALF_PI);

var rx = i === last ? 0 : rx * c * cos(theta + HALF_PI);
var ry = i === last ? 0 : ry * c * sin(theta + HALF_PI);
rx = i === last ? 0 : rx * c * cos(theta + HALF_PI);
ry = i === last ? 0 : ry * c * sin(theta + HALF_PI);

var v = this.vertices[i];

Expand Down Expand Up @@ -205,7 +205,7 @@
var object = Path.prototype.toObject.call(this);

_.each(Ellipse.Properties, function(property) {
object[property] = this[property]
object[property] = this[property];
}, this);

return object;
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
var object = Path.prototype.toObject.call(this);

_.each(Polygon.Properties, function(property) {
object[property] = this[property]
object[property] = this[property];
}, this);

return object;
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/rounded-rectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
var object = Path.prototype.toObject.call(this);

_.each(RoundedRectangle.Properties, function(property) {
object[property] = this[property]
object[property] = this[property];
}, this);

object.radius = _.isNumber(this.radius)
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/star.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
var object = Path.prototype.toObject.call(this);

_.each(Star.Properties, function(property) {
object[property] = this[property]
object[property] = this[property];
}, this);

return object;
Expand Down
4 changes: 2 additions & 2 deletions src/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@
// TODO: Update this to not __always__ update. Just when it needs to.
this._update(true);

matrix = !!shallow ? this._matrix : getComputedMatrix(this);
matrix = shallow ? this._matrix : getComputedMatrix(this);

var height = this.leading;
var width = this.value.length * this.size * Text.Ratio;
Expand Down Expand Up @@ -614,7 +614,7 @@
console.warn('Two.js: Unable to create canvas for Two.Text measurements.');
return {
getContext: _.identity
}
};
}
}

Expand Down
Loading

0 comments on commit eacba1a

Please sign in to comment.