File tree 1 file changed +16
-2
lines changed
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> {
40
40
* From Node 22 requiring on ESM module returns the module object
41
41
* @see https://github.com/bmish/eslint-doc-generator/issues/615
42
42
*/
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
+ } ;
44
51
// eslint-disable-next-line import/no-dynamic-require
45
52
const _plugin = require ( pluginRoot ) as cjsOrEsmPlugin ;
46
53
47
54
/* 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
+ ) {
49
63
return _plugin . default ;
50
64
}
51
65
return _plugin as Plugin ;
You can’t perform that action at this time.
0 commit comments