Skip to content

Commit

Permalink
Merge branch 'main' into bug-13222
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Sep 20, 2023
2 parents 2f4ee48 + 70340d0 commit f8a70c7
Show file tree
Hide file tree
Showing 2,511 changed files with 63,380 additions and 48,247 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ aliases:
app-dir: ~/jest

orbs:
node: circleci/node@5.0.0
node: circleci/node@5.1.0

jobs:
test-node:
Expand Down Expand Up @@ -58,5 +58,6 @@ workflows:
name: test-node-partial-<< matrix.node-version >>
matrix:
parameters:
node-version: ['14', '16', '18']
# For some reason, v20 fails to run yarn install…
node-version: ['16', '18']
- test-jest-jasmine
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ bin/
packages/*/build/**
packages/*/dist/**
website/.docusaurus
website/blog
website/build
website/node_modules
website/i18n/*.js
Expand Down
2 changes: 1 addition & 1 deletion .eslintplugin/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
Expand Down
91 changes: 78 additions & 13 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -40,11 +40,7 @@ module.exports = {
},
overrides: [
{
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:import/typescript',
],
extends: ['plugin:@typescript-eslint/strict', 'plugin:import/typescript'],
files: ['*.ts', '*.tsx'],
plugins: ['@typescript-eslint/eslint-plugin', 'local'],
rules: {
Expand All @@ -61,9 +57,15 @@ module.exports = {
'consistent-return': 'off',
'no-dupe-class-members': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
// TODO: enable at some point
'@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',
},
},
{
Expand Down Expand Up @@ -128,7 +130,7 @@ module.exports = {
rules: {
'@typescript-eslint/ban-types': [
'error',
// TODO: remove these overrides: https://github.com/facebook/jest/issues/10177
// TODO: remove these overrides: https://github.com/jestjs/jest/issues/10177
{types: {Function: false, object: false, '{}': false}},
],
'local/ban-types-eventually': [
Expand Down Expand Up @@ -162,14 +164,36 @@ module.exports = {
],
env: {'jest/globals': true},
excludedFiles: ['**/__typetests__/**'],
extends: ['plugin:jest/style'],
plugins: ['jest'],
rules: {
'jest/no-alias-methods': 'error',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/require-to-throw-message': 'error',
'jest/valid-expect': 'error',
},
},

{
files: ['e2e/__tests__/*'],
rules: {
'jest/no-restricted-jest-methods': [
'error',
{
fn: 'Please use fixtures instead of mocks in the end-to-end tests.',
mock: 'Please use fixtures instead of mocks in the end-to-end tests.',
doMock:
'Please use fixtures instead of mocks in the end-to-end tests.',
setMock:
'Please use fixtures instead of mocks in the end-to-end tests.',
spyOn:
'Please use fixtures instead of mocks in the end-to-end tests.',
},
],
},
},

// to make it more suitable for running on code examples in docs/ folder
{
files: ['**/*.md/**'],
Expand All @@ -178,19 +202,50 @@ module.exports = {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'arrow-body-style': 'off',
'consistent-return': 'off',
'import/export': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'jest/no-focused-tests': 'off',
'jest/require-to-throw-message': 'off',
'no-console': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'off',
'sort-keys': 'off',
},
},
// demonstration of matchers usage
{
files: ['**/UsingMatchers.md/**'],
rules: {
'jest/prefer-to-be': 'off',
},
},
// demonstration of 'jest/valid-expect' rule
{
files: [
'**/2017-05-06-jest-20-delightful-testing-multi-project-runner.md/**',
],
rules: {
'jest/valid-expect': 'off',
},
},
// Jest 11 did not had `toHaveLength` matcher
{
files: ['**/2016-04-12-jest-11.md/**'],
rules: {
'jest/prefer-to-have-length': 'off',
},
},
// snapshot in an example needs to keep escapes
{
files: [
'**/2017-02-21-jest-19-immersive-watch-mode-test-platform-improvements.md/**',
],
rules: {
'no-useless-escape': 'off',
},
},

// snapshots in examples plus inline snapshots need to keep backtick
{
Expand All @@ -216,8 +271,7 @@ module.exports = {
{
files: ['examples/**/*'],
rules: {
'import/no-unresolved': ['error', {ignore: ['^react-native$']}],
'import/order': 'off',
'no-restricted-imports': 'off',
},
},
{
Expand Down Expand Up @@ -295,6 +349,8 @@ module.exports = {
files: ['**/__typetests__/**'],
rules: {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/no-useless-constructor': 'off',
},
},
{
Expand All @@ -305,7 +361,7 @@ module.exports = {
files: [
'scripts/*',
'packages/*/__benchmarks__/test.js',
'packages/jest-cli/src/init/index.ts',
'packages/create-jest/src/runCreate.ts',
'packages/jest-repl/src/cli/runtime-cli.ts',
],
rules: {
Expand All @@ -322,6 +378,7 @@ module.exports = {
'**/__typetests__/**',
],
rules: {
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'import/no-unresolved': 'off',
'no-console': 'off',
Expand All @@ -333,7 +390,7 @@ module.exports = {
parserOptions: {
sourceType: 'module',
},
plugins: ['import'],
plugins: ['import', 'jsdoc', 'unicorn'],
rules: {
'accessor-pairs': ['warn', {setWithoutGet: true}],
'block-scoped-var': 'off',
Expand Down Expand Up @@ -390,6 +447,7 @@ module.exports = {
},
],
'init-declarations': 'off',
'jsdoc/check-alignment': 'error',
'lines-around-comment': 'off',
'max-depth': 'off',
'max-nested-callbacks': 'off',
Expand Down Expand Up @@ -537,6 +595,13 @@ module.exports = {
'wrap-iife': 'off',
'wrap-regex': 'off',
yoda: 'off',

'unicorn/explicit-length-check': 'error',
'unicorn/no-array-for-each': 'error',
'unicorn/no-negated-condition': 'error',
'unicorn/prefer-default-parameters': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/template-indent': 'error',
},
settings: {
'import/ignore': ['react-native'],
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 👉 [Please follow one of these issue templates](https://github.com/facebook/jest/issues/new/choose) 👈
## 👉 [Please follow one of these issue templates](https://github.com/jestjs/jest/issues/new/choose) 👈

<!-- Love Jest? Please consider supporting our collective: 👉 https://opencollective.com/jest/donate -->

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ body:
label: Version
description: |
The version of Jest you are using.
Is it the [latest](https://github.com/facebook/jest/releases)? Test and see if the bug has already been fixed.
Is it the [latest](https://github.com/jestjs/jest/releases)? Test and see if the bug has already been fixed.
placeholder: ex. 27.0.6
validations:
required: true
Expand Down
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Documentation 📖
description: Submit a request to add or update documentation
title: '[Docs]: '
labels: ['Documentation :book:']
body:
- type: markdown
attributes:
value: |
### Thank you for helping us improve our documentation!
Please be sure you are looking at [the latest version of the documentation](https://jestjs.io/docs) before opening an issue here.
- type: textarea
id: links
attributes:
label: Page(s)
description: |
Links to one or more documentation pages that should be modified.
If you are reporting an issue with a specific section of a page, try to link directly to the nearest anchor.
If you are suggesting that a new page be created, link to the parent of the proposed page.
validations:
required: true
- type: textarea
id: description
attributes:
label: Description
description: |
Describe the change you are requesting.
If the issue pertains to a single function or matcher, be sure to specify the entire call signature.
validations:
required: true
6 changes: 0 additions & 6 deletions .github/dependabot.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"],
"lockFileMaintenance": {"enabled": true, "automerge": false},
"rangeStrategy": "replace",
"postUpdateOptions": ["yarnDedupeHighest"],
"packageRules": [
{
"matchPackageNames": ["@tsd/typescript", "typescript"],
"groupName": "typescript"
},
{
"matchPackageNames": ["jest-runner-tsd", "tsd-lite"],
"groupName": "tsd"
}
]
}
12 changes: 9 additions & 3 deletions .github/workflows/close-stale.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '*/10 * * * *'
- cron: '0 * * * *'

permissions:
issues: write # to close stale issues (actions/stale)
pull-requests: write # to close stale PRs (actions/stale)

jobs:
stale:
name: 'Close month old issues and PRs'
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v6
- uses: actions/stale@v8
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 @@ -21,13 +25,14 @@ jobs:
days-before-pr-close: 30
exempt-all-milestones: true
exempt-issue-labels: Pinned
exempt-pr-labels: Pinned
exempt-draft-pr: true
operations-per-run: 1750
stale-legacy:
name: 'Close year old issues and PRs'
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v6
- uses: actions/stale@v8
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 All @@ -39,4 +44,5 @@ jobs:
days-before-pr-close: 30
exempt-all-milestones: true
exempt-issue-labels: Pinned
exempt-pr-labels: Pinned
operations-per-run: 1750
23 changes: 13 additions & 10 deletions .github/workflows/issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@ on:
issues:
types: [labeled]

permissions:
issues: write # to close issues (peter-evans/close-issue)

jobs:
questions:
name: Questions
runs-on: ubuntu-latest
steps:
- name: Close Issue
uses: peter-evans/close-issue@v2
if: "${{ github.event.label.name == ':speech_balloon: Question' }}"
with:
comment: Please note this issue tracker is not a help forum. We recommend using [StackOverflow](https://stackoverflow.com/questions/tagged/jestjs) or our [discord channel](https://discord.gg/j6FKKQQrW9) for questions.
- if: "${{ github.event.label.name == ':speech_balloon: Question' }}"
run: gh issue close $ISSUE --comment "Please note this issue tracker is not a help forum. We recommend using [StackOverflow](https://stackoverflow.com/questions/tagged/jestjs) or our [discord channel](https://discord.gg/j6FKKQQrW9) for questions."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE: ${{ github.event.issue.html_url }}
bug-without-repro:
name: Bug reports without reproductions
runs-on: ubuntu-latest
steps:
- name: Close Issue
uses: peter-evans/close-issue@v2
if: "${{ github.event.label.name == 'Needs Reproduction' }}"
with:
comment: As noted in the [Bug Report template](https://github.com/facebook/jest/blob/main/.github/ISSUE_TEMPLATE/bug.yml), all bug reports requires a minimal reproduction. Please open up a new issue providing one. Read more at https://stackoverflow.com/help/minimal-reproducible-example.
- if: "${{ github.event.label.name == 'Needs Reproduction' }}"
run: gh issue close $ISSUE --comment "As noted in the [Bug Report template](https://github.com/jestjs/jest/blob/main/.github/ISSUE_TEMPLATE/bug.yml), all bug reports requires a minimal reproduction. Please open up a new issue providing one. Read more at https://stackoverflow.com/help/minimal-reproducible-example."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE: ${{ github.event.issue.html_url }}

0 comments on commit f8a70c7

Please sign in to comment.