Skip to content

Commit

Permalink
tons of linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
englercj committed Mar 13, 2016
1 parent 69d2b5c commit b492846
Show file tree
Hide file tree
Showing 11 changed files with 271 additions and 263 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// Possible Errors
"comma-dangle": [2, "never"],
"no-cond-assign": [2, "except-parens"],
"no-console": 2,
"no-console": 0,
"no-constant-condition": 2,
"no-control-regex": 2,
"no-debugger": 2,
Expand Down
36 changes: 18 additions & 18 deletions .jscsrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

"disallowEmptyBlocks": true,
"disallowIdenticalDestructuringNames": true,
"disallowImplicitTypeConversion": [ "numeric", "binary", "string" ],
"disallowImplicitTypeConversion": [ "numeric", "string" ],
"disallowKeywords": [ "with" ],
// "disallowKeywordsOnNewLine": [ "else", "while" ],
"disallowMixedSpacesAndTabs": true,
"disallowMultiLineTernary": true,
"disallowMultiLineTernary": false,
"disallowMultipleLineBreaks": true,
"disallowMultipleLineStrings": true,
"disallowMultipleVarDecl": true,
Expand All @@ -32,26 +32,26 @@
"disallowUnusedParams": true,
"disallowYodaConditions": true,

"jsDoc": {
"checkAnnotations": "jsdoc3",
"checkParamExistence": true,
"checkParamNames": true,
"requireParamTypes": true,
"checkRedundantParams": true,
"checkReturnTypes": true,
"checkRedundantReturns": true,
"checkTypes": true,
"checkRedundantAccess": true,
"leadingUnderscoreAccess": "private",
"requireHyphenBeforeDescription": true,
"requireNewlineAfterDescription": true
},
// "jsDoc": {
// "checkAnnotations": "jsdoc3",
// "checkParamExistence": true,
// "checkParamNames": true,
// "requireParamTypes": true,
// "checkRedundantParams": true,
// "checkReturnTypes": true,
// "checkRedundantReturns": true,
// "checkTypes": true,
// "checkRedundantAccess": true,
// "leadingUnderscoreAccess": "private",
// "requireHyphenBeforeDescription": true,
// "requireNewlineAfterDescription": true
// },

"maximumLineLength": 120,
"maximumLineLength": 140,

"requireAlignedMultilineParams": "firstParam",
"requireBlocksOnNewline": false,
"requireCamelCaseOrUpperCaseIdentifiers": true,
"requireCamelCaseOrUpperCaseIdentifiers": false,
// "requireNewlineBeforeBlockStatements": true,
"requireCapitalizedConstructors": true,
"requireCommaBeforeLineBreak": true,
Expand Down
6 changes: 1 addition & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ var gutil = require('gulp-util');
var eslint = require('gulp-eslint');
var jscs = require('gulp-jscs');

var pkg = require('./package.json');

var source = require('vinyl-source-stream');
var watchify = require('watchify');
var browserify = require('browserify');
Expand All @@ -15,8 +13,6 @@ var outdir = './build';
var bundle = 'Phaser.Plugin.Tiled';
var outfile = 'phaser-tiled.js';

var version = pkg.version.split('.');

