更改 Eclipse 设置以忽略特定文件上的错误

2022-01-20 00:00:00 ide jquery eclipse

在我的 Eclipse 动态 Web 项目中,我的 js 源文件夹中有 jQuery.出于某种原因,Eclipse 没有正确处理它并将许多行解释为标准 jQuery 文件中的错误(即使我安装了 javascript 开发工具).

In my dynamic web project in eclipse, I have jQuery in my js source folder. For some reason, Eclipse is not handling it correctly and interpreting many lines as errors in the standard jQuery file (even though I have the javascript development tools installed).

我可以关闭对 jQuery 文件(并且仅限该文件)的错误检查吗?我仍然希望它像往常一样检测错误,但忽略 jQuery.js 中的任何内容.

Can I turn off the error checking on the jQuery file (and that file only)? I still want it to detect errors as usual, but ignore anything in jQuery.js.

推荐答案

eclipse好像变了一点,
但是以下对我有用的方法似乎与旧方法非常接近.

It looks like eclipse has changed a bit,
but the following method which worked for me seems very close to the old one.

解决方案包括两个步骤:

The solution consists of 2 steps:

  1. 首先你必须更新 Eclipse 的首选项(Window > Preferences):

确保同时检查 ManualBuild 在您需要的 Validator 旁边
(在我的情况下 - 一个 javascript 的).

Make sure that you check both Manual & Build next to the Validator you need
(in my case - a javascript one).

最后你应该更改项目的验证器:

Last you should change your project's Validators:

点击Client-side JavaScript Settings(或您需要的任何其他验证器):

Click on Client-side JavaScript Settings (or any other validator you need):

解释很清楚,但基本上你应该做的如下:

The explanation is clear but basically what you should do is as follows:

点击Add Exclude Group...,选择它然后点击Add rule....
然后选择文件夹或文件名(注意还有其他选项),并指定你的文件/文件夹.

Click on Add Exclude Group..., select it and then click on Add rule....
Then pick Folder or file name (note that there are other options), and specify your file/folder.

您应该能够通过删除现有错误/警告来验证其是否正常工作,
然后左键单击您的项目并选择 Validate 选项.

You should be able to verify that its working by deleting the existing errors/warnings,
and then left-click your project and select the Validate option.

此设置也可以提交到源代码管理中.

This setting can be committed into source control as well.

相关文章