The continuous integration software I am using runs JavaScript files through JSLint and complains if they fail (using default JSLint settings it appears).
I've always prepended a ;
to the start of my jQuery plugins, so concatenating them doesn't lead to something like this...
I don't have access to this file, and can't enforce a semi colon at the end.
var abc = function() {
alert(arguments[0]);
}
This is my file that is concatenated with common.js
. It is appended straight to the end of common.js
.
(function($) {
$.fn.somePlugin = function() {}
})(jQuery);
jsFiddle of the problem this can cause.
jsFiddle of the solution (leading semi-colon of my plugin).
However, JSLint complains with...
Error:
Problem at line 1 character 1: Unexpected space between '(begin)' and ';'.
;(function($) {
Problem at line 1 character 1: Expected ';' at column 5, not column 1.
;(function($) {
Problem at line 1 character 2: Missing space between ';' and '('.
...
I tried using a bang operator (!
) instead, and a few other alternatives, but JSLint still complained.
What can I do to get this safety net and pass JSLint?
Patch JSLint to not mind. Everyone will benefit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With