Skip to content

Commit

Permalink
Avoid using Array#reduce (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Sep 24, 2020
1 parent 9060c49 commit e630220
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions source/index.ts
Expand Up @@ -426,10 +426,9 @@ class Conf<T extends Record<string, any> = Record<string, unknown>> implements I
return;
}

// eslint-disable-next-line unicorn/no-reduce
const errors = this.#validator.errors.reduce((error, {dataPath, message = ''}) =>
error + ` \`${dataPath.slice(1)}\` ${message};`, '');
throw new Error('Config schema violation:' + errors.slice(0, -1));
const errors = this.#validator.errors
.map(({dataPath, message = ''}) => `\`${dataPath.slice(1)}\` ${message}`);
throw new Error('Config schema violation: ' + errors.join('; '));
}

private _ensureDirectory(): void {
Expand Down

0 comments on commit e630220

Please sign in to comment.