-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Bug
Copy link
Labels
bugESLint is working incorrectlyESLint is working incorrectlyrepro:yesIssues with a reproducible exampleIssues with a reproducible example
Description
Environment
Node version: v23.1.0
npm version: v10.9.0
Local ESLint version: v9.20.0 (Currently used)
Global ESLint version: Not found
Operating System: darwin 24.2.0
What parser are you using?
Default (Espree)
What did you do?
Repro: https://github.com/brandongit2/eslint-jiti-bug-repro
Steps:
What did you expect to happen?
I expected the file to lint successfully.
What actually happened?
TypeError: Cannot read properties of undefined (reading 'configs')
Link to Minimal Reproducible Example
https://github.com/brandongit2/eslint-jiti-bug-repro
Participation
- I am willing to submit a pull request for this issue.
Additional comments
I was able to track down the issue to this line:
eslint/lib/config/config-loader.js
Line 186 in ccb60c0
const jiti = createJiti(__filename, { moduleCache: false, interopDefault: false }); |
Setting interopDefault: true
fixes the exception.
Reason for the exception:
- eslint-plugin-react-compiler is a pure-CJS library
- ESLint loads TypeScript configs with Jiti
- Jiti uses @babel/plugin-transform-modules-commonjs during its Babel transform step
- When your
config-loader.js
setsinteropDefault: false
, the Babel plugin turns off itsimportInterop
setting which breaks the eslint-plugin-react-compiler import (info on theimportInterop
setting) - That Babel plugin rewrites all references to default imports. So when I do
import reactCompiler from 'eslint-plugin-react-compiler'
, every reference toreactCompiler
in the config becomesreactCompiler.default
. - The
.default
property doesn't exist on that import, henceCannot read properties of undefined (reading 'configs')
when I try to accessreactCompiler.configs.recommended
.
This PR in the Jiti repo mentions how the interopDefault
setting is important in many cases.
Metadata
Metadata
Assignees
Labels
bugESLint is working incorrectlyESLint is working incorrectlyrepro:yesIssues with a reproducible exampleIssues with a reproducible example
Type
Projects
Status
Complete