Skip to content

Commit

Permalink
infra(unicorn): prefer-object-from-entries (#2443)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Oct 8, 2023
1 parent eaf714d commit 3e4952b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ module.exports = defineConfig({
'unicorn/prefer-native-coercion-functions': 'off',
'unicorn/prefer-negative-index': 'off',
'unicorn/prefer-number-properties': 'off',
'unicorn/prefer-object-from-entries': 'off',
'unicorn/prefer-optional-catch-binding': 'off',
'unicorn/prefer-spread': 'off',
'unicorn/prefer-string-slice': 'off',
Expand Down
8 changes: 1 addition & 7 deletions scripts/apidoc/apiDocsWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,7 @@ function writeApiDocsModuleData(
methods: Method[]
): void {
const content = JSON.stringify(
methods.reduce<Record<string, Method>>(
(map, method) => ({
...map,
[method.name]: method,
}),
{}
)
Object.fromEntries(methods.map((method) => [method.name, method]))
);

writeFileSync(resolve(pathOutputDir, `${lowerModuleName}.json`), content);
Expand Down
2 changes: 1 addition & 1 deletion scripts/apidoc/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function generate(): Promise<void> {
]);
await writeApiPagesIndex(pages.map(({ text, link }) => ({ text, link })));
writeApiDiffIndex(
pages.reduce((data, { text, diff }) => ({ ...data, [text]: diff }), {})
Object.fromEntries(pages.map(({ text, diff }) => [text, diff]))
);
writeApiSearchIndex(pages);

Expand Down
5 changes: 2 additions & 3 deletions scripts/apidoc/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ export function mapByName<TInput extends { name: string }, TValue>(
input: TInput[],
valueExtractor: (item: TInput) => TValue
): Record<string, TValue> {
return input.reduce(
(acc, item) => ({ ...acc, [item.name]: valueExtractor(item) }),
{}
return Object.fromEntries(
input.map((item) => [item.name, valueExtractor(item)])
);
}

Expand Down

0 comments on commit 3e4952b

Please sign in to comment.