Skip to content

Commit 06c953a

Browse files
committed
Merge pull request phaserjs#647 from xtian/grunt-jshint
Run jshint as part of build process and fix jshint errors
2 parents 953ae83 + 0841f77 commit 06c953a

165 files changed

Lines changed: 2156 additions & 2070 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.jshintrc

Lines changed: 38 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,49 @@
11
{
2-
"globals" : { "Phaser": false, "PIXI": false, "p2": false },
2+
"globals" : { "Phaser": false, "PIXI": false, "p2": false },
33
// Ignore Environment Globals
4-
"browser" : true, // Standard browser globals e.g. `window`, `document`.
5-
"couch" : false,
6-
"dojo" : false,
7-
"jquery" : true,
8-
"mootools" : false,
9-
"node" : false,
10-
"nonstandard" : false,
11-
"phantom" : false,
12-
"prototypejs" : false,
13-
"rhino" : false,
14-
"worker" : false,
15-
"wsh" : true, // Windows Scripting Host.
16-
"yui" : false,
4+
"browser" : true, // Standard browser globals e.g. `window`, `document`.
175

186
// Development
19-
"debug" : true, // Allow debugger statements e.g. browser breakpoints.
20-
"devel" : true, // Allow developments statements e.g. `console.log();`.
7+
"devel" : true, // Allow developments statements e.g. `console.log();`.
218

229
// ECMAScript Support
23-
"es3" : true, // Support legacy browser and javascript environments.
24-
"esnext" : false, // This option tells JSHint that your code uses ECMAScript 6 specific syntax.
25-
"strict" : false, // Require `use strict` pragma in every file.
26-
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
10+
"es3" : true, // Support legacy browser and javascript environments.
11+
"esnext" : false, // This option tells JSHint that your code uses ECMAScript 6 specific syntax.
12+
"strict" : false, // Require `use strict` pragma in every file.
13+
"globalstrict": false, // Allow global "use strict" (also enables 'strict').
2714

2815
// Functionality
29-
"asi" : true, // Tolerate Automatic Semicolon Insertion (no semicolons).
30-
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
31-
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
32-
"camelcase" : true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
33-
"curly" : true, // Require {} for every new block or scope.
34-
"eqeqeq" : false, // Require triple equals i.e. `===`.
35-
"eqnull" : true, // Tolerate use of `== null`.
36-
"evil" : false, // Tolerate use of `eval`.
37-
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
38-
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
39-
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array and Date.
40-
"funcscope" : true, // This option suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
41-
"immed" : false, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
42-
"iterator" : true, // This option suppresses warnings about the __iterator__ property.
43-
"lastsemic" : true, // This option suppresses warnings about missing semicolons, but only when the semicolon is omitted for the last statement in a one-line block.
44-
"latedef" : false, // Prohipit variable use before definition.
45-
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
46-
"laxcomma" : false, // This option suppresses warnings about comma-first coding style.
47-
"loopfunc" : true, // Allow functions to be defined within loops.
48-
// "maxcomplexity" : 10, // This option lets you control cyclomatic complexity throughout your code.
49-
// "maxdepth" : 2, // This option lets you control how nested do you want your blocks to be.
50-
// "maxlen" : 80, // This option lets you set the maximum length of a line.
51-
// "maxparams" : 5, // This option lets you set the max number of formal parameters allowed per function.
52-
// "maxstatements" : 25, // This option lets you set the max number of statements allowed per function.This option lets you set the max number of formal parameters allowed per function.
53-
"moz" : false, // This options tells JSHint that your code uses Mozilla JavaScript extensions.
54-
"multistr" : true, // This option suppresses warnings about multi-line strings.
55-
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
56-
"notypeof" : false, // This option suppresses warnings about invalid typeof operator values.
57-
"proto" : true, // This option suppresses warnings about the __proto__ property.
58-
"scripturl" : true, // Tolerate script-targeted URLs.
59-
"shadow" : true, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
60-
"smarttabs" : false, // This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only.
61-
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
62-
"undef" : true, // Require all non-global variables be declared before they are used.
63-
"unused" : true, // This option warns when you define and never use your variables.
64-
"validthis" : true, // This option suppresses warnings about possible strict violations when the code is running in strict mode and you use this in a non-constructor function.
16+
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
17+
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
18+
"camelcase" : true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
19+
"curly" : true, // Require {} for every new block or scope.
20+
"eqeqeq" : false, // Require triple equals i.e. `===`.
21+
"eqnull" : true, // Tolerate use of `== null`.
22+
"evil" : false, // Tolerate use of `eval`.
23+
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
24+
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
25+
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array and Date.
26+
"funcscope" : true, // This option suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
27+
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
28+
"latedef" : true, // Prohibit variable use before definition.
29+
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
30+
"laxcomma" : false, // This option suppresses warnings about comma-first coding style.
31+
"loopfunc" : true, // Allow functions to be defined within loops.
32+
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
33+
"notypeof" : false, // This option suppresses warnings about invalid typeof operator values.
34+
"shadow" : true, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
35+
"smarttabs" : false, // This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only.
36+
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
37+
"undef" : true, // Require all non-global variables be declared before they are used.
38+
"unused" : true, // This option warns when you define and never use your variables.
6539

6640
// Styling
67-
"indent" : 4, // Specify indentation spacing
68-
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
69-
"noempty" : true, // Prohibit use of empty blocks.
70-
"nonew" : true, // Prohibit use of constructors for side-effects.
71-
"plusplus" : false, // Prohibit use of `++` & `--`.
72-
"quotmark" : false, // This option enforces the consistency of quotation marks used throughout your code.
73-
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
74-
"trailing" : true // Prohibit trailing whitespaces.
41+
"indent" : 4, // Specify indentation spacing
42+
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
43+
"noempty" : true, // Prohibit use of empty blocks.
44+
"nonew" : true, // Prohibit use of constructors for side-effects.
45+
"plusplus" : false, // Prohibit use of `++` & `--`.
46+
"quotmark" : false, // This option enforces the consistency of quotation marks used throughout your code.
47+
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
48+
"trailing" : true // Prohibit trailing whitespaces.
7549
}

