Tuesday, August 20, 2013

Eliminating JavaScript validation errors due to jQuery in an Eclipse dynamic web project

If your Eclipse project includes jQuery files such as jquery-1.8.3.min.js, Eclipse's JavaScript validation may report syntax errors that, although harmless, makes it look as  if your project contains bugs.



Much has been written online about how to resolve this problem, but not all of it is correct. In particular, suggestions involving Properties | Validation | Client-side JavaScript are off the mark, as these settings affect JavaScript within  HTML pages, not standalone .js files.

This comment -- https://bugs.eclipse.org/bugs/show_bug.cgi?id=349020#c15 -- has it right but doesn't give much detail. Here are the exact steps I followed to correct the problem:

1. Right-click the project name in Project Explorer and select Properties.

2. Expand JavaScript and select Include Path.


3. Expand the folder that contains the offending JavaScript files (which will vary depending on how you've set up your project), and click Excluded.


4. Click Edit. Click the Add button next to the Exclusion patterns textarea.


5. Now type in the pattern for files to be excluded, being careful to include the correct path, which will vary depending on how you've set up your project. In my project, the pattern is resources\lib\jquery*.*.


6. Click OK. Click Finish. Click OK. The errors should now disappear.


Behind the scenes, this added the following line to my project's .settings\.jsdtscope file:
<classpathentry excluding="resources/lib/jquery*.*" kind="src" path="src/main/webapp"/>

13 comments:

  1. Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject. https://verifications.io

    ReplyDelete
  2. Really i appreciate the effort you made to share the knowledge. The topic here i found was really effective...

    Looking for Software Training in Bangalore , learn from Softgen Infotech Software Courses on online training and classroom training. Join today!

    ReplyDelete
  3. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site. Real Time Experts Training in Bangalore center address bangalore

    ReplyDelete
  4. Thanks for the really informative article and detailed description with images.

    artificial intelligence course in indore

    ReplyDelete
  5. your blog' s design is simple and clean and i like it. Your blog posts about Online writing Help are superb. Please keep them coming. Greets!

    Big Data Hadoop Online Training

    ReplyDelete