Skip to content

Commit

Permalink
chore: prefer using array spread (jestjs#14820)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored Dec 31, 2023
1 parent eefdf5d commit bd3a7e9
Show file tree
Hide file tree
Showing 83 changed files with 391 additions and 381 deletions.
9 changes: 5 additions & 4 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ module.exports = {
'packages/expect/src/index.ts',
'packages/jest-fake-timers/src/legacyFakeTimers.ts',
'packages/jest-jasmine2/src/jestExpect.ts',
'packages/jest-resolve/src/resolver.ts',
],
rules: {
'local/prefer-spread-eventually': 'warn',
Expand Down Expand Up @@ -332,8 +331,9 @@ module.exports = {
],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'unicorn/no-await-expression-member': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/no-await-expression-member': 'off',
'unicorn/prefer-spread': 'off',
},
},
{
Expand Down Expand Up @@ -676,6 +676,9 @@ module.exports = {
// reduce is fine
'unicorn/no-array-reduce': 'off',

// this is very aggressive (600+ files changed). might make sense to apply bit by bit over time?
'unicorn/prevent-abbreviations': 'off',

// nah
'unicorn/consistent-destructuring': 'off',
'unicorn/no-lonely-if': 'off',
Expand All @@ -696,9 +699,7 @@ module.exports = {
'unicorn/error-message': 'off',
'unicorn/no-object-as-default-parameter': 'off',
'unicorn/prefer-object-from-entries': 'off',
'unicorn/prefer-spread': 'off',
'unicorn/prefer-string-replace-all': 'off',
'unicorn/prevent-abbreviations': 'off',

// enabling this is blocked by https://github.com/microsoft/rushstack/issues/2780
'unicorn/prefer-export-from': 'off',
Expand Down
2 changes: 1 addition & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,7 @@ class CustomSequencer extends Sequencer {
sort(tests) {
// Test structure information
// https://github.com/jestjs/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21
const copyTests = Array.from(tests);
const copyTests = [...tests];
return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1));
}
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exports[`moduleNameMapper wrong array configuration 1`] = `
12 | module.exports = () => 'test';
13 |
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1174:17)
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1172:17)
at Object.require (index.js:10:1)
at Object.require (__tests__/index.js:10:20)"
`;
Expand Down Expand Up @@ -71,7 +71,7 @@ exports[`moduleNameMapper wrong configuration 1`] = `
12 | module.exports = () => 'test';
13 |
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1174:17)
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1172:17)
at Object.require (index.js:10:1)
at Object.require (__tests__/index.js:10:20)"
`;
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/requireMissingExt.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports[`shows a proper error from deep requires 1`] = `
12 | test('dummy', () => {
13 | expect(1).toBe(1);
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:929:11)
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:927:11)
at Object.<anonymous> (node_modules/discord.js/src/index.js:21:12)
at Object.require (__tests__/test.js:10:1)"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports[`show error message with matching files 1`] = `
| ^
9 |
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:929:11)
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:927:11)
at Object.require (index.js:8:18)
at Object.require (__tests__/test.js:8:11)"
`;
Loading

0 comments on commit bd3a7e9

Please sign in to comment.