Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jest-community/eslint-plugin-jest
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v24.3.6
Choose a base ref
...
head repository: jest-community/eslint-plugin-jest
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v24.3.7
Choose a head ref

Commits on Apr 26, 2021

  1. chore(deps): lock file maintenance (#834)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Apr 26, 2021
    Copy the full SHA
    3618d67 View commit details
  2. Copy the full SHA
    5a513b2 View commit details
  3. chore(deps): lock file maintenance (#835)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Apr 26, 2021
    Copy the full SHA
    1d6b8c0 View commit details
  4. chore(deps): update codecov/codecov-action action to v1.4.1 (#826)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored Apr 26, 2021
    Copy the full SHA
    c9324ff View commit details
  5. Copy the full SHA
    9bf2781 View commit details

Commits on May 3, 2021

  1. Copy the full SHA
    24428dc View commit details
  2. chore(deps): update codecov/codecov-action action to v1.5.0 (#838)

    Co-authored-by: Renovate Bot <bot@renovateapp.com>
    renovate[bot] and renovate-bot authored May 3, 2021
    Copy the full SHA
    516a424 View commit details

Commits on May 10, 2021

  1. chore: update prettier

    SimenB committed May 10, 2021
    Copy the full SHA
    fd94623 View commit details
  2. Copy the full SHA
    87d0fcb View commit details
  3. Copy the full SHA
    2904278 View commit details

Commits on May 13, 2021

  1. Copy the full SHA
    96031ec View commit details

Commits on May 25, 2021

  1. Copy the full SHA
    c021163 View commit details
  2. Copy the full SHA
    529aeb6 View commit details
  3. chore: refresh lockfile

    SimenB committed May 25, 2021
    Copy the full SHA
    82e219c View commit details
  4. Copy the full SHA
    03bdccb View commit details
  5. Copy the full SHA
    9d89c29 View commit details

Commits on Jun 9, 2021

  1. Copy the full SHA
    fdf4750 View commit details

Commits on Jun 15, 2021

  1. Copy the full SHA
    9f4f669 View commit details

Commits on Jul 12, 2021

  1. Copy the full SHA
    a4229bb View commit details
  2. chore: update yarn

    SimenB committed Jul 12, 2021
    Copy the full SHA
    6111270 View commit details
  3. Copy the full SHA
    9484ee2 View commit details
  4. Copy the full SHA
    024b19d View commit details

Commits on Jul 19, 2021

  1. Copy the full SHA
    38f8436 View commit details

Commits on Jul 21, 2021

  1. Copy the full SHA
    71c5299 View commit details
  2. chore(release): 24.3.7 [skip ci]

    ## [24.3.7](v24.3.6...v24.3.7) (2021-07-21)
    
    ### Bug Fixes
    
    * **valid-describe:** report on concise-body arrow functions ([#863](#863)) ([71c5299](71c5299))
    semantic-release-bot committed Jul 21, 2021
    Copy the full SHA
    19e3a6e View commit details
Showing with 2,267 additions and 2,345 deletions.
  1. +5 −0 .git-blame-ignore-revs
  2. +1 −1 .github/renovate.json
  3. +1 −1 .github/workflows/lint.yml
  4. +43 −68 .github/workflows/nodejs.yml
  5. +2 −0 .prettierignore
  6. +5 −5 .yarn/releases/{yarn-2.4.1.cjs → yarn-2.4.2.cjs}
  7. +1 −1 .yarnrc.yml
  8. +7 −0 CHANGELOG.md
  9. +2 −2 README.md
  10. +1 −1 docs/rules/unbound-method.md
  11. +6 −0 docs/rules/valid-describe.md
  12. +3 −3 package.json
  13. +3 −5 src/processors/__tests__/snapshot-processor.test.ts
  14. +11 −22 src/rules/__tests__/no-deprecated-functions.test.ts
  15. +5 −10 src/rules/__tests__/no-export.test.ts
  16. +3 −6 src/rules/__tests__/no-interpolation-in-snapshots.test.ts
  17. +4 −8 src/rules/__tests__/no-standalone-expect.test.ts
  18. +1 −2 src/rules/__tests__/prefer-spy-on.test.ts
  19. +2 −2 src/rules/__tests__/unbound-method.test.ts
  20. +27 −1 src/rules/__tests__/utils.test.ts
  21. +10 −5 src/rules/__tests__/valid-describe.test.ts
  22. +8 −0 src/rules/__tests__/valid-expect-in-promise.test.ts
  23. +7 −14 src/rules/__tests__/valid-expect.test.ts
  24. +15 −10 src/rules/consistent-test-it.ts
  25. +2 −3 src/rules/expect-expect.ts
  26. +2 −3 src/rules/no-conditional-expect.ts
  27. +3 −2 src/rules/no-deprecated-functions.ts
  28. +2 −3 src/rules/no-if.ts
  29. +3 −1 src/rules/no-mocks-import.ts
  30. +3 −4 src/rules/no-test-return-statement.ts
  31. +4 −6 src/rules/no-try-expect.ts
  32. +1 −1 src/rules/prefer-todo.ts
  33. +26 −29 src/rules/utils.ts
  34. +8 −1 src/rules/valid-describe.ts
  35. +2 −8 src/rules/valid-expect-in-promise.ts
  36. +2,038 −2,117 yarn.lock
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# See https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt
# Run git config blame.ignoreRevsFile .git-blame-ignore-revs

# prettier bumps
fd946237c143f6cddb6ddb367a01ac2933f0b343
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": ["config:base"],
"lockFileMaintenance": { "enabled": true },
"lockFileMaintenance": { "enabled": true, "automerge": true },
"rangeStrategy": "replace",
"postUpdateOptions": ["yarnDedupeHighest"]
}
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -18,6 +18,6 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Danger
uses: danger/danger-js@10.6.4
uses: danger/danger-js@10.6.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111 changes: 43 additions & 68 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -18,20 +18,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2.1.5
- uses: actions/setup-node@v2.2.0
with:
node-version: 14.x
cache: yarn

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- uses: actions/cache@v2.1.5
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn2-
- name: Validate cache
env:
# Use PnP and disable postinstall scripts as this just needs to
@@ -40,10 +31,38 @@ jobs:
YARN_ENABLE_SCRIPTS: false
run: yarn --immutable

prettier:
needs: prepare-yarn-cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2.2.0
with:
node-version: 14.x
cache: yarn
- name: install
run: yarn
- name: run prettier
run: yarn prettier:check

typecheck:
needs: prepare-yarn-cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2.2.0
with:
node-version: 14.x
cache: yarn
- name: install
run: yarn
- name: run typecheck
run: yarn typecheck

test-node:
name:
# prettier-ignore
Test on Node.js v${{ matrix.node-version }} and eslint v${{matrix.eslint-version }}
Test on Node.js v${{ matrix.node-version }} and eslint v${{ matrix.eslint-version }}
needs: prepare-yarn-cache
strategy:
fail-fast: false
@@ -54,35 +73,21 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn2-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.1.5
uses: actions/setup-node@v2.2.0
with:
node-version: ${{ matrix.node-version }}
- name: install with eslint v${{matrix.eslint-version }}
cache: yarn
- name: install with eslint v${{ matrix.eslint-version }}
run: |
yarn
yarn add --dev eslint@${{matrix.eslint-version }}
- name: run prettier
run: yarn prettier:check
- name: run typecheck
run: yarn typecheck
yarn add --dev eslint@${{ matrix.eslint-version }}
- name: run tests
# only collect coverage on eslint versions that support the suggestions api
run: yarn test --coverage ${{ matrix.eslint-version >= 6 }}
env:
CI: true
- uses: codecov/codecov-action@v1.3.2
- uses: codecov/codecov-action@v1.5.2
if: ${{ matrix.eslint-version >= 6 }}
test-os:
name: Test on ${{ matrix.os }} using Node.js LTS
@@ -95,24 +100,12 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn2-
- uses: actions/setup-node@v2.1.5
- uses: actions/setup-node@v2.2.0
with:
node-version: 14.x
cache: yarn
- name: install
run: yarn
- name: run prettier
run: yarn prettier:check
- name: run typecheck
run: yarn typecheck
- name: run tests
run: yarn test --coverage
env:
@@ -124,20 +117,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn2-
- uses: actions/setup-node@v2.1.5
- uses: actions/setup-node@v2.2.0
with:
node-version: 14.x
cache: yarn
- name: install
run: yarn
- name: regenerate docs
@@ -153,22 +136,14 @@ jobs:
# prettier-ignore
${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' }}
name: Release new version
needs: [test-node, test-os]
needs: [prettier, typecheck, test-node, test-os]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn2-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn2-
- uses: actions/setup-node@v2.1.5
- uses: actions/setup-node@v2.2.0
with:
node-version: 14.x
cache: yarn
- name: install
run: yarn
- run: yarn semantic-release
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CHANGELOG.md
src/rules/__tests__/fixtures/
10 changes: 5 additions & 5 deletions .yarn/releases/yarn-2.4.1.cjs → .yarn/releases/yarn-2.4.2.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -6,4 +6,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'

yarnPath: .yarn/releases/yarn-2.4.1.cjs
yarnPath: .yarn/releases/yarn-2.4.2.cjs
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [24.3.7](https://github.com/jest-community/eslint-plugin-jest/compare/v24.3.6...v24.3.7) (2021-07-21)


### Bug Fixes

* **valid-describe:** report on concise-body arrow functions ([#863](https://github.com/jest-community/eslint-plugin-jest/issues/863)) ([71c5299](https://github.com/jest-community/eslint-plugin-jest/commit/71c5299b14cac6d85ba8f8bd939461503a60468f))

## [24.3.6](https://github.com/jest-community/eslint-plugin-jest/compare/v24.3.5...v24.3.6) (2021-04-26)


4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@

## Installation

```
$ yarn add --dev eslint eslint-plugin-jest
```bash
yarn add --dev eslint eslint-plugin-jest
```

**Note:** If you installed ESLint globally then you must also install
2 changes: 1 addition & 1 deletion docs/rules/unbound-method.md
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ are not using TypeScript.
overrides: [
{
files: ['test/**'],
extends: ['jest'],
plugins: ['jest'],
rules: {
// you should turn the original rule off *only* for test files
'@typescript-eslint/unbound-method': 'off',
6 changes: 6 additions & 0 deletions docs/rules/valid-describe.md
Original file line number Diff line number Diff line change
@@ -43,6 +43,12 @@ describe('myFunction', () => {
});
});
});

// Returning a value from a describe block is not allowed
describe('myFunction', () =>
it('returns a truthy value', () => {
expect(myFunction()).toBeTruthy();
}));
```

The following patterns are not considered warnings:
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-jest",
"version": "24.3.6",
"version": "24.3.7",
"description": "Eslint rules for Jest",
"keywords": [
"eslint",
@@ -97,7 +97,7 @@
"@types/prettier": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"babel-jest": "^26.0.1",
"babel-jest": "^27.0.0",
"babel-plugin-replace-ts-export-assignment": "^0.0.2",
"dedent": "^0.7.0",
"eslint": "^5.1.0 || ^6.0.0 || ^7.0.0",
@@ -110,7 +110,7 @@
"eslint-plugin-prettier": "^3.0.0",
"husky": "^6.0.0",
"is-ci": "^3.0.0",
"jest": "^26.0.1",
"jest": "^27.0.0",
"jest-runner-eslint": "^0.10.0",
"lint-staged": "^10.2.2",
"pinst": "^2.0.0",
8 changes: 3 additions & 5 deletions src/processors/__tests__/snapshot-processor.test.ts
Original file line number Diff line number Diff line change
@@ -22,11 +22,9 @@ describe('snapshot-processor', () => {
it('should only return messages about snapshot specific rules', () => {
const { postprocess } = snapshotProcessor;
const result = postprocess([
[
'no-console',
'global-require',
'jest/no-large-snapshots',
].map(ruleId => ({ ruleId })),
['no-console', 'global-require', 'jest/no-large-snapshots'].map(
ruleId => ({ ruleId }),
),
]);

expect(result).toEqual([{ ruleId: 'jest/no-large-snapshots' }]);
33 changes: 11 additions & 22 deletions src/rules/__tests__/no-deprecated-functions.test.ts
Original file line number Diff line number Diff line change
@@ -153,34 +153,23 @@ describe('the rule', () => {
});

describe.each<JestVersion>([
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
])('when using jest version %i', jestVersion => {
beforeEach(async () =>
process.chdir(await setupFakeProjectDirectory(jestVersion)),
);

const allowedFunctions: string[] = [];
const deprecations = ([
[15, 'jest.resetModuleRegistry', 'jest.resetModules'],
[17, 'jest.addMatchers', 'expect.extend'],
[21, 'require.requireMock', 'jest.requireMock'],
[21, 'require.requireActual', 'jest.requireActual'],
[22, 'jest.runTimersToTime', 'jest.advanceTimersByTime'],
[26, 'jest.genMockFromModule', 'jest.createMockFromModule'],
] as const).filter(deprecation => {
const deprecations = (
[
[15, 'jest.resetModuleRegistry', 'jest.resetModules'],
[17, 'jest.addMatchers', 'expect.extend'],
[21, 'require.requireMock', 'jest.requireMock'],
[21, 'require.requireActual', 'jest.requireActual'],
[22, 'jest.runTimersToTime', 'jest.advanceTimersByTime'],
[26, 'jest.genMockFromModule', 'jest.createMockFromModule'],
] as const
).filter(deprecation => {
if (deprecation[0] > jestVersion) {
allowedFunctions.push(deprecation[1]);

15 changes: 5 additions & 10 deletions src/rules/__tests__/no-export.test.ts
Original file line number Diff line number Diff line change
@@ -23,8 +23,7 @@ ruleTester.run('no-export', rule, {
],
invalid: [
{
code:
'export const myThing = "invalid"; test("a test", () => { expect(1).toBe(1);});',
code: 'export const myThing = "invalid"; test("a test", () => { expect(1).toBe(1);});',
parserOptions: { sourceType: 'module' },
errors: [{ endColumn: 34, column: 1, messageId: 'unexpectedExport' }],
},
@@ -62,24 +61,20 @@ ruleTester.run('no-export', rule, {
errors: [{ endColumn: 34, column: 1, messageId: 'unexpectedExport' }],
},
{
code:
'export default function() {}; test("a test", () => { expect(1).toBe(1);});',
code: 'export default function() {}; test("a test", () => { expect(1).toBe(1);});',
parserOptions: { sourceType: 'module' },
errors: [{ endColumn: 29, column: 1, messageId: 'unexpectedExport' }],
},
{
code:
'module.exports["invalid"] = function() {}; test("a test", () => { expect(1).toBe(1);});',
code: 'module.exports["invalid"] = function() {}; test("a test", () => { expect(1).toBe(1);});',
errors: [{ endColumn: 26, column: 1, messageId: 'unexpectedExport' }],
},
{
code:
'module.exports = function() {}; ; test("a test", () => { expect(1).toBe(1);});',
code: 'module.exports = function() {}; ; test("a test", () => { expect(1).toBe(1);});',
errors: [{ endColumn: 15, column: 1, messageId: 'unexpectedExport' }],
},
{
code:
'module.export.invalid = function() {}; ; test("a test", () => { expect(1).toBe(1);});',
code: 'module.export.invalid = function() {}; ; test("a test", () => { expect(1).toBe(1);});',
errors: [{ endColumn: 22, column: 1, messageId: 'unexpectedExport' }],
},
],
Loading