Skip to content

Conversation

@lumirlumir
Copy link
Member

@lumirlumir lumirlumir commented Dec 11, 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)

In this PR, I've corrected the typings for loadESLint() and shouldUseFlatConfig().


After dropping support for ESLintrc, it seems the typings for loadESLint() were not updated. As a result, the current implementation doesn't accept any value, but the typings do:

eslint/lib/api.js

Lines 21 to 27 in e7673ae

/**
* Loads the correct ESLint constructor given the options.
* @returns {Promise<ESLint>} The ESLint constructor
*/
async function loadESLint() {
return ESLint;
}

eslint/lib/types/index.d.ts

Lines 1340 to 1342 in e7673ae

export function loadESLint(options?: {
useFlatConfig?: boolean | undefined;
}): Promise<typeof ESLint>;

Just to confirm: git blame shows it wasn't updated when eslintrc support was dropped.

image

Also, it seems the typings for shouldUseFlatConfig were not updated. As a result, the current implementation only returns true, but the type definition specifies boolean:

eslint/lib/eslint/eslint.js

Lines 1347 to 1353 in e7673ae

/**
* Returns whether flat config should be used.
* @returns {Promise<boolean>} Whether flat config should be used.
*/
async function shouldUseFlatConfig() {
return true;
}

/** @deprecated */
export function shouldUseFlatConfig(): Promise<boolean>;

Just to confirm: git blame shows it wasn't updated when eslintrc support was dropped.

image

Also, as a minor refactor, I replaced the [number, number] type with the SourceRange type.

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

N/A

@eslint-github-bot eslint-github-bot bot added the bug ESLint is working incorrectly label Dec 11, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Dec 11, 2025
@netlify
Copy link

netlify bot commented Dec 11, 2025

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit 4cffbd7
🔍 Latest deploy log https://app.netlify.com/projects/docs-eslint/deploys/693a7982440f8e0008902760

@lumirlumir lumirlumir added the types Related to TypeScript types label Dec 11, 2025
@lumirlumir lumirlumir marked this pull request as ready for review December 11, 2025 06:53
@lumirlumir lumirlumir requested a review from a team as a code owner December 11, 2025 06:53
Copilot AI review requested due to automatic review settings December 11, 2025 06:53
Copy link
Contributor

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 corrects the TypeScript type definitions for the loadESLint() function to match its actual implementation, which no longer accepts parameters after ESLint v10.0.0 dropped support for ESLintrc.

  • Updated the loadESLint() type signature to remove the optional useFlatConfig parameter
  • Refactored AST.Range type to use SourceRange instead of inline [number, number] tuple
  • Updated type tests to verify that passing arguments now produces TypeScript errors

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
lib/types/index.d.ts Updated loadESLint() signature to accept no parameters and refactored AST.Range to use SourceRange type
tests/lib/types/types.test.ts Added @ts-expect-error annotations to verify that passing arguments to loadESLint() correctly produces TypeScript errors

@lumirlumir lumirlumir marked this pull request as draft December 11, 2025 07:40
@lumirlumir lumirlumir changed the title fix: correct typings for loadESLint() fix: correct typings for loadESLint() and shouldUseFlatConfig() Dec 11, 2025
@github-actions github-actions bot added cli Relates to ESLint's command-line interface core Relates to ESLint's core APIs and features labels Dec 11, 2025
@lumirlumir lumirlumir marked this pull request as ready for review December 11, 2025 07:54
@nzakas nzakas moved this from Needs Triage to Implementing in Triage Dec 11, 2025
Copy link
Contributor

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

@snitin315 snitin315 merged commit ba6ebfa into main Dec 12, 2025
31 checks passed
@snitin315 snitin315 deleted the fix-correct-typings-for-loadeslint branch December 12, 2025 18:36
@github-project-automation github-project-automation bot moved this from Implementing to Complete in Triage Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ESLint is working incorrectly cli Relates to ESLint's command-line interface core Relates to ESLint's core APIs and features types Related to TypeScript types

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants