File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -40,12 +40,26 @@ export async function loadPlugin(path: string): Promise<Plugin> {
4040 * From Node 22 requiring on ESM module returns the module object
4141 * @see https://github.com/bmish/eslint-doc-generator/issues/615
4242 */
43- type cjsOrEsmPlugin = Plugin | { __esModule : boolean ; default : Plugin } ;
43+ type cjsOrEsmPlugin =
44+ | Plugin
45+ | {
46+ __esModule : boolean ;
47+ default : Plugin ;
48+ /* some plugins might have additional exports besides `default` */
49+ [ key : string ] : unknown ;
50+ } ;
4451 // eslint-disable-next-line import/no-dynamic-require
4552 const _plugin = require ( pluginRoot ) as cjsOrEsmPlugin ;
4653
4754 /* istanbul ignore next */
48- if ( '__esModule' in _plugin && _plugin . __esModule && _plugin . default ) {
55+ if (
56+ '__esModule' in _plugin &&
57+ _plugin . __esModule &&
58+ // Ensure that we return only the default key when only a default export is present
59+ // @see https://github.com/bmish/eslint-doc-generator/issues/656#issuecomment-2726745618
60+ Object . keys ( _plugin ) . length === 2 &&
61+ [ '__esModule' , 'default' ] . every ( ( it ) => Boolean ( _plugin [ it ] ) )
62+ ) {
4963 return _plugin . default ;
5064 }
5165 return _plugin as Plugin ;
You can’t perform that action at this time.
0 commit comments