Skip to content

Conversation

@Pixel998
Copy link
Contributor

@Pixel998 Pixel998 commented Jan 6, 2026

Prerequisites checklist

What is the purpose of this pull request?

This PR adds a CustomRuleVisitorWithExit type to the @eslint/plugin-kit package to address the need for a shared type that can generate exit selectors for rule visitors. Currently, each language plugin (JavaScript, JSON, CSS, Markdown) has to reimplement this same helper type separately.

What changes did you make? (Give an overview)

  • Added a new CustomRuleVisitorWithExit type.
  • Added type tests for CustomRuleVisitorWithExit

Related Issues

Fixes #318

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

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.

We also need to export CustomRuleVisitorWithExit from packages/plugin-it/source-code.js, probably like this:

/** @typedef {import("@eslint/core").RuleVisitor} RuleVisitor */
/**
 * @typedef {import("./types.ts").CustomRuleVisitorWithExit<RuleVisitorType>} CustomRuleVisitorWithExit<RuleVisitorType>
 * @template {RuleVisitor} RuleVisitorType
 */

The next step is ensuring that packages/plugin-kit/dist/cjs/index.d.cts references import("./types.cts") instead of import("./types.ts"). This kind of substitution is already being done in tools/build-cts.js, but only for static imports:

const newSourceText = oldSourceText.replaceAll(
' from "./types.ts";\n',
' from "./types.cts";\n',
);

@Pixel998 Pixel998 marked this pull request as ready for review January 12, 2026 00:32
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 a second review.

@fasttime fasttime moved this from Needs Triage to Second Review Needed in Triage Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Second Review Needed

Development

Successfully merging this pull request may close these issues.

Change Request: Export WithExit helper type from @eslint/plugin-kit

3 participants