Jshint jasmine函数在mean.js中未定义

时间:2015-03-01 12:56:30

标签: jshint

我运行了一个mean.js应用程序,并且每个jasmine函数名称都返回undefined,即使我做了以下告诉我的操作:

JSHint thinks Jasmine functions are undefined

这是我项目的相关代码:

.jshintrc

{
    "node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
    "jasmine": true,
    "browser": true, // Standard browser globals e.g. `window`, `document`.
    "esnext": true, // Allow ES.next specific features such as `const` and `let`.
    "bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
    "camelcase": false, // Permit only camelcase for `var` and `object indexes`.
    "curly": false, // Require {} for every new block or scope.
    "eqeqeq": true, // Require triple equals i.e. `===`.
    "immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
    "latedef": true, // Prohibit variable use before definition.
    "newcap": true, // Require capitalization of all constructor functions e.g. `new F()`.
    "noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
    "quotmark": "single", // Define quotes to string values.
    "regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
    "undef": true, // Require all non-global variables be declared before they are used.
    "unused": false, // Warn unused variables.
    "strict": true, // Require `use strict` pragma in every file.
    "trailing": true, // Prohibit trailing whitespaces.
    "smarttabs": false, // Suppresses warnings about mixed tabs and spaces
    "predef": [ // Extra globals.
        "jasmine",
        "angular",
        "ApplicationConfiguration",
        "define",
        "require",
        "exports",
        "module",
        "describe",
        "before",
        "beforeEach",
        "after",
        "afterEach",
        "it",
        "inject",
        "expect"
    ],
    "indent": 4, // Specify indentation spacing
    "devel": true, // Allow development statements e.g. `console.log();`.
    "noempty": true // Prohibit use of empty blocks.
}

gruntfile.js

jshint: {
            all: {
                src: watchFiles.clientJS.concat(watchFiles.serverJS),
                options: {
                    jshintrc: true,
                    node: true,
                    jasmine: true
                }
            }
        },

仍然,'它没有定义'...... 扫管笏是错的?

1 个答案:

答案 0 :(得分:3)

答案/ jshint API已过期。请尝试将"predef"作为.jshintrc中的密钥,而不是"globals"。它也是一个阵列。最终文件应如下所示:

{
   "node": true,
   "jasmine": true,
   .... 
    "predef": [
        "jasmine",
        "angular",
        "ApplicationConfiguration"
    ],
}

另外,请确保其前面有.(应为.jshintrc

参考:http://jshint.com/docs/