Gruntfile.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = function (grunt) {
44
grunt.loadNpmTasks('grunt-contrib-concat');
55
grunt.loadNpmTasks('grunt-contrib-connect');
66
grunt.loadNpmTasks('grunt-contrib-copy');
7+
grunt.loadNpmTasks('grunt-contrib-jshint');
78
grunt.loadNpmTasks('grunt-contrib-uglify');
89
grunt.loadNpmTasks('grunt-text-replace');
910
grunt.loadTasks('./tasks');
@@ -379,12 +380,43 @@ module.exports = function (grunt) {
379380
hostname: '*'
380381
}
381382
}
382-
}
383+
},
384+
385+
jshint: {
386+
src: {
387+
src: [
388+
'plugins/**/*.js',
389+
'src/**/*.js',
390+
'!src/Intro.js',
391+
'!src/Outro.js',
392+
'!src/pixi/**/*',
393+
'!src/physics/p2/p2.js'
394+
],
395+
options: { jshintrc: '.jshintrc' }
396+
},
397+
398+
filters: {
399+
src: ['filters/**/*.js'],
400+
options: { jshintrc: 'filters/.jshintrc', }
401+
},
383402

403+
tooling: {
404+
src: [
405+
'Gruntfile.js',
406+
'tasks/**/*.js'
407+
],
408+
options: { jshintrc: 'tasks/.jshintrc' }
409+
},
410+
411+
options: {
412+
force: true
413+
}
414+
}
384415
});
385416

386417
grunt.registerTask('default', ['build']);
387-
grunt.registerTask('build', ['clean', 'concat', 'uglify']);
388-
grunt.registerTask('dist', ['clean', 'concat', 'uglify', 'copy']);
418+
419+
grunt.registerTask('build', ['clean', 'jshint', 'concat', 'uglify']);
420+
grunt.registerTask('dist', ['build', 'copy']);
389421

390422
};

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ We now have a full [Contributors Guide][contribute] which goes into the process
282282

283283
- If you issue a Pull Request for Phaser, please only do so againt the `dev` branch and *not* against the `master` branch.
284284

