8

I'm a novice at gulp, and trying to play with it. I get this error when I try to use gulp-jscs

'default' errored after 98 ms
[16:58:00] TypeError: Object.keys called on non-object
    at Function.keys (native)
    at NodeConfiguration.Configuration._throwNonCamelCaseErrorIfNeeded (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp-jscs/node_modules/jscs/lib/config/configuration.js:440:12)
    at NodeConfiguration.Configuration.load (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp-jscs/node_modules/jscs/lib/config/configuration.js:51:10)
    at StringChecker.configure (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp-jscs/node_modules/jscs/lib/string-checker.js:66:29)
    at Checker.configure (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp-jscs/node_modules/jscs/lib/checker.js:26:39)
    at module.exports (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp-jscs/index.js:31:11)
    at Gulp.<anonymous> (/home/kbadr/Node_Projects/demo/membership/gulpfile.js:22:15)
    at module.exports (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/home/kbadr/Node_Projects/demo/membership/node_modules/gulp/node_modules/orchestrator/index.js:214:10

and here's my gulpfile

var gulp = require('gulp');
var jscs = require('gulp-jscs');

gulp.task('default', function () {
    return gulp.src('src/app.js')
        .pipe(jscs());
});
fernandopasik
  • 9,565
  • 7
  • 48
  • 55
Khaled Karam
  • 173
  • 1
  • 4
  • 13
  • Dunno. Do you have a file called `app.js` in a `src` folder? – Andy Feb 06 '15 at 15:11
  • Yeah, and I used gulp-jshint and it went well. But had a problem with gulp-jscs – Khaled Karam Feb 06 '15 at 15:14
  • 3
    And do you have a `.jscsrc` config file? Not a `.jscs.json` file which was the old way of doing things iirc. – Andy Feb 06 '15 at 15:18
  • 1
    I don't know I got this code from the npm website. But isn't there a default .jscsrc file that comes with the package? – Khaled Karam Feb 06 '15 at 15:25
  • I don't use it myself. I was just googling `object.keys gulp` to see what I could find and that was one of the issues. Perhaps see if your node and version of jscs is up to date, and then see if there's a .jscsrc file on your system and create one if there isn't. – Andy Feb 06 '15 at 15:30
  • 1
    It seems it's a versions conflict, since jshint worked well. Thanks man! – Khaled Karam Feb 06 '15 at 15:39

3 Answers3

8

This seems to happen if jscs doesn't have read access to your .jscsrc or if it doesn't exist. This happened to me after copying and pasting it from an old git repro. To fix this open the file with a text editor and resave it, accepting the prompt to overwrite as well as starting with a '.' (e.g. .jscsrc) Run your task again and it will complete.

TechnoTim
  • 3,065
  • 1
  • 23
  • 28
2

I had the same problem: "Unable to load JSCS config file at /Desktop/node/My_Project_Name/.jscsrc Unexpected end of input...."

I was able to solve the problem by first checking to see if the file existed in the root of my project. in terminal run this command: ls -ld .?*

The file was never created for me so I created the .jscsrc file then I added the following code:

{
 "excludeFiles": ["node_modules/**", "bower_components/**"],

"requireCurlyBraces": [
    "if",
    "else",
    "for",
    "while",
    "do",
    "try",
    "catch"
],
"requireOperatorBeforeLineBreak": true,
"requireCamelCaseOrUpperCaseIdentifiers": true,
"maximumLineLength": {
  "value": 100,
  "allowComments": true,
  "allowRegex": true
},
"validateIndentation": 4,
"validateQuoteMarks": "'",

"disallowMultipleLineStrings": true,
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowMultipleVarDecl": null,

"requireSpaceAfterKeywords": [
  "if",
  "else",
  "for",
  "while",
  "do",
  "switch",
  "return",
  "try",
  "catch"
],
"requireSpaceBeforeBinaryOperators": [
    "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
    "&=", "|=", "^=", "+=",

    "+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
    "|", "^", "&&", "||", "===", "==", ">=",
    "<=", "<", ">", "!=", "!=="
],
"requireSpaceAfterBinaryOperators": true,
"requireSpacesInConditionalExpression": true,
"requireSpaceBeforeBlockStatements": true,
"requireLineFeedAtFileEnd": true,
"disallowSpacesInsideObjectBrackets": "all",
"disallowSpacesInsideArrayBrackets": "all",
"disallowSpacesInsideParentheses": true,

"validateJSDoc": {
    "checkParamNames": true,
    "requireParamTypes": true
},

"disallowMultipleLineBreaks": true,

"disallowCommaBeforeLineBreak": null,
"disallowDanglingUnderscores": null,
"disallowEmptyBlocks": null,
"disallowMultipleLineStrings": null,
"disallowTrailingComma": null,
"requireCommaBeforeLineBreak": null,
"requireDotNotation": null,
"requireMultipleVarDecl": null,
"requireParenthesesAroundIIFE": true
}

Save this file to the root of your project, then run the gulp task command again it should work.

tjacks3
  • 597
  • 4
  • 5
0

Updated the dependency in bower.json on ngCordova and resolved the issue !!!