Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Commit

Permalink
adding and enforcing jscs
Browse files Browse the repository at this point in the history
  • Loading branch information
tymondesigns committed Jun 8, 2015
1 parent ce12bac commit 695d250
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 9 deletions.
59 changes: 59 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"requireCurlyBraces": [
"else",
"for",
"while",
"do",
"try",
"catch"
],
"validateIndentation": 4,
"validateQuoteMarks": "'",

"disallowMultipleLineStrings": true,
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,

"disallowKeywordsOnNewLine": ["else"],

"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],

"requireSpaceBeforeBinaryOperators": [
"=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
"&=", "|=", "^=", "+=",

"+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
"|", "^", "&&", "||", "===", "==", ">=",
"<=", "<", ">", "!=", "!=="
],

"requireSpaceAfterBinaryOperators": true,
"requireSpacesInConditionalExpression": true,
"requireSpaceBeforeBlockStatements": true,
"requireSpacesInForStatement": true,
"requireLineFeedAtFileEnd": true,
"requireCamelCaseOrUpperCaseIdentifiers": true,
"requireSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},

"disallowSpacesInCallExpression": true,
"disallowSpaceAfterObjectKeys": true,
"requireSpaceBeforeObjectValues": true,
"requireCapitalizedConstructors": true,
"requireDotNotation": true,
"validateParameterSeparator": ", ",

"maximumLineLength": 120
}
7 changes: 5 additions & 2 deletions dist/angular-locker.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@
};

/**
* Try to parse value as json, if it fails then it probably isn't json so just return it
* Try to parse value as json, if it fails then it probably isn't json
* so just return it
*
* @param {String} value
*
Expand Down Expand Up @@ -262,7 +263,9 @@
this._event('locker.item.added', { key: key, value: value });
}
} catch (e) {
if (['QUOTA_EXCEEDED_ERR', 'NS_ERROR_DOM_QUOTA_REACHED', 'QuotaExceededError'].indexOf(e.name) !== -1) {
if (['QUOTA_EXCEEDED_ERR',
'NS_ERROR_DOM_QUOTA_REACHED',
'QuotaExceededError'].indexOf(e.name) !== -1) {
_error('The browser storage quota has been exceeded');
} else {
_error('Could not add item with key "' + key + '"');
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-locker.min.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ var gulp = require('gulp'),
// Lint the JS
gulp.task('lint', fizzy.task('lint', { src: paths.scripts }));

// Check the coding style
gulp.task('jscs', fizzy.task('jscs', { src: paths.scripts[0] }));

// Remove the output folder
gulp.task('clean', fizzy.task('clean', { src: paths.output }));

Expand All @@ -30,7 +33,7 @@ gulp.task('gitdown', fizzy.task('gitdown', {
}));

// Define the build tasks
gulp.task('build', ['lint', 'scripts', 'test', 'gitdown']);
gulp.task('build', ['lint', 'jscs', 'scripts', 'test', 'gitdown']);

// Increment versions
gulp.task('version', fizzy.task('version', {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"devDependencies": {
"angular-mocks": ">=1.2.0 <2.0.0",
"gulp": "~3.8.6",
"fizzy": "^0.1.10",
"fizzy": "^0.2.1",
"karma": "^0.12.16",
"karma-coverage": "~0.2.6",
"karma-jasmine": "~0.2.0",
Expand Down
11 changes: 7 additions & 4 deletions src/angular-locker.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
/**
* Check browser support
*
* @see https://github.com/Modernizr/Modernizr/blob/master/feature-detects/storage/localstorage.js#L38-L47
* @see github.com/Modernizr/Modernizr/blob/master/feature-detects/storage/localstorage.js#L38-L47
* @param {String} driver
*
* @return {Boolean}
Expand Down Expand Up @@ -212,7 +212,8 @@
};

/**
* Try to parse value as json, if it fails then it probably isn't json so just return it
* Try to parse value as json, if it fails then it probably isn't json
* so just return it
*
* @param {String} value
*
Expand Down Expand Up @@ -262,7 +263,9 @@
this._event('locker.item.added', { key: key, value: value });
}
} catch (e) {
if (['QUOTA_EXCEEDED_ERR', 'NS_ERROR_DOM_QUOTA_REACHED', 'QuotaExceededError'].indexOf(e.name) !== -1) {
if (['QUOTA_EXCEEDED_ERR',
'NS_ERROR_DOM_QUOTA_REACHED',
'QuotaExceededError'].indexOf(e.name) !== -1) {
_error('The browser storage quota has been exceeded');
} else {
_error('Could not add item with key "' + key + '"');
Expand Down Expand Up @@ -585,7 +588,7 @@
/**
* Check browser support
*
* @see https://github.com/Modernizr/Modernizr/blob/master/feature-detects/storage/localstorage.js#L38-L47
* @see github.com/Modernizr/Modernizr/blob/master/feature-detects/storage/localstorage.js#L38-L47
* @param {String} driver
* @return {Boolean}
*/
Expand Down

0 comments on commit 695d250

Please sign in to comment.