gulp-jscs Object.keys called on non-object
Asked Answered
E

3

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());
});
Evonneevonymus answered 6/2, 2015 at 15:6 Comment(6)
Dunno. Do you have a file called app.js in a src folder?Indonesia
Yeah, and I used gulp-jshint and it went well. But had a problem with gulp-jscsEvonneevonymus
And do you have a .jscsrc config file? Not a .jscs.json file which was the old way of doing things iirc.Indonesia
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?Evonneevonymus
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.Indonesia
It seems it's a versions conflict, since jshint worked well. Thanks man!Evonneevonymus
F
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.

Floria answered 21/2, 2015 at 15:7 Comment(8)
It seems to be another problem, I checked .jscsrc but it has all the required privilegesEvonneevonymus
Weird, I had to actually save and overwrite it with a text editor in OSX so that I could allow the file name to start with a '.'Floria
try overwriting it with a text editor and make sure the file name starts with '.'Floria
I already did that; just in case; but didn't have any effect on the problemEvonneevonymus
I am also have this issue, using nvm with node v0.11Ashtoreth
I have the same problem. Did you fix it?Catalano
Yeah, I added .jscsrc file to my application root directory. Then it worked like a charm!!Evonneevonymus
I tried TechnoTims approach but that didn't work for me. I had to copy the file to the root folder. Very hacky indeed!Combust
S
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.

Spina answered 13/8, 2015 at 18:43 Comment(0)
S
0

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

Selectee answered 17/4, 2016 at 2:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.