From c4c3bc9caa6980338bbaf7009cde047c7870cebe Mon Sep 17 00:00:00 2001 From: Jon Ursenbach Date: Tue, 31 Oct 2023 10:53:58 -0700 Subject: [PATCH] feat(eslint): disabling default exports in ESM libraries (#765) * feat(eslint): disabling default exports in ESM libraries * fix: pr feedback --- packages/eslint-config/esm.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/eslint-config/esm.js b/packages/eslint-config/esm.js index 359fea7f..c787454e 100644 --- a/packages/eslint-config/esm.js +++ b/packages/eslint-config/esm.js @@ -6,6 +6,17 @@ const config = { // see here for more rules to possibly enable in the future: // https://gist.github.com/Jaid/164668c0151ae09d2bc81be78a203dd5 'import/no-commonjs': 'error', + + /** + * This rule enablement is generally only intended for public-facing libraries but when shipping + * a package that exports CJS and ESM exports you cannot do `export default` and also + * `export type` in the same file because `export default` gets translated to `export =` in CJS + * and TS types can't be layered on top of that. + * + * @see {@link https://github.com/isaacs/tshy#handling-default-exports} + */ + 'import/no-default-export': 'warn', + 'node/no-extraneous-import': 'error', 'unicorn/prefer-module': 'error', 'unicorn/prefer-node-protocol': 'error',