tamzinblake / js3-mode

A chimeric fork of js2-mode and js-mode
GNU General Public License v3.0
181 stars 13 forks source link

items in /*global */ declaration not parsed if passed as foo:true or foo:false #78

Closed plumlee closed 11 years ago

plumlee commented 11 years ago

Far as I can tell, js3-mode fails to properly handle the :true or :false when applied to an item in the list of global variables. I'm far from a lisp expert, but the main code in question seems to be here:

    (let ((btext
       (replace-regexp-in-string
        "[\n\t ]+" " "
        (buffer-substring-no-properties
         1 (buffer-size)) t t)))
      (setq js3-additional-externs
        (nconc js3-additional-externs
           (split-string
            (if (string-match "/\\* *global \\(.*?\\)\\*/" btext)
            (match-string-no-properties 1 btext)
              "")
            "[ ,]+" t))))

Seems that the items in the /global / declaration are only correctly parsed w/o the :true or :false.

Example code that fails to detect 'define' as a pre-defined global:

/*global require, define:true */
require(['foo'], function() {

    define('bar', function () {
        return true;
    });

});
tamzinblake commented 11 years ago

Let me know if that does it