eslint-plugin-jest 25.3.0 → 25.3.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [25.3.1](https://github.com/jest-community/eslint-plugin-jest/compare/v25.3.0...v25.3.1) (2021-12-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **prefer-to-be:** support template literals ([#1006](https://github.com/jest-community/eslint-plugin-jest/issues/1006)) ([aa428e6](https://github.com/jest-community/eslint-plugin-jest/commit/aa428e6598d5f7b259d3cec1bc505989a0fe9885))
7
+
1
8
  # [25.3.0](https://github.com/jest-community/eslint-plugin-jest/compare/v25.2.4...v25.3.0) (2021-11-23)
2
9
 
3
10
 
package/README.md CHANGED
@@ -128,7 +128,7 @@ config file:
128
128
  ```
129
129
 
130
130
  See
131
- [ESLint documentation](http://eslint.org/docs/user-guide/configuring#extending-configuration-files)
131
+ [ESLint documentation](https://eslint.org/docs/user-guide/configuring/configuration-files#extending-configuration-files)
132
132
  for more information about extending configuration files.
133
133
 
134
134
  ### All
@@ -20,9 +20,16 @@ const isNullEqualityMatcher = matcher => isNullLiteral(getFirstArgument(matcher)
20
20
 
21
21
  const isFirstArgumentIdentifier = (matcher, name) => (0, _utils.isIdentifier)(getFirstArgument(matcher), name);
22
22
 
23
- const isPrimitiveLiteral = matcher => {
23
+ const shouldUseToBe = matcher => {
24
24
  const firstArg = getFirstArgument(matcher);
25
- return firstArg.type === _experimentalUtils.AST_NODE_TYPES.Literal && !('regex' in firstArg);
25
+
26
+ if (firstArg.type === _experimentalUtils.AST_NODE_TYPES.Literal) {
27
+ // regex literals are classed as literals, but they're actually objects
28
+ // which means "toBe" will give different results than other matchers
29
+ return !('regex' in firstArg);
30
+ }
31
+
32
+ return firstArg.type === _experimentalUtils.AST_NODE_TYPES.TemplateLiteral;
26
33
  };
27
34
 
28
35
  const getFirstArgument = matcher => {
@@ -116,7 +123,7 @@ var _default = (0, _utils.createRule)({
116
123
  return;
117
124
  }
118
125
 
119
- if (isPrimitiveLiteral(matcher) && matcher.name !== _utils.EqualityMatcher.toBe) {
126
+ if (shouldUseToBe(matcher) && matcher.name !== _utils.EqualityMatcher.toBe) {
120
127
  reportPreferToBe(context, '', matcher);
121
128
  }
122
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "25.3.0",
3
+ "version": "25.3.1",
4
4
  "description": "Eslint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",
@@ -159,5 +159,5 @@
159
159
  "resolutions": {
160
160
  "@typescript-eslint/experimental-utils": "^5.0.0"
161
161
  },
162
- "packageManager": "yarn@3.1.0"
162
+ "packageManager": "yarn@3.1.1"
163
163
  }