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

Give ignore-warnings functions full warning object #11

Closed
tivac opened this issue May 8, 2019 · 3 comments
Closed

Give ignore-warnings functions full warning object #11

tivac opened this issue May 8, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@tivac
Copy link

tivac commented May 8, 2019

messages = (ignore_warnings ? warnings.filter(({ code }) => !ignore_warnings(code)) : warnings).map(({ code, message, start, end }) => ({

Currently it looks like a function defined to handle warnings only gets passed the code value, though the svelte compiler actually returns multiple properties for a warning. I understand not passing the location pieces through but I'd at least like to be able to access the message property.

if #10 gets fixed I personally stop caring about this, because I'm trying to add a programmatic warning handler to work around the lack of preprocessor support, but it's probably still a good idea to pass more details along anyways.

@Conduitry
Copy link
Member

Yeah, I'm definitely into this in theory. I'd considered this in the past, but it doesn't play entirely nicely with the current settings stuff. I'm trying to make most of the settings be at least somewhat usable without having them be set to a callback - that requires having a .eslintrc.js file, which I think is still way less common than a JSON or YAML one.

The callback currently only gets the code of the warning, because when the setting is an array, it's taken as an array of codes to ignore.

The simplest way to add this (and one that would still be backwards compatible) that I can think of is to add the entire warning object as a second argument to the ignore-warnings callback, in addition to the first argument which will still be its code. This is a bit clunky, but it a) wouldn't be a breaking change, and b) would still also allow the array-of-codes form to work in a sensible way.

Thoughts?

@tivac
Copy link
Author

tivac commented May 10, 2019

That's how I'd add support for this, yes. It's a tiny bit clunky but worth it to continue supporting the folks stuck in the dark ages of JSON/YAML eslint configs.

@Conduitry
Copy link
Member

This has been added in v1.2.0, which the entire warning object passed as a second argument.

@Conduitry Conduitry added the enhancement New feature or request label Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants