Skip to content

Conversation

lumirlumir
Copy link
Member

@lumirlumir lumirlumir commented Apr 6, 2025

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[X] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Hello,

This PR addresses #19521.

I've implemented tests for JSRuleDefinition by referencing the existing test in @eslint/markdown.

The most notable change in this PR is the addition of the JSRuleDefinition type to the Rule namespace, in order to follow the existing convention.

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

Fixes: #19521

@lumirlumir lumirlumir requested a review from a team as a code owner April 6, 2025 10:44
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Apr 6, 2025
@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Apr 6, 2025
Copy link

netlify bot commented Apr 6, 2025

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 0baf3a4
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/67f63127a2bfc400087458c6
😎 Deploy Preview https://deploy-preview-19604--docs-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@fasttime fasttime moved this from Needs Triage to Implementing in Triage Apr 6, 2025
@fasttime fasttime added accepted There is consensus among the team that this change meets the criteria for inclusion types Related to TypeScript types labels Apr 6, 2025
@lumirlumir lumirlumir requested a review from fasttime April 8, 2025 13:13
Comment on lines 602 to 606
type JSRuleDefinitionTypeOptions = {
RuleOptions: unknown[];
MessageIds: string;
ExtRuleDocs: Record<string, unknown>;
};
Copy link
Member

Choose a reason for hiding this comment

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

We keep defining this structure in every plugin. Maybe we should make a generic RuleDefinitionTypeOptions in @eslint/core instead of copying this everywhere? @fasttime what do you think?

Copy link
Member

@fasttime fasttime Apr 8, 2025

Choose a reason for hiding this comment

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

We are already exporting an interface with that name (https://github.com/eslint/rewrite/blob/core-v0.13.0/packages/core/src/types.ts#L545-L556), but we could export a new type just for those options that should be customizable for a language-specific RuleDefinition generic type.

Copy link
Member

Choose a reason for hiding this comment

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

I opened an issue in the rewrite repo: eslint/rewrite#177

@lumirlumir
Copy link
Member Author

I've moved JSRuleDefinition types to top-level export in 0baf3a4!

Copy link
Member

@fasttime fasttime 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! Leaving open for @nzakas to review.

@fasttime fasttime moved this from Implementing to Second Review Needed in Triage Apr 9, 2025
Copy link
Member

@nzakas nzakas 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!

@nzakas nzakas merged commit 90228e5 into eslint:main Apr 9, 2025
31 checks passed
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Apr 9, 2025
@lumirlumir lumirlumir deleted the feat-support-js-rule-definition-type branch April 10, 2025 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion contributor pool feature This change adds a new feature to ESLint types Related to TypeScript types
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Change Request: Support generic types for Rule.RuleModule type
3 participants