How to exclude a Javascript file from Javascript Validation in Eclipse
Asked Answered
T

2

87

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.

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.

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.!

Thyself answered 1/2, 2011 at 21:2 Comment(5)
It's there for me - it's called JavaScript Syntax Validation. I have Eclipse TPTP, I believe.Ravenravening
I don't have it, see the srceenshot I added for more details.Thyself
Matthieu, are you using any special plugins? as they might have replaced the default validator with a different one.Ewald
No no plugin regarding Javascript, the only one is PHPTools, which adds PHPUnit into Eclipse, but this doesn't relate to Javascript. I am on Eclipse PDT, are you ? Is that specific to the PDT release, or is my Eclipse bugged ?Thyself
More info: #3132378Radiosonde
H
151

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!

Huneycutt answered 19/2, 2011 at 18:10 Comment(6)
@Matthieu: doing that task I got the biggest lesson working with Eclipse: think differently ;) Root of task was to turn off the validation, but in fact we had to look for "how to tell Eclipse that this is not JavaScript" ;)Huneycutt
@Huneycutt - are you sure this is the right way of doing it? I believe you have just excluded test.js from the build. I thought the objective was to exclude the script from the validation, not the build. Am I missing something here? Thanks.Farming
@jdias: depends on what you mean by "build". If the build is something that you deploy (ready to use application), then I'm not sure that I excluded anything... Here you just tells where to look for javascript sources (and therefore what code style to use etc.). By excluding I just tell that this file still belongs to my project, but I don't want IDE to treat it as javascript file. It seems that you can't tell the IDE which files to validate, and which not, you can't tell that this js file should be validated this way, and another js file should use another rules...Huneycutt
@Huneycutt - thank you for the comment back. Since I posted my comment on Sep 8th, I had the opportunity to work further with Eclipse PDT and I agree with your statement. Thank you again for the follow up.Farming
If you can't find the window described above, make sure you are looking at the PROJECT Properties view, not Eclipse Preferences!Essonite
It did help, but I must say I've found this to be not very sticky. Every now and then I go back and find that it's decided to revalidate all of the scripts under node_modules/, and I have to exclude them again.Waadt
E
17

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

Enthalpy answered 10/9, 2012 at 12:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.