285-
- Before submitting a Pull Request please run your code through [JSHint](http://www.jshint.com/) to check for stylistic or formatting errors. To use JSHint, first install it by running `npm install jshint`, then test your code by running `jshint src`. This isn't a strict requirement and we are happy to receive Pull Requests that haven't been JSHinted, so don't let it put you off contributing, but do know that we'll reformat your source before going live with it.
285+
- Before submitting a Pull Request please run your code through [JSHint](http://www.jshint.com/) to check for stylistic or formatting errors. To use JSHint, run `grunt jshint`. This isn't a strict requirement and we are happy to receive Pull Requests that haven't been JSHinted, so don't let it put you off contributing, but do know that we'll reformat your source before going live with it.
286286

287287

288288
Bugs?

filters/.jshintrc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"globals" : { "Phaser": false, "PIXI": false, "p2": false },
3+
// Ignore Environment Globals
4+
"browser" : true, // Standard browser globals e.g. `window`, `document`.
5+
6+
// Development
7+
"devel" : true, // Allow developments statements e.g. `console.log();`.
8+
9+
// ECMAScript Support
10+
"es3" : true, // Support legacy browser and javascript environments.
11+
"esnext" : false, // This option tells JSHint that your code uses ECMAScript 6 specific syntax.
12+
"strict" : false, // Require `use strict` pragma in every file.
13+
"globalstrict": false, // Allow global "use strict" (also enables 'strict').
14+
15+
// Functionality
16+
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
17+
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
18+
"camelcase" : false, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
19+
"curly" : true, // Require {} for every new block or scope.
20+
"eqeqeq" : false, // Require triple equals i.e. `===`.
21+
"eqnull" : true, // Tolerate use of `== null`.
22+
"evil" : false, // Tolerate use of `eval`.
23+
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
24+
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
25+
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array and Date.
26+
"funcscope" : true, // This option suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
27+
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
28+
"latedef" : true, // Prohibit variable use before definition.
29+
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
30+
"laxcomma" : false, // This option suppresses warnings about comma-first coding style.
31+
"loopfunc" : true, // Allow functions to be defined within loops.
32+
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
33+
"notypeof" : false, // This option suppresses warnings about invalid typeof operator values.
34+
"shadow" : true, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
35+
"smarttabs" : false, // This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only.
36+
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
37+
"undef" : true, // Require all non-global variables be declared before they are used.
38+
"unused" : true, // This option warns when you define and never use your variables.
39+
40+
// Styling
41+
"indent" : false, // Specify indentation spacing
42+
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
43+
"noempty" : true, // Prohibit use of empty blocks.
44+
"nonew" : true, // Prohibit use of constructors for side-effects.
45+
"plusplus" : false, // Prohibit use of `++` & `--`.
46+
"quotmark" : false, // This option enforces the consistency of quotation marks used throughout your code.
47+
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
48+
"trailing" : true // Prohibit trailing whitespaces.
49+
}

filters/BinarySerpents.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Phaser.Filter.BinarySerpents = function (game) {
99
this.uniforms.march = { type: '1i', value: 100 };
1010
this.uniforms.maxDistance = { type: '1f', value: 5.0 };
1111
this.uniforms.fog = { type: '1f', value: 5.0 };
12-
12+
1313
this.fragmentSrc = [
1414

1515
"precision mediump float;",
@@ -65,7 +65,7 @@ Phaser.Filter.BinarySerpents = function (game) {
6565
"float r = Texture3D(ray, 33.);",
6666
"gl_FragColor = result * (step(r, .3) + r * .2 + .1);",
6767
"}"
68-
];
68+
];
6969

7070
};
7171

@@ -81,7 +81,7 @@ Phaser.Filter.BinarySerpents.prototype.init = function (width, height, march, ma
8181
this.uniforms.march.value = march;
8282
this.uniforms.maxDistance.value = maxDistance;
8383

84-
}
84+
};
8585

