如何从 Eclipse 中的 Javascript 验证中排除 Javascript 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4867885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to exclude a Javascript file from Javascript Validation in Eclipse
提问by Matthieu Napoli
I have the javascript validation working good for my own code. I want to keep the validation. But when it comes to open source library, like jquery for example, the validation creates warnings.
我的 javascript 验证适用于我自己的代码。我想保留验证。但是当涉及到开源库时,例如 jquery,验证会产生警告。
I don't want warnings over a downloaded library. But I want to keep warnings for my code.
我不希望对下载的库发出警告。但我想为我的代码保留警告。
I know you can exclude files from validation in the "Preferences > Validation" window, but the javascript validation is not there! I've looked each validator, the javascript validator is not there.
我知道您可以在“首选项 > 验证”窗口中从验证中排除文件,但是javascript 验证不存在!我查看了每个验证器,但 javascript 验证器不存在。
So how can I exclude specific files from the validation ?
那么如何从验证中排除特定文件呢?
Here is the list of validators I have : Screenshot
这是我拥有的验证器列表: 屏幕截图
Thanks !
谢谢 !
PS : I use Eclipse PDT.!
PS:我使用Eclipse PDT。!
回答by Maxym
well, probably I've managed to do what you need ;) It is a bit tricky. So my steps:
好吧,可能我已经设法做你需要的 ;) 这有点棘手。所以我的步骤:
- downloaded Eclipse PDT (to be sure that it works for you, because I use Eclipse for Java EE)
- created project TestJS (it was JavaScript project)
- created two files, test.js and htmlparser.js (last one copied from John Resig's site)
- typed "broken" script in both of them, so Eclipse told me that there were errors in both of them
- went to Project Properties > JavaScript > Include Path > Source, there is "Excluded" to highlight and press "Edit" button, here you are able to add what you want to exclude (file, folder, pattern).
- I excluded "test.js" file, pressed apply...
- ...and got a happy ending: now Eclipse point me out that there is error in htmlparser.js, but not in test.js ;)
- 下载 Eclipse PDT(确保它适合你,因为我使用 Eclipse for Java EE)
- 创建项目 TestJS(它是 JavaScript 项目)
- 创建了两个文件,test.js 和 htmlparser.js(最后一个从 John Resig 的站点复制)
- 在它们两个中都输入了“损坏的”脚本,所以 Eclipse 告诉我它们都存在错误
- 转到Project Properties > JavaScript > Include Path > Source,有“排除”突出显示并按“编辑”按钮,在这里您可以添加要排除的内容(文件,文件夹,模式)。
- 我排除了“test.js”文件,按下应用...
- ...并有一个圆满的结局:现在 Eclipse 指出 htmlparser.js 中存在错误,但 test.js 中没有;)
ScreenShot:
截屏:
Really hope that it helps!
真的希望它有帮助!
回答by Aram Kocharyan
Following from Maxym's excellent answer: since I usually keep all my JavaScript libraries in one place and the Eclipse validator tends to find unusual errors (perhaps entirely false positives), I used the Add Multipleoption and selected the folders that contained those libraries. No need to update each time you add a file!
遵循 Maxym 的出色回答:由于我通常将所有 JavaScript 库放在一个地方,而 Eclipse 验证器往往会发现异常错误(可能完全是误报),因此我使用了“添加多个”选项并选择了包含这些库的文件夹。无需每次添加文件时更新!