Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): bump eslint-plugin-jest from 27.2.3 to 27.4.0 #1615

Merged

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Sep 18, 2023

Bumps eslint-plugin-jest from 27.2.3 to 27.4.0.

Release notes

Sourced from eslint-plugin-jest's releases.

v27.4.0

27.4.0 (2023-09-15)

Features

  • valid-title: support ignoring leading and trailing whitespace (#1433) (bc96473)

v27.3.0

27.3.0 (2023-09-15)

Features

Changelog

Sourced from eslint-plugin-jest's changelog.

27.4.0 (2023-09-15)

Features

  • valid-title: support ignoring leading and trailing whitespace (#1433) (bc96473)

27.3.0 (2023-09-15)

Features

Commits
  • 42fec48 chore(release): 27.4.0 [skip ci]
  • bc96473 feat(valid-title): support ignoring leading and trailing whitespace (#1433)
  • bc4eae4 chore(release): 27.3.0 [skip ci]
  • ff8e482 feat: add no-confusing-set-time rule (#1425)
  • 1b96756 chore(deps): lock file maintenance
  • eeafcc9 chore: enforce curly braces (#1429)
  • e44693f chore(deps): update actions/checkout action to v4 (#1428)
  • fefd488 chore(deps): lock file maintenance
  • 44fb78a chore: update prettier (#1427)
  • 2198f4a ci: test against v5 and v6 of @typescript-eslint/eslint-plugin (#1424)
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot added dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Sep 18, 2023
@github-actions github-actions bot enabled auto-merge (squash) September 18, 2023 03:06
@github-actions
Copy link
Contributor

Diff between eslint-plugin-jest 27.2.3 and 27.4.0
diff --git a/lib/rules/expect-expect.js b/lib/rules/expect-expect.js
index v27.2.3..v27.4.0 100644
--- a/lib/rules/expect-expect.js
+++ b/lib/rules/expect-expect.js
@@ -21,5 +21,7 @@
 function matchesAssertFunctionName(nodeName, patterns) {
   return patterns.some(p => new RegExp(`^${p.split('.').map(x => {
-    if (x === '**') return '[a-z\\d\\.]*';
+    if (x === '**') {
+      return '[a-z\\d\\.]*';
+    }
     return x.replace(/\*/gu, '[a-z\\d]*');
   }).join('\\.')}(\\.|$)`, 'ui').test(nodeName));
diff --git a/lib/rules/no-test-return-statement.js b/lib/rules/no-test-return-statement.js
index v27.2.3..v27.4.0 100644
--- a/lib/rules/no-test-return-statement.js
+++ b/lib/rules/no-test-return-statement.js
@@ -37,5 +37,7 @@
         const body = getBody(node.arguments);
         const returnStmt = body.find(t => t.type === _utils.AST_NODE_TYPES.ReturnStatement);
-        if (!returnStmt) return;
+        if (!returnStmt) {
+          return;
+        }
         context.report({
           messageId: 'noReturnValue',
@@ -46,7 +48,11 @@
         const declaredVariables = context.getDeclaredVariables(node);
         const testCallExpressions = (0, _utils2.getTestCallExpressionsFromDeclaredVariables)(declaredVariables, context);
-        if (testCallExpressions.length === 0) return;
+        if (testCallExpressions.length === 0) {
+          return;
+        }
         const returnStmt = node.body.body.find(t => t.type === _utils.AST_NODE_TYPES.ReturnStatement);
-        if (!returnStmt) return;
+        if (!returnStmt) {
+          return;
+        }
         context.report({
           messageId: 'noReturnValue',
diff --git a/lib/rules/no-untyped-mock-factory.js b/lib/rules/no-untyped-mock-factory.js
index v27.2.3..v27.4.0 100644
--- a/lib/rules/no-untyped-mock-factory.js
+++ b/lib/rules/no-untyped-mock-factory.js
@@ -57,5 +57,7 @@
             node,
             fix(fixer) {
-              if (!moduleName) return [];
+              if (!moduleName) {
+                return [];
+              }
               return [fixer.insertTextAfter(callee, `<typeof import(${moduleName.raw})>`)];
             }
diff --git a/lib/rules/prefer-spy-on.js b/lib/rules/prefer-spy-on.js
index v27.2.3..v27.4.0 100644
--- a/lib/rules/prefer-spy-on.js
+++ b/lib/rules/prefer-spy-on.js
@@ -62,7 +62,11 @@
           right
         } = node;
-        if (left.type !== _utils.AST_NODE_TYPES.MemberExpression) return;
+        if (left.type !== _utils.AST_NODE_TYPES.MemberExpression) {
+          return;
+        }
         const jestFnCall = getJestFnCall(right);
-        if (!jestFnCall) return;
+        if (!jestFnCall) {
+          return;
+        }
         context.report({
           node,
diff --git a/lib/rules/unbound-method.js b/lib/rules/unbound-method.js
index v27.2.3..v27.4.0 100644
--- a/lib/rules/unbound-method.js
+++ b/lib/rules/unbound-method.js
@@ -64,5 +64,5 @@
           }
         }
-        (_baseSelectors$Member = baseSelectors.MemberExpression) === null || _baseSelectors$Member === void 0 ? void 0 : _baseSelectors$Member.call(baseSelectors, node);
+        (_baseSelectors$Member = baseSelectors.MemberExpression) === null || _baseSelectors$Member === void 0 || _baseSelectors$Member.call(baseSelectors, node);
       }
     };
diff --git a/lib/rules/valid-title.js b/lib/rules/valid-title.js
index v27.2.3..v27.4.0 100644
--- a/lib/rules/valid-title.js
+++ b/lib/rules/valid-title.js
@@ -69,4 +69,8 @@
       type: 'object',
       properties: {
+        ignoreSpaces: {
+          type: 'boolean',
+          default: false
+        },
         ignoreTypeOfDescribeName: {
           type: 'boolean',
@@ -102,8 +106,10 @@
   },
   defaultOptions: [{
+    ignoreSpaces: false,
     ignoreTypeOfDescribeName: false,
     disallowedWords: []
   }],
   create(context, [{
+    ignoreSpaces,
     ignoreTypeOfDescribeName,
     disallowedWords = [],
@@ -160,5 +166,5 @@
           }
         }
-        if (title.trim().length !== title.length) {
+        if (ignoreSpaces === false && title.trim().length !== title.length) {
           context.report({
             messageId: 'accidentalSpace',
diff --git a/package.json b/package.json
index v27.2.3..v27.4.0 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
 {
   "name": "eslint-plugin-jest",
-  "version": "27.2.3",
+  "version": "27.4.0",
   "description": "ESLint rules for Jest",
   "keywords": [
@@ -46,6 +46,5 @@
     "endOfLine": "auto",
     "proseWrap": "always",
-    "singleQuote": true,
-    "trailingComma": "all"
+    "singleQuote": true
   },
   "release": {
@@ -106,20 +105,18 @@
     "@commitlint/cli": "^17.0.3",
     "@commitlint/config-conventional": "^17.0.3",
-    "@schemastore/package": "^0.0.8",
+    "@schemastore/package": "^0.0.10",
     "@semantic-release/changelog": "^6.0.0",
     "@semantic-release/git": "^10.0.0",
     "@tsconfig/node14": "^14.1.0",
-    "@types/dedent": "^0.7.0",
     "@types/eslint": "^8.4.6",
     "@types/jest": "^29.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": "^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",
+    "dedent": "^1.5.0",
+    "eslint": "^7.0.0 || ^8.0.0",
+    "eslint-config-prettier": "^9.0.0",
     "eslint-doc-generator": "^1.0.0",
     "eslint-plugin-eslint-comments": "^3.1.2",
@@ -127,5 +124,5 @@
     "eslint-plugin-import": "^2.25.1",
     "eslint-plugin-node": "^11.0.0",
-    "eslint-plugin-prettier": "^4.2.1",
+    "eslint-plugin-prettier": "^5.0.0",
     "eslint-remote-tester": "^3.0.0",
     "eslint-remote-tester-repositories": "~1.0.0",
@@ -137,5 +134,5 @@
     "markdown-link-check": "^3.10.2",
     "pinst": "^3.0.0",
-    "prettier": "^2.0.5",
+    "prettier": "^3.0.0",
     "rimraf": "^5.0.0",
     "semantic-release": "^21.0.0",
@@ -157,5 +154,5 @@
     }
   },
-  "packageManager": "yarn@3.6.1",
+  "packageManager": "yarn@3.6.3",
   "engines": {
     "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
diff --git a/README.md b/README.md
index v27.2.3..v27.4.0 100644
--- a/README.md
+++ b/README.md
@@ -221,4 +221,5 @@
 | [no-conditional-expect](docs/rules/no-conditional-expect.md)                 | Disallow calling `expect` conditionally                                   | ✅  |     |     |     |     |
 | [no-conditional-in-test](docs/rules/no-conditional-in-test.md)               | Disallow conditional logic in tests                                       |     |     |     |     |     |
+| [no-confusing-set-timeout](docs/rules/no-confusing-set-timeout.md)           | Disallow confusing usages of jest.setTimeout                              |     |     |     |     |     |
 | [no-deprecated-functions](docs/rules/no-deprecated-functions.md)             | Disallow use of deprecated functions                                      | ✅  |     | 🔧  |     |     |
 | [no-disabled-tests](docs/rules/no-disabled-tests.md)                         | Disallow disabled tests                                                   |     | ✅  |     |     |     |
diff --git a/docs/rules/valid-title.md b/docs/rules/valid-title.md
index v27.2.3..v27.4.0 100644
--- a/docs/rules/valid-title.md
+++ b/docs/rules/valid-title.md
@@ -126,5 +126,6 @@
 **accidentalSpace**
 
-A `describe` / `test` block should not contain accidentalSpace
+A `describe` / `test` block should not contain accidentalSpace, but can be
+turned off via the `ignoreSpaces` option:
 
 Examples of **incorrect** code for this rule
@@ -162,4 +163,5 @@
 ```ts
 interface Options {
+  ignoreSpaces?: boolean;
   ignoreTypeOfDescribeName?: boolean;
   disallowedWords?: string[];
@@ -169,4 +171,10 @@
 ```
 
+#### `ignoreSpaces`
+
+Default: `false`
+
+When enabled, the leading and trailing spaces won't be checked.
+
 #### `ignoreTypeOfDescribeName`
 
diff --git a/lib/rules/no-confusing-set-timeout.js b/lib/rules/no-confusing-set-timeout.js
new file mode 100644
index v27.2.3..v27.4.0 
--- a/lib/rules/no-confusing-set-timeout.js
+++ b/lib/rules/no-confusing-set-timeout.js
@@ -0,0 +1,65 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.default = void 0;
+var _utils = require("./utils");
+function isJestSetTimeout(jestFnCall) {
+  return jestFnCall.type === 'jest' && jestFnCall.members.length === 1 && (0, _utils.isIdentifier)(jestFnCall.members[0], 'setTimeout');
+}
+var _default = (0, _utils.createRule)({
+  name: __filename,
+  meta: {
+    docs: {
+      category: 'Best Practices',
+      description: 'Disallow confusing usages of jest.setTimeout',
+      recommended: false
+    },
+    messages: {
+      globalSetTimeout: '`jest.setTimeout` should be call in `global` scope',
+      multipleSetTimeouts: 'Do not call `jest.setTimeout` multiple times, as only the last call will have an effect',
+      orderSetTimeout: '`jest.setTimeout` should be placed before any other jest methods'
+    },
+    type: 'problem',
+    schema: []
+  },
+  defaultOptions: [],
+  create(context) {
+    let seenJestTimeout = false;
+    let shouldEmitOrderSetTimeout = false;
+    return {
+      CallExpression(node) {
+        const scope = context.getScope();
+        const jestFnCall = (0, _utils.parseJestFnCall)(node, context);
+        if (!jestFnCall) {
+          return;
+        }
+        if (!isJestSetTimeout(jestFnCall)) {
+          shouldEmitOrderSetTimeout = true;
+          return;
+        }
+        if (!['global', 'module'].includes(scope.type)) {
+          context.report({
+            messageId: 'globalSetTimeout',
+            node
+          });
+        }
+        if (shouldEmitOrderSetTimeout) {
+          context.report({
+            messageId: 'orderSetTimeout',
+            node
+          });
+        }
+        if (seenJestTimeout) {
+          context.report({
+            messageId: 'multipleSetTimeouts',
+            node
+          });
+        }
+        seenJestTimeout = true;
+      }
+    };
+  }
+});
+exports.default = _default;
\ No newline at end of file
diff --git a/docs/rules/no-confusing-set-timeout.md b/docs/rules/no-confusing-set-timeout.md
new file mode 100644
index v27.2.3..v27.4.0 
--- a/docs/rules/no-confusing-set-timeout.md
+++ b/docs/rules/no-confusing-set-timeout.md
@@ -0,0 +1,62 @@
+# Disallow confusing usages of jest.setTimeout (`no-confusing-set-timeout`)
+
+<!-- end auto-generated rule header -->
+
+While `jest.setTimeout` can be called multiple times anywhere within a single
+test file only the last call before any test functions run will have an effect.
+
+## Rule details
+
+this rule checks for several confusing usages of `jest.setTimeout` that looks
+like it applies to specific tests within the same file, such as:
+
+- being called anywhere other than in global scope
+- being called multiple times
+- being called after other Jest functions like hooks, `describe`, `test`, or
+  `it`
+
+Examples of **incorrect** code for this rule:
+
+```js
+describe('test foo', () => {
+  jest.setTimeout(1000);
+  it('test-description', () => {
+    // test logic;
+  });
+});
+
+describe('test bar', () => {
+  it('test-description', () => {
+    jest.setTimeout(1000);
+    // test logic;
+  });
+});
+
+test('foo-bar', () => {
+  jest.setTimeout(1000);
+});
+
+describe('unit test', () => {
+  beforeEach(() => {
+    jest.setTimeout(1000);
+  });
+});
+```
+
+Examples of **correct** code for this rule:
+
+```js
+jest.setTimeout(500);
+test('test test', () => {
+  // do some stuff
+});
+```
+
+```js
+jest.setTimeout(1000);
+describe('test bar bar', () => {
+  it('test-description', () => {
+    // test logic;
+  });
+});
+```
Size Files
309.3 KB → 313.0 KB (+3.7 KB 🟡) 116 → 118 (+2 🟡)
Command details
npm diff --diff=eslint-plugin-jest@27.2.3 --diff=eslint-plugin-jest@27.4.0 --diff-unified=2

See also the npm diff document.

Reported by ybiquitous/npm-diff-action@v1.5.0 (Node.js 20.6.1 and npm 10.1.0)

Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 27.2.3 to 27.4.0.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md)
- [Commits](jest-community/eslint-plugin-jest@v27.2.3...v27.4.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-jest
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/eslint-plugin-jest-27.4.0 branch from dccdcc5 to d2d0cab Compare September 18, 2023 03:07
@github-actions github-actions bot merged commit 20e16ca into main Sep 18, 2023
@github-actions github-actions bot deleted the dependabot/npm_and_yarn/eslint-plugin-jest-27.4.0 branch September 18, 2023 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants