-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix: correct typings for loadESLint() and shouldUseFlatConfig()
#20393
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
Conversation
✅ Deploy Preview for docs-eslint canceled.
|
There was a problem hiding this 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 optionaluseFlatConfigparameter - Refactored
AST.Rangetype to useSourceRangeinstead 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 |
loadESLint()loadESLint() and shouldUseFlatConfig()
snitin315
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
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()andshouldUseFlatConfig().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
eslint/lib/types/index.d.ts
Lines 1340 to 1342 in e7673ae
Just to confirm: git blame shows it wasn't updated when eslintrc support was dropped.
Also, it seems the typings for
shouldUseFlatConfigwere not updated. As a result, the current implementation only returnstrue, but the type definition specifiesboolean:eslint/lib/eslint/eslint.js
Lines 1347 to 1353 in e7673ae
eslint/lib/types/use-at-your-own-risk.d.ts
Lines 33 to 34 in e7673ae
Just to confirm: git blame shows it wasn't updated when eslintrc support was dropped.
Also, as a minor refactor, I replaced the
[number, number]type with theSourceRangetype.Is there anything you'd like reviewers to focus on?
N/A