diff --git a/js2-mode.el b/js2-mode.el index a07d5c53..4491d488 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -226,6 +226,13 @@ variable with predicate PRED." (make-variable-buffer-local name) (put name 'safe-local-variable pred)) +(defcustom js2-ignored-warnings nil + "A list of warning message types that will not be reported. + +Possible values are the keys of `js2-message-table'." + :group 'js2-mode + :type 'list) + (defcustom js2-highlight-level 2 "Amount of syntax highlighting to perform. 0 or a negative value means none. @@ -8130,11 +8137,23 @@ Scanner should be initialized." (setq js2-mode-ast root) ; Make sure this is available for callbacks. ;; Give extensions a chance to muck with things before highlighting starts. (let ((js2-additional-externs js2-additional-externs)) + (js2-filter-parsed-errors) (save-excursion (run-hooks 'js2-post-parse-callbacks)) (js2-highlight-undeclared-vars)) root)) +(defun js2-filter-parsed-errors () + "Remove `js2-ignored-warnings' from `js2-parsed-errors'." + (when js2-ignored-warnings + (setq js2-parsed-warnings + (cl-remove-if + (lambda (warning) + (let ((msg (caar warning))) + (and msg (member msg js2-ignored-warnings)))) + js2-parsed-warnings))) + js2-parsed-warnings) + (defun js2-parse-function-closure-body (fn-node) "Parse a JavaScript 1.8 function closure body." (let ((js2-nesting-of-function (1+ js2-nesting-of-function)))