eslint-plugin-jest 27.4.3 → 27.6.0

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.
@@ -51,10 +51,9 @@ xtest('foo', () => {});
51
51
 
52
52
  **titleMustBeString**
53
53
 
54
- Titles for test blocks should always be a string.
55
-
56
- This is also applied to `describe` blocks by default, but can be turned off via
57
- the `ignoreTypeOfDescribeName` option:
54
+ Titles for `describe`, `test`, and `it` blocks should always be a string; you
55
+ can disable this with the `ignoreTypeOfDescribeName` and `ignoreTypeOfTestName`
56
+ options.
58
57
 
59
58
  Examples of **incorrect** code for this rule:
60
59
 
@@ -93,6 +92,18 @@ xdescribe(myFunction, () => {});
93
92
  describe(6, function () {});
94
93
  ```
95
94
 
95
+ Examples of **correct** code when `ignoreTypeOfTestName` is `true`:
96
+
97
+ ```js
98
+ const myTestName = 'is a string';
99
+
100
+ it(String(/.+/), () => {});
101
+ it(myFunction, () => {});
102
+ it(myTestName, () => {});
103
+ xit(myFunction, () => {});
104
+ it(6, function () {});
105
+ ```
106
+
96
107
  **duplicatePrefix**
97
108
 
98
109
  A `describe` / `test` block should not start with `duplicatePrefix`
package/lib/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  var _fs = require("fs");
4
4
  var _path = require("path");
5
+ var _package = require("../package.json");
5
6
  var _globals = _interopRequireDefault(require("./globals.json"));
6
7
  var snapshotProcessor = _interopRequireWildcard(require("./processors/snapshot-processor"));
7
8
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -30,6 +31,10 @@ const createConfig = rules => ({
30
31
  rules
31
32
  });
32
33
  module.exports = {
34
+ meta: {
35
+ name: _package.name,
36
+ version: _package.version
37
+ },
33
38
  configs: {
34
39
  all: createConfig(allRules),
35
40
  recommended: createConfig(recommendedRules),
@@ -76,6 +76,10 @@ var _default = exports.default = (0, _utils2.createRule)({
76
76
  type: 'boolean',
77
77
  default: false
78
78
  },
79
+ ignoreTypeOfTestName: {
80
+ type: 'boolean',
81
+ default: false
82
+ },
79
83
  disallowedWords: {
80
84
  type: 'array',
81
85
  items: {
@@ -107,11 +111,13 @@ var _default = exports.default = (0, _utils2.createRule)({
107
111
  defaultOptions: [{
108
112
  ignoreSpaces: false,
109
113
  ignoreTypeOfDescribeName: false,
114
+ ignoreTypeOfTestName: false,
110
115
  disallowedWords: []
111
116
  }],
112
117
  create(context, [{
113
118
  ignoreSpaces,
114
119
  ignoreTypeOfDescribeName,
120
+ ignoreTypeOfTestName,
115
121
  disallowedWords = [],
116
122
  mustNotMatch,
117
123
  mustMatch
@@ -133,7 +139,7 @@ var _default = exports.default = (0, _utils2.createRule)({
133
139
  if (argument.type === _utils.AST_NODE_TYPES.BinaryExpression && doesBinaryExpressionContainStringNode(argument)) {
134
140
  return;
135
141
  }
136
- if (argument.type !== _utils.AST_NODE_TYPES.TemplateLiteral && !(ignoreTypeOfDescribeName && jestFnCall.type === 'describe')) {
142
+ if (!(jestFnCall.type === 'describe' && ignoreTypeOfDescribeName || jestFnCall.type === 'test' && ignoreTypeOfTestName) && argument.type !== _utils.AST_NODE_TYPES.TemplateLiteral) {
137
143
  context.report({
138
144
  messageId: 'titleMustBeString',
139
145
  loc: argument.loc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "27.4.3",
3
+ "version": "27.6.0",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",
@@ -122,7 +122,7 @@
122
122
  "eslint-plugin-eslint-comments": "^3.1.2",
123
123
  "eslint-plugin-eslint-plugin": "^5.0.6",
124
124
  "eslint-plugin-import": "^2.25.1",
125
- "eslint-plugin-node": "^11.0.0",
125
+ "eslint-plugin-n": "^15.0.0",
126
126
  "eslint-plugin-prettier": "^5.0.0",
127
127
  "eslint-remote-tester": "^3.0.0",
128
128
  "eslint-remote-tester-repositories": "~1.0.0",