Skip to content

Commit ed53462

Browse files
author
Eric Koleda
committed
Added JSHint linting to the gulp file and fixed errors and warnings.
1 parent 00794fe commit ed53462

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

gulpfile.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var gulpif = require('gulp-if');
66
var del = require('del');
77
var bump = require('gulp-bump');
88
var rename = require("gulp-rename");
9+
var jshint = require('gulp-jshint');
10+
var stylish = require('jshint-stylish');
911

1012
gulp.task('release', ['clean', 'dist'], function() {
1113
gulp.src('./package.json')
@@ -30,3 +32,9 @@ gulp.task('clean', function() {
3032
'dist/*'
3133
]);
3234
});
35+
36+
gulp.task('lint', function() {
37+
return gulp.src('src/*.gs')
38+
.pipe(jshint())
39+
.pipe(jshint.reporter(stylish));
40+
});

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
"gulp-concat": "^2.6.0",
2121
"gulp-expose": "0.0.7",
2222
"gulp-if": "^1.2.5",
23+
"gulp-jshint": "^1.12.0",
2324
"gulp-rename": "^1.2.2",
24-
"gulp-strip-line": "0.0.1"
25+
"gulp-strip-line": "0.0.1",
26+
"jshint-stylish": "^2.0.1"
2527
},
2628
"dependencies": {
2729
"underscore": "^1.8.3"

src/OAuth2.gs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ if (module) {
5656
module.exports = {
5757
createService: createService,
5858
getRedirectUri: getRedirectUri
59-
}
59+
};
6060
}

src/Service.gs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* @fileoverview Contains the Service_ class.
1717
*/
1818

19+
// Disable JSHint warnings for the use of eval(), since it's required to prevent
20+
// scope issues in Apps Script.
21+
// jshint evil:true
22+
1923
/**
2024
* Creates a new OAuth2 service.
2125
* @param {string} serviceName The name of the service.
@@ -170,7 +174,7 @@ Service_.prototype.setCache = function(cache) {
170174
*/
171175
Service_.prototype.setScope = function(scope, opt_separator) {
172176
var separator = opt_separator || ' ';
173-
this.params_['scope'] = _.isArray(scope) ? scope.join(separator) : scope;
177+
this.params_.scope = _.isArray(scope) ? scope.join(separator) : scope;
174178
return this;
175179
};
176180

@@ -574,10 +578,10 @@ Service_.prototype.createJwt_ = function() {
574578
iat: Math.round(now.getTime() / 1000)
575579
};
576580
if (this.subject_) {
577-
claimSet['sub'] = this.subject_;
581+
claimSet.sub = this.subject_;
578582
}
579-
if (this.params_['scope']) {
580-
claimSet['scope'] = this.params_['scope'];
583+
if (this.params_.scope) {
584+
claimSet.scope = this.params_.scope;
581585
}
582586
var toSign = Utilities.base64EncodeWebSafe(JSON.stringify(header)) + '.' + Utilities.base64EncodeWebSafe(JSON.stringify(claimSet));
583587
var signatureBytes = Utilities.computeRsaSha256Signature(toSign, this.privateKey_);

src/Utilities.gs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function validate_(params) {
5353
* @private
5454
*/
5555
function isEmpty_(value) {
56-
return value == null || value == undefined ||
56+
return value === null || value === undefined ||
5757
((_.isObject(value) || _.isString(value)) && _.isEmpty(value));
5858
}
5959

0 commit comments

Comments
 (0)