ckknight / gorillascript

GorillaScript is a compile-to-JavaScript language designed to empower the user while attempting to prevent some common errors.
MIT License
300 stars 34 forks source link

Support jshint/jslint special comment? #10

Open unc0 opened 11 years ago

unc0 commented 11 years ago
/*global $:false, jQuery:false */
alert "Hello, GorillaScript!"

I tested in gorilla -c -p, compiler deletes that special comment.

ckknight commented 11 years ago

I was thinking about solving the global access issue by having an explicit statement at the top of a file such as

global jQuery // or something like global $ = jQuery or global $: jQuery for aliasing

jQuery #($)
  $("body").do-stuff()

Would turn into

let jQuery = GLOBAL.jQuery

jQuery #($)
  $("body").do-stuff()

At which point I can then test every ident access to assure that it is either in-scope or an expected primordial (e.g. String, setTimeout)

I think this would be a better solution, but I'd like to hear feedback.

unc0 commented 11 years ago

Yes, I think that's better, no more grunt jshint tasks in my Gruntfile.