Validating Scripts

For technical support for all editions of CSE HTML Validator. Includes bug reports.
Post Reply
ReneK
Rank II - Novice
Rank II - Novice
Posts: 22
Joined: Sun Jun 16, 2013 10:27 am

Validating Scripts

Post by ReneK » Sat Mar 12, 2016 4:36 am

Hi,

I'm trying to validate some scripts with CSE, but unfortunately I'm unable to even do some basic configuration and need some help with that. Take this one-line test script as an example:

Code: Select all

var elem = document.getElementById("meow");
I now enabled messages for "JavaScript Lint", "JSHint" and "JSLint" and started validation. This gives no errors and warnings. This is not what I expected. I then disabled "JavaScript Lint", re-validated the script and finally got the desired messages "implied global", "Undeclared 'document'" and "unused variable". OK, fine, exactly what to expect, I'll leave out "JavaScript Lint" then.

Then I went to Options->Validator Engine Options->Options->JavaScript->JSHint and entered "qwerty" into the "Options" Edit-Control. Suddenly, JSHint is perfectly fine with the script in question, no more warnings about "implied globals" and "unused variables". Huh?!?

Same with JSLint: Just enter "abcdefg" into the Options-Box and the remaining message vanishes as well.

Alternatively, try this script:

Code: Select all

var elem = document.getElementById("meow");
 var n = 0;
++n
Here, document is not declared, the indention on line 2 is wrong, ++ is used and finally there's a missing semicolon. Nothing gets detected once there's some garbage entered into the option's box.

So how I configure the script validators?

Rene

ReneK
Rank II - Novice
Rank II - Novice
Posts: 22
Joined: Sun Jun 16, 2013 10:27 am

Re: Validating Scripts

Post by ReneK » Sat Mar 12, 2016 4:41 am

Sorry, forgot to mention the version used: v16.0200 (Pro)

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3202
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Validating Scripts

Post by Albert Wiersch » Sat Mar 12, 2016 8:56 am

Hello,

First, CSE HTML Validator has to know that the document is a JavaScript document and the primary way it does this is by checking the filename extension so be sure to save the JavaScript document with a "js" extension if it doesn't have a filename yet. CSE HTML Validator should then run the JavaScript linters when you validate the file.

If you enter garbage into the options then it seems that it causes the linter(s) not to run properly. I will look into this in more depth and see what can be done to show this problem. I agree there should at least be an error generated if JSHint fails because of bad options.

Please go back to the JSHint page in the Validator Engine Options and press the Help button. It should display the help file where there is information about configuring JSHint and a link to the JSHint options page here:
http://jshint.com/docs/options/

I hope this helps. Please let me know if you have further questions and I will try to help but please note that JSHint is a 3rd party tool.
Image
Albert Wiersch

ReneK
Rank II - Novice
Rank II - Novice
Posts: 22
Joined: Sun Jun 16, 2013 10:27 am

Re: Validating Scripts

Post by ReneK » Sun Mar 13, 2016 3:59 am

No, that does not help at all. I configured JSLint with previous versions of CSE HTML Validator and it worked just fine back then. Now, starting with v16, every script validates just fine. It simply does not matter, what options you specify, not matter if they are real or garbage. Same for JSHint.

Paired with the fact that enabling "JavaScript Lint" practically disables JSLint as well as JSHint does not make me feel comfortable either (there is no hint in the UI that these settings are mutually exclusive).

And yes, the script in question actually has the js extension and I do get the "JavaScript document detected" message.

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3202
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Validating Scripts

Post by Albert Wiersch » Sun Mar 13, 2016 10:19 am

Sorry about that. I researched further and believe I've solved these issues in v16.0207. Please re-download CSE HTML Validator Pro and you should get v16.0207 (even though the download page doesn't say that version is available yet). Please let me know if it fixes these issues you reported.

https://www.htmlvalidator.com/download/registered.php
Image
Albert Wiersch

ReneK
Rank II - Novice
Rank II - Novice
Posts: 22
Joined: Sun Jun 16, 2013 10:27 am

Re: Validating Scripts

Post by ReneK » Fri Mar 25, 2016 6:17 am

Hello Albert,

I'm sorry for the delay, but I finally tested the new version: It actually does the business now. Thank you very much!

Please allow me a follow-up question: The validator does not check scripts embedded in HTML documents. I am under the impression that it did in V15 (and older). So is there anything I am doing wrong or do I remember that one incorrectly?

Rene

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3202
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Validating Scripts

Post by Albert Wiersch » Fri Mar 25, 2016 9:00 am

ReneK wrote:I'm sorry for the delay, but I finally tested the new version: It actually does the business now. Thank you very much!
Great! I'm glad it fixed the problem.
ReneK wrote:The validator does not check scripts embedded in HTML documents. I am under the impression that it did in V15 (and older). So is there anything I am doing wrong or do I remember that one incorrectly?
If I recall correctly, JavaScript Lint, the deprecated checker can check scripts embedded in HTML documents so you could try turning that on. The current versions of JSHint and JSLint (which are included in v16) do not check scripts embedded in HTML documents. The old version of JSLint did but the new rewrite of JSLint (which is included in v16) doesn't. Again, if I recall what I read about this, one of the big reasons that it doesn't is because it is considered best practice to keep JavaScript separate and put it in its own file, like it is for CSS (best to put it in a separate CSS file), so the developer of JSLint did not want to continue to support that "poor" practice when he did his major re-write/update.
Image
Albert Wiersch

ReneK
Rank II - Novice
Rank II - Novice
Posts: 22
Joined: Sun Jun 16, 2013 10:27 am

Re: Validating Scripts

Post by ReneK » Sat Apr 02, 2016 5:30 am

Hi Albert!

I have the "pleasure" to maintain an old HTA, so these embedded scripts are by intention and it will definitely stay this way. Unfortunately, I didn't keep my copy of the latest v15. Is it possible to download it from somewhere? I could install it on a different machine and use it while working on this ancient stuff then.

Rene

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3202
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Validating Scripts

Post by Albert Wiersch » Sat Apr 02, 2016 7:45 am

ReneK wrote:Unfortunately, I didn't keep my copy of the latest v15. Is it possible to download it from somewhere?
Sure. Versions back to v12 are still available here:
https://www.htmlvalidator.com/download/registered.php

Just be sure to select what edition and version you want before pressing the "Start Download" button.
Image
Albert Wiersch

ReneK
Rank II - Novice
Rank II - Novice
Posts: 22
Joined: Sun Jun 16, 2013 10:27 am

Re: Validating Scripts

Post by ReneK » Sun Apr 03, 2016 6:42 am

Wow, I really wasn't aware that there is actually a ComboBox to choose the version required. Thank you very much, Albert! :)

Post Reply