Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Aug 28, 2022
2 parents 39719a3 + 755e279 commit 699d149
Show file tree
Hide file tree
Showing 17 changed files with 886 additions and 777 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Expand Up @@ -60,8 +60,8 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [12.x, 14.x, 16.x, 17.x, 18.x]
eslint-version: [6, 7, 8]
node-version: [14.x, 16.x, 18.x]
eslint-version: [7, 8]
runs-on: ubuntu-latest

steps:
Expand Down
36 changes: 36 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,39 @@
# [27.0.0-next.2](https://github.com/jest-community/eslint-plugin-jest/compare/v27.0.0-next.1...v27.0.0-next.2) (2022-08-28)


### Bug Fixes

* **unbound-method:** don't suppress errors from base rule ([#1219](https://github.com/jest-community/eslint-plugin-jest/issues/1219)) ([7c1389e](https://github.com/jest-community/eslint-plugin-jest/commit/7c1389e3d8c59e283de37ed86f3f4c12fb38c3ff))


### Features

* make `no-alias-methods` recommended ([#1221](https://github.com/jest-community/eslint-plugin-jest/issues/1221)) ([914b24a](https://github.com/jest-community/eslint-plugin-jest/commit/914b24a0bc12a151e6f7ecec37a440769b555b94))
* **no-jest-import:** remove rule ([#1220](https://github.com/jest-community/eslint-plugin-jest/issues/1220)) ([918873b](https://github.com/jest-community/eslint-plugin-jest/commit/918873beb15d4a698fe5150d826d44b696283683))
* **no-restricted-matchers:** match based on start of chain, requiring each permutation to be set ([#1218](https://github.com/jest-community/eslint-plugin-jest/issues/1218)) ([f4dd97a](https://github.com/jest-community/eslint-plugin-jest/commit/f4dd97a7ec3b985d0f7e42a5a6331bc0c65a7d56))


### BREAKING CHANGES

* `no-alias-methods` is now recommended as the methods themselves will be removed in the next major version of Jest
* **no-jest-import:** removed `no-jest-import` rule
* **unbound-method:** errors thrown by the `unbound-method` base rule are no longer suppressed - really this means that if you don't specify `project` when this rule is enabled and `@typescript-eslint/eslint-plugin` is present, that error will no longer be suppressed instead of silently doing nothing; it will still not throw if this rule is enabled without the base rule being present
* **no-restricted-matchers:** `no-restricted-matchers` now checks against the start of the expect chain, meaning you have to explicitly list each possible matcher & modifier permutations that you want to restrict

# [27.0.0-next.1](https://github.com/jest-community/eslint-plugin-jest/compare/v26.8.7...v27.0.0-next.1) (2022-08-23)


### Features

* drop support for `eslint@6` ([#1212](https://github.com/jest-community/eslint-plugin-jest/issues/1212)) ([21fc2fe](https://github.com/jest-community/eslint-plugin-jest/commit/21fc2feea67a8fd9f6673fd6a1e91ca1f5bdda11))
* drop support for Node versions 12 and 17 ([#1211](https://github.com/jest-community/eslint-plugin-jest/issues/1211)) ([4c987f5](https://github.com/jest-community/eslint-plugin-jest/commit/4c987f5f566398d95584668bd2bc18bfdf438e40))


### BREAKING CHANGES

* Support for ESLint version 6 is removed
* Node versions 12 and 17 are no longer supported

# [26.9.0](https://github.com/jest-community/eslint-plugin-jest/compare/v26.8.7...v26.9.0) (2022-08-28)


Expand Down
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -203,7 +203,7 @@ installations requiring long-term consistency.
| [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | |
| [max-expects](docs/rules/max-expects.md) | Enforces a maximum number assertion calls in a test body | | |
| [max-nested-describe](docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | | |
| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] |
| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![recommended][] | ![fixable][] |
| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | |
| [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | ![recommended][] | |
| [no-conditional-in-test](docs/rules/no-conditional-in-test.md) | Disallow conditional logic in tests | | |
Expand All @@ -217,7 +217,6 @@ installations requiring long-term consistency.
| [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | |
| [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside snapshots | ![recommended][] | |
| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] |
| [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | |
| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | |
| [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from `__mocks__` | ![recommended][] | |
| [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | |
Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-alias-methods.md
@@ -1,5 +1,8 @@
# Disallow alias methods (`no-alias-methods`)

> These aliases are going to be removed in the next major version of Jest - see
> https://github.com/facebook/jest/issues/13164 for more
Several Jest methods have alias names, such as `toThrow` having the alias of
`toThrowError`. This rule ensures that only the canonical name as used in the
Jest documentation is used in the code. This makes it easier to search for all
Expand Down
20 changes: 0 additions & 20 deletions docs/rules/no-jest-import.md

This file was deleted.

15 changes: 12 additions & 3 deletions docs/rules/no-restricted-matchers.md
Expand Up @@ -8,8 +8,9 @@ alternatives.
Bans are expressed in the form of a map, with the value being either a string
message to be shown, or `null` if the default rule message should be used.

Both matchers, modifiers, and chains of the two are checked, allowing for
specific variations of a matcher to be banned if desired.
Bans are checked against the start of the `expect` chain - this means that to
ban a specific matcher entirely you must specify all six permutations, but
allows you to ban modifiers as well.

By default, this map is empty, meaning no matchers or modifiers are banned.

Expand All @@ -22,7 +23,12 @@ For example:
{
"toBeFalsy": null,
"resolves": "Use `expect(await promise)` instead.",
"not.toHaveBeenCalledWith": null
"toHaveBeenCalledWith": null,
"not.toHaveBeenCalledWith": null,
"resolves.toHaveBeenCalledWith": null,
"rejects.toHaveBeenCalledWith": null,
"resolves.not.toHaveBeenCalledWith": null,
"rejects.not.toHaveBeenCalledWith": null
}
]
}
Expand All @@ -32,15 +38,18 @@ Examples of **incorrect** code for this rule with the above configuration

```js
it('is false', () => {
// if this has a modifer (i.e. `not.toBeFalsy`), it would be considered fine
expect(a).toBeFalsy();
});

it('resolves', async () => {
// all uses of this modifier are disallowed, regardless of matcher
await expect(myPromise()).resolves.toBe(true);
});

describe('when an error happens', () => {
it('does not upload the file', async () => {
// all uses of this matcher are disallowed
expect(uploadFileMock).not.toHaveBeenCalledWith('file.name');
});
});
Expand Down
26 changes: 13 additions & 13 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-jest",
"version": "26.9.0",
"version": "27.0.0-next.2",
"description": "ESLint rules for Jest",
"keywords": [
"eslint",
Expand Down Expand Up @@ -103,34 +103,34 @@
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-typescript": "^7.3.3",
"@commitlint/cli": "^16.0.0",
"@commitlint/config-conventional": "^16.0.0",
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@schemastore/package": "^0.0.6",
"@semantic-release/changelog": "^6.0.0",
"@semantic-release/git": "^10.0.0",
"@types/dedent": "^0.7.0",
"@types/jest": "^28.0.0",
"@types/node": "^16.0.0",
"@types/node": "^14.18.26",
"@types/prettier": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"babel-jest": "^28.0.0",
"babel-jest": "^29.0.0",
"babel-plugin-replace-ts-export-assignment": "^0.0.2",
"dedent": "^0.7.0",
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-eslint-plugin": "^4.0.0",
"eslint-plugin-eslint-plugin": "^5.0.6",
"eslint-plugin-import": "^2.25.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-remote-tester": "^3.0.0",
"eslint-remote-tester-repositories": "~0.0.5",
"husky": "^7.0.2",
"husky": "^8.0.1",
"is-ci": "^3.0.0",
"jest": "^28.0.0",
"jest-runner-eslint": "^1.0.0",
"lint-staged": "^12.0.0",
"jest": "^29.0.0",
"jest-runner-eslint": "^1.1.0",
"lint-staged": "^13.0.3",
"pinst": "^3.0.0",
"prettier": "^2.0.5",
"rimraf": "^3.0.0",
Expand All @@ -141,7 +141,7 @@
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^5.0.0",
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
"eslint": "^7.0.0 || ^8.0.0"
},
"peerDependenciesMeta": {
"@typescript-eslint/eslint-plugin": {
Expand All @@ -153,6 +153,6 @@
},
"packageManager": "yarn@3.2.3",
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
}
27 changes: 13 additions & 14 deletions src/__tests__/__snapshots__/rules.test.ts.snap
@@ -1,15 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`rules should export configs that refer to actual rules 1`] = `
Object {
"all": Object {
"env": Object {
{
"all": {
"env": {
"jest/globals": true,
},
"plugins": Array [
"plugins": [
"jest",
],
"rules": Object {
"rules": {
"jest/consistent-test-it": "error",
"jest/expect-expect": "error",
"jest/max-expects": "error",
Expand All @@ -28,7 +28,6 @@ Object {
"jest/no-identical-title": "error",
"jest/no-interpolation-in-snapshots": "error",
"jest/no-jasmine-globals": "error",
"jest/no-jest-import": "error",
"jest/no-large-snapshots": "error",
"jest/no-mocks-import": "error",
"jest/no-restricted-matchers": "error",
Expand Down Expand Up @@ -62,15 +61,16 @@ Object {
"jest/valid-title": "error",
},
},
"recommended": Object {
"env": Object {
"recommended": {
"env": {
"jest/globals": true,
},
"plugins": Array [
"plugins": [
"jest",
],
"rules": Object {
"rules": {
"jest/expect-expect": "warn",
"jest/no-alias-methods": "error",
"jest/no-commented-out-tests": "warn",
"jest/no-conditional-expect": "error",
"jest/no-deprecated-functions": "error",
Expand All @@ -81,7 +81,6 @@ Object {
"jest/no-identical-title": "error",
"jest/no-interpolation-in-snapshots": "error",
"jest/no-jasmine-globals": "error",
"jest/no-jest-import": "error",
"jest/no-mocks-import": "error",
"jest/no-standalone-expect": "error",
"jest/no-test-prefixes": "error",
Expand All @@ -91,11 +90,11 @@ Object {
"jest/valid-title": "error",
},
},
"style": Object {
"plugins": Array [
"style": {
"plugins": [
"jest",
],
"rules": Object {
"rules": {
"jest/no-alias-methods": "warn",
"jest/prefer-to-be": "error",
"jest/prefer-to-contain": "error",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/rules.test.ts
Expand Up @@ -2,7 +2,7 @@ import { existsSync } from 'fs';
import { resolve } from 'path';
import plugin from '../';

const numberOfRules = 51;
const numberOfRules = 50;
const ruleNames = Object.keys(plugin.rules);
const deprecatedRules = Object.entries(plugin.rules)
.filter(([, rule]) => rule.meta.deprecated)
Expand Down
47 changes: 0 additions & 47 deletions src/rules/__tests__/no-jest-import.test.ts

This file was deleted.

0 comments on commit 699d149

Please sign in to comment.