-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Conversation
With this feature, I'd scrap much of what is in my current js2-mode config, and replace it with this: (with-eval-after-load "js2-mode"
(setq-default
js2-ignored-warnings
'("msg.return.inconsistent" "msg.anon.no.return.value" "msg.no.return.value"))
(make-variable-buffer-local 'js2-ignored-warnings)
(defun my-js2-test-file-setup ()
(when (string-match-p "_test.js$" (buffer-file-name))
(push "msg.no.side.effects" js2-ignored-warnings)))
(add-hook 'js2-mode-hook 'my-js2-test-file-setup)) |
|
||
Possible values are the keys of `js2-message-table'." | ||
:group 'js2-mode | ||
:type 'list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:type '(repeat string))
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar enough with defcustom
types to comment on the "maybe", I'lll have to defer to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way to review this kind of suggestion is to make the change and see if the customize-variable
UI looks no worse (or probably better) than before.
Anyway, it must be fine.
(cl-remove-if | ||
(lambda (warning) | ||
(let ((msg (caar warning))) | ||
(and msg (member msg js2-ignored-warnings)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think (and msg
is unnecessary here. And are there any warnings with empty message anyway?
(save-excursion | ||
(run-hooks 'js2-post-parse-callbacks)) | ||
(js2-highlight-undeclared-vars)) | ||
root)) | ||
|
||
(defun js2-filter-parsed-errors () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be called js2-filter-parsed-warnings
?
(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'." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better:
Remove js2-parsed-warnings
elements that match js2-ignored-warnings
.
Just noticed the ping on #355. Thanks for your work on this, I'm sure many will find this useful, including myself. |
f3aa627
to
da4793e
Compare
@dgutov I've updated the commit with all your suggestions, let me know if there's anything else I can do. |
@jordonbiondo Thanks. Have you contributed to Emacs before? This patch meets the allowed limit, but any further patches will require signed copyright assignment papers. |
@dgutov No I have not signed the assignment papers. |
I am in the process up signing the assignment paperwork now. |
Thanks! |
For more info * See `js2-message-table` variable for all error messages (C-h v js2-message-table). * PR: mooz/js2-mode#404
BTW just in case anyone is reading this years later, this feature can also be utilised by placing something like the following in ("test"
. ((js2-mode
. ((js2-ignored-warnings . ("msg.no.side.effects")))))) Then it would apply to the |
The need for disabling specific warning messages has come up a few times.
I've seen that there have been changes made to support disabling specific warnings such as dangling commas and no semicolons, but there's not a blanket method for disabling anything you want.
This was discussed shortly in #260, but a conclusion wasn't reached.
This is a much smaller first-class version of the functionality I've built in my own config: https://github.com/jordonbiondo/.emacs.d/blob/master/init.el#L901
Let me know what you think about the possibility of this feature being accepted using this method or any other.