如何在 Eclipse 中从 Javascript 验证中排除 Javascript 文件

对于我自己的代码,javascript 验证工作得很好。我想保持认可。但是当涉及到开放源码库时,例如 jquery,验证会创建警告。

我不希望在下载的库上出现警告,但是我希望为我的代码保留警告。

我知道你可以排除文件验证在“ 偏好 > 验证”窗口,但 没有 javascript 验证!我查看了每个验证程序,javascript 验证程序不在那里。

那么如何从验证中排除特定文件呢?

下面是我的验证器列表: 截图

谢谢!

PS: 我使用 Eclipse PDT!

40561 次浏览

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 ;)

ScreenShot: enter image description here

Really hope that it helps!

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 Multiple option and selected the folders that contained those libraries. No need to update each time you add a file!

enter image description here