function rebundle(file) {
if (file) {
gutil.log('Rebundling,', path.basename(file[0]), 'has changes.');
Expand All @@ -39,7 +35,7 @@ function createBundler(args) {
/*****
* Dev task, incrementally rebuilds the output bundle as the the sources change
*****/
gulp.task('dev', function() {
gulp.task('dev', function () {
watchify.args.standalone = bundle;
var bundler = watchify(createBundler(watchify.args));

Expand Down
6 changes: 4 additions & 2 deletions src/physics.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ module.exports = {
}

body.data.shapes[0].sensor = !!(object.properties && object.properties.sensor);
body.data.shapes[0].collisionResponse =
(object.properties && typeof object.properties.collisionResponse !== 'undefined') ? object.properties.collisionResponse : true;

if (object.properties && typeof object.properties.collisionResponse === 'boolean') {
body.data.shapes[0].collisionResponse = object.properties.collisionResponse;
}

var bodyType = object.properties && object.properties.bodyType || 'static';

Expand Down
47 changes: 24 additions & 23 deletions src/tiled/Objectlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ function Objectlayer(game, map, layer, index) {

if (this.properties.batch) {
this.container = this.addChild(new Phaser.SpriteBatch(game));
} else {
}
else {
this.container = this;
}
}
Expand All @@ -114,12 +115,12 @@ module.exports = Objectlayer;
Objectlayer.prototype.spawn = function (physicsBodyType, spawnCallback) {
// we go through these backwards so that things that are higher in the
// list of object gets rendered on top.
for(var i = this.objects.length - 1; i >= 0; --i) {
var o = this.objects[i],
props = o.properties,
set,
// interactive,
obj;
for (var i = this.objects.length - 1; i >= 0; --i) {
var o = this.objects[i];
var props = o.properties;
var set;
// var interactive;
var obj;

props.tileprops = {};
props.animation = null;
Expand Down Expand Up @@ -162,8 +163,8 @@ Objectlayer.prototype.spawn = function (physicsBodyType, spawnCallback) {
obj.height = o.height;
}

obj.blendMode = (props.blendMode || this.properties.blendMode) ?
PIXI.blendModes[(props.blendMode || this.properties.blendMode)] : PIXI.blendModes.NORMAL;
var blendMode = props.blendMode || this.properties.blendMode;
obj.blendMode = blendMode ? Phaser.blendModes[blendMode] : Phaser.blendModes.NORMAL;

// create physics if this body is physical.
if (props.collides || props.tileprops.collides) {
Expand Down Expand Up @@ -217,7 +218,7 @@ Objectlayer.prototype.spawn = function (physicsBodyType, spawnCallback) {
obj.rotation = o.rotation;
}

//visible was recently added to Tiled, default old versions to true
// visible was recently added to Tiled, default old versions to true
obj.visible = o.visible !== undefined ? !!o.visible : true;

// if (this.map.orientation === 'isometric') {
Expand All @@ -244,14 +245,14 @@ Objectlayer.prototype.spawn = function (physicsBodyType, spawnCallback) {
// obj.mouseupoutside = this.onObjectEvent.bind(this, 'mouseupoutside', obj);
// }

//set custom properties
// set custom properties
obj.properties = {};
for(var t in props.tileprops) {
for (var t in props.tileprops) {
obj.properties[t] = props.tileprops[t];
}

for(var k in props) {
if(k !== 'tileprops') {
for (var k in props) {
if (k !== 'tileprops') {
obj.properties[k] = props[k];
}
}
Expand Down Expand Up @@ -297,7 +298,7 @@ Objectlayer.prototype.onObjectEvent = function (eventName, obj, data) {
*/
Objectlayer.prototype._getPolygon = function (o) {
var points = [];
for(var i = 0, il = o.polygon.length; i < il; ++i) {
for (var i = 0, il = o.polygon.length; i < il; ++i) {
points.push(new Phaser.Point(o.polygon[i].x, o.polygon[i].y));
}

Expand All @@ -314,7 +315,7 @@ Objectlayer.prototype._getPolygon = function (o) {
*/
Objectlayer.prototype._getPolyline = function (o) {
var points = [];
for(var i = 0, il = o.polyline.length; i < il; ++i) {
for (var i = 0, il = o.polyline.length; i < il; ++i) {
points.push(new Phaser.Point(o.polyline[i].x, o.polyline[i].y));
}

Expand Down Expand Up @@ -355,13 +356,13 @@ Objectlayer.prototype._getRectangle = function (o) {
* @private
*/
Objectlayer.prototype._getInteractive = function (set, props) {
//TODO: This is wrong, if 'false' is set on a lower level a higher level will override
//first check the lowest level value (on the tile iteself)
return props.interactive || //obj interactive
props.tileprops.interactive || //tile object interactive
(set && set.properties.interactive) || //tileset interactive
this.properties.interactive || //layer interactive
this.map.properties.interactive; //map interactive
// TODO: This is wrong, if 'false' is set on a lower level a higher level will override
// first check the lowest level value (on the tile iteself)
return props.interactive || // obj interactive
props.tileprops.interactive || // tile object interactive
(set && set.properties.interactive) || // tileset interactive
this.properties.interactive || // layer interactive
this.map.properties.interactive; // map interactive
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/tiled/Tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ function Tile(game, x, y, tileId, tileset, layer) {
}

// set the blend mode
this.blendMode = (this.properties.blendMode || layer.properties.blendMode) ?
Phaser.blendModes[(this.properties.blendMode || layer.properties.blendMode)] : Phaser.blendModes.NORMAL;
var blendMode = this.properties.blendMode || layer.properties.blendMode;
this.blendMode = blendMode ? Phaser.blendModes[blendMode] : Phaser.blendModes.NORMAL;

// setup the flipped states
if (this.properties.flippedX) {
Expand Down
38 changes: 19 additions & 19 deletions src/tiled/Tilelayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,14 @@ function Tilelayer(game, map, layer, index) {
// if batch is true, store children in a spritebatch
if (this.properties.batch) {
this.container = this.addChild(new Phaser.SpriteBatch(game));
} else {
}
else {
this.container = this;
}

for (var i = 0; i < this.tileIds.length; ++i) {
var x = i % this.size.x,
y = (i - x) / this.size.x;
var x = i % this.size.x;
var y = (i - x) / this.size.x;

if (!this.tiles[y]) {
this.tiles[y] = {};
Expand Down Expand Up @@ -356,16 +357,16 @@ Tilelayer.prototype._createTile = function () {

Tilelayer.prototype._resetTile = function (tile, x, y, tileId, tileset) {
// calculate some values for the tile
var texture = tileset.getTileTexture(tileId),
props = tileset.getTileProperties(tileId),
animData = tileset.getTileAnimations(tileId);
var texture = tileset.getTileTexture(tileId);
var props = tileset.getTileProperties(tileId);
var animData = tileset.getTileAnimations(tileId);
var blendMode = props.blendMode || this.properties.blendMode;

tile.reset(x, y);

tile.setTexture(texture);

tile.blendMode = (props.blendMode || this.properties.blendMode) ?
Phaser.blendModes[(props.blendMode || this.properties.blendMode)] : Phaser.blendModes.NORMAL;
tile.blendMode = blendMode ? Phaser.blendModes[blendMode] : Phaser.blendModes.NORMAL;

// add animations if there are any
if (animData) {
Expand Down Expand Up @@ -439,10 +440,10 @@ Tilelayer.prototype.moveTileSprite = function (fromTileX, fromTileY, toTileX, to
return null;
}

var tile,
id = (toTileX + (toTileY * this.size.x)),
tileId = this.tileIds[id],
tileset = this.map.getTileset(tileId);
var tile;
var id = (toTileX + (toTileY * this.size.x));
var tileId = this.tileIds[id];
var tileset = this.map.getTileset(tileId);

// if no tileset, return
if (!tileset) {
Expand Down Expand Up @@ -471,7 +472,6 @@ Tilelayer.prototype.moveTileSprite = function (fromTileX, fromTileY, toTileX, to
tileset
);


// update sprite reference in the map
this.tiles[toTileY][toTileX] = tile;

Expand Down Expand Up @@ -634,8 +634,8 @@ Tilelayer.prototype.getTiles = function (x, y, width, height, collides, interest
this._mc.th = (this.game.math.snapToCeil(height, this._mc.ch) + this._mc.ch) / this._mc.ch;

// This should apply the layer x/y here
var results = [],
tile = null;
var results = [];
var tile = null;

for (var wy = this._mc.ty; wy < this._mc.ty + this._mc.th; wy++)
{
Expand Down Expand Up @@ -670,7 +670,7 @@ Tilelayer.prototype.getTile = function (x, y) {
Tilelayer.prototype._renderLeft = function (forceNew) {
this._renderArea.x--;

//move all the far right tiles to the left side
// move all the far right tiles to the left side
for (var i = 0; i < this._renderArea.height; ++i) {
this.moveTileSprite(
forceNew ? -1 : this._renderArea.right,
Expand All @@ -693,7 +693,7 @@ Tilelayer.prototype._renderLeft = function (forceNew) {
* @private
*/
Tilelayer.prototype._renderRight = function (forceNew) {
//move all the far left tiles to the right side
// move all the far left tiles to the right side
for (var i = 0; i < this._renderArea.height; ++i) {
this.moveTileSprite(
forceNew ? -1 : this._renderArea.left,
Expand Down Expand Up @@ -722,7 +722,7 @@ Tilelayer.prototype._renderRight = function (forceNew) {
Tilelayer.prototype._renderUp = function (forceNew) {
this._renderArea.y--;

//move all the far bottom tiles to the top side
// move all the far bottom tiles to the top side
for (var i = 0; i < this._renderArea.width; ++i) {
this.moveTileSprite(
forceNew ? -1 : this._renderArea.left + i,
Expand All @@ -745,7 +745,7 @@ Tilelayer.prototype._renderUp = function (forceNew) {
* @private
*/
Tilelayer.prototype._renderDown = function (forceNew) {
//move all the far top tiles to the bottom side
// move all the far top tiles to the bottom side
for (var i = 0; i < this._renderArea.width; ++i) {
this.moveTileSprite(
forceNew ? -1 : this._renderArea.left + i,
Expand Down
Loading

0 comments on commit b492846

Please sign in to comment.