How to get brackets to ignore particular repeating errors?

社会主义新天地 提交于 2019-11-28 09:28:35

问题


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 other linting errors?


回答1:


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.



来源:https://stackoverflow.com/questions/19453259/how-to-get-brackets-to-ignore-particular-repeating-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!