Skip to content

Commit

Permalink
chore: use Object.fromEntries over reduce (jestjs#14822)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Dec 31, 2023
1 parent a22fa55 commit 8f296b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ module.exports = {

// TODO: turn on at some point
'unicorn/error-message': 'off',
'unicorn/prefer-object-from-entries': 'off',
'unicorn/prefer-string-replace-all': 'off',

// enabling this is blocked by https://github.com/microsoft/rushstack/issues/2780
Expand Down
6 changes: 1 addition & 5 deletions packages/jest-each/src/table/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type {Global} from '@jest/types';
import type {EachTests} from '../bind';
import {
type Headings,
type Template,
type Templates,
interpolateVariables,
} from './interpolation';
Expand Down Expand Up @@ -41,8 +40,5 @@ const convertTableToTemplates = (
headings: Headings,
): Templates =>
table.map(row =>
row.reduce<Template>(
(acc, value, index) => Object.assign(acc, {[headings[index]]: value}),
{},
),
Object.fromEntries(row.map((value, index) => [headings[index], value])),
);
9 changes: 5 additions & 4 deletions scripts/buildUtils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ function getPackages() {
},
/* eslint-enable */
'./package.json': './package.json',
...Object.values(pkg.bin || {}).reduce(
(mem, curr) =>
Object.assign(mem, {[curr.replace(/\.js$/, '')]: curr}),
{},
...Object.fromEntries(
Object.values(pkg.bin || {}).map(curr => [
curr.replace(/\.js$/, ''),
curr,
]),
),
...(pkg.name === 'jest-circus'
? {'./runner': './build/runner.js'}
Expand Down

0 comments on commit 8f296b6

Please sign in to comment.