Question

I am trying out JSLint on some of the javascript files in our projects at work and have come across several errors like the following:

JS Lint: '<var name>' is not defined

The issue is that the variable is defined in a separate file that is referenced elsewhere. e.g. the HTML page has global.js and pageSpecific.js

I am aware using the syntax

/* global varName */ 

to tell JSLint that yes infact this variable does exist but this is not ideal in this scenario due to the number of different variables causing these errors (there would be lines of these globals at the top of every page). Nor do I just want to ignore this error, after all maybe there is a 'genuine' undefined error there that needs some attention.

My feeling is that either there is a JSLint solution I am unaware of or, perhaps more likely, that is indicative of a problem with how the JS is structured in this project? Are 'global.js' files (of this sort) a bad practice?

Ideas/feedback appreciated.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top