How to get brackets to ignore particular repeating errors?

后端 未结 1 1118
北海茫月
北海茫月 2020-12-21 10:55

I get JSLint errors in a file for undeclared functions and variables referenced from another file. Does brackets have a configuration/menu to remove these while keeping othe

1条回答
  •  隐瞒了意图╮
    2020-12-21 11:34

    JSLint complains whenever you reference an identifier that it can't see any declaration for in the file. So if you're using global variables/functions that were set by some other file, you'll get these warnings.

    You can stop the warnings by individually specifying which undeclared globals you want to allow. To do that, place a directive like this at the top of your file:

    /*jslint indent: 4 */
    /*global ClassFoo, ClassBar, someFunction */
    

    But of course, it's a pain to list things manually in each file.

    Perhaps the best way to clean this up is to use a module loader like RequireJS. Then most your references to other files won't be through globals, and you'll only have to tell JSLint to ignore the few globals needed for RequireJS itself (usually just define).

    Using a module loader has other benefits too. It eliminates "dependency spaghetti" by making cross-file dependencies very explicit, and it automatically load modules in proper dependency order. And there are easy tools that automatically concatenate all your modules into one file when you're ready for deployment.

    0 讨论(0)
提交回复
热议问题