fix: allow JSONRuleDefinition to report on tokens#210
Open
Conversation
lumirlumir
requested changes
Feb 2, 2026
Member
lumirlumir
left a comment
There was a problem hiding this comment.
Could you update the PR description to include the bug template? It will help others clearly identify the problem you're facing.
DMartens
reviewed
Feb 2, 2026
|
@lumirlumir This would allow reporting tokens such as a comma export default {
create(context) {
return {
Object(object) {
const lastMember = object.members.at(-1);
const danglingComma = sourceCode.getTokenAfter(lastMember);
if (danglingComma !== null) {
// The type does not allow passing a token as the `node`
context.report({ message: 'No dangling commas', node: danglingComma });
}
}
}
}
} |
lumirlumir
requested changes
Feb 8, 2026
lumirlumir
approved these changes
Feb 15, 2026
Member
lumirlumir
left a comment
There was a problem hiding this comment.
LGTM, thanks.
Would like @DMartens to verify before merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites checklist
What is the purpose of this pull request?
This PR fixes an issue where the
JSONRuleDefinitiontype was overly restrictive, preventing rules from reporting issues on tokens (including comments and punctuation).Previously, the
Nodetype parameter was set toAnyNode, which caused TypeScript errors when rules attempted to usecontext.report()with tokens retrieved fromsourceCode.commentsornode.tokens.What changes did you make? (Give an overview)
Fixed the
Nodeconstraint inJSONRuleDefinitionby changing it fromAnyNodetoJSONSyntaxElement.Related Issues
Is there anything you'd like reviewers to focus on?