]> code.delx.au - gnu-emacs-elpa/commitdiff
Add js2-mode-assume-strict custom variable
authorStephen Hicks <sdh@google.com>
Fri, 10 Jun 2016 00:07:02 +0000 (17:07 -0700)
committerStephen Hicks <sdh@google.com>
Fri, 10 Jun 2016 23:57:55 +0000 (16:57 -0700)
This allows all files to be parsed as if 'use strict' were on top of
every file, for the case of JS passed through compilers that assume
strict input.

Closes #341.

js2-mode.el

index 4d9bbf8da02e85ea35cb873dcb0bb879874c4951..a46423e60a31b97cee977b0766b8d6a35657dec4 100644 (file)
@@ -277,6 +277,11 @@ end of the line, otherwise, at the beginning of the next line."
   :type 'boolean
   :group 'js2-mode)
 
+(defcustom js2-mode-assume-strict nil
+  "Non-nil to start files in strict mode automatically."
+  :type 'boolean
+  :group 'js2-mode)
+
 (defcustom js2-mode-show-strict-warnings t
   "Non-nil to emit Ecma strict-mode warnings.
 Some of the warnings can be individually disabled by other flags,
@@ -7988,7 +7993,7 @@ Scanner should be initialized."
           js2-nesting-of-function 0
           js2-labeled-stmt nil
           js2-recorded-identifiers nil  ; for js2-highlight
-          js2-in-use-strict-directive nil)
+          js2-in-use-strict-directive js2-mode-assume-strict)
     (while (/= (setq tt (js2-get-token)) js2-EOF)
       (if (= tt js2-FUNCTION)
           (progn