如何从 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 14:29:56  来源:igfitidea点击:

How to exclude a Javascript file from Javascript Validation in Eclipse

javascripteclipseeclipse-pdt

提问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:

好吧,可能我已经设法做你需要的 ;) 这有点棘手。所以我的步骤:

  1. downloaded Eclipse PDT (to be sure that it works for you, because I use Eclipse for Java EE)
  2. created project TestJS (it was JavaScript project)
  3. created two files, test.js and htmlparser.js (last one copied from John Resig's site)
  4. typed "broken" script in both of them, so Eclipse told me that there were errors in both of them
  5. 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).
  6. I excluded "test.js" file, pressed apply...
  7. ...and got a happy ending: now Eclipse point me out that there is error in htmlparser.js, but not in test.js ;)
  1. 下载 Eclipse PDT(确保它适合你,因为我使用 Eclipse for Java EE)
  2. 创建项目 TestJS(它是 JavaScript 项目)
  3. 创建了两个文件,test.js 和 htmlparser.js(最后一个从 John Resig 的站点复制)
  4. 在它们两个中都输入了“损坏的”脚本,所以 Eclipse 告诉我它们都存在错误
  5. 转到Project Properties > JavaScript > Include Path > Source,有“排除”突出显示并按“编辑”按钮,在这里您可以添加要排除的内容(文件,文件夹,模式)。
  6. 我排除了“test.js”文件,按下应用...
  7. ...并有一个圆满的结局:现在 Eclipse 指出 htmlparser.js 中存在错误,但 test.js 中没有;)

ScreenShot: enter image description here

截屏: 在此处输入图片说明

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 验证器往往会发现异常错误(可能完全是误报),因此我使用了“添加多个”选项并选择了包含这些库的文件夹。无需每次添加文件时更新!

enter image description here

在此处输入图片说明