質問

Using Microsoft Visual Studio 2013 Premium

I have a javascript file that contains all of my "extensions", lets call this extensions.js

Inside this extensions.js file I have a function. Lets call it RandomFunction.

Inside another javascript file (lets call this RandomFile.js) I make use of the RandomFunction file, and inside browsers this is absolutely fine. However the JsHint is insistent that

JsHint (W117): 'RandomFunction' is not defined.

Inside of RandomFile.js I have included a

/// <reference path="../extensions/extensions.js" />

as well as adding a global _references.js to the project.

The references seem to work at least as far as my Intellisense is concerned.

Has anyone any idea how to get rid of the warnings without flat out turning them off?

I'd prefer not to do this as some warnings are genuine.

I am using the WebEssenstials addon.

Regards.

役に立ちましたか?

解決

You can do this on a per-file basis by adding the names of the functions the warnings for which you want suppressed to a global line at the very beginning of each file:

/* global RandomFunction1, RandomFunction2: true */

Alternatively, if you're using a customised .jshintrc file you can add the function names to the globals object:

{
  "globals": {
    "RandomFunction1": true,
    "RandomFunction2": true
  },
  ... rest of the .jshintrc file.
}

There's a lot of information in the JSHint documentation on both global lines and .jshintrc files.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top