MCPcopy Create free account
hub / github.com/code-pushup/cli / filterKebabCaseKeys

Function filterKebabCaseKeys

packages/cli/src/lib/implementation/global.utils.ts:5–23  ·  view source on GitHub ↗
(
  obj: T,
)

Source from the content-addressed store, hash-verified

3import { OptionValidationError } from './validate-filter-options.utils.js';
4
5export function filterKebabCaseKeys<T extends Record<string, unknown>>(
6 obj: T,
7): T {
8 return Object.entries(obj)
9 .filter(([key]) => !key.includes('-'))
10 .reduce(
11 (acc, [key, value]) =>
12 typeof value === 'string' ||
13 (typeof value === 'object' && Array.isArray(obj[key]))
14 ? { ...acc, [key]: value }
15 : typeof value === 'object' && !Array.isArray(value) && value != null
16 ? {
17 ...acc,
18 [key]: filterKebabCaseKeys(value as Record<string, unknown>),
19 }
20 : { ...acc, [key]: value },
21 {},
22 ) as T;
23}
24
25// Log error and flush stdout to ensure all logs are printed
26// before Yargs exits or rethrows the error.

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected