Skip to content

Commit 22b1167

Browse files
Make some rules consistent and fix some files
1 parent 51e8745 commit 22b1167

5 files changed

Lines changed: 38 additions & 16 deletions

File tree

Gruntfile.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*jshint node:true, quotmark:single */
1+
/*jshint node:true */
22
'use strict';
33

44
module.exports = function (grunt) {
@@ -24,6 +24,27 @@ module.exports = function (grunt) {
2424
source: 'src/**/*.js',
2525
tests: 'test/**/*.js'
2626
},
27+
jscs: {
28+
options: {
29+
requireCommaBeforeLineBreak: true,
30+
requireLineFeedAtFileEnd: true,
31+
requireSemicolons: true,
32+
requireSpaceBeforeKeywords: ['else', 'while', 'catch'],
33+
requireSpaceAfterKeywords: true,
34+
requireSpaceAfterLineComment: true,
35+
requireSpaceBeforeBlockStatements: true,
36+
requireSpaceBeforeObjectValues: true,
37+
validateIndentation: '\t',
38+
validateLineBreaks: 'LF',
39+
validateQuoteMarks: true,
40+
disallowSpacesInsideArrayBrackets: 'all',
41+
disallowSpacesInsideParentheses: true,
42+
disallowTrailingWhitespace: true
43+
},
44+
grunt: 'Gruntfile.js',
45+
source: 'src/**/*.js',
46+
tests: ['test/**/*.js', '!test/polyfill.js']
47+
},
2748
uglify: {
2849
options: {
2950
banner: '/*! <%= pkg.name %> v<%= pkg.version %> | <%= pkg.license %> */\n'

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"grunt-contrib-qunit": "0.7.0",
2525
"grunt-contrib-uglify": "0.9.1",
2626
"grunt-contrib-watch": "0.6.1",
27+
"grunt-jscs": "1.6.0",
2728
"grunt-saucelabs": "8.6.0",
2829
"gzip-js": "0.3.2",
2930
"qunitjs": "1.18.0",

src/js.cookie.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
if (/^[\{\[]/.test(result)) {
5656
value = result;
5757
}
58-
} catch(e) {}
58+
} catch (e) {}
5959

6060
value = encodeURIComponent(String(value));
6161
value = value.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
@@ -100,7 +100,7 @@
100100
if (this.json) {
101101
try {
102102
cookie = JSON.parse(cookie);
103-
} catch(e) {}
103+
} catch (e) {}
104104
}
105105

106106
if (key === name) {

test/node.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*jshint node:true */
22
exports.node = {
3-
should_load_js_cookie: function(test) {
3+
should_load_js_cookie: function (test) {
44
test.expect(3);
55
var Cookies = require('../src/js.cookie');
6-
7-
test.ok( !!Cookies.get, 'should expose get api' );
8-
test.ok( !!Cookies.set, 'should expose set api' );
9-
test.ok( !!Cookies.remove, 'should expose remove api' );
10-
6+
7+
test.ok(!!Cookies.get, 'should expose get api');
8+
test.ok(!!Cookies.set, 'should expose set api');
9+
test.ok(!!Cookies.remove, 'should expose remove api');
10+
1111
test.done();
1212
}
1313
};

test/tests.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ asyncTest('malformed cookie value in IE', function () {
4848
// Sandbox in an iframe so that we can poke around with document.cookie.
4949
var iframe = document.createElement('iframe');
5050
var addEvent = function (element, eventName, fn) {
51-
var method = "addEventListener";
51+
var method = 'addEventListener';
5252
if (element.attachEvent) {
5353
eventName = 'on' + eventName;
54-
method = "attachEvent";
54+
method = 'attachEvent';
5555
}
5656
element[ method ](eventName, fn);
5757
};
@@ -186,12 +186,12 @@ test('passing options reference', function () {
186186
var options = { path: '/' };
187187
Cookies.set('c', 'v', options);
188188
Cookies.remove('c', options);
189-
deepEqual(options, { path: '/' }, "won't alter options object");
189+
deepEqual(options, { path: '/' }, 'won\'t alter options object');
190190
});
191191

192192
module('converters', lifecycle);
193193

194-
//github.com/carhartl/jquery-cookie/pull/166
194+
// github.com/carhartl/jquery-cookie/pull/166
195195
test('provide a way for decoding characters encoded by the escape function', function () {
196196
expect(1);
197197
document.cookie = 'c=%u5317%u4eac';
@@ -209,7 +209,7 @@ test('should decode a malformed char that matches the decodeURIComponent regex',
209209
test('should be able to conditionally decode a single malformed cookie', function () {
210210
expect(4);
211211
var cookies = Cookies.withConverter(function (value, name) {
212-
if ( name === 'escaped' ) {
212+
if (name === 'escaped') {
213213
return unescape(value);
214214
}
215215
});
@@ -278,7 +278,7 @@ test('Object Constructor', function () {
278278
strictEqual(Cookies.get('c'), '{"k":"v"}', 'should return a String');
279279
});
280280

281-
test('Use String(value) for unsupported objects that do not stringify into JSON', function() {
281+
test('Use String(value) for unsupported objects that do not stringify into JSON', function () {
282282
expect(2);
283283

284284
Cookies.set('date', new Date(2015, 04, 13, 0, 0, 0, 0));
@@ -295,7 +295,7 @@ test('Call to read all cookies with mixed json', function () {
295295

296296
module('noConflict', lifecycle);
297297

298-
test('do not conflict with existent globals', function() {
298+
test('do not conflict with existent globals', function () {
299299
expect(2);
300300
var Cookies = window.Cookies.noConflict();
301301
Cookies.set('c', 'v');

0 commit comments

Comments
 (0)