Eclipse JavaScript Libraries Validation

I use several JavaScript libraries in my web apps. Just one of the many reasons I like Spring MVC over other web frameworks – like JSF – is that you can easily use current web technologies. HTML5? CSS3? jQuery? No problem!

Actually there is one problem, but it’s an Eclipse (or Spring STS) problem. When you add JavaScript to your project, Eclipse will validate the code. This is what I want when I am developing code! But I don’t want to debug or modify third party code. The Eclipse validator will almost always complain about minified versions of JavaScript files.

Project with JavaScript validation errors
Click to Enlarge

You can turn off validation. Problem solved. You can also remove squirrels from your backyard bird feeders with a bazooka.

A better solution

  • Open the project’s properties dialog. (right click, properties or Command-I)
  • Select JavaScript then Include Path from the tree on the left.
  • Select the Source tab in the property sheet.
  • Select the Excluded node from the project tree.
  • Press the Edit button.
  • In the modal dialog that pops up, add an Exclusion Pattern.

I put third party JavaScript in src/main/webapp/resources/js/libs and my own JavaScript in src/main/webapp/resources/js. So I add only src/main/webapp/resources/js/libs as an exclusion pattern. Then I no longer see jQuery, modernizr, or bootstrap errors, but I do see JavaScript errors in the code that I’m developing.

Eclipse JavaScript Validation
Click to Enlarge

Article by gene

It seems like this author has no description. Add your discription/bio at user profile or disable this widget in theme customizer if you dont want to use it.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">