eslint-plugin-jest 27.3.0 → 27.4.1
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.
|
@@ -125,7 +125,8 @@ describe('foo', () => {
|
|
|
125
125
|
|
|
126
126
|
**accidentalSpace**
|
|
127
127
|
|
|
128
|
-
A `describe` / `test` block should not contain accidentalSpace
|
|
128
|
+
A `describe` / `test` block should not contain accidentalSpace, but can be
|
|
129
|
+
turned off via the `ignoreSpaces` option:
|
|
129
130
|
|
|
130
131
|
Examples of **incorrect** code for this rule
|
|
131
132
|
|
|
@@ -161,6 +162,7 @@ describe('foo', () => {
|
|
|
161
162
|
|
|
162
163
|
```ts
|
|
163
164
|
interface Options {
|
|
165
|
+
ignoreSpaces?: boolean;
|
|
164
166
|
ignoreTypeOfDescribeName?: boolean;
|
|
165
167
|
disallowedWords?: string[];
|
|
166
168
|
mustNotMatch?: Partial<Record<'describe' | 'test' | 'it', string>> | string;
|
|
@@ -168,6 +170,12 @@ interface Options {
|
|
|
168
170
|
}
|
|
169
171
|
```
|
|
170
172
|
|
|
173
|
+
#### `ignoreSpaces`
|
|
174
|
+
|
|
175
|
+
Default: `false`
|
|
176
|
+
|
|
177
|
+
When enabled, the leading and trailing spaces won't be checked.
|
|
178
|
+
|
|
171
179
|
#### `ignoreTypeOfDescribeName`
|
|
172
180
|
|
|
173
181
|
Default: `false`
|
|
@@ -4,9 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _utils = require("
|
|
8
|
-
var
|
|
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: {
|
|
@@ -35,39 +34,28 @@ var _default = (0, _utils2.createRule)({
|
|
|
35
34
|
create(context, [{
|
|
36
35
|
max
|
|
37
36
|
}]) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
});
|
package/lib/rules/valid-title.js
CHANGED
|
@@ -68,6 +68,10 @@ var _default = (0, _utils2.createRule)({
|
|
|
68
68
|
schema: [{
|
|
69
69
|
type: 'object',
|
|
70
70
|
properties: {
|
|
71
|
+
ignoreSpaces: {
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
71
75
|
ignoreTypeOfDescribeName: {
|
|
72
76
|
type: 'boolean',
|
|
73
77
|
default: false
|
|
@@ -101,10 +105,12 @@ var _default = (0, _utils2.createRule)({
|
|
|
101
105
|
fixable: 'code'
|
|
102
106
|
},
|
|
103
107
|
defaultOptions: [{
|
|
108
|
+
ignoreSpaces: false,
|
|
104
109
|
ignoreTypeOfDescribeName: false,
|
|
105
110
|
disallowedWords: []
|
|
106
111
|
}],
|
|
107
112
|
create(context, [{
|
|
113
|
+
ignoreSpaces,
|
|
108
114
|
ignoreTypeOfDescribeName,
|
|
109
115
|
disallowedWords = [],
|
|
110
116
|
mustNotMatch,
|
|
@@ -159,7 +165,7 @@ var _default = (0, _utils2.createRule)({
|
|
|
159
165
|
return;
|
|
160
166
|
}
|
|
161
167
|
}
|
|
162
|
-
if (title.trim().length !== title.length) {
|
|
168
|
+
if (ignoreSpaces === false && title.trim().length !== title.length) {
|
|
163
169
|
context.report({
|
|
164
170
|
messageId: 'accidentalSpace',
|
|
165
171
|
node: argument,
|