From 052f6a60cd208b722fba7a5e2c151274432072eb Mon Sep 17 00:00:00 2001 From: Bartosz Date: Fri, 6 Sep 2024 10:51:31 +0200 Subject: [PATCH] fix: allow ignores param to be function --- configs/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/configs/index.js b/configs/index.js index 5f51a00..c77b442 100644 --- a/configs/index.js +++ b/configs/index.js @@ -33,10 +33,11 @@ export const configs = { * Creates eslint flat config based on provided configuration object. * * @param {{ [K in Exclude]?: Config | true }} [providedConfigs] configs to enable with optional parameters - * @param {string[]} [ignores] ignores config pattern, defaults to `['node_modules/', 'dist/', 'coverage/', '.vercel/']` + * @param {string[] | ((defaults: string[]) => string[])} [ignores] ignores pattern, defaults to `['node_modules/', 'dist/', 'coverage/', '.vercel/']` * @returns */ -export async function prepareConfig(providedConfigs = {}, ignores = ['node_modules/', 'dist/', 'coverage/', '.vercel/']) { +const DEFAULT_IGNORES = ['node_modules/', 'dist/', 'coverage/', '.vercel/']; +export async function prepareConfig(providedConfigs = {}, ignores = DEFAULT_IGNORES) { /** @type {{ [K in keyof typeof configs]?: Config | true }} */ const config = { ...providedConfigs, base: true }; const configKeys = /** @type {Array} */(Object.keys(configs)); @@ -57,7 +58,7 @@ export async function prepareConfig(providedConfigs = {}, ignores = ['node_modul } return tseslint.config( - { ignores }, + { ignores: ignores instanceof Function ? ignores(DEFAULT_IGNORES) : ignores }, ...base(), ...(await Promise.all(configKeys.map(mapConfig))).flatMap(x => x) );