UNPKG

@jimmy.codes/eslint-config

Version:

A simple, modern ESLint config that covers most use cases.

29 lines (28 loc) 1.11 kB
//#region src/utils/extract-options.ts /** * A simple utility to derive options for configurations when one option is a boolean. * * @param options - The options to derive. * * @returns The extracted options or `undefined` if the input was a boolean. */ const extractOptions = (options) => { if (typeof options !== "boolean") return options; }; //#endregion //#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 unwrapDefault = async (module) => { const resolved = await module; return resolved?.default ?? resolved; }; //#endregion export { extractOptions as n, unwrapDefault as t };