Permalink
Browse files

extract jscs config into .jscsrc; resolves #632

- removed JSCS config from `Gruntfile.js`; config now lives in `.jscsrc`
- added `util/` to paths covered by JSCS
- fixed JSCS errors in `util/xbee.js`
  - a couple formatting problems
  - you can't `return` a `process.exit()` call
  - fixed what appeared to be a logic error when no port name specified; would exit too early
  - the above three issues were reported by JSCS
  • Loading branch information...
1 parent b0a4c70 commit 4bf24c04e60f773b8ccfba3303afe3a870682b87 @boneskull boneskull committed Feb 24, 2015
Showing with 47 additions and 45 deletions.
  1. +29 −0 .jscsrc
  2. +8 −34 Gruntfile.js
  3. +10 −11 util/xbee.js
View
@@ -0,0 +1,29 @@
+{
+ "requireCurlyBraces": [
+ "if",
+ "else",
+ "for",
+ "while",
+ "do",
+ "try",
+ "catch"
+ ],
+ "disallowNewlineBeforeBlockStatements": true,
+ "requireSpaceBeforeBlockStatements": true,
+ "requireParenthesesAroundIIFE": true,
+ "requireSpacesInConditionalExpression": true,
+ "requireSpaceAfterKeywords": [
+ "if", "else",
+ "switch", "case",
+ "try", "catch",
+ "do", "while", "for",
+ "return", "typeof", "void"
+ ],
+ "validateQuoteMarks": {
+ "mark": "\"",
+ "escape": true
+ },
+ "excludeFiles": [
+ "node_modules/**/*.js"
+ ]
+}
View
@@ -108,41 +108,15 @@ module.exports = function(grunt) {
}
},
jscs: {
- files: {
- src: [
- "Gruntfile.js",
- "lib/**/!(johnny-five)*.js",
- "test/**/*.js",
- "eg/**/*.js",
- ]
- },
+ src: [
+ "Gruntfile.js",
+ "lib/**/!(johnny-five)*.js",
+ "test/**/*.js",
+ "eg/**/*.js",
+ "util/**/*.js"
+ ],
options: {
- config: ".jscsrc",
- requireCurlyBraces: [
- "if",
- "else",
- "for",
- "while",
- "do",
- "try",
- "catch",
- ],
- disallowNewlineBeforeBlockStatements: true,
- requireSpaceBeforeBlockStatements: true,
- requireParenthesesAroundIIFE: true,
- requireSpacesInConditionalExpression: true,
- // requireSpaceBeforeKeywords: true,
- requireSpaceAfterKeywords: [
- "if", "else",
- "switch", "case",
- "try", "catch",
- "do", "while", "for",
- "return", "typeof", "void",
- ],
- validateQuoteMarks: {
- mark: "\"",
- escape: true
- }
+ config: ".jscsrc"
}
},
jsbeautifier: {
View
@@ -45,18 +45,17 @@ var args = optimist
if (args.help) {
optimist.showHelp();
- return process.exit(-1);
+ process.exit(-1);
}
if (!args.portname) {
console.error("Serial port name is required. \n `-p /dev/PORTNAME` \n Use one of the following");
- serialport.list(function(err, data){
- data.forEach(function(v){
+ serialport.list(function (err, data) {
+ data.forEach(function (v) {
console.log("\t" + v.comName);
});
- return process.exit(-1);
});
- return;
+ process.exit(-1);
}
var guardTime = args.guardtime * 1000;
@@ -76,8 +75,8 @@ var open = function (cb) {
port.once("open", cb);
};
-var wait = function(ms) {
- return function(cb) {
+var wait = function (ms) {
+ return function (cb) {
setTimeout(cb, ms);
};
};
@@ -110,16 +109,16 @@ var exit = function () {
process.exit(0);
};
-var print = function(str) {
- return function(cb){
+var print = function (str) {
+ return function (cb) {
console.log(str);
cb();
};
};
-var printCmd = function(msg, str) {
+var printCmd = function (msg, str) {
return function (cb) {
- readCmd(str + "\r")(function(err, data){
+ readCmd(str + "\r")(function (err, data) {
console.log(msg + " (" + str + "): " + data);
cb();
});

0 comments on commit 4bf24c0

Please sign in to comment.