Updated pdexter 2022-05-23
JSHint has been introduced into Ruleset and Ruleset Include Editor templates as of Feb 2022. It has been configured to work as well as possible with the way Formbird script is written.
This was introduced to replace the old native syntax checking that came with a simple "eval" call on the script. While this worked, it only provided line numbers of errors in Firefox, leaving it nearly useless for other browsers.
While all efforts have been made to configure JSHint to only highlight real problem lines in Formbird script, there are times when it throws a "false" error (ie, a code discrepancy that we in fact live with).
To bypass on single line
To avoid an error on a single line, follow the code with the following
// jshint ignore:line
var x = swal; // jshint ignore : line
To bypass a block of script
Define a block to bypass by
/* jshint ignore:start */ and
/* jshint ignore:end */
// Code here will be checked with JSHint. var x = 'hello world'; /* jshint ignore:start */ // Code here will be ignored by JSHint. var y = 'nah nah can\'t catch me'; /* jshint ignore:end */ var z = 'hello again world';
Placing the start tag-comment
/* jshint ignore:start */ at the beginning of a script, without setting an end tag-comment, will bypass checking for the whole script HIGHLY NOT RECOMMENDED.
Gotchas & how to avoid
Global objects "not defined"
Often using a global object or property will raise an error, eg
var x = location.href (error: location not defined).
var x = window.location.href
var x = global.widgetService ; (server side global use unverified -- pdexter 2022-05-23).
Unreachable code after return
Often we use a
return; statement in a block of script in order to bypass the rest of the block. JSHint will complain about this.
a) Remove or comment the code following
b) If you want to keep the following script for reference or later restoration, change the
return line to
if (true) return;