Skip to content

Commit

Permalink
Deprecate jshint/jscs in favor of eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSurabian committed Feb 2, 2017
1 parent 153a259 commit a151864
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 144 deletions.
9 changes: 9 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": [
"./eslint/eslint-defaults.json",
"./eslint/eslint-babel.json"
],
"env" : {
"browser": true
}
}
65 changes: 0 additions & 65 deletions .jscsrc

This file was deleted.

3 changes: 0 additions & 3 deletions .jshintrc

This file was deleted.

26 changes: 26 additions & 0 deletions eslint/eslint-babel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"ecmaFeatures": {
"modules": true
},
"env": {
"es6": true
},
"parserOptions": {
"sourceType": "module"
},
"rules": {
"arrow-parens": [2, "always"],
"arrow-spacing": [2, {"before": true, "after": true}],
"constructor-super": 2,
"generator-star-spacing": [2, "before"],
"no-class-assign": 2,
"no-const-assign": 2,
"no-this-before-super": 2,
"no-var": 2,
"object-shorthand": [2, "always"],
"prefer-const": 2,
"prefer-spread": 2,
"prefer-reflect": 0,
"require-yield": 2
}
}
22 changes: 22 additions & 0 deletions eslint/eslint-defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": [
"eslint:recommended"
],
"rules": {
"comma-dangle": [2, "only-multiline"],
"indent": ["error", 2, { "SwitchCase": 1, "ObjectExpression": 1 }],
"keyword-spacing": ["error", { "before": true, "after": true}],
"max-len": [1, {"ignoreComments": true, "code": 120}],
"no-console": [2],
"no-trailing-spaces": [2],
"quotes": [2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}],
"semi": ["error", "always", { "omitLastInOneLineBlock": true}],
"space-before-function-paren": ["error", "never"]
},
"env": {
"commonjs": true
},
"globals": {
"console": false
}
}
22 changes: 2 additions & 20 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
var gulp = require('gulp');
var babelify = require('babelify');
var browserify = require('browserify');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var source = require('vinyl-source-stream');
var audiosprite = require('audiosprite');
var glob = require('glob');
Expand All @@ -23,24 +21,8 @@ gulp.task('modules', function() {
.pipe(connect.reload());
});

gulp.task('jshint', function() {
return gulp.src([
'src/modules/**',
'duckhunt.js'
]).pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'))
});

gulp.task('jscs', function() {
return gulp.src([
'src/modules/*.js',
'duckhunt.js'
]).pipe(jscs())
});

gulp.task('watch', function() {
gulp.watch(['./src/modules/*.js', './src/data/*.json', 'main.js', 'libs/*.js'], ['jshint', 'jscs', 'modules']);
gulp.watch(['./src/modules/*.js', './src/data/*.json', 'main.js', 'libs/*.js'], ['modules']);
gulp.watch(['./src/assets/images/**/*.png'], ['images']);
gulp.watch(['./src/assets/sounds/**/*.mp3'], ['audio']);
});
Expand Down Expand Up @@ -94,6 +76,6 @@ gulp.task('deploy', function() {
]));
});

