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

Matthieu Napoli
  • 48,448
  • 45
  • 173
  • 261
  • It's there for me - it's called JavaScript Syntax Validation. I have Eclipse TPTP, I believe. – Michael K Feb 01 '11 at 21:06
  • I don't have it, see the srceenshot I added for more details. – Matthieu Napoli Feb 01 '11 at 21:15
  • Matthieu, are you using any special plugins? as they might have replaced the default validator with a different one. – Augusto Feb 18 '11 at 11:13
  • 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 ? – Matthieu Napoli Feb 18 '11 at 15:52
  • More info: http://stackoverflow.com/questions/3131878/how-do-i-remove-javascript-validation-from-my-eclipse-project – Craigo Aug 28 '12 at 05:14

2 Answers2

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!

Maxym
  • 11,836
  • 3
  • 44
  • 48
  • 2
    @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" ;) – Maxym Feb 21 '11 at 13:58
  • @Maxym - 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. – jdias Sep 08 '11 at 00:39
  • 1
    @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... – Maxym Sep 12 '11 at 13:48
  • @Maxym - 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. – jdias Sep 12 '11 at 14:36
  • 1
    If you can't find the window described above, make sure you are looking at the PROJECT Properties view, not Eclipse Preferences! – Lambart Jun 17 '13 at 21:19
  • 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. – Auspex Dec 17 '18 at 22:59
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

Aram Kocharyan
  • 20,165
  • 11
  • 81
  • 96