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.4
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.5
Choose a head ref
  • 4 commits
  • 8 files changed
  • 3 contributors

Commits on Apr 5, 2021

  1. Copy the full SHA
    72fe0c6 View commit details

Commits on Apr 10, 2021

  1. docs(no-focused-tests): remove references to ftest method (#816)

    There's no such prefixed method for `test`; only `fit` & `fdescribe`
    G-Rath authored Apr 10, 2021
    Copy the full SHA
    ce76579 View commit details
  2. Copy the full SHA
    cbdbcef View commit details
  3. chore(release): 24.3.5 [skip ci]

    ## [24.3.5](v24.3.4...v24.3.5) (2021-04-10)
    
    ### Bug Fixes
    
    * **valid-describe:** support using `each` with modifiers ([#820](#820)) ([cbdbcef](cbdbcef))
    semantic-release-bot committed Apr 10, 2021
    Copy the full SHA
    9c31a8d View commit details
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ jobs:
run: yarn test --coverage ${{ matrix.eslint-version >= 6 }}
env:
CI: true
- uses: codecov/codecov-action@v1.3.1
- uses: codecov/codecov-action@v1.3.2
if: ${{ matrix.eslint-version >= 6 }}
test-os:
name: Test on ${{ matrix.os }} using Node.js LTS
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [24.3.5](https://github.com/jest-community/eslint-plugin-jest/compare/v24.3.4...v24.3.5) (2021-04-10)


### Bug Fixes

* **valid-describe:** support using `each` with modifiers ([#820](https://github.com/jest-community/eslint-plugin-jest/issues/820)) ([cbdbcef](https://github.com/jest-community/eslint-plugin-jest/commit/cbdbcef47984eb01509493bd5b2423f518a2663d))

## [24.3.4](https://github.com/jest-community/eslint-plugin-jest/compare/v24.3.3...v24.3.4) (2021-04-05)


6 changes: 1 addition & 5 deletions docs/rules/no-focused-tests.md
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ whenever you are using the exclusivity feature.
## Rule Details

This rule looks for every `describe.only`, `it.only`, `test.only`, `fdescribe`,
`fit` and `ftest` occurrences within the source code. Of course there are some
and `fit` occurrences within the source code. Of course there are some
edge-cases which can’t be detected by this rule e.g.:

```js
@@ -31,13 +31,9 @@ test.only('foo', () => {});
test['only']('bar', () => {});
fdescribe('foo', () => {});
fit('foo', () => {});
ftest('bar', () => {});
fit.each`
table
`();
ftest.each`
table
`();
```

These patterns would not be considered warnings:
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-jest",
"version": "24.3.4",
"version": "24.3.5",
"description": "Eslint rules for Jest",
"keywords": [
"eslint",
16 changes: 0 additions & 16 deletions src/rules/__tests__/no-focused-tests.test.ts
Original file line number Diff line number Diff line change
@@ -317,21 +317,5 @@ ruleTester.run('no-focused-tests', rule, {
},
],
},
{
code: 'ftest.each`table`()',
errors: [
{
messageId: 'focusedTest',
column: 1,
line: 1,
suggestions: [
{
messageId: 'suggestRemoveFocus',
output: 'test.each`table`()',
},
],
},
],
},
],
});
26 changes: 16 additions & 10 deletions src/rules/__tests__/valid-describe.test.ts
Original file line number Diff line number Diff line change
@@ -12,11 +12,6 @@ const ruleTester = new TSESLint.RuleTester({

ruleTester.run('valid-describe', rule, {
valid: [
'describe["each"]()()',
'describe["each"](() => {})()',
'describe["each"](() => {})("foo")',
'describe["each"]()(() => {})',
'describe["each"]("foo")(() => {})',
'describe.each([1, 2, 3])("%s", (a, b) => {});',
'describe("foo", function() {})',
'describe("foo", () => {})',
@@ -51,18 +46,21 @@ ruleTester.run('valid-describe', rule, {
}
`,
dedent`
describe.each\`
something | other
${1} | ${2} |
\`
("$something", ({ something, other }) => { });
describe.each\`
foo | foe
${1} | ${2}
\`('$something', ({ foo, foe }) => {});
`,
],
invalid: [
{
code: 'describe.each()()',
errors: [{ messageId: 'nameAndCallback', line: 1, column: 1 }],
},
{
code: 'describe["each"]()()',
errors: [{ messageId: 'nameAndCallback', line: 1, column: 1 }],
},
{
code: 'describe.each(() => {})()',
errors: [{ messageId: 'nameAndCallback', line: 1, column: 1 }],
@@ -75,10 +73,18 @@ ruleTester.run('valid-describe', rule, {
code: 'describe.each()(() => {})',
errors: [{ messageId: 'nameAndCallback', line: 1, column: 17 }],
},
{
code: 'describe["each"]()(() => {})',
errors: [{ messageId: 'nameAndCallback', line: 1, column: 20 }],
},
{
code: 'describe.each("foo")(() => {})',
errors: [{ messageId: 'nameAndCallback', line: 1, column: 22 }],
},
{
code: 'describe.only.each("foo")(() => {})',
errors: [{ messageId: 'nameAndCallback', line: 1, column: 27 }],
},
{
code: 'describe(() => {})',
errors: [{ messageId: 'nameAndCallback', line: 1, column: 10 }],
15 changes: 0 additions & 15 deletions src/rules/utils.ts
Original file line number Diff line number Diff line change
@@ -763,21 +763,6 @@ export const isDescribeCall = (
return false;
};

export const isDescribe = (
node: TSESTree.CallExpression,
): node is JestFunctionCallExpression<DescribeAlias> =>
(node.callee.type === AST_NODE_TYPES.Identifier &&
DescribeAlias.hasOwnProperty(node.callee.name)) ||
(node.callee.type === AST_NODE_TYPES.MemberExpression &&
node.callee.object.type === AST_NODE_TYPES.Identifier &&
DescribeAlias.hasOwnProperty(node.callee.object.name) &&
node.callee.property.type === AST_NODE_TYPES.Identifier &&
DescribeProperty.hasOwnProperty(node.callee.property.name)) ||
(node.callee.type === AST_NODE_TYPES.TaggedTemplateExpression &&
node.callee.tag.type === AST_NODE_TYPES.MemberExpression &&
node.callee.tag.object.type === AST_NODE_TYPES.Identifier &&
DescribeAlias.hasOwnProperty(node.callee.tag.object.name));

/**
* Checks if the given node` is a call to `<describe|test|it>.each(...)()`.
* If `true`, the code must look like `<method>.each(...)()`.
4 changes: 2 additions & 2 deletions src/rules/valid-describe.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import {
import {
createRule,
getJestFunctionArguments,
isDescribe,
isDescribeCall,
isEachCall,
isFunction,
} from './utils';
@@ -46,7 +46,7 @@ export default createRule({
return {
CallExpression(node) {
if (
!isDescribe(node) ||
!isDescribeCall(node) ||
node.callee.type === AST_NODE_TYPES.TaggedTemplateExpression
) {
return;