eslint-plugin-jest 25.0.0-next.6 → 25.0.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,67 @@
1
+ ## [25.0.2](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.1...v25.0.2) (2021-10-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **valid-expect-in-promise:** support out of order awaits ([#939](https://github.com/jest-community/eslint-plugin-jest/issues/939)) ([07d2137](https://github.com/jest-community/eslint-plugin-jest/commit/07d213719de974d6b5a1cab75e836dc39b432f87))
7
+
8
+ ## [25.0.1](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.0...v25.0.1) (2021-10-10)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * specify peer dependency ranges correctly ([cb87458](https://github.com/jest-community/eslint-plugin-jest/commit/cb87458d5f7dc7f669ab0c4067d75fc06ee29553))
14
+
15
+ # [25.0.0](https://github.com/jest-community/eslint-plugin-jest/compare/v24.7.0...v25.0.0) (2021-10-10)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * stop testing ESLint 5 ([#893](https://github.com/jest-community/eslint-plugin-jest/issues/893)) ([47a0138](https://github.com/jest-community/eslint-plugin-jest/commit/47a0138856e6247cde00b17682e49865b8f5a1f6))
21
+ * stop testing on Node 10 and 15 ([#891](https://github.com/jest-community/eslint-plugin-jest/issues/891)) ([bcd8d11](https://github.com/jest-community/eslint-plugin-jest/commit/bcd8d112fcd98a7652c767bd246d05101979239c))
22
+
23
+
24
+ ### Features
25
+
26
+ * add `prefer-to-be` to style ruleset ([2a3376f](https://github.com/jest-community/eslint-plugin-jest/commit/2a3376fc9f5fe60d03d9aad0c4e5c7c423487e60))
27
+ * **lowercase-name:** rename to `prefer-lowercase-title` ([b860084](https://github.com/jest-community/eslint-plugin-jest/commit/b8600841e371d5d9f36be4e50e53252fd8f62734))
28
+ * **prefer-to-be-null:** remove rule ([809bcda](https://github.com/jest-community/eslint-plugin-jest/commit/809bcda12c555a24c764d152bcac9814ea55e72f))
29
+ * **prefer-to-be-undefined:** remove rule ([3434d9b](https://github.com/jest-community/eslint-plugin-jest/commit/3434d9bd22b92bace6e0a50e2c72b401ac17704d))
30
+ * remove deprecated rules ([#661](https://github.com/jest-community/eslint-plugin-jest/issues/661)) ([e8f16ec](https://github.com/jest-community/eslint-plugin-jest/commit/e8f16ec0e204a94a0e549cb9b415b3c6c8981aee))
31
+ * **valid-describe:** rename to `valid-describe-callback` ([f3e9e9a](https://github.com/jest-community/eslint-plugin-jest/commit/f3e9e9a64e183a0fb8af3436611a7f70366a528d))
32
+
33
+
34
+ ### BREAKING CHANGES
35
+
36
+ * **valid-describe:** renamed `valid-describe` to `valid-describe-callback`
37
+ * **lowercase-name:** renamed `lowercase-name` to `prefer-lowercase-title`
38
+ * **prefer-to-be-undefined:** removed `prefer-to-be-undefined` rule
39
+ * **prefer-to-be-null:** removed `prefer-to-be-null` rule
40
+ * recommend `prefer-to-be` rule
41
+ * Removes rules `no-expect-resolves`, `no-truthy-falsy`, `no-try-expect`, and `prefer-inline-snapshots`
42
+ * Drop support for ESLint 5
43
+ * Drop support for Node 10 and 15
44
+
45
+ # [25.0.0-next.7](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.0-next.6...v25.0.0-next.7) (2021-10-10)
46
+
47
+
48
+ ### Features
49
+
50
+ * add `prefer-to-be` to style ruleset ([2a3376f](https://github.com/jest-community/eslint-plugin-jest/commit/2a3376fc9f5fe60d03d9aad0c4e5c7c423487e60))
51
+ * **lowercase-name:** rename to `prefer-lowercase-title` ([b860084](https://github.com/jest-community/eslint-plugin-jest/commit/b8600841e371d5d9f36be4e50e53252fd8f62734))
52
+ * **prefer-to-be-null:** remove rule ([809bcda](https://github.com/jest-community/eslint-plugin-jest/commit/809bcda12c555a24c764d152bcac9814ea55e72f))
53
+ * **prefer-to-be-undefined:** remove rule ([3434d9b](https://github.com/jest-community/eslint-plugin-jest/commit/3434d9bd22b92bace6e0a50e2c72b401ac17704d))
54
+ * **valid-describe:** rename to `valid-describe-callback` ([f3e9e9a](https://github.com/jest-community/eslint-plugin-jest/commit/f3e9e9a64e183a0fb8af3436611a7f70366a528d))
55
+
56
+
57
+ ### BREAKING CHANGES
58
+
59
+ * **valid-describe:** renamed `valid-describe` to `valid-describe-callback`
60
+ * **lowercase-name:** renamed `lowercase-name` to `prefer-lowercase-title`
61
+ * **prefer-to-be-undefined:** removed `prefer-to-be-undefined` rule
62
+ * **prefer-to-be-null:** removed `prefer-to-be-null` rule
63
+ * recommend `prefer-to-be` rule
64
+
1
65
  # [25.0.0-next.6](https://github.com/jest-community/eslint-plugin-jest/compare/v25.0.0-next.5...v25.0.0-next.6) (2021-10-10)
2
66
 
3
67
 
package/README.md CHANGED
@@ -154,7 +154,6 @@ installations requiring long-term consistency.
154
154
  | ---------------------------------------------------------------------------- | ------------------------------------------------------------------- | ---------------- | ------------ |
155
155
  | [consistent-test-it](docs/rules/consistent-test-it.md) | Have control over `test` and `it` usages | | ![fixable][] |
156
156
  | [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | |
157
- | [lowercase-name](docs/rules/lowercase-name.md) | Enforce lowercase test names | | ![fixable][] |
158
157
  | [max-nested-describe](docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | | |
159
158
  | [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] |
160
159
  | [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | |
@@ -181,16 +180,17 @@ installations requiring long-term consistency.
181
180
  | [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | ![suggest][] |
182
181
  | [prefer-expect-resolves](docs/rules/prefer-expect-resolves.md) | Prefer `await expect(...).resolves` over `expect(await ...)` syntax | | ![fixable][] |
183
182
  | [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest having hooks before any test cases | | |
183
+ | [prefer-lowercase-title](docs/rules/prefer-lowercase-title.md) | Enforce lowercase test names | | ![fixable][] |
184
184
  | [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] |
185
185
  | [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using `toStrictEqual()` | | ![suggest][] |
186
- | [prefer-to-be](docs/rules/prefer-to-be.md) | Suggest using `toBe()` for primitive literals | | ![fixable][] |
186
+ | [prefer-to-be](docs/rules/prefer-to-be.md) | Suggest using `toBe()` for primitive literals | ![style][] | ![fixable][] |
187
187
  | [prefer-to-contain](docs/rules/prefer-to-contain.md) | Suggest using `toContain()` | ![style][] | ![fixable][] |
188
188
  | [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | ![style][] | ![fixable][] |
189
189
  | [prefer-todo](docs/rules/prefer-todo.md) | Suggest using `test.todo` | | ![fixable][] |
190
190
  | [require-hook](docs/rules/require-hook.md) | Require setup and teardown code to be within a hook | | |
191
191
  | [require-to-throw-message](docs/rules/require-to-throw-message.md) | Require a message for `toThrow()` | | |
192
192
  | [require-top-level-describe](docs/rules/require-top-level-describe.md) | Require test cases and hooks to be inside a `describe` block | | |
193
- | [valid-describe](docs/rules/valid-describe.md) | Enforce valid `describe()` callback | ![recommended][] | |
193
+ | [valid-describe-callback](docs/rules/valid-describe-callback.md) | Enforce valid `describe()` callback | ![recommended][] | |
194
194
  | [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage | ![recommended][] | |
195
195
  | [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | Ensure promises that have expectations in their chain are valid | ![recommended][] | |
196
196
  | [valid-title](docs/rules/valid-title.md) | Enforce valid titles | ![recommended][] | ![fixable][] |
@@ -1,4 +1,4 @@
1
- # Enforce lowercase test names (`lowercase-name`)
1
+ # Enforce lowercase test names (`prefer-lowercase-title`)
2
2
 
3
3
  ## Rule details
4
4
 
@@ -1,4 +1,4 @@
1
- # Enforce valid `describe()` callback (`valid-describe`)
1
+ # Enforce valid `describe()` callback (`valid-describe-callback`)
2
2
 
3
3
  Using an improper `describe()` callback function can lead to unexpected test
4
4
  errors.
package/lib/index.js CHANGED
@@ -52,8 +52,7 @@ module.exports = {
52
52
  plugins: ['jest'],
53
53
  rules: {
54
54
  'jest/no-alias-methods': 'warn',
55
- 'jest/prefer-to-be-null': 'error',
56
- 'jest/prefer-to-be-undefined': 'error',
55
+ 'jest/prefer-to-be': 'error',
57
56
  'jest/prefer-to-contain': 'error',
58
57
  'jest/prefer-to-have-length': 'error'
59
58
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.postprocess = exports.preprocess = void 0;
6
+ exports.preprocess = exports.postprocess = void 0;
7
7
 
8
8
  // https://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins
9
9
  // https://github.com/typescript-eslint/typescript-eslint/issues/808
@@ -3,8 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.getAccessorValue = exports.followTypeAssertionChain = exports.createRule = exports.TestCaseProperty = exports.TestCaseName = exports.ModifierName = exports.HookName = exports.EqualityMatcher = exports.DescribeProperty = exports.DescribeAlias = void 0;
6
7
  exports.getNodeName = getNodeName;
7
- exports.scopeHasLocalReference = exports.isDescribeCall = exports.isTestCaseCall = exports.getTestCallExpressionsFromDeclaredVariables = exports.isHook = exports.isFunction = exports.TestCaseProperty = exports.DescribeProperty = exports.HookName = exports.TestCaseName = exports.DescribeAlias = exports.parseExpectCall = exports.isParsedEqualityMatcherCall = exports.EqualityMatcher = exports.ModifierName = exports.isExpectMember = exports.isExpectCall = exports.getAccessorValue = exports.isSupportedAccessor = exports.isIdentifier = exports.hasOnlyOneArgument = exports.getStringValue = exports.isStringNode = exports.followTypeAssertionChain = exports.createRule = void 0;
8
+ exports.scopeHasLocalReference = exports.parseExpectCall = exports.isTestCaseCall = exports.isSupportedAccessor = exports.isStringNode = exports.isParsedEqualityMatcherCall = exports.isIdentifier = exports.isHook = exports.isFunction = exports.isExpectMember = exports.isExpectCall = exports.isDescribeCall = exports.hasOnlyOneArgument = exports.getTestCallExpressionsFromDeclaredVariables = exports.getStringValue = void 0;
8
9
 
9
10
  var _path = require("path");
10
11
 
@@ -61,7 +62,8 @@ const isStringLiteral = (node, value) => node.type === _experimentalUtils.AST_NO
61
62
  *
62
63
  * @template V
63
64
  */
64
- const isTemplateLiteral = (node, value) => node.type === _experimentalUtils.AST_NODE_TYPES.TemplateLiteral && node.quasis.length === 1 && (value === undefined || node.quasis[0].value.raw === value);
65
+ const isTemplateLiteral = (node, value) => node.type === _experimentalUtils.AST_NODE_TYPES.TemplateLiteral && node.quasis.length === 1 && ( // bail out if not simple
66
+ value === undefined || node.quasis[0].value.raw === value);
65
67
 
66
68
  /**
67
69
  * Checks if the given `node` is a {@link StringNode}.
@@ -101,7 +101,7 @@ const isPromiseMethodThatUsesValue = (node, identifier) => {
101
101
  }
102
102
  }
103
103
 
104
- return node.argument.type === _experimentalUtils.AST_NODE_TYPES.Identifier && (0, _utils.isIdentifier)(node.argument, name);
104
+ return (0, _utils.isIdentifier)(node.argument, name);
105
105
  };
106
106
  /**
107
107
  * Attempts to determine if the runtime value represented by the given `identifier`
@@ -126,8 +126,8 @@ const isValueAwaitedOrReturned = (identifier, body) => {
126
126
  }
127
127
 
128
128
  if (node.type === _experimentalUtils.AST_NODE_TYPES.ExpressionStatement) {
129
- if (node.expression.type === _experimentalUtils.AST_NODE_TYPES.AwaitExpression) {
130
- return isPromiseMethodThatUsesValue(node.expression, identifier);
129
+ if (node.expression.type === _experimentalUtils.AST_NODE_TYPES.AwaitExpression && isPromiseMethodThatUsesValue(node.expression, identifier)) {
130
+ return true;
131
131
  } // (re)assignment changes the runtime value, so if we've not found an
132
132
  // await or return already we act as if we've reached the end of the body
133
133
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "25.0.0-next.6",
3
+ "version": "25.0.2",
4
4
  "description": "Eslint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",
@@ -123,8 +123,8 @@
123
123
  "typescript": "^4.4.0"
124
124
  },
125
125
  "peerDependencies": {
126
- "@typescript-eslint/eslint-plugin": ">= 4",
127
- "eslint": ">=6"
126
+ "@typescript-eslint/eslint-plugin": "^4.0.0",
127
+ "eslint": "^6.0.0 || ^7.0.0"
128
128
  },
129
129
  "peerDependenciesMeta": {
130
130
  "@typescript-eslint/eslint-plugin": {
@@ -1,37 +0,0 @@
1
- # Suggest using `toBeNull()` (`prefer-to-be-null`)
2
-
3
- ## Deprecated
4
-
5
- This rule has been deprecated in favor of [`prefer-to-be`](prefer-to-be.md).
6
-
7
- In order to have a better failure message, `toBeNull()` should be used upon
8
- asserting expectations on null value.
9
-
10
- ## Rule details
11
-
12
- This rule triggers a warning if `toBe()`, `toEqual()` or `toStrictEqual()` is
13
- used to assert a null value.
14
-
15
- ```js
16
- expect(null).toBe(null);
17
- ```
18
-
19
- This rule is enabled by default.
20
-
21
- ### Default configuration
22
-
23
- The following patterns are considered warnings:
24
-
25
- ```js
26
- expect(null).toBe(null);
27
-
28
- expect(null).toEqual(null);
29
-
30
- expect(null).toStrictEqual(null);
31
- ```
32
-
33
- The following pattern is not warning:
34
-
35
- ```js
36
- expect(null).toBeNull();
37
- ```
@@ -1,37 +0,0 @@
1
- # Suggest using `toBeUndefined()` (`prefer-to-be-undefined`)
2
-
3
- ## Deprecated
4
-
5
- This rule has been deprecated in favor of [`prefer-to-be`](prefer-to-be.md).
6
-
7
- In order to have a better failure message, `toBeUndefined()` should be used upon
8
- asserting expectations on undefined value.
9
-
10
- ## Rule details
11
-
12
- This rule triggers a warning if `toBe()`, `toEqual()` or `toStrictEqual()` is
13
- used to assert an undefined value.
14
-
15
- ```js
16
- expect(undefined).toBe(undefined);
17
- ```
18
-
19
- This rule is enabled by default.
20
-
21
- ### Default configuration
22
-
23
- The following patterns are considered warnings:
24
-
25
- ```js
26
- expect(undefined).toBe(undefined);
27
-
28
- expect(undefined).toEqual(undefined);
29
-
30
- expect(undefined).toStrictEqual(undefined);
31
- ```
32
-
33
- The following pattern is not warning:
34
-
35
- ```js
36
- expect(undefined).toBeUndefined();
37
- ```
@@ -1,69 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _experimentalUtils = require("@typescript-eslint/experimental-utils");
9
-
10
- var _utils = require("./utils");
11
-
12
- const isNullLiteral = node => node.type === _experimentalUtils.AST_NODE_TYPES.Literal && node.value === null;
13
- /**
14
- * Checks if the given `ParsedExpectMatcher` is a call to one of the equality matchers,
15
- * with a `null` literal as the sole argument.
16
- *
17
- * @param {ParsedExpectMatcher} matcher
18
- *
19
- * @return {matcher is ParsedEqualityMatcherCall<MaybeTypeCast<NullLiteral>>}
20
- */
21
-
22
-
23
- const isNullEqualityMatcher = matcher => (0, _utils.isParsedEqualityMatcherCall)(matcher) && isNullLiteral((0, _utils.followTypeAssertionChain)(matcher.arguments[0]));
24
-
25
- var _default = (0, _utils.createRule)({
26
- name: __filename,
27
- meta: {
28
- docs: {
29
- category: 'Best Practices',
30
- description: 'Suggest using `toBeNull()`',
31
- recommended: false
32
- },
33
- messages: {
34
- useToBeNull: 'Use toBeNull() instead'
35
- },
36
- deprecated: true,
37
- replacedBy: ['prefer-to-be'],
38
- fixable: 'code',
39
- type: 'suggestion',
40
- schema: []
41
- },
42
- defaultOptions: [],
43
-
44
- create(context) {
45
- return {
46
- CallExpression(node) {
47
- if (!(0, _utils.isExpectCall)(node)) {
48
- return;
49
- }
50
-
51
- const {
52
- matcher
53
- } = (0, _utils.parseExpectCall)(node);
54
-
55
- if (matcher && isNullEqualityMatcher(matcher)) {
56
- context.report({
57
- fix: fixer => [fixer.replaceText(matcher.node.property, 'toBeNull'), fixer.remove(matcher.arguments[0])],
58
- messageId: 'useToBeNull',
59
- node: matcher.node.property
60
- });
61
- }
62
- }
63
-
64
- };
65
- }
66
-
67
- });
68
-
69
- exports.default = _default;
@@ -1,69 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _experimentalUtils = require("@typescript-eslint/experimental-utils");
9
-
10
- var _utils = require("./utils");
11
-
12
- const isUndefinedIdentifier = node => node.type === _experimentalUtils.AST_NODE_TYPES.Identifier && node.name === 'undefined';
13
- /**
14
- * Checks if the given `ParsedExpectMatcher` is a call to one of the equality matchers,
15
- * with a `undefined` identifier as the sole argument.
16
- *
17
- * @param {ParsedExpectMatcher} matcher
18
- *
19
- * @return {matcher is ParsedEqualityMatcherCall<MaybeTypeCast<UndefinedIdentifier>>}
20
- */
21
-
22
-
23
- const isUndefinedEqualityMatcher = matcher => (0, _utils.isParsedEqualityMatcherCall)(matcher) && isUndefinedIdentifier((0, _utils.followTypeAssertionChain)(matcher.arguments[0]));
24
-
25
- var _default = (0, _utils.createRule)({
26
- name: __filename,
27
- meta: {
28
- docs: {
29
- category: 'Best Practices',
30
- description: 'Suggest using `toBeUndefined()`',
31
- recommended: false
32
- },
33
- messages: {
34
- useToBeUndefined: 'Use toBeUndefined() instead'
35
- },
36
- deprecated: true,
37
- replacedBy: ['prefer-to-be'],
38
- fixable: 'code',
39
- type: 'suggestion',
40
- schema: []
41
- },
42
- defaultOptions: [],
43
-
44
- create(context) {
45
- return {
46
- CallExpression(node) {
47
- if (!(0, _utils.isExpectCall)(node)) {
48
- return;
49
- }
50
-
51
- const {
52
- matcher
53
- } = (0, _utils.parseExpectCall)(node);
54
-
55
- if (matcher && isUndefinedEqualityMatcher(matcher)) {
56
- context.report({
57
- fix: fixer => [fixer.replaceText(matcher.node.property, 'toBeUndefined'), fixer.remove(matcher.arguments[0])],
58
- messageId: 'useToBeUndefined',
59
- node: matcher.node.property
60
- });
61
- }
62
- }
63
-
64
- };
65
- }
66
-
67
- });
68
-
69
- exports.default = _default;