gulp.task('js', ['jshint', 'jscs', 'modules']);
gulp.task('js', ['modules']);
gulp.task('dev', ['default', 'watch', 'serve']);
gulp.task('default', ['images', 'audio', 'js']);
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "main.js",
"scripts": {
"gulp": "gulp",
"lint": "eslint src/**/*.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
Expand All @@ -25,13 +26,12 @@
"babelify": "^7.3.0",
"bluebird": "^3.4.7",
"browserify": "^14.0.0",
"eslint": "^3.14.1",
"glob": "^7.1.1",
"gsap": "^1.18.0",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.2",
"gulp-connect": "^5.0.0",
"gulp-jscs": "^4.0.0",
"gulp-jshint": "^2.0.4",
"gulp-rename": "^1.2.2",
"gulp-shell": "^0.5.2",
"howler": "^2.0.2",
Expand Down
8 changes: 5 additions & 3 deletions src/libs/utils.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
module.exports.pointDistance = function(point1, point2) {
return Math.sqrt((Math.pow((point1.x - point2.x), 2) + Math.pow((point1.y - point2.y), 2)))
return Math.sqrt(
(Math.pow((point1.x - point2.x), 2) + Math.pow((point1.y - point2.y), 2))
);
};

module.exports.directionOfTravel = function(pointStart, pointEnd) {
let direction = '';

//positive means down
let rise = pointEnd.y - pointStart.y;
const rise = pointEnd.y - pointStart.y;
//positive means right
let run = pointEnd.x - pointStart.x;
const run = pointEnd.x - pointStart.x;

if (run < 1 && rise < 1) {
direction = 'top-left';
Expand Down
16 changes: 8 additions & 8 deletions src/modules/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ class Character extends PIXI.extras.MovieClip {
* given sprite id.
*/
constructor(spriteId, spritesheet, states) {
let gameTextures = PIXI.loader.resources[spritesheet].textures;
for (let textureKey in gameTextures) {
const gameTextures = PIXI.loader.resources[spritesheet].textures;
for (const textureKey in gameTextures) {
if (!gameTextures.hasOwnProperty(textureKey) || textureKey.indexOf(spriteId) === -1) {
continue;
}

let parts = textureKey.split('/');
const parts = textureKey.split('/');
parts.length -= 1; //truncate to remove media file

let state = parts.join('/').replace(spriteId + '/', '');
const state = parts.join('/').replace(spriteId + '/', '');

// Only add textures if the state is supported by the class
let stateObj = _find(states, {name: state});
const stateObj = _find(states, {name: state});
if (!stateObj) {
continue;
}
Expand Down Expand Up @@ -57,7 +57,7 @@ class Character extends PIXI.extras.MovieClip {
*/
stopAndClearTimeline() {
this.timeline.pause();
let timelineItem = this.timeline.getChildren();
const timelineItem = this.timeline.getChildren();
for (let i = 0; i < timelineItem.length; i++) {
timelineItem[i].kill();
}
Expand Down Expand Up @@ -93,9 +93,9 @@ class Character extends PIXI.extras.MovieClip {
* @throws {Error} In order for a state to be set, a texture must be specified in the spritesheet
*/
set state(value) {
let stateObj = _find(this.states, {name: value});
const stateObj = _find(this.states, {name: value});
if (!stateObj) {
throw new Error('The requested state (' + state + ') is not availble for this Character.');
throw new Error('The requested state (' + value + ') is not availble for this Character.');
}
this.stateVal = value;
this._textures = stateObj.textures;
Expand Down
17 changes: 9 additions & 8 deletions src/modules/Dog.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*global Howl, TweenMax*/

import 'gsap/src/uncompressed/TweenMax.js';
import _delay from 'lodash/function/delay';
import _noop from 'lodash/utility/noop';
import _extend from 'lodash/object/assign';
import Howler from 'howler';
import 'howler';
import audioSpriteSheet from '../../dist/audio.json';
import Character from './Character';

Expand All @@ -17,7 +18,7 @@ class Dog extends Character {
* @param {PIXI.Point} options.upPoint The point the dog should rise to when retrieving ducks
*/
constructor(options) {
let states = [
const states = [
{
name: 'double',
animationSpeed: 0.1
Expand Down Expand Up @@ -60,7 +61,7 @@ class Dog extends Character {
* @returns {Dog}
*/
sniff(opts) {
let options = _extend({
const options = _extend({
startPoint: this.position,
endPoint: this.position,
onStart: _noop,
Expand Down Expand Up @@ -104,7 +105,7 @@ class Dog extends Character {
* return {Dog}
*/
upDownTween(opts) {
let options = _extend({
const options = _extend({
startPoint: this.options.downPoint || this.position,
endPoint: this.options.upPoint || this.position,
onStart: _noop,
Expand All @@ -115,7 +116,7 @@ class Dog extends Character {
point: options.startPoint
});

this.timeline.add(TweenMax.to(this.position, 0.4, {
this.timeline.add(TweenMax.to(this.position, 0.4, {
y: options.endPoint.y,
yoyo: true,
repeat: 1,
Expand All @@ -138,7 +139,7 @@ class Dog extends Character {
* @returns {Dog}
*/
find(opts) {
let options = _extend({
const options = _extend({
onStart: _noop,
onComplete: _noop
}, opts);
Expand Down Expand Up @@ -175,7 +176,7 @@ class Dog extends Character {
* @returns {Dog}
*/
sit(opts) {
let options = _extend({
const options = _extend({
point: this.position,
onStart: _noop,
onComplete: _noop
Expand Down
16 changes: 9 additions & 7 deletions src/modules/Duck.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Howler from 'howler';
/*global Howl*/

import 'howler';
import _random from 'lodash/number/random';
import _extend from 'lodash/object/assign';
import _noop from 'lodash/utility/noop';
Expand All @@ -22,8 +24,8 @@ class Duck extends Character {
* @param {Number} [options.randomFlightDelta] The minimum distance the duck must travel when randomly flying
*/
constructor(options) {
let spriteId = 'duck/' + options.colorProfile;
let states = [
const spriteId = 'duck/' + options.colorProfile;
const states = [
{
name: 'left',
animationSpeed: 0.18
Expand Down Expand Up @@ -74,7 +76,7 @@ class Duck extends Character {
* @param {Number} [opts.speed=1] Speed of travel on a scale of 0 (slow) to 10 (fast)
*/
randomFlight(opts) {
let options = _extend({
const options = _extend({
minX: 0,
maxX: this.options.maxX || Infinity,
minY: 0,
Expand Down Expand Up @@ -110,7 +112,7 @@ class Duck extends Character {
* @returns {Duck}
*/
flyTo(opts) {
let options = _extend({
const options = _extend({
point: this.position,
speed: this.speed,
onStart: _noop,
Expand All @@ -119,8 +121,8 @@ class Duck extends Character {

this.speed = options.speed;

let direction = Utils.directionOfTravel(this.position, options.point);
let tweenSeconds = (this.flightAnimationMs + _random(0, 300)) / 1000;
const direction = Utils.directionOfTravel(this.position, options.point);
const tweenSeconds = (this.flightAnimationMs + _random(0, 300)) / 1000;

this.timeline.to(this.position, tweenSeconds, {
x: options.point.x,
Expand Down
Loading

0 comments on commit a151864

Please sign in to comment.