Skip to content

Commit

Permalink
fix: add code style verification
Browse files Browse the repository at this point in the history
closes #17
  • Loading branch information
sylvain-hamel committed Apr 1, 2014
1 parent b849231 commit d482680
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 14 deletions.
116 changes: 116 additions & 0 deletions .jscs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"disallowSpaceAfterKeywords": [],
"requireParenthesesAroundIIFE": true,
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireBlocksOnNewline": true,
"disallowEmptyBlocks": true,
"disallowSpacesInsideObjectBrackets": true,
"disallowSpacesInsideArrayBrackets": true,
"disallowSpaceAfterObjectKeys": true,
"requireCommaBeforeLineBreak": true,
"disallowLeftStickedOperators": [
"?",
"+",
"/",
"*",
"=",
"==",
"===",
"!=",
"!==",
">",
">=",
"<",
"<="
],
"requireRightStickedOperators": ["!"],
"disallowRightStickedOperators": [
"?",
"+",
"/",
"*",
":",
"=",
"==",
"===",
"!=",
"!==",
">",
">=",
"<",
"<="
],
"requireLeftStickedOperators": [","],
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"requireSpaceBeforeBinaryOperators": [
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!=="
],
"requireSpaceAfterBinaryOperators": [
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!=="
],
"requireCamelCaseOrUpperCaseIdentifiers": true,
"disallowKeywords": ["with"],
"disallowMultipleLineStrings": true,
"validateLineBreaks": "LF",
"validateQuoteMarks": {
"mark": "'",
"escape": true
},
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowKeywordsOnNewLine": ["else"],
"requireLineFeedAtFileEnd": true,
"maximumLineLength": 100,
"requireCapitalizedConstructors": true,
"requireDotNotation": true


}
45 changes: 45 additions & 0 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
JSHINT_NODE =
node: true,
strict: false

module.exports = (grunt) ->

# Project configuration.
Expand All @@ -17,13 +21,54 @@ module.exports = (grunt) ->
options:
checkTravisBuild: false

# JSHint options
# http://www.jshint.com/options/
jshint:
default:
files:
src: ['index.js']
options: JSHINT_NODE

options:
quotmark: 'single'
bitwise: true
freeze: true
indent: 2
camelcase: true
strict: true
trailing: true
curly: true
eqeqeq: true
immed: true
latedef: true
newcap: true
noempty: true
unused: true
noarg: true
sub: true
undef: true
maxdepth: 4
maxstatements: 100
maxcomplexity: 100
maxlen: 100
globals: {}

jscs:
default: files: src: ['index.js']
options:
config: '.jscs.json'

grunt.loadNpmTasks 'grunt-npm'
grunt.loadNpmTasks 'grunt-bump'
grunt.loadNpmTasks 'grunt-auto-release'
grunt.loadNpmTasks 'grunt-contrib-jshint'
grunt.loadNpmTasks 'grunt-jscs-checker'

grunt.registerTask 'release', 'Bump the version and publish to NPM.', (type) ->
grunt.task.run [
'npm-contributors',
"bump:#{type||'patch'}",
'npm-publish'
]
grunt.registerTask 'default', ['lint']
grunt.registerTask 'lint', ['jshint', 'jscs']
27 changes: 14 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ var IEBrowser = function(baseBrowserDecorator, logger, args) {
exec(wmic, function(err) {
if (err) {
log.error('Killing extra IE process failed. ' + err);
}
else {
} else {
log.debug('Killed extra IE process ' + pid);
}
cb();
});

}

this._getOptions = function (url) {
this._getOptions = function(url) {
var urlObj = urlparse(url, true);

handleXUaCompatible(args, urlObj);
Expand All @@ -84,18 +83,20 @@ var IEBrowser = function(baseBrowserDecorator, logger, args) {
};

function getInternetExplorerExe() {
var suffix = '\\Internet Explorer\\' + processName,
prefixes = [process.env['PROGRAMW6432'], process.env['PROGRAMFILES(X86)'], process.env['PROGRAMFILES']],
prefix, i;

for (i = 0; i < prefixes.length; i++) {
prefix = prefixes[i];
if (prefix && fs.existsSync(prefix + suffix)) {
return prefix + suffix;
}
var suffix = '\\Internet Explorer\\' + processName,
prefixes = [process.env['' + 'PROGRAMW6432'], // '' + ' trick to keep jscs happy
process.env['' + 'PROGRAMFILES(X86)'],
process.env['' + 'PROGRAMFILES']],
prefix, i;

for (i = 0; i < prefixes.length; i++) {
prefix = prefixes[i];
if (prefix && fs.existsSync(prefix + suffix)) {
return prefix + suffix;
}
}

throw new Error("Internet Explorer not found");
throw new Error('Internet Explorer not found');
}

IEBrowser.prototype = {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"grunt": "~0.4.1",
"grunt-bump": "~0.0.7",
"grunt-npm": "~0.0.2",
"grunt-auto-release": "~0.0.2"
"grunt-auto-release": "~0.0.2",
"grunt-contrib-jshint": "~0.7.2",
"grunt-jscs-checker": "~0.4.0"
},
"contributors": [
"Andreas Krummsdorf <[email protected]>",
Expand Down

0 comments on commit d482680

Please sign in to comment.