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

Conversation

jordonbiondo
Copy link
Contributor

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.

@jordonbiondo
Copy link
Contributor Author

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))

This code would also satisfy the needs of @blaenk in #355

@dgutov dgutov changed the title Allow specific warnings to be ignored. Allow specific warnings to be ignored Jan 27, 2017

Possible values are the keys of `js2-message-table'."
:group 'js2-mode
:type 'list)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:type '(repeat string))

maybe?

Copy link
Contributor Author

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.

Copy link
Collaborator

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))))
Copy link
Collaborator

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 ()
Copy link
Collaborator

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'."
Copy link
Collaborator

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.

@blaenk
Copy link

blaenk commented Jan 28, 2017

Just noticed the ping on #355. Thanks for your work on this, I'm sure many will find this useful, including myself.

@jordonbiondo jordonbiondo force-pushed the feature/ignore-warnings branch from f3aa627 to da4793e Compare January 28, 2017 02:41
@jordonbiondo
Copy link
Contributor Author

@dgutov I've updated the commit with all your suggestions, let me know if there's anything else I can do.

@dgutov
Copy link
Collaborator

dgutov commented Jan 28, 2017

@jordonbiondo Thanks. Have you contributed to Emacs before?

This patch meets the allowed limit, but any further patches will require signed copyright assignment papers.

@jordonbiondo
Copy link
Contributor Author

@dgutov No I have not signed the assignment papers.

@jordonbiondo
Copy link
Contributor Author

I am in the process up signing the assignment paperwork now.

@dgutov dgutov merged commit faf73e8 into mooz:master Feb 2, 2017
@dgutov
Copy link
Collaborator

dgutov commented Feb 2, 2017

Thanks!

tejasbubane added a commit to tejasbubane/dotemacs that referenced this pull request May 8, 2017
For more info
* See `js2-message-table` variable for all error messages
(C-h v js2-message-table).
* PR: mooz/js2-mode#404
@jordonbiondo jordonbiondo deleted the feature/ignore-warnings branch January 14, 2020 19:03
@aspiers
Copy link

aspiers commented Dec 18, 2021

BTW just in case anyone is reading this years later, this feature can also be utilised by placing something like the following in .dir-locals.el:

 ("test"
  . ((js2-mode
      . ((js2-ignored-warnings . ("msg.no.side.effects"))))))

Then it would apply to the test/ subdirectory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants