Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362250 - Need ability to exclude specific JavaScript files from validation
Summary: Need ability to exclude specific JavaScript files from validation
Status: RESOLVED INVALID
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
: 368900 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-27 18:57 EDT by Alex Pogrebnyak CLA
Modified: 2013-06-18 10:44 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Pogrebnyak CLA 2011-10-27 18:57:41 EDT
Build Identifier: 20110615-0604

I don't mind strict validation of the JavaScript files that are produced by me, but I don't want Eclipse to fail the build, or pollute problems window, when a 3rd party library does not adhere to the Eclipse validation rules.

Case in point, minified version of JQuery (http://code.jquery.com/jquery-1.5.min.js) produces build error, while uncompressed version (http://code.jquery.com/jquery-1.5.js) produces a bunch of warnings.  Needless to say that I really don't want to edit these files, one of the very prosaic reasons may be that it would violate the license agreement.

I know that I can disable JavaScript validation all together, but I think it's a too drastic approach, and I do want my sources to pass strict validation.

I propose to introduce Validation Filters to JavaScript in the same way as with other validated resources ( HTML, XML, etc. ).

Reproducible: Always
Comment 1 Nitin Dahyabhai CLA 2011-10-27 22:06:22 EDT
Standalone files are validated through our own builder; it's not related to the Validation Framework.  Putting those files into a separate Library Folder on the Include Path may help, or just using the already-existing Exclusion Patterns available on Source Folders to keep them out of the JavaScript model altogether.
Comment 2 Alex Pogrebnyak CLA 2011-10-29 12:15:37 EDT
(In reply to comment #1)
Thanks Nitin,

Include Path is the functionality that I was looking for.

However, based on many forum questions this feature is not in the most intuitive place.  Many people give the advice of turning off semantic validation all together or, much worse, even disabling JavaScript Validator builder.

I think somebody should add a paragraph ( or link to Include Path ) on 'JavaScript->Validation' property page that explains how to exclude individual files from validation.
Comment 3 Vladimir Nicolici CLA 2012-01-04 04:27:22 EST
I have a similar problem, in my case I am not able to disable JavaScript validation at all.

I tried anything I could think of. Disable it at project level. Disable it
globally. Suspend all validators at project level, suspend them globally, add
the directory with the problem files to an Exclude group for the JavaScript
validator, cleaning the project, rebuilding the project, closing / reopening
the project, disabling JavaScript semantic validation. Nothing works.

Setting the directory as derived seemed reduced the number of errors and
warnings, but thousands still remain.

Using Indigo Service Release 1, m2e 1.0.100, Subversive 2.2.2 on Windows 8
Developer Preview.
Comment 4 Alex Pogrebnyak CLA 2012-01-04 07:02:39 EST
(In reply to comment #3)

Vladimir, if you need to exclude all JavaScript files, just add '**/*' to the `Exclusion patterns`

Just to clarify, I am talking about
Project Properties -> JavaScript -> Include Path -> Source Tab

I've documented detailed steps here -> http://stackoverflow.com/a/7931839/185722

As I've told in my previous comment, it's not clear at all where to find this functionality.  Some link to here with explanation is needed through either QuickFix or Validation page.

Once you know the trick, it all makes sense.
Comment 5 Vladimir Nicolici CLA 2012-01-04 07:51:58 EST
Thanks Alex, that fixed my issue. Previously I lost four hours trying to fix it.
Comment 6 Nitin Dahyabhai CLA 2012-01-18 08:28:31 EST
*** Bug 368900 has been marked as a duplicate of this bug. ***
Comment 7 Mauro Molinari CLA 2012-01-31 03:21:50 EST
Is there a bug here yet? Why is it in the "reopened" state?
Comment 8 Alex Pogrebnyak CLA 2012-01-31 04:00:07 EST
(In reply to comment #7)
> Is there a bug here yet? Why is it in the "reopened" state?

Maybe not a bug per se, but definitely a usability problem, so that users who encounter JavaScript validation warnings for the first time do not know that they can control this behavior through JavaScript->Include Path setting.

I think the right solution would be to add action to fix Include Path in Quick Fix view.
Comment 9 Mauro Molinari CLA 2012-01-31 04:26:23 EST
(In reply to comment #8)
> I think the right solution would be to add action to fix Include Path in Quick
> Fix view.

I agree with this. However maybe the summary should be updated accordingly then?

What the JSDT devs plan to do here?
Comment 10 Alex Pogrebnyak CLA 2012-01-31 04:29:49 EST
(In reply to comment #9)
 
> I agree with this. However maybe the summary should be updated accordingly
> then?

I agree, but I think somebody on JSDT dev team should update the summary.
Comment 11 Adib Saikali CLA 2012-01-31 09:41:00 EST
(In reply to comment #8)
> (In reply to comment #7)
> > Is there a bug here yet? Why is it in the "reopened" state?
> 
> Maybe not a bug per se, but definitely a usability problem, so that users who
> encounter JavaScript validation warnings for the first time do not know that
> they can control this behavior through JavaScript->Include Path setting.
> 
> I think the right solution would be to add action to fix Include Path in Quick
> Fix view.

JavaScript-> include Path does not work with dojo, I tried to put Dojo into my dynamic web project and use the JavaScript-->Include Path it did not work. I had to create a dojo dynamic web project and tun off JavaScript completely from that project to get dojo into workspace without having to get errors and warnings.
Comment 12 Nitin Dahyabhai CLA 2012-01-31 09:52:21 EST
(In reply to comment #8)
> I think the right solution would be to add action to fix Include Path in Quick
> Fix view.

Fix it in what way?


(In reply to comment #11)
> JavaScript-> include Path does not work with dojo, I tried to put Dojo into my
> dynamic web project and use the JavaScript-->Include Path it did not work. I
> had to create a dojo dynamic web project and tun off JavaScript completely from
> that project to get dojo into workspace without having to get errors and
> warnings.

I'm not sure what "does not work", but you can also try placing Dojo itself into a Library folder, instead of a Source folder and then ignoring parts of it.
Comment 13 Adib Saikali CLA 2012-01-31 10:04:44 EST
(In reply to comment #12)
> (In reply to comment #8)
> > I think the right solution would be to add action to fix Include Path in Quick
> > Fix view.
> 
> Fix it in what way?

When you see errors on a JS file in the Problems view or a warning you should be able to use the CTRL+1 shortcut to quick fix the problem by adding the file to the list of files that should be ignored by the validator. 


> (In reply to comment #11)
> > JavaScript-> include Path does not work with dojo, I tried to put Dojo into my
> > dynamic web project and use the JavaScript-->Include Path it did not work. I
> > had to create a dojo dynamic web project and tun off JavaScript completely from
> > that project to get dojo into workspace without having to get errors and
> > warnings.
> 
> I'm not sure what "does not work", but you can also try placing Dojo itself
> into a Library folder, instead of a Source folder and then ignoring parts of
> it.

"What does not work" is that there is no way to have dojo in the WebContent/ folder of a Dynamic Java Project without having errors and warnings from the JavaScript compiler and validators. On my team we have a policy that projects should have zero warnings and zero errors and it is very frustrating to have third party code from a high quality project like Dojo which does not validate and has warnings when I include it in my project.

Dojo has to be in a Dynamic Web Project otherwise you can not serve it out to the browser. My understanding is that adding dojo as JavaScript library means things like content assist work better, but how does adding it as a library help get the files to the browser via tomcat or some other app server?
Comment 14 Nitin Dahyabhai CLA 2012-01-31 10:28:49 EST
(In reply to comment #13)
> Dojo has to be in a Dynamic Web Project otherwise you can not serve it out to
> the browser. My understanding is that adding dojo as JavaScript library means
> things like content assist work better, but how does adding it as a library
> help get the files to the browser via tomcat or some other app server?

Set that folder as an exclusion on the existing Source Folder and you can then add it as a Library.
Comment 15 Chris Jaun CLA 2013-06-18 10:44:19 EDT
Nitin's comments have addressed this issue. The ability to exclude files already exists.