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
Custom formatting of existing rules #10705
Comments
Hi, thanks for creating an issue. A few thoughts:
Configs are currently static data (while we allow people to use |
Hi, thanks for your response! I'd not spotted I'm not really a fan of 2) - given that we really want to help new developers (particularly those new to developing systems generally) get up to speed with the reasoning behind the rules I'd rather avoid having to then make them parse a different rule name that's not widely used. The overhead of maintaining custom versions of every rule we use just to add a link to the message seems high. 3) Sounds like it could be used to accommodate this, depending on the exact implementation. I think for us it would be useful if we were able to override the default locale to point at our messages file / function. Presumably we'd be able to do that in our Having read the linked thread #9870 it sounds like there's a few issues to be worked through before that lands. FWIW I'd be happy to implement something on a fork and then share our experiences of it, if you'd be open to providing a bit of a steer here and there. I also agree with your point about executable config - I imagine this would have to take the form of a path to a local module that exports the transformer function (this could potentially be a separate module from node_modules, if it was just |
I had this exact need -- setting personalized context on rules and adding links to project-specific reasons why a rule was turned on and how to fix it. My solution was:
The results are https://www.npmjs.com/package/eslint-formatter-compassion It's not a perfect solution for a couple reasons:
That said, being able to set team-based context, shortcutting the overhead for a failure etc. is a huge win for my teams. If there was a long-term ask from ESLint, it would be
A nice thing is that this problem gets much much simpler even if we only go with a few of those asks. |
Also, this would go hand-in-hand with #9870 because if both were implemented, rules that didn't have language support in a certain language could be augmented by third-parties in a blessed-path fashion while they build up the body of work. |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
The version of ESLint you are using.
3.5.0
The problem you want to solve.
We're currently investigating the ability to embed a link in eslint messages that would point to our own internal discussions and justifications for particular rules & config, along with examples of best practice specific to our codebase. This is primarily aimed at helping new developers on the team get up to speed with the rules more easily.
As far as I can see eslint would currently require us to write a custom formatter. That's probably achievable, but really we're after something more lightweight that would just customise the message the rule produces, and is compatible with existing formatters, particularly those that provide IDE integration.
Your take on the correct solution to problem.
Ideally we'd be able to provide a custom function as part of our eslint config that would be given each message (along with some available context, e.g. the rule that triggered the message), which would be required to return a new string, which would become the new message. I'm not familiar with the implementation of the rules, and if each individual message is still available after the formatter has done it's work. An alternative would be to require each formatter to call this new customising function. That would however require each formatter to be updated to use this hook.
Thanks in advance!
The text was updated successfully, but these errors were encountered: