Skip to content

feat: Add config types in @eslint/core #237

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

feat: Add config types in @eslint/core #237

wants to merge 6 commits into from

Conversation

nzakas
Copy link
Member

@nzakas nzakas commented Jul 9, 2025

Prerequisites checklist

What is the purpose of this pull request?

Copied config-related types over from the eslint package into @eslint/core

What changes did you make? (Give an overview)

  • Updated package.json files in packages/compat, packages/config-helpers, and packages/migrate-config to move @eslint/core to the dependencies section, ensuring it is available at runtime. [1] [2] [3]
  • Replaced eslint type imports with @eslint/core in packages/compat/src/fixup-rules.js, packages/compat/src/ignore-file.js, packages/config-helpers/src/define-config.js, packages/config-helpers/src/global-ignores.js, packages/config-helpers/src/types.ts, and packages/migrate-config/src/migrate-config.js. This includes updates to typedefs like Config, Plugin, RuleEntry, and others to their corresponding @eslint/core counterparts. [1] [2] [3] [4] [5] [6]
  • Renamed or adjusted type aliases for improved consistency, such as RuleEntry to RuleConfig and Linter.Config to ConfigObject. [1] [2]
  • Updated @typescript-eslint/array-type to enforce consistent array type definitions in TypeScript files. The rule is configured to use generic for default array types and array for readonly arrays.

Related Issues

fixes #226

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

@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jul 9, 2025
@nzakas nzakas requested a review from Copilot July 9, 2025 19:15
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR centralizes config-related types in the @eslint/core package, updates downstream packages to import those types, and enforces a consistent array type syntax.

  • Moved or added @eslint/core as a dependency and replaced eslint type imports with @eslint/core equivalents in compat, config-helpers, and migrate-config.
  • Renamed several type aliases for consistency (e.g., RuleEntryRuleConfig, Linter.ConfigConfigObject).
  • Enabled the @typescript-eslint/array-type rule and updated all array type declarations to the generic form.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/migrate-config/src/migrate-config.js Updated JSDoc typedefs to import new config types from @eslint/core.
packages/migrate-config/package.json Replaced @types/eslint with @eslint/core in devDependencies.
packages/config-helpers/src/types.ts Switched imports and array type syntax to use @eslint/core and Array<T>.
packages/config-helpers/src/global-ignores.js Updated JSDoc typedef to use @eslint/core ConfigObject.
packages/config-helpers/src/define-config.js Replaced several JSDoc typedefs to import types from @eslint/core.
packages/config-helpers/package.json Moved @eslint/core from devDependencies to dependencies.
packages/compat/src/ignore-file.js Updated typedef to import ConfigObject from @eslint/core.
packages/compat/src/fixup-rules.js Replaced JSDoc typedefs to import plugin, rule, and config types from core.
packages/compat/package.json Moved @eslint/core from devDependencies to dependencies.
packages/core/src/types.ts Converted all T[] and any[] usages to Array<T> and added new config types.
eslint.config.js Enforced the @typescript-eslint/array-type rule (generic for default arrays).
Comments suppressed due to low confidence (2)

packages/core/src/types.ts:723

  • It may be helpful to add type-level tests (e.g., with dtslint) for the new ConfigObject and related types to ensure they enforce the intended constraints and catch future regressions.
export interface ConfigObject<Rules extends RulesConfig = RulesConfig> {

packages/core/src/types.ts:103

  • [nitpick] This file has grown significantly in size and responsibility. Consider splitting core, config, and legacy type definitions into separate modules to improve readability and maintainability.
	((...args: Array<any>) => void) | undefined

/**
* The configuration for a set of files.
*/
export interface ConfigObject<Rules extends RulesConfig = RulesConfig> {
Copy link
Member Author

Choose a reason for hiding this comment

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

I used ConfigObject instead of Config to disambiguate with the Config class in eslint.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1, this has been a mild confusion for me for a while!

/* eslint-disable @typescript-eslint/consistent-indexed-object-style, @typescript-eslint/no-explicit-any -- needed for backward compatibility */

/** @deprecated Only supported in legacy eslintrc config format. */
export type GlobalAccess =
Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed from GlobalConf for clarity.

| "writeable";

/** @deprecated Only supported in legacy eslintrc config format. */
export interface GlobalsConfig {
Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed from Globals for clarity.

/**
* The type of JavaScript source code.
*/
type JavaScriptSourceType = "script" | "module" | "commonjs";
Copy link
Member Author

Choose a reason for hiding this comment

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

renamed from SourceType for clarity

* @deprecated Only supported in legacy eslintrc config format.
* @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options)
*/
export interface JavaScriptParserOptionsConfig {
Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed from ParserOptions for clarity.

}

/** @deprecated Only supported in legacy eslintrc config format. */
export interface EnvironmentConfig {
Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed from Environments for clarity.

* @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
*/
// https://github.com/eslint/eslint/blob/v8.57.0/conf/config-schema.js
export interface LegacyConfigObject<
Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed from LegacyConfig to match ConfigObject

@lumirlumir lumirlumir moved this from Needs Triage to Implementing in Triage Jul 15, 2025
@lumirlumir
Copy link
Member

Hi, it looks like the CI is currently failing. Would you mind taking a look when you have a moment?

Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

🔥 Lovely! I'm really excited to have @eslint/core provide these types as a full dependency.

I'd like to see input from @kirkwaiblinger since Kirk has been working more deeply on the types integrations. This structure looks good to me and on playing around with the types, but if there's some deep intricate issue I might not know it.

*/
interface LintSuggestion {
/** A short description. */

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

/**
* The configuration for a set of files.
*/
export interface ConfigObject<Rules extends RulesConfig = RulesConfig> {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1, this has been a mild confusion for me for a while!

@@ -496,7 +496,7 @@ interface ViolationReportBase {
/**
* The fix to be applied for the violation.
*/
fix?: RuleFixer | null | undefined;
fix?: RuleTextEdit | undefined;

Copy link
Contributor

Choose a reason for hiding this comment

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

Just confirming, was this actual change intentional?

* An object containing settings related to how JavaScript is configured for
* linting.
*/
languageOptions?: LanguageOptions;

Choose a reason for hiding this comment

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

I see that LanguageOptions is just Record<string, unknown> for now...

Can it include a parser field with a real Parser type (also exported)?

I had a hard time finding an ESLint-authored type for a parser, see https://github.com/typescript-eslint/typescript-eslint/pull/11190/files#diff-4f6c93a5b54f249fc56a41d19a39f8279bb5f633f2f379c7b8a2272aca3b68ebR13-R15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Implementing
Development

Successfully merging this pull request may close these issues.

Bug: config-helpers lacks a dependency on eslint required by exported types
4 participants