You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(eslint-config-turbo): use module.exports for ESLint v8 compatibility (#10902)
### Description
Fixes#10901
In PR #10794, we changed from `module.exports` to `export default`,
which caused bunchee to generate `exports.default = config` instead of
`module.exports = config` in the CommonJS build.
ESLint v8 with legacy `.eslintrc.*` configuration expects shareable
configs to export directly via `module.exports`. When it encounters
`exports.default`, it interprets `'default'` as an unexpected top-level
configuration property, resulting in the error:
```
Unexpected top-level property "default"
```
### Changes
1. **`packages/eslint-config-turbo/src/index.ts`**
- Reverted from `export default config;` to `module.exports = config;`
- Ensures compiled CommonJS output properly exports the config object
directly
2. **`packages/eslint-config-turbo/package.json`**
- Removed the `module` field (no longer generating ESM for main entry)
- Updated `exports[".'"]` to point both `import` and `require` to the
CommonJS build
- Maintains compatibility while ensuring ESLint v8 can properly load the
configuration
### Why This Fixes The Problem
- **Before**: Using `export default` caused bunchee to generate
`exports.default = config;`
- **After**: Using `module.exports` generates `module.exports = config;`
which is what ESLint v8 expects
- ESLint v9 flat config support is maintained through the separate
`./flat` export path
### Testing Instructions
1. Build the package: `pnpm --filter=eslint-config-turbo build`
2. Run package validation: `pnpm --filter=eslint-config-turbo
package:lint`
3. Run type checking: `pnpm --filter=eslint-config-turbo package:types`
4. Verify compiled output: `cat
packages/eslint-config-turbo/dist/cjs/index.js` (should show
`module.exports = config;`)
All checks pass:
- ✅ `publint --strict`
- ✅ `attw --profile node16 --pack`
- ✅ `pnpm lint`
- ✅ Correct CommonJS output
### Compatibility
- ✅ **ESLint v8 (legacy config)**: Uses `require('eslint-config-turbo')`
- now works correctly
- ✅ **ESLint v9 (flat config)**: Uses `import turboConfig from
'eslint-config-turbo/flat'` - continues to work
- ✅ **Modern bundlers**: Can import from either path
CLOSES TURBO-4861
---------
Co-authored-by: pauloZion <[email protected]>
0 commit comments