eslint-plugin-jest 27.4.0 → 27.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ var _default = (0, _utils2.createRule)({
15
15
  recommended: false
16
16
  },
17
17
  messages: {
18
- exceededMaxAssertion: 'Too many assertion calls ({{ count }}). Maximum allowed is {{ max }}.'
18
+ exceededMaxAssertion: 'Too many assertion calls ({{ count }}) - maximum allowed is {{ max }}'
19
19
  },
20
20
  type: 'suggestion',
21
21
  schema: [{
@@ -4,9 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _utils = require("@typescript-eslint/utils");
8
- var _utils2 = require("./utils");
9
- var _default = (0, _utils2.createRule)({
7
+ var _utils = require("./utils");
8
+ var _default = (0, _utils.createRule)({
10
9
  name: __filename,
11
10
  meta: {
12
11
  docs: {
@@ -15,7 +14,7 @@ var _default = (0, _utils2.createRule)({
15
14
  recommended: false
16
15
  },
17
16
  messages: {
18
- exceededMaxDepth: 'Too many nested describe calls ({{ depth }}). Maximum allowed is {{ max }}.'
17
+ exceededMaxDepth: 'Too many nested describe calls ({{ depth }}) - maximum allowed is {{ max }}'
19
18
  },
20
19
  type: 'suggestion',
21
20
  schema: [{
@@ -35,39 +34,28 @@ var _default = (0, _utils2.createRule)({
35
34
  create(context, [{
36
35
  max
37
36
  }]) {
38
- const describeCallbackStack = [];
39
- function pushDescribeCallback(node) {
40
- const {
41
- parent
42
- } = node;
43
- if ((parent === null || parent === void 0 ? void 0 : parent.type) !== _utils.AST_NODE_TYPES.CallExpression || !(0, _utils2.isTypeOfJestFnCall)(parent, context, ['describe'])) {
44
- return;
45
- }
46
- describeCallbackStack.push(0);
47
- if (describeCallbackStack.length > max) {
48
- context.report({
49
- node: parent,
50
- messageId: 'exceededMaxDepth',
51
- data: {
52
- depth: describeCallbackStack.length,
53
- max
37
+ const describes = [];
38
+ return {
39
+ CallExpression(node) {
40
+ if ((0, _utils.isTypeOfJestFnCall)(node, context, ['describe'])) {
41
+ describes.unshift(node);
42
+ if (describes.length > max) {
43
+ context.report({
44
+ node,
45
+ messageId: 'exceededMaxDepth',
46
+ data: {
47
+ depth: describes.length,
48
+ max
49
+ }
50
+ });
54
51
  }
55
- });
56
- }
57
- }
58
- function popDescribeCallback(node) {
59
- const {
60
- parent
61
- } = node;
62
- if ((parent === null || parent === void 0 ? void 0 : parent.type) === _utils.AST_NODE_TYPES.CallExpression && (0, _utils2.isTypeOfJestFnCall)(parent, context, ['describe'])) {
63
- describeCallbackStack.pop();
52
+ }
53
+ },
54
+ 'CallExpression:exit'(node) {
55
+ if (describes[0] === node) {
56
+ describes.shift();
57
+ }
64
58
  }
65
- }
66
- return {
67
- FunctionExpression: pushDescribeCallback,
68
- 'FunctionExpression:exit': popDescribeCallback,
69
- ArrowFunctionExpression: pushDescribeCallback,
70
- 'ArrowFunctionExpression:exit': popDescribeCallback
71
59
  };
72
60
  }
73
61
  });
@@ -15,7 +15,7 @@ var _default = (0, _utils2.createRule)({
15
15
  recommended: 'error'
16
16
  },
17
17
  messages: {
18
- unexpectedExport: `Do not export from a test file.`
18
+ unexpectedExport: `Do not export from a test file`
19
19
  },
20
20
  type: 'suggestion',
21
21
  schema: []
@@ -15,8 +15,8 @@ var _default = (0, _utils2.createRule)({
15
15
  recommended: 'error'
16
16
  },
17
17
  messages: {
18
- focusedTest: 'Unexpected focused test.',
19
- suggestRemoveFocus: 'Remove focus from test.'
18
+ focusedTest: 'Unexpected focused test',
19
+ suggestRemoveFocus: 'Remove focus from test'
20
20
  },
21
21
  schema: [],
22
22
  type: 'suggestion',
@@ -33,7 +33,7 @@ var _default = (0, _utils2.createRule)({
33
33
  if (jestFnCall.name.startsWith('f')) {
34
34
  context.report({
35
35
  messageId: 'focusedTest',
36
- node,
36
+ node: jestFnCall.head.node,
37
37
  suggest: [{
38
38
  messageId: 'suggestRemoveFocus',
39
39
  fix(fixer) {
@@ -18,8 +18,8 @@ var _default = (0, _utils.createRule)({
18
18
  recommended: 'error'
19
19
  },
20
20
  messages: {
21
- multipleTestTitle: 'Test title is used multiple times in the same describe block.',
22
- multipleDescribeTitle: 'Describe block title is used multiple times in the same describe block.'
21
+ multipleTestTitle: 'Test title is used multiple times in the same describe block',
22
+ multipleDescribeTitle: 'Describe block title is used multiple times in the same describe block'
23
23
  },
24
24
  schema: [],
25
25
  type: 'suggestion'
@@ -22,7 +22,7 @@ var _default = (0, _utils2.createRule)({
22
22
  recommended: false
23
23
  },
24
24
  messages: {
25
- conditionalInTest: 'Test should not contain {{ condition }} statements.'
25
+ conditionalInTest: 'Test should not contain {{ condition }} statements'
26
26
  },
27
27
  deprecated: true,
28
28
  replacedBy: ['no-conditional-in-test'],
@@ -19,7 +19,7 @@ var _default = (0, _utils.createRule)({
19
19
  recommended: 'error'
20
20
  },
21
21
  messages: {
22
- noManualImport: `Mocks should not be manually imported from a ${mocksDirName} directory. Instead use \`jest.mock\` and import from the original module path.`
22
+ noManualImport: `Mocks should not be manually imported from a ${mocksDirName} directory. Instead use \`jest.mock\` and import from the original module path`
23
23
  },
24
24
  schema: []
25
25
  },
@@ -42,7 +42,7 @@ var _default = (0, _utils2.createRule)({
42
42
  recommended: 'error'
43
43
  },
44
44
  messages: {
45
- unexpectedExpect: 'Expect must be inside of a test block.'
45
+ unexpectedExpect: 'Expect must be inside of a test block'
46
46
  },
47
47
  type: 'suggestion',
48
48
  schema: [{
@@ -22,7 +22,7 @@ var _default = (0, _utils2.createRule)({
22
22
  recommended: false
23
23
  },
24
24
  messages: {
25
- noReturnValue: 'Jest tests should not return a value.'
25
+ noReturnValue: 'Jest tests should not return a value'
26
26
  },
27
27
  schema: [],
28
28
  type: 'suggestion'
@@ -16,7 +16,7 @@ var _default = (0, _utils2.createRule)({
16
16
  },
17
17
  fixable: 'code',
18
18
  messages: {
19
- expectResolves: 'Use `await expect(...).resolves instead.'
19
+ expectResolves: 'Use `await expect(...).resolves instead'
20
20
  },
21
21
  schema: [],
22
22
  type: 'suggestion'
@@ -47,7 +47,7 @@ var _default = (0, _utils2.createRule)({
47
47
  recommended: false
48
48
  },
49
49
  messages: {
50
- useJestSpyOn: 'Use jest.spyOn() instead.'
50
+ useJestSpyOn: 'Use jest.spyOn() instead'
51
51
  },
52
52
  fixable: 'code',
53
53
  schema: [],
@@ -63,13 +63,13 @@ var _default = (0, _utils2.createRule)({
63
63
  recommended: 'error'
64
64
  },
65
65
  messages: {
66
- tooManyArgs: 'Expect takes at most {{ amount }} argument{{ s }}.',
67
- notEnoughArgs: 'Expect requires at least {{ amount }} argument{{ s }}.',
68
- modifierUnknown: 'Expect has an unknown modifier.',
69
- matcherNotFound: 'Expect must have a corresponding matcher call.',
70
- matcherNotCalled: 'Matchers must be called to assert.',
71
- asyncMustBeAwaited: 'Async assertions must be awaited{{ orReturned }}.',
72
- promisesWithAsyncAssertionsMustBeAwaited: 'Promises which return async assertions must be awaited{{ orReturned }}.'
66
+ tooManyArgs: 'Expect takes at most {{ amount }} argument{{ s }}',
67
+ notEnoughArgs: 'Expect requires at least {{ amount }} argument{{ s }}',
68
+ modifierUnknown: 'Expect has an unknown modifier',
69
+ matcherNotFound: 'Expect must have a corresponding matcher call',
70
+ matcherNotCalled: 'Matchers must be called to assert',
71
+ asyncMustBeAwaited: 'Async assertions must be awaited{{ orReturned }}',
72
+ promisesWithAsyncAssertionsMustBeAwaited: 'Promises which return async assertions must be awaited{{ orReturned }}'
73
73
  },
74
74
  type: 'suggestion',
75
75
  schema: [{
@@ -58,7 +58,7 @@ var _default = (0, _utils2.createRule)({
58
58
  emptyTitle: '{{ jestFunctionName }} should not have an empty title',
59
59
  duplicatePrefix: 'should not have duplicate prefix',
60
60
  accidentalSpace: 'should not have leading or trailing spaces',
61
- disallowedWord: '"{{ word }}" is not allowed in test titles.',
61
+ disallowedWord: '"{{ word }}" is not allowed in test titles',
62
62
  mustNotMatch: '{{ jestFunctionName }} should not match {{ pattern }}',
63
63
  mustMatch: '{{ jestFunctionName }} should match {{ pattern }}',
64
64
  mustNotMatchCustom: '{{ message }}',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "27.4.0",
3
+ "version": "27.4.2",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",
@@ -135,7 +135,7 @@
135
135
  "pinst": "^3.0.0",
136
136
  "prettier": "^3.0.0",
137
137
  "rimraf": "^5.0.0",
138
- "semantic-release": "^21.0.0",
138
+ "semantic-release": "^22.0.0",
139
139
  "semver": "^7.3.5",
140
140
  "ts-node": "^10.2.1",
141
141
  "typescript": "^5.0.4"