【问题标题】:Jshint jasmine functions undefined in mean.jsmean.js 中未定义的 Jshint jasmine 函数
【发布时间】:2015-03-01 12:56:30
【问题描述】:

我有一个 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
                }
            }
        },

仍然,'它没有被定义' .... 怎么了?

【问题讨论】:

    标签: jshint


    【解决方案1】:

    Answer/jshint API 已过时。尝试将"predef" 作为.jshintrc 中的键,而不是"globals"。它也是一个数组。最终文件应如下所示:

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

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

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

    【讨论】:

      猜你喜欢
      • 2014-11-23
      • 1970-01-01
      • 2015-11-14
      • 2016-01-07
      • 1970-01-01
      • 2015-07-10
      • 2013-09-07
      • 2014-01-17
      • 2012-02-09
      相关资源
      最近更新 更多