Closed olmaygti closed 10 years ago
The way to declare globals for Jslint is simpler than that:
/global foo, bar/
I know, but in my company we use the command line --predef parameter just avoid that: writing those comments with global variables in every single js file on your app, which are just so much.
Or did you mean writing those comments in the JSLint.sublime-build file?? I tried to but I couldn't make it work that way.
If it's supported on the command line, it should be supported in the "advanced build settings", but if it isn't I'll try to add it. Thanks for the heads up!
Follow-up: it isn't, as far as I've tried. Please add support. Thanks!
yep, it's still not supported by the plugin and I'd like to have it working too. Here's what I did:
Trying to Lint after that fails - and does it silently, e.g. console doesn't say anything at all. I presume it's not allowed to use array as value in cmd array of the build file? Because if I use string - the linter runs, but doesn't do anything with my "predef" parameter (which is understandable).
As I don't really want to wait for this to be officially added, I'd like some help on how I get it working. Thanks.
Just apply 33eff39 (worked for me)
oh, ok, thanks! But because eval is evil, I changed the array matching in linter.js (24) to:
var array_match = String(val).match(/\[([^\]]+)\]/);
if (array_match) {
val = array_match[1].replace(/["']/g, '').split(',');
}
would be cool tho, if cmd array could take arrays as values
Hi there Darren,
I installed your jslint plugin yesterday, which I found pretty useful, but wasn't able to find the way to pass some global variables to JSLint.
Inspecting the code, I saw that JSLint accepted predef variables in the form of either an Array or and object (line 6068), so I just made a pretty straigthforward change in linter.js to accept a "predef" argument followed by a string containing a javascript syntax compliant array of strings.
Do as you wish with this commit.
Regards.