Skip to content

Commit 6c750cc

Browse files
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]>
1 parent 39c6c2b commit 6c750cc

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

packages/eslint-config-turbo/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
],
3333
"main": "./dist/cjs/index.js",
3434
"types": "./dist/cjs/index.d.ts",
35-
"module": "./dist/es/index.mjs",
3635
"exports": {
3736
"./flat": {
3837
"import": {
@@ -46,8 +45,8 @@
4645
},
4746
".": {
4847
"import": {
49-
"types": "./dist/es/index.d.mts",
50-
"default": "./dist/es/index.mjs"
48+
"types": "./dist/cjs/index.d.ts",
49+
"default": "./dist/cjs/index.js"
5150
},
5251
"require": {
5352
"types": "./dist/cjs/index.d.ts",

packages/eslint-config-turbo/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ const config = {
22
extends: ["plugin:turbo/recommended"],
33
};
44

5-
// eslint-disable-next-line import/no-default-export -- ESLint convention is a default export
6-
export default config;
5+
module.exports = config;

0 commit comments

Comments
 (0)