Skip to content

Commit

Permalink
Merge branch 'main' into feat-async-setupFilesAfterEnv
Browse files Browse the repository at this point in the history
  • Loading branch information
vkml committed Jan 1, 2024
2 parents 22570e9 + fb2bac0 commit ba8c54a
Show file tree
Hide file tree
Showing 418 changed files with 8,805 additions and 9,454 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -12,7 +12,7 @@ aliases:
app-dir: ~/jest

orbs:
node: circleci/node@5.1.0
node: circleci/node@5.1.1

jobs:
test-node:
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Expand Up @@ -12,6 +12,7 @@ website/static

# Third-party script
packages/jest-diff/src/cleanupSemantic.ts
e2e/native-esm/wasm-bindgen/index_bg.js

**/.yarn
**/.pnp.*
Expand Down
131 changes: 100 additions & 31 deletions .eslintrc.cjs
Expand Up @@ -33,14 +33,21 @@ module.exports = {
'plugin:markdown/recommended',
'plugin:import/errors',
'plugin:eslint-comments/recommended',
'plugin:unicorn/recommended',
'plugin:promise/recommended',
'plugin:prettier/recommended',
],
globals: {
console: 'readonly',
},
overrides: [
{
extends: ['plugin:@typescript-eslint/strict', 'plugin:import/typescript'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/strict',
'plugin:@typescript-eslint/stylistic',
'plugin:import/typescript',
],
files: ['*.ts', '*.tsx'],
plugins: ['@typescript-eslint/eslint-plugin', 'local'],
rules: {
Expand All @@ -58,6 +65,7 @@ module.exports = {
],
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
// TS verifies these
'consistent-return': 'off',
'no-dupe-class-members': 'off',
Expand All @@ -67,24 +75,14 @@ module.exports = {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-invalid-void-type': 'off',

// TODO: part of "stylistic" rules, remove explicit activation when that lands
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/consistent-type-definitions': 'off',

// not needed to be enforced for TS
'import/namespace': 'off',
},
},
{
files: [
'packages/jest-jasmine2/src/jasmine/Env.ts',
'packages/jest-jasmine2/src/jasmine/ReportDispatcher.ts',
'packages/jest-jasmine2/src/jasmine/Spec.ts',
'packages/jest-jasmine2/src/jasmine/SpyStrategy.ts',
'packages/jest-jasmine2/src/jasmine/Suite.ts',
'packages/jest-jasmine2/src/jasmine/createSpy.ts',
'packages/jest-jasmine2/src/jasmine/jasmineLight.ts',
'packages/jest-mock/src/__tests__/index.test.ts',
'packages/jest-mock/src/index.ts',
'packages/pretty-format/src/__tests__/Immutable.test.ts',
Expand All @@ -99,13 +97,7 @@ module.exports = {
files: [
'packages/expect/src/index.ts',
'packages/jest-fake-timers/src/legacyFakeTimers.ts',
'packages/jest-jasmine2/src/jasmine/Env.ts',
'packages/jest-jasmine2/src/jasmine/ReportDispatcher.ts',
'packages/jest-jasmine2/src/jasmine/Spec.ts',
'packages/jest-jasmine2/src/jasmine/Suite.ts',
'packages/jest-jasmine2/src/jasmine/jasmineLight.ts',
'packages/jest-jasmine2/src/jestExpect.ts',
'packages/jest-resolve/src/resolver.ts',
],
rules: {
'local/prefer-spread-eventually': 'warn',
Expand All @@ -122,8 +114,6 @@ module.exports = {
'packages/expect-utils/src/utils.ts',
'packages/jest-core/src/collectHandles.ts',
'packages/jest-core/src/plugins/UpdateSnapshotsInteractive.ts',
'packages/jest-jasmine2/src/jasmine/SpyStrategy.ts',
'packages/jest-jasmine2/src/jasmine/Suite.ts',
'packages/jest-leak-detector/src/index.ts',
'packages/jest-matcher-utils/src/index.ts',
'packages/jest-mock/src/__tests__/index.test.ts',
Expand Down Expand Up @@ -229,6 +219,11 @@ module.exports = {
'no-undef': 'off',
'no-unused-vars': 'off',
'sort-keys': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/error-message': 'off',
'unicorn/no-await-expression-member': 'off',
'unicorn/no-static-only-class': 'off',
'unicorn/prefer-number-properties': 'off',
},
},
// demonstration of matchers usage
Expand Down Expand Up @@ -324,6 +319,7 @@ module.exports = {
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/class-literal-property-style': 'off',
},
},
{
Expand All @@ -336,6 +332,9 @@ module.exports = {
],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/no-await-expression-member': 'off',
'unicorn/prefer-spread': 'off',
},
},
{
Expand All @@ -344,8 +343,12 @@ module.exports = {
'packages/expect-utils/src/jasmineUtils.ts',
],
rules: {
'@typescript-eslint/ban-types': 'off',
'eslint-comments/disable-enable-pair': 'off',
'eslint-comments/no-unlimited-disable': 'off',
'prefer-rest-params': 'off',
'prefer-spread': 'off',
'sort-keys ': 'off',
},
},
{
Expand All @@ -365,11 +368,13 @@ module.exports = {
'website/**',
'**/__benchmarks__/**',
'**/__tests__/**',
'packages/jest-types/**/*',
'**/__typetests__/**',
'.eslintplugin/**',
],
rules: {
'import/no-extraneous-dependencies': 'off',
'unicorn/consistent-function-scoping': 'off',
'unicorn/error-message': 'off',
},
},
{
Expand Down Expand Up @@ -412,12 +417,43 @@ module.exports = {
'no-unused-vars': 'off',
},
},
{
files: 'packages/jest-mock/src/__tests__/**/*',
rules: {
'unicorn/no-static-only-class': 'off',
},
},
{
files: '**/*.mjs',
rules: {
'unicorn/prefer-top-level-await': 'error',
},
},
{
files: [
'e2e/coverage-report/__mocks__/sumDependency.js',
'e2e/require-main-after-create-require/empty.js',
'packages/create-jest/src/__tests__/__fixtures__/**/*',
'packages/jest-core/src/__tests__/**/*',
'packages/jest-haste-map/src/__tests__/test_dotfiles_root/**/*',
'packages/jest-resolve/src/__mocks__/**/*',
],
rules: {
'unicorn/no-empty-file': 'off',
},
},
{
files: 'packages/expect/src/__tests__/*.test.js',
rules: {
'unicorn/prefer-number-properties': 'off',
},
},
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
},
plugins: ['import', 'jsdoc', 'unicorn'],
plugins: ['import', 'jsdoc'],
rules: {
'accessor-pairs': ['warn', {setWithoutGet: true}],
'block-scoped-var': 'off',
Expand Down Expand Up @@ -540,9 +576,7 @@ module.exports = {
'no-multi-str': 'error',
'no-multiple-empty-lines': 'off',
'no-native-reassign': ['error', {exceptions: ['Map', 'Set']}],
'no-negated-condition': 'off',
'no-negated-in-lhs': 'error',
'no-nested-ternary': 'off',
'no-new': 'warn',
'no-new-func': 'error',
'no-new-object': 'warn',
Expand Down Expand Up @@ -604,6 +638,11 @@ module.exports = {
'prefer-arrow-callback': ['error', {allowNamedFunctions: true}],
'prefer-const': 'error',
'prefer-template': 'error',

'promise/always-return': 'off',
'promise/catch-or-return': 'off',
'promise/no-callback-in-promise': 'off',

quotes: [
'error',
'single',
Expand All @@ -625,13 +664,43 @@ module.exports = {
'wrap-regex': 'off',
yoda: 'off',

'unicorn/explicit-length-check': 'error',
'unicorn/no-array-for-each': 'error',
'unicorn/no-negated-condition': 'error',
'unicorn/numeric-separators-style': 'error',
'unicorn/prefer-default-parameters': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/template-indent': 'error',
// doesn't work without ESModuleInterop
'unicorn/import-style': 'off',
// we're a CJS project
'unicorn/prefer-module': 'off',

// enforced by `@typescript-eslint/no-this-alias` already
'unicorn/no-this-assignment': 'off',

// Not an issue with TypeScript
'unicorn/no-array-callback-reference': 'off',

// 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',
'unicorn/no-null': 'off',
'unicorn/no-process-exit': 'off',
'unicorn/no-useless-undefined': 'off',
'unicorn/prefer-event-target': 'off',
'unicorn/prefer-switch': 'off',
'unicorn/prefer-ternary': 'off',
'unicorn/prefer-top-level-await': 'off',
'unicorn/switch-case-braces': 'off',

// TODO: decide whether or not we want these
'unicorn/filename-case': 'off',
'unicorn/prefer-reflect-apply': 'off',

// enabling this is blocked by https://github.com/microsoft/rushstack/issues/2780
'unicorn/prefer-export-from': 'off',
// enabling this is blocked by https://github.com/jestjs/jest/pull/14297
'unicorn/prefer-node-protocol': 'off',
},
settings: {
'import/ignore': ['react-native'],
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/close-stale.yml
Expand Up @@ -12,7 +12,7 @@ jobs:
name: 'Close month old issues and PRs'
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
start-date: '2022-01-01T00:00:00Z'
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.'
Expand All @@ -32,7 +32,7 @@ jobs:
name: 'Close year old issues and PRs'
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.'
stale-pr-message: 'This PR is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.'
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/nodejs.yml
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: ts integration
run: yarn test-ts --selectProjects ts-integration
- name: type tests
run: yarn test-ts --selectProjects type-tests
run: yarn tstyche --target 5.0,latest && yarn test-ts --selectProjects type-tests
- name: verify TypeScript@5.0 compatibility
run: yarn verify-old-ts
- name: run ESLint with type info
Expand Down Expand Up @@ -202,7 +202,12 @@ jobs:
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v2
- name: run tests with coverage
run: yarn jest-coverage --color --config jest.config.ci.mjs --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
retry_on: error
command: yarn jest-coverage --color --config jest.config.ci.mjs --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}
- name: map coverage
run: node ./scripts/mapCoverage.mjs
if: always()
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/test-nightly.yml
Expand Up @@ -33,7 +33,12 @@ jobs:
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v2
- name: run tests
run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
retry_on: error
command: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}

test-jasmine:
strategy:
Expand All @@ -60,4 +65,9 @@ jobs:
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v2
- name: run tests using jest-jasmine
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
retry_on: error
command: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ matrix.shard }}
14 changes: 12 additions & 2 deletions .github/workflows/test.yml
Expand Up @@ -36,7 +36,12 @@ jobs:
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v2
- name: run tests
run: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ inputs.shard }}
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
retry_on: error
command: yarn test-ci-partial:parallel --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ inputs.shard }}

test-jasmine:
name: Node LTS using jest-jasmine2
Expand All @@ -59,4 +64,9 @@ jobs:
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v2
- name: run tests using jest-jasmine
run: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ inputs.shard }}
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
retry_on: error
command: yarn jest-jasmine-ci --max-workers ${{ steps.cpu-cores.outputs.count }} --shard=${{ inputs.shard }}

0 comments on commit ba8c54a

Please sign in to comment.