From 287a2396f1219ecaf3241b801c913aafff3b177e Mon Sep 17 00:00:00 2001 From: Joe Lencioni Date: Tue, 8 Apr 2014 12:56:27 -0700 Subject: [PATCH] Make .jshintrc more strict When I originally added this file to the project, I simply copied another project's settings. This commit removes most of the relaxing options and adds most of the enforcing options. If we had these lints enabled, we would have avoided the previous bug. Descriptions of these options can be found at: http://www.jshint.com/docs/options/ At the same time I made some adjustments to the code to satisfy the new lints. Change-Id: I1b83b8c439812bac843f1705f9bff3d54e5fdfc0 Reviewed-on: http://gerrit.causes.com/37022 Tested-by: Joe Lencioni Reviewed-by: Hao Su --- .jshintrc | 32 ++++++++++++++++++++------------ Gruntfile.js | 30 +++++++++++++++--------------- method-proxy.js | 4 +++- spec/method-proxy.js | 12 +++++++++++- 4 files changed, 49 insertions(+), 29 deletions(-) diff --git a/.jshintrc b/.jshintrc index 959f0a5..e5934ae 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,16 +1,24 @@ { - "asi" : true, + "bitwise" : true, "boss" : true, "browser" : true, - "curly" : false, - "debug" : true, - "devel" : true, - "eqeqeq" : false, - "eqnull" : true, - "expr" : true, - "laxbreak" : true, - "laxcomma" : true, - "multistr" : true, - "supernew" : true, - "validthis" : true + "camelcase" : true, + "curly" : true, + "eqeqeq" : true, + "es3" : true, + "forin" : true, + "freeze" : true, + "immed" : true, + "indent" : 2, + "latedef" : true, + "newcap" : true, + "noarg" : true, + "noempty" : true, + "nonbsp" : true, + "nonew" : true, + "quotmark" : "single", + "undef" : true, + "unused" : true, + "strict" : true, + "trailing" : true } diff --git a/Gruntfile.js b/Gruntfile.js index 306b1cb..0c62e9d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,23 +1,23 @@ /* jshint node: true */ module.exports = function(grunt) { - "use strict"; + 'use strict'; grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - jshint: { - all: [ - "*.js", - "spec/*.js" - ], - options: { - jshintrc: '.jshintrc' - } - }, - jasmine: { - src: "method-proxy.js", - options: { - specs: "spec/**/*.js" + pkg: grunt.file.readJSON('package.json'), + jshint: { + all: [ + '*.js', + 'spec/*.js' + ], + options: { + jshintrc: '.jshintrc' + } + }, + jasmine: { + src: 'method-proxy.js', + options: { + specs: 'spec/**/*.js' } } }); diff --git a/method-proxy.js b/method-proxy.js index 9172888..63e785f 100644 --- a/method-proxy.js +++ b/method-proxy.js @@ -1,4 +1,6 @@ -var MethodProxy = function(object, queue) { +window.MethodProxy = function(object, queue) { + 'use strict'; + this.init = function(object, queue) { var item; diff --git a/spec/method-proxy.js b/spec/method-proxy.js index 32f4ba5..cc2584c 100644 --- a/spec/method-proxy.js +++ b/spec/method-proxy.js @@ -1,4 +1,14 @@ +/* global MethodProxy:false */ +/* global describe:false */ +/* global it:false */ +/* global beforeEach:false */ +/* global spyOn:false */ +/* global expect:false */ describe('MethodProxy', function() { + 'use strict'; + + var FB, FBMethodProxy; + beforeEach(function() { FB = { aMethod : function() {}, @@ -54,7 +64,7 @@ describe('MethodProxy', function() { spyOn(FB, 'aMethod'); spyOn(FB.anObject, 'anotherMethod'); - new MethodProxy(FB, queue); + queue = new MethodProxy(FB, queue); expect(FB.aMethod).toHaveBeenCalledWith('my argument'); expect(FB.anObject.anotherMethod) .toHaveBeenCalledWith('my other argument', 'one more');