Skip to content

fix: allow JSONRuleDefinition to report on tokens#210

Open
Pixel998 wants to merge 3 commits intomainfrom
fix/rule-definition-node-type
Open

fix: allow JSONRuleDefinition to report on tokens#210
Pixel998 wants to merge 3 commits intomainfrom
fix/rule-definition-node-type

Conversation

@Pixel998
Copy link
Contributor

Prerequisites checklist

What is the purpose of this pull request?

This PR fixes an issue where the JSONRuleDefinition type was overly restrictive, preventing rules from reporting issues on tokens (including comments and punctuation).

Previously, the Node type parameter was set to AnyNode, which caused TypeScript errors when rules attempted to use context.report() with tokens retrieved from sourceCode.comments or node.tokens.

What changes did you make? (Give an overview)

Fixed the Node constraint in JSONRuleDefinition by changing it from AnyNode to JSONSyntaxElement.

Related Issues

Is there anything you'd like reviewers to focus on?

@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Jan 31, 2026
@eslintbot eslintbot added this to Triage Jan 31, 2026
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jan 31, 2026
Copy link
Member

@lumirlumir lumirlumir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the PR description to include the bug template? It will help others clearly identify the problem you're facing.

@lumirlumir lumirlumir moved this from Needs Triage to Triaging in Triage Feb 2, 2026
@DMartens
Copy link

DMartens commented Feb 2, 2026

@lumirlumir This would allow reporting tokens such as a comma , or an opening brace {.
For example in a rule like no-comma-dangle this would be currently not allowed:

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 lumirlumir moved this from Triaging to Implementing in Triage Feb 8, 2026
Copy link
Member

@lumirlumir lumirlumir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

Would like @DMartens to verify before merging.

@lumirlumir lumirlumir moved this from Implementing to Second Review Needed in Triage Feb 15, 2026
@lumirlumir lumirlumir requested a review from DMartens February 15, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted bug Something isn't working

Projects

Status: Second Review Needed

Development

Successfully merging this pull request may close these issues.

3 participants