8686
Object.defineProperty(Phaser.Filter.BinarySerpents.prototype, 'fog', {
8787

filters/BlurX.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Phaser.Filter.BlurX = function (game) {
66
Phaser.Filter.call(this, game);
77

88
this.uniforms.blur = { type: '1f', value: 1 / 512 };
9-
9+
1010
this.fragmentSrc = [
1111

1212
"precision mediump float;",
@@ -27,7 +27,7 @@ Phaser.Filter.BlurX = function (game) {
2727
"sum += texture2D(uSampler, vec2(vTextureCoord.x + 2.0*blur, vTextureCoord.y)) * 0.12;",
2828
"sum += texture2D(uSampler, vec2(vTextureCoord.x + 3.0*blur, vTextureCoord.y)) * 0.09;",
2929
"sum += texture2D(uSampler, vec2(vTextureCoord.x + 4.0*blur, vTextureCoord.y)) * 0.05;",
30-
30+
3131
"gl_FragColor = sum;",
3232

3333
"}"

filters/BlurY.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Phaser.Filter.BlurY = function (game) {
66
Phaser.Filter.call(this, game);
77

88
this.uniforms.blur = { type: '1f', value: 1 / 512 };
9-
9+
1010
this.fragmentSrc = [
1111

1212
"precision mediump float;",
@@ -27,7 +27,7 @@ Phaser.Filter.BlurY = function (game) {
2727
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 2.0*blur)) * 0.12;",
2828
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 3.0*blur)) * 0.09;",
2929
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 4.0*blur)) * 0.05;",
30-
30+
3131
"gl_FragColor = sum;",
3232

3333
"}"

filters/CausticLight.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Phaser.Filter.SampleFilter = function (game) {
66
Phaser.Filter.call(this, game);
77

88
this.uniforms.divisor = { type: '1f', value: 0.5 };
9-
9+
1010
// The fragment shader source
1111
this.fragmentSrc = [
1212

@@ -53,9 +53,9 @@ Phaser.Filter.SampleFilter.prototype.constructor = Phaser.Filter.SampleFilter;
5353

5454
Phaser.Filter.SampleFilter.prototype.init = function (width, height, divisor) {
5555

56-
if (typeof divisor == 'undefined') { divisor = 0.5 };
56+
if (typeof divisor == 'undefined') { divisor = 0.5; }
5757

5858
this.setResolution(width, height);
5959
this.uniforms.divisor.value = divisor;
6060

61-
}
61+
};

filters/CheckerWave.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Phaser.Filter.CheckerWave = function (game) {
1010
this.uniforms.vrp = { type: '3f', value: { x: 0.0, y: -5.0, z: 0.0 }};
1111
this.uniforms.color1 = { type: '3f', value: { x: 0, y: 1, z: 1 }};
1212
this.uniforms.color2 = { type: '3f', value: { x: 1, y: 1, z: 1 }};
13-
13+
1414
this.fragmentSrc = [
1515

1616
"precision mediump float;",
@@ -91,7 +91,7 @@ Phaser.Filter.CheckerWave = function (game) {
9191
"gl_FragColor=color;",
9292
"}",
9393
"else gl_FragColor=vec4(0,0,0.1,alpha); //background color",
94-
"}",
94+
"}"
9595

9696
];
9797

@@ -104,23 +104,23 @@ Phaser.Filter.CheckerWave.prototype.init = function (width, height) {
104104

105105
this.setResolution(width, height);
106106

107-
}
107+
};
108108

109109
Phaser.Filter.CheckerWave.prototype.setColor1 = function (red, green, blue) {
110110

111111
this.uniforms.color1.value.x = red;
112112
this.uniforms.color1.value.y = green;
113113
this.uniforms.color1.value.z = blue;
114114

115-
}
115+
};
116116

117117
Phaser.Filter.CheckerWave.prototype.setColor2 = function (red, green, blue) {
118118

119119
this.uniforms.color2.value.x = red;
120120
this.uniforms.color2.value.y = green;
121121
this.uniforms.color2.value.z = blue;
122122

123-
}
123+
};
124124

125125
Object.defineProperty(Phaser.Filter.CheckerWave.prototype, 'alpha', {
126126

filters/ColorBars.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ Phaser.Filter.ColorBars = function (game) {
66

77
Phaser.Filter.call(this, game);
88

9-
this.uniforms.alpha = { type: '1f', value: 1 }
9+
this.uniforms.alpha = { type: '1f', value: 1 };
1010
// this.uniforms.origin = { type: '1f', value: 2.0 }
11-
11+
1212
this.fragmentSrc = [
13-
13+
1414
"// bars - thygate@gmail.com",
1515
"// rotation and color mix modifications by malc (mlashley@gmail.com)",
1616
"// modified by @hintz 2013-04-30",
@@ -58,8 +58,8 @@ Phaser.Filter.ColorBars = function (game) {
5858
"color.a = alpha;",
5959
"gl_FragColor = color;",
6060
"}"
61-
62-
];
61+
62+
];
6363

6464
};
6565

@@ -70,7 +70,7 @@ Phaser.Filter.ColorBars.prototype.init = function (width, height) {
7070

7171
this.setResolution(width, height);
7272

73-
}
73+
};
7474

7575
Object.defineProperty(Phaser.Filter.ColorBars.prototype, 'alpha', {
7676

0 commit comments

Comments
 (0)