gulp-jscs Object.keys 调用非对象

gulp-jscs Object.keys called on non-object

我是 gulp 的新手,正在尝试使用它。当我尝试使用 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

这是我的 gulpfile

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

gulp.task('default', function () {
    return gulp.src('src/app.js')
        .pipe(jscs());
});

如果 jscs 没有对您的 .jscsrc 的读取权限或者它不存在,这似乎会发生。从旧的 git 复制粘贴后,这发生在我身上。要解决此问题,请使用文本编辑器打开文件并重新保存,接受覆盖提示并以“.”开头。 (例如 .jscsrc)运行 再次执行您的任务,它将完成。

我遇到了同样的问题:“无法在 /Desktop/node/My_Project_Name/.jscsrc 加载 JSCS 配置文件 输入意外结束...."

我能够通过首先检查文件是否存在于我的项目的根目录中来解决问题。在终端 运行 这个命令中: ls -ld .?*

该文件从未为我创建,所以我创建了 .jscsrc 文件,然后添加了以下代码:

{
 "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
}

将此文件保存到项目的根目录,然后 运行 gulp 任务命令再次运行。

更新 bower.json 中对 ngCordova 的依赖并解决问题!!!