@jimmy.codes/eslint-config
Version:
A simple, modern ESLint config that covers most use cases.
17 lines (16 loc) • 728 B
JavaScript
//#region src/utils/interop-default.ts
/**
* Utility to safely fetch an imported `ESLint` plugin.
*
* Since ESLint Flat Config still isn't widely adopted, many plugins don't include types or a default import by default. Additionally, since we accept large version ranges in our peer dependencies, the structure of plugins may change at times. This function normalizes an import of a generic ESLint plugin, ensuring it is typed and accessible.
*
* @param module the result of `import('eslint-plugin-name')`.
*
* @returns The normalized and awaited default export.
*/
const interopDefault = async (module) => {
const resolved = await module;
return resolved?.default ?? resolved;
};
//#endregion
export { interopDefault as t };