0

Is there an option parameter to force JSHint to check for explicitly defined global variables and output a warning?

clarification: http://jsbin.com/odUcabUL/6/watch?js

Ozrix
  • 3,489
  • 2
  • 17
  • 27
  • Just to be 100% clear, you want to see a warning on `window.foo` (or `global.foo`) and on global-scope `var foo`? Or only the second one? – apsillers Dec 06 '13 at 15:26
  • just when declaring foo in the global scope, i.e. var foo. – Ozrix Dec 06 '13 at 15:39
  • 2
    Why should that issue a warning? You *did* explicitly declare it there for a reason, didn't you? – Bergi Dec 06 '13 at 15:48
  • in my new work environment, colleagues use variables outside of their respective function scope, polluting the namespace. they are not aware of this and i want to enforce it via linting. – Ozrix Dec 06 '13 at 15:54

1 Answers1

1

You might want to have a look at ESLint, which is a completely pluggable alternative to JSHint. Has a lot of rules already and if you can't find what you're looking for in there you can always write your own rule. There's a grunt task available too.

  1. https://github.com/sindresorhus/grunt-eslint
  2. https://github.com/nzakas/eslint
Ben
  • 10,106
  • 3
  • 40
  • 58