-
Notifications
You must be signed in to change notification settings - Fork 0
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
github-actions
merged 1 commit into
main
from
dependabot/npm_and_yarn/eslint-plugin-jest-27.4.0
Sep 18, 2023
Merged
build(deps-dev): bump eslint-plugin-jest from 27.2.3 to 27.4.0 #1615
github-actions
merged 1 commit into
main
from
dependabot/npm_and_yarn/eslint-plugin-jest-27.4.0
Sep 18, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependabot
bot
added
dependencies
Pull requests that update a dependency file
javascript
Pull requests that update Javascript code
labels
Sep 18, 2023
Diff between eslint-plugin-jest 27.2.3 and 27.4.0diff --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;
+ });
+});
+```
Command detailsnpm diff --diff=eslint-plugin-jest@27.2.3 --diff=eslint-plugin-jest@27.4.0 --diff-unified=2 See also the 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
bot
force-pushed
the
dependabot/npm_and_yarn/eslint-plugin-jest-27.4.0
branch
from
September 18, 2023 03:07
dccdcc5
to
d2d0cab
Compare
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
0 participants
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bumps eslint-plugin-jest from 27.2.3 to 27.4.0.
Release notes
Sourced from eslint-plugin-jest's releases.
Changelog
Sourced from eslint-plugin-jest's changelog.
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: addno-confusing-set-time
rule (#1425)1b96756
chore(deps): lock file maintenanceeeafcc9
chore: enforce curly braces (#1429)e44693f
chore(deps): update actions/checkout action to v4 (#1428)fefd488
chore(deps): lock file maintenance44fb78a
chore: update prettier (#1427)2198f4a
ci: test against v5 and v6 of@typescript-eslint/eslint-plugin
(#1424)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)