Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specific warnings to be ignored #404

Merged
merged 1 commit into from
Feb 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions js2-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 '(repeat string))

(defcustom js2-highlight-level 2
"Amount of syntax highlighting to perform.
0 or a negative value means none.
Expand Down Expand Up @@ -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-warnings)
(save-excursion
(run-hooks 'js2-post-parse-callbacks))
(js2-highlight-undeclared-vars))
root))

(defun js2-filter-parsed-warnings ()
"Remove `js2-parsed-warnings' elements that match `js2-ignored-warnings'."
(when js2-ignored-warnings
(setq js2-parsed-warnings
(cl-remove-if
(lambda (warning)
(let ((msg (caar warning)))
(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)))
Expand Down