UNPKG

@jimmy.codes/eslint-config

Version:

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

20 lines (19 loc) 593 B
//#region src/utils/rebrand.ts /** * Renames the prefix of ESLint rule keys. * * @param rules - A partial set of ESLint rules. * * @param from - The current rule prefix to replace (without trailing slash). * * @param to - The new rule prefix (without trailing slash). * * @returns A new rules object with matching prefixes renamed. */ const rebrand = (rules = {}, from, to) => { return Object.fromEntries(Object.entries(rules).map(([rule, option]) => { return [rule.startsWith(`${from}/`) ? rule.replace(`${from}/`, `${to}/`) : rule, option]; })); }; //#endregion export { rebrand as t };