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
Could we put lint messages in rule metadata? #6740
Could we put lint messages in rule metadata? #6740
Comments
This was discussed as part of the original metadata proposal and was dropped due to the complexity of referencing those strings from within the rule body (search for "meta" in closed PRs -- I'm sure you'll find those old discussions). We saw the same benefits of doing this, but the logistics ended up getting in the way, so we abandoned that part of the proposal. We even discussed something like |
I should have known I wasn't the first to think of this. Sorry about that! I would like to suggest one more possible implementation that might be less onerous to developers:
This seems less intrusive to me, but if even this approach is too intrusive or cumbersome, then I'm happy to close this issue. Thanks for your consideration. |
|
Sounds rational. @ilyavolodin thoughts? |
Sounds good to me. I would love to move messages into metadata. My only concern is that we have to support both IDs and strings (for backwards compatibility), in |
Wrapping those strings in |
I think I count 3 approvals (@mysticatea, @nzakas, @ilyavolodin) and I'm willing to champion and implement. Regarding i18n, I propose that we agree to try to implement in an i18n friendly manner, but that we do not attempt to include i18n in this specific proposal or to choose a particular library for it in this discussion. Regarding potential implementation, I would propose something like this:
Does this seem like a sensible approach? Am I missing anything? |
Documentation update should go with step 2 as well. @sindresorhus Any specific concerns about moving message into metadata? That would enable us to eventually have i18n support and probably improve documentation, but automatically appending all possible message to each individual article (should help with search results). |
|
Just as a reminder, this is really a "nice to have," so if you have some free time, it would be great to use that on the JSCS tasks first. We can always come back to this at a later time. (Not trying to detail, we just really need to focus our attention, both coding and reviewing, on the highest priority stuff first.) |
Fair enough @nzakas, I'll re-evaluate when I get back in town. Perhaps you On Jul 26, 2016 8:37 AM, "Nicholas C. Zakas" notifications@github.com
|
@eslint/eslint-tsc I've put a "help wanted" on this issue since it's a low priority for core team but could still be worth doing. Please remove the label if this is not desired. Thanks! |
TSC Summary: This issue is accepted, but I wanted to see if this merited being included on the core roadmap project. TSC Question: Should this issue be added to the core roadmap project? |
@platinumazure what's the implication of being in the core roadmap? Why do you think this (and your other proposals) should be included? |
@alberto To me, it's a matter of asking if we want to consider these as important for the next big milestone (e.g., do we want these done in core as part of 4.0). The "core roadmap" project was added and some issues were added to that project with a not-very-transparent process, and I wanted to put these up as potential candidates. If the TSC decides they do not belong on a core roadmap, then at least it's documented via TSC meeting notes and in this issue. So this is also an opportunity for TSC to gain awareness of these potential core roadmap-worthy issues, even if the ultimate outcome is not to put them on the core roadmap project. As for why these should or shouldn't be in the core roadmap, that comes down to the merits of each issue (i.e., what change is proposed in each issue) and evaluating whether or not that meshes with the vision of the project and/or is important enough to schedule for the next major version milestone. I believe the issues should be considered for inclusion, but not necessarily actually included. Make sense? |
As per the discussion during today's TSC meeting, this issue has been added to the Core Roadmap. |
An addition to this could be the ability for |
I’m starting work on this as outlined in #6740 (comment). |
* New: Add context.report({ messageId }) (fixes #6740) * Chore: Extract out loop variables in rule-tester.js * New: RuleTester checks the messageId of expected errors * Chore: Extract the {{ }} substitutions into a separate file * Chore: Test interpolate() * Docs: document messageIds * Fix: Node 4 compatibility * Docs: Specify `node` in messageIds example * Update: Throw if a rule uses a messageId, but doesn’t have meta.messages * Fix: Don’t mutate the descriptor * Chore: Use hOP instead of Object.keys().indexOf * Docs: Add explanation for messageIds * Chore: Fix lint errors * Docs: Show how to use placeholders in messages
Inspired by #6738, where it was noticed that some of our lint messages are inconsistent about ending in periods.
I think it would be really awesome to have lint messages as a part of rule metadata. This does not have immediate benefit for linting, but it would allow us to do interesting things with auto-generated documentation, and even allow searching by error message on the site.
Proposed API
We would support a new
messages
key on rulemeta
objects. The value of this key is an object with arbitrary keys and with string values equal to different messages being used.Examples
Example usage:
Challenges
The main challenge is figuring out how to access the messages from within the rule visitor functions, where we typically don't use object-oriented patterns. Very worst case (I'm hoping to avoid this), maybe we could augment RuleContext to support a
getMessages()
function which can return the available messages.A smaller challenge is to convert messages that use string concatenation (see
array-bracket-spacing
source for an example) to use our token replacement engine instead. I assume this is not a significant roadblock.Benefits
Here are the benefits I can see with doing this (none of which have to do with actual linting):
Etc.
What do folks think? Am I missing any significant challenges or roadblocks? Have I overstated the potential benefits? Or could this be worth pursuing at some point?
The text was updated successfully, but these errors were encountered: