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 ignoring specific warnings. #260

Open
jordonbiondo opened this issue Sep 2, 2015 · 4 comments
Open

Allow ignoring specific warnings. #260

jordonbiondo opened this issue Sep 2, 2015 · 4 comments

Comments

@jordonbiondo
Copy link
Contributor

From what I see there isn't a way to ignore specific warnings from js2-mode. There are certain times (usually in a test file) where I would like to ignore false warnings brought up by js2-mode.

For instance in a test file using chai's expect. I may have a line like this:

expect(true && false).to.be.false;

These lines are always highlighted because js2-mode thinks the line has no side effects even though they actually do.

My suggestion would be to have a buffer-local variable that contains a list of warnings to ignore. And then in js2-report-warning check if the warning is in the list before proceeding.

That way I can do something like this in my config in order to solve my problem.

(add-hook 'js2-mode-hook
                 (lambda ()
                   (when (is-a-test-file)
                     (add-to-list 'js2-var-with-a-list-of-ignored-warnings "msg.no.side.effects"))))

If this could be added to js2-mode I'd be happy to submit a pull request. But given the size of the project, there may be a better way to do this I overlooked.

@jordonbiondo
Copy link
Contributor Author

I have this implemented in my config like this:

    (defvar-local jordon-js2-ignored-warnings nil)

    (defadvice js2-report-warning (around ignore-some-warnings activate)
      (unless (member (ad-get-arg 0) jordon-js2-ignored-warnings)
        ad-do-it))

Then in a hook I add certain warnings to the list depending on the type of file.

@dgutov
Copy link
Collaborator

dgutov commented Sep 3, 2015

Another option is to add a function to js2-post-parse-callbacks which would filter out undesired elements from js2-parsed-errors and js2-parsed-warnings.

@decoursin
Copy link

bump

@RockyRoad29
Copy link

Some details about possible solutions would be welcome on emacswiki or elsewhere with a pointer here ...
I am also trying to get rid of those annoying warnings on statements like:
http://chaijs.com/api/bdd/#method_true
Thanks

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

No branches or pull requests

4 participants