Gulp Jscs-TypeError:无法将未定义或null转换为对象

Gulp Jscs-TypeError:无法将未定义或null转换为对象,gulp,gulp-jscs,Gulp,Gulp Jscs,我想在我的项目中使用gulp JSC,因此我按照以下步骤安装了它: 但是,当我尝试运行gulp文件时,出现以下错误: TypeError: Cannot convert undefined or null to object at Function.keys (native) at copyConfiguration (C:\Users\[User]\Desktop\[Project]\ node_modules\jscs\lib\config\configuration

我想在我的项目中使用gulp JSC,因此我按照以下步骤安装了它:

但是,当我尝试运行gulp文件时,出现以下错误:

TypeError: Cannot convert undefined or null to object
    at Function.keys (native)
    at copyConfiguration (C:\Users\[User]\Desktop\[Project]\
    node_modules\jscs\lib\config\configuration.js:920:12)
此外,还有其他与此相关的错误:

at NodeConfiguration.Configuration.
_processConfig([location-path]\node_modules\jscs\lib\config\configuration.js:459:5)
    at NodeConfiguration.Configuration.load 
([location-path]\node_modules\jscs\lib\config\configuration.js:211:10)
    at null.StringChecker.configure 
([location-path]\node_modules\jscs\lib\string-checker.js:62:29)
    at null.Checker.configure ([location-path]\node_modules\jscs\lib\checker.js:27:39)
    at Object.module.exports ([location-path]\node_modules\gulp-jscs\index.js:35:10)
    at Gulp.<anonymous> ([location-path]\Gulpfile.js:60:17)
    at module.exports ([location-path]\node_modules\orchestrator\lib\runTask.js:34:7)
    at Gulp.Orchestrator._runTask ([location-path]\node_modules\orchestrator\index.js:273:3)
Process terminated with code 1.
位于NodeConfiguration.Configuration。
_processConfig([位置路径]\node\u modules\jscs\lib\config\configuration.js:459:5)
在节点处配置.Configuration.load
([位置路径]\node\u modules\jscs\lib\config\configuration.js:211:10)
在null.StringChecker.configure处
([位置路径]\node\u modules\jscs\lib\string checker.js:62:29)
在null.Checker.configure([位置路径]\node\u modules\jscs\lib\Checker.js:27:39)
在Object.module.exports([位置路径]\node\u modules\gulp jscs\index.js:35:10)
狼吞虎咽。([位置路径]\Gulpfile.js:60:17)
在module.exports([位置路径]\node\u modules\orchestrator\lib\runTask.js:34:7)
在Gulp.Orchestrator.\u runTask([位置路径]\node\u modules\Orchestrator\index.js:273:3)
进程以代码1终止。

您需要在当前项目的根目录中有一个
.jscsrc
文件。在那里,你可以提供,以及应该遵循

下面是
.jscsrc
,这是一个很好的例子。您可以使用它来建立自己的配置

{
    "preset": "google",
    "fileExtensions": [".js", "jscs"],

    "requireSemicolons": true,
    "requireParenthesesAroundIIFE": true,
    "maximumLineLength": 120,
    "validateLineBreaks": "LF",
    "validateIndentation": 4,
    "disallowTrailingComma": true,
    "disallowUnusedParams": true,

    "disallowSpacesInsideObjectBrackets": null,
    "disallowImplicitTypeConversion": ["string"],

    "safeContextKeyword": "_this",

    "jsDoc": {
        "checkAnnotations": "closurecompiler",
        "checkParamNames": true,
        "requireParamTypes": true,
        "checkRedundantParams": true,
        "checkReturnTypes": true,
        "checkRedundantReturns": true,
        "requireReturnTypes": true,
        "checkTypes": "capitalizedNativeCase",
        "checkRedundantAccess": true,
        "requireNewlineAfterDescription": true
    },

    "excludeFiles": [
        "test/data/**",
        "patterns/*"
    ]
}
请注意,
jscs
实际上不会检查任何内容,除非您在
.jscsrc
中有一个
预设“
,或者明确指定了应该遵循的

{
    "preset": "google",
    "fileExtensions": [".js", "jscs"],

    "requireSemicolons": true,
    "requireParenthesesAroundIIFE": true,
    "maximumLineLength": 120,
    "validateLineBreaks": "LF",
    "validateIndentation": 4,
    "disallowTrailingComma": true,
    "disallowUnusedParams": true,

    "disallowSpacesInsideObjectBrackets": null,
    "disallowImplicitTypeConversion": ["string"],

    "safeContextKeyword": "_this",

    "jsDoc": {
        "checkAnnotations": "closurecompiler",
        "checkParamNames": true,
        "requireParamTypes": true,
        "checkRedundantParams": true,
        "checkReturnTypes": true,
        "checkRedundantReturns": true,
        "requireReturnTypes": true,
        "checkTypes": "capitalizedNativeCase",
        "checkRedundantAccess": true,
        "requireNewlineAfterDescription": true
    },

    "excludeFiles": [
        "test/data/**",
        "patterns/*"
    ]
}