eslint-plugin-jest 26.9.0 → 27.0.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.
package/README.md CHANGED
@@ -203,7 +203,7 @@ installations requiring long-term consistency.
203
203
  | [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | |
204
204
  | [max-expects](docs/rules/max-expects.md) | Enforces a maximum number assertion calls in a test body | | |
205
205
  | [max-nested-describe](docs/rules/max-nested-describe.md) | Enforces a maximum depth to nested describe calls | | |
206
- | [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] |
206
+ | [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![recommended][] | ![fixable][] |
207
207
  | [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | |
208
208
  | [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | ![recommended][] | |
209
209
  | [no-conditional-in-test](docs/rules/no-conditional-in-test.md) | Disallow conditional logic in tests | | |
@@ -217,7 +217,6 @@ installations requiring long-term consistency.
217
217
  | [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | |
218
218
  | [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside snapshots | ![recommended][] | |
219
219
  | [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] |
220
- | [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | |
221
220
  | [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | |
222
221
  | [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from `__mocks__` | ![recommended][] | |
223
222
  | [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | |
@@ -1,5 +1,8 @@
1
1
  # Disallow alias methods (`no-alias-methods`)
2
2
 
3
+ > These aliases are going to be removed in the next major version of Jest - see
4
+ > https://github.com/facebook/jest/issues/13164 for more
5
+
3
6
  Several Jest methods have alias names, such as `toThrow` having the alias of
4
7
  `toThrowError`. This rule ensures that only the canonical name as used in the
5
8
  Jest documentation is used in the code. This makes it easier to search for all
@@ -8,8 +8,9 @@ alternatives.
8
8
  Bans are expressed in the form of a map, with the value being either a string
9
9
  message to be shown, or `null` if the default rule message should be used.
10
10
 
11
- Both matchers, modifiers, and chains of the two are checked, allowing for
12
- specific variations of a matcher to be banned if desired.
11
+ Bans are checked against the start of the `expect` chain - this means that to
12
+ ban a specific matcher entirely you must specify all six permutations, but
13
+ allows you to ban modifiers as well.
13
14
 
14
15
  By default, this map is empty, meaning no matchers or modifiers are banned.
15
16
 
@@ -22,7 +23,12 @@ For example:
22
23
  {
23
24
  "toBeFalsy": null,
24
25
  "resolves": "Use `expect(await promise)` instead.",
25
- "not.toHaveBeenCalledWith": null
26
+ "toHaveBeenCalledWith": null,
27
+ "not.toHaveBeenCalledWith": null,
28
+ "resolves.toHaveBeenCalledWith": null,
29
+ "rejects.toHaveBeenCalledWith": null,
30
+ "resolves.not.toHaveBeenCalledWith": null,
31
+ "rejects.not.toHaveBeenCalledWith": null
26
32
  }
27
33
  ]
28
34
  }
@@ -32,15 +38,18 @@ Examples of **incorrect** code for this rule with the above configuration
32
38
 
33
39
  ```js
34
40
  it('is false', () => {
41
+ // if this has a modifer (i.e. `not.toBeFalsy`), it would be considered fine
35
42
  expect(a).toBeFalsy();
36
43
  });
37
44
 
38
45
  it('resolves', async () => {
46
+ // all uses of this modifier are disallowed, regardless of matcher
39
47
  await expect(myPromise()).resolves.toBe(true);
40
48
  });
41
49
 
42
50
  describe('when an error happens', () => {
43
51
  it('does not upload the file', async () => {
52
+ // all uses of this matcher are disallowed
44
53
  expect(uploadFileMock).not.toHaveBeenCalledWith('file.name');
45
54
  });
46
55
  });
@@ -89,9 +89,7 @@ var _default = (0, _utils2.createRule)({
89
89
 
90
90
  return {
91
91
  CallExpression(node) {
92
- var _getNodeName;
93
-
94
- const name = (_getNodeName = (0, _utils2.getNodeName)(node.callee)) !== null && _getNodeName !== void 0 ? _getNodeName : '';
92
+ const name = (0, _utils2.getNodeName)(node.callee) ?? '';
95
93
 
96
94
  if ((0, _utils2.isTypeOfJestFnCall)(node, context, ['test']) || additionalTestBlockFunctions.includes(name)) {
97
95
  if (node.callee.type === _utils.AST_NODE_TYPES.MemberExpression && (0, _utils2.isSupportedAccessor)(node.callee.property, 'todo')) {
@@ -13,7 +13,7 @@ var _default = (0, _utils.createRule)({
13
13
  docs: {
14
14
  category: 'Best Practices',
15
15
  description: 'Disallow alias methods',
16
- recommended: false
16
+ recommended: 'error'
17
17
  },
18
18
  messages: {
19
19
  replaceAlias: `Replace {{ alias }}() with its canonical name of {{ canonical }}()`
@@ -47,11 +47,9 @@ var _default = (0, _utils2.createRule)({
47
47
  },
48
48
 
49
49
  CallExpression(node) {
50
- var _parseJestFnCall;
51
-
52
50
  const {
53
51
  type: jestFnCallType
54
- } = (_parseJestFnCall = (0, _utils2.parseJestFnCall)(node, context)) !== null && _parseJestFnCall !== void 0 ? _parseJestFnCall : {};
52
+ } = (0, _utils2.parseJestFnCall)(node, context) ?? {};
55
53
 
56
54
  if (jestFnCallType === 'test') {
57
55
  inTestCase = true;
@@ -50,10 +50,10 @@ var _default = (0, _utils2.createRule)({
50
50
  create(context) {
51
51
  return {
52
52
  CallExpression(node) {
53
- var _getNodeName$endsWith, _getNodeName;
53
+ var _getNodeName;
54
54
 
55
55
  // done is the second argument for it.each, not the first
56
- const isJestEach = (_getNodeName$endsWith = (_getNodeName = (0, _utils2.getNodeName)(node.callee)) === null || _getNodeName === void 0 ? void 0 : _getNodeName.endsWith('.each')) !== null && _getNodeName$endsWith !== void 0 ? _getNodeName$endsWith : false;
56
+ const isJestEach = ((_getNodeName = (0, _utils2.getNodeName)(node.callee)) === null || _getNodeName === void 0 ? void 0 : _getNodeName.endsWith('.each')) ?? false;
57
57
 
58
58
  if (isJestEach && node.callee.type !== _utils.AST_NODE_TYPES.TaggedTemplateExpression) {
59
59
  // isJestEach but not a TaggedTemplateExpression, so this must be
@@ -107,10 +107,8 @@ var _default = (0, _utils2.createRule)({
107
107
  }
108
108
 
109
109
  if (['toMatchInlineSnapshot', 'toThrowErrorMatchingInlineSnapshot'].includes((0, _utils2.getAccessorValue)(jestFnCall.matcher)) && jestFnCall.args.length) {
110
- var _options$inlineMaxSiz;
111
-
112
110
  reportOnViolation(context, jestFnCall.args[0], { ...options,
113
- maxSize: (_options$inlineMaxSiz = options.inlineMaxSize) !== null && _options$inlineMaxSiz !== void 0 ? _options$inlineMaxSiz : options.maxSize
111
+ maxSize: options.inlineMaxSize ?? options.maxSize
114
112
  });
115
113
  }
116
114
  }
@@ -23,7 +23,7 @@ var _default = (0, _utils.createRule)({
23
23
  }
24
24
  }],
25
25
  messages: {
26
- restrictedChain: 'Use of `{{ chain }}` is disallowed',
26
+ restrictedChain: 'Use of `{{ restriction }}` is disallowed',
27
27
  restrictedChainWithMessage: '{{ message }}'
28
28
  }
29
29
  },
@@ -38,31 +38,19 @@ var _default = (0, _utils.createRule)({
38
38
  return;
39
39
  }
40
40
 
41
- const permutations = [jestFnCall.members];
41
+ const chain = jestFnCall.members.map(nod => (0, _utils.getAccessorValue)(nod)).join('.');
42
42
 
43
- if (jestFnCall.members.length > 2) {
44
- permutations.push([jestFnCall.members[0], jestFnCall.members[1]]);
45
- permutations.push([jestFnCall.members[1], jestFnCall.members[2]]);
46
- }
47
-
48
- if (jestFnCall.members.length > 1) {
49
- permutations.push(...jestFnCall.members.map(nod => [nod]));
50
- }
51
-
52
- for (const permutation of permutations) {
53
- const chain = permutation.map(nod => (0, _utils.getAccessorValue)(nod)).join('.');
54
-
55
- if (chain in restrictedChains) {
56
- const message = restrictedChains[chain];
43
+ for (const [restriction, message] of Object.entries(restrictedChains)) {
44
+ if (chain.startsWith(restriction)) {
57
45
  context.report({
58
46
  messageId: message ? 'restrictedChainWithMessage' : 'restrictedChain',
59
47
  data: {
60
48
  message,
61
- chain
49
+ restriction
62
50
  },
63
51
  loc: {
64
- start: permutation[0].loc.start,
65
- end: permutation[permutation.length - 1].loc.end
52
+ start: jestFnCall.members[0].loc.start,
53
+ end: jestFnCall.members[jestFnCall.members.length - 1].loc.end
66
54
  }
67
55
  });
68
56
  break;
@@ -67,11 +67,9 @@ var _default = (0, _utils.createRule)({
67
67
  'ForOfStatement:exit': exitForLoop,
68
68
 
69
69
  CallExpression(node) {
70
- var _parseJestFnCall;
71
-
72
70
  const {
73
71
  type: jestFnCallType
74
- } = (_parseJestFnCall = (0, _utils.parseJestFnCall)(node, context)) !== null && _parseJestFnCall !== void 0 ? _parseJestFnCall : {};
72
+ } = (0, _utils.parseJestFnCall)(node, context) ?? {};
75
73
 
76
74
  if (jestFnCallType === 'hook' || jestFnCallType === 'describe' || jestFnCallType === 'test') {
77
75
  jestFnCalls.push(jestFnCallType);
@@ -83,11 +81,9 @@ var _default = (0, _utils.createRule)({
83
81
  },
84
82
 
85
83
  'CallExpression:exit'(node) {
86
- var _parseJestFnCall2;
87
-
88
84
  const {
89
85
  type: jestFnCallType
90
- } = (_parseJestFnCall2 = (0, _utils.parseJestFnCall)(node, context)) !== null && _parseJestFnCall2 !== void 0 ? _parseJestFnCall2 : {};
86
+ } = (0, _utils.parseJestFnCall)(node, context) ?? {};
91
87
 
92
88
  if (jestFnCallType === 'test') {
93
89
  inTestCaseCall = false;
@@ -104,10 +104,8 @@ var _default = (0, _utils.createRule)({
104
104
 
105
105
  'CallExpression:exit'(node) {
106
106
  if ((0, _utils.isTypeOfJestFnCall)(node, context, ['describe', 'test'])) {
107
- var _depths$pop;
108
-
109
107
  /* istanbul ignore next */
110
- expressionDepth = (_depths$pop = depths.pop()) !== null && _depths$pop !== void 0 ? _depths$pop : 0;
108
+ expressionDepth = depths.pop() ?? 0;
111
109
  }
112
110
  },
113
111
 
@@ -77,11 +77,9 @@ var _default = (0, _utils2.createRule)({
77
77
  }],
78
78
 
79
79
  create(context) {
80
- var _context$options$;
81
-
82
80
  const {
83
81
  allowedFunctionCalls
84
- } = (_context$options$ = context.options[0]) !== null && _context$options$ !== void 0 ? _context$options$ : {};
82
+ } = context.options[0] ?? {};
85
83
 
86
84
  const checkBlockBody = body => {
87
85
  for (const statement of body) {
@@ -37,11 +37,9 @@ var _default = (0, _utils.createRule)({
37
37
  defaultOptions: [{}],
38
38
 
39
39
  create(context) {
40
- var _context$options$;
41
-
42
40
  const {
43
41
  maxNumberOfTopLevelDescribes = Infinity
44
- } = (_context$options$ = context.options[0]) !== null && _context$options$ !== void 0 ? _context$options$ : {};
42
+ } = context.options[0] ?? {};
45
43
  let numberOfTopLevelDescribeBlocks = 0;
46
44
  let numberOfDescribeBlocks = 0;
47
45
  return {
@@ -28,14 +28,6 @@ const baseRule = (() => {
28
28
  }
29
29
  })();
30
30
 
31
- const tryCreateBaseRule = context => {
32
- try {
33
- return baseRule === null || baseRule === void 0 ? void 0 : baseRule.create(context);
34
- } catch {
35
- return null;
36
- }
37
- };
38
-
39
31
  const DEFAULT_MESSAGE = 'This rule requires `@typescript-eslint/eslint-plugin`';
40
32
 
41
33
  var _default = (0, _utils2.createRule)({
@@ -62,7 +54,7 @@ var _default = (0, _utils2.createRule)({
62
54
  },
63
55
 
64
56
  create(context) {
65
- const baseSelectors = tryCreateBaseRule(context);
57
+ const baseSelectors = baseRule === null || baseRule === void 0 ? void 0 : baseRule.create(context);
66
58
 
67
59
  if (!baseSelectors) {
68
60
  return {};
@@ -69,9 +69,9 @@ const determineJestFnType = name => {
69
69
  const ValidJestFnCallChains = ['afterAll', 'afterEach', 'beforeAll', 'beforeEach', 'describe', 'describe.each', 'describe.only', 'describe.only.each', 'describe.skip', 'describe.skip.each', 'fdescribe', 'fdescribe.each', 'xdescribe', 'xdescribe.each', 'it', 'it.concurrent', 'it.concurrent.each', 'it.concurrent.only.each', 'it.concurrent.skip.each', 'it.each', 'it.failing', 'it.only', 'it.only.each', 'it.only.failing', 'it.skip', 'it.skip.each', 'it.skip.failing', 'it.todo', 'fit', 'fit.each', 'fit.failing', 'xit', 'xit.each', 'xit.failing', 'test', 'test.concurrent', 'test.concurrent.each', 'test.concurrent.only.each', 'test.concurrent.skip.each', 'test.each', 'test.failing', 'test.only', 'test.only.each', 'test.only.failing', 'test.skip', 'test.skip.each', 'test.skip.failing', 'test.todo', 'xtest', 'xtest.each', 'xtest.failing'];
70
70
 
71
71
  const resolvePossibleAliasedGlobal = (global, context) => {
72
- var _context$settings$jes, _context$settings$jes2;
72
+ var _context$settings$jes;
73
73
 
74
- const globalAliases = (_context$settings$jes = (_context$settings$jes2 = context.settings.jest) === null || _context$settings$jes2 === void 0 ? void 0 : _context$settings$jes2.globalAliases) !== null && _context$settings$jes !== void 0 ? _context$settings$jes : {};
74
+ const globalAliases = ((_context$settings$jes = context.settings.jest) === null || _context$settings$jes === void 0 ? void 0 : _context$settings$jes.globalAliases) ?? {};
75
75
  const alias = Object.entries(globalAliases).find(([, aliases]) => aliases.includes(global));
76
76
 
77
77
  if (alias) {
@@ -110,7 +110,7 @@ const parseJestFnCallWithReason = (node, context) => {
110
110
  exports.parseJestFnCallWithReason = parseJestFnCallWithReason;
111
111
 
112
112
  const parseJestFnCallWithReasonInner = (node, context) => {
113
- var _resolved$original, _node$parent2, _node$parent3;
113
+ var _node$parent2, _node$parent3;
114
114
 
115
115
  const chain = getNodeChain(node);
116
116
 
@@ -137,7 +137,7 @@ const parseJestFnCallWithReasonInner = (node, context) => {
137
137
  return null;
138
138
  }
139
139
 
140
- const name = (_resolved$original = resolved.original) !== null && _resolved$original !== void 0 ? _resolved$original : resolved.local;
140
+ const name = resolved.original ?? resolved.local;
141
141
  const links = [name, ...rest.map(link => (0, _utils2.getAccessorValue)(link))];
142
142
 
143
143
  if (name !== 'jest' && name !== 'expect' && !ValidJestFnCallChains.includes(links.join('.'))) {
@@ -293,9 +293,7 @@ const findImportSourceNode = node => {
293
293
  }
294
294
 
295
295
  if (node.type === _utils.AST_NODE_TYPES.CallExpression && (0, _utils2.isIdentifier)(node.callee, 'require')) {
296
- var _node$arguments$;
297
-
298
- return (_node$arguments$ = node.arguments[0]) !== null && _node$arguments$ !== void 0 ? _node$arguments$ : null;
296
+ return node.arguments[0] ?? null;
299
297
  }
300
298
 
301
299
  return null;
@@ -124,12 +124,10 @@ var _default = (0, _utils2.createRule)({
124
124
  mustMatch
125
125
  }]) {
126
126
  const disallowedWordsRegexp = new RegExp(`\\b(${disallowedWords.join('|')})\\b`, 'iu');
127
- const mustNotMatchPatterns = compileMatcherPatterns(mustNotMatch !== null && mustNotMatch !== void 0 ? mustNotMatch : {});
128
- const mustMatchPatterns = compileMatcherPatterns(mustMatch !== null && mustMatch !== void 0 ? mustMatch : {});
127
+ const mustNotMatchPatterns = compileMatcherPatterns(mustNotMatch ?? {});
128
+ const mustMatchPatterns = compileMatcherPatterns(mustMatch ?? {});
129
129
  return {
130
130
  CallExpression(node) {
131
- var _mustNotMatchPatterns, _mustMatchPatterns$je;
132
-
133
131
  const jestFnCall = (0, _utils2.parseJestFnCall)(node, context);
134
132
 
135
133
  if ((jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'describe' && (jestFnCall === null || jestFnCall === void 0 ? void 0 : jestFnCall.type) !== 'test') {
@@ -205,7 +203,7 @@ var _default = (0, _utils2.createRule)({
205
203
  }
206
204
 
207
205
  const jestFunctionName = unprefixedName;
208
- const [mustNotMatchPattern, mustNotMatchMessage] = (_mustNotMatchPatterns = mustNotMatchPatterns[jestFunctionName]) !== null && _mustNotMatchPatterns !== void 0 ? _mustNotMatchPatterns : [];
206
+ const [mustNotMatchPattern, mustNotMatchMessage] = mustNotMatchPatterns[jestFunctionName] ?? [];
209
207
 
210
208
  if (mustNotMatchPattern) {
211
209
  if (mustNotMatchPattern.test(title)) {
@@ -222,7 +220,7 @@ var _default = (0, _utils2.createRule)({
222
220
  }
223
221
  }
224
222
 
225
- const [mustMatchPattern, mustMatchMessage] = (_mustMatchPatterns$je = mustMatchPatterns[jestFunctionName]) !== null && _mustMatchPatterns$je !== void 0 ? _mustMatchPatterns$je : [];
223
+ const [mustMatchPattern, mustMatchMessage] = mustMatchPatterns[jestFunctionName] ?? [];
226
224
 
227
225
  if (mustMatchPattern) {
228
226
  if (!mustMatchPattern.test(title)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "26.9.0",
3
+ "version": "27.0.0",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",
@@ -103,34 +103,34 @@
103
103
  "@babel/core": "^7.4.4",
104
104
  "@babel/preset-env": "^7.4.4",
105
105
  "@babel/preset-typescript": "^7.3.3",
106
- "@commitlint/cli": "^16.0.0",
107
- "@commitlint/config-conventional": "^16.0.0",
106
+ "@commitlint/cli": "^17.0.3",
107
+ "@commitlint/config-conventional": "^17.0.3",
108
108
  "@schemastore/package": "^0.0.6",
109
109
  "@semantic-release/changelog": "^6.0.0",
110
110
  "@semantic-release/git": "^10.0.0",
111
111
  "@types/dedent": "^0.7.0",
112
112
  "@types/jest": "^28.0.0",
113
- "@types/node": "^16.0.0",
113
+ "@types/node": "^14.18.26",
114
114
  "@types/prettier": "^2.0.0",
115
115
  "@typescript-eslint/eslint-plugin": "^5.0.0",
116
116
  "@typescript-eslint/parser": "^5.0.0",
117
- "babel-jest": "^28.0.0",
117
+ "babel-jest": "^29.0.0",
118
118
  "babel-plugin-replace-ts-export-assignment": "^0.0.2",
119
119
  "dedent": "^0.7.0",
120
120
  "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0",
121
121
  "eslint-config-prettier": "^8.3.0",
122
122
  "eslint-plugin-eslint-comments": "^3.1.2",
123
- "eslint-plugin-eslint-plugin": "^4.0.0",
123
+ "eslint-plugin-eslint-plugin": "^5.0.6",
124
124
  "eslint-plugin-import": "^2.25.1",
125
125
  "eslint-plugin-node": "^11.0.0",
126
- "eslint-plugin-prettier": "^3.4.1",
126
+ "eslint-plugin-prettier": "^4.2.1",
127
127
  "eslint-remote-tester": "^3.0.0",
128
128
  "eslint-remote-tester-repositories": "~0.0.5",
129
- "husky": "^7.0.2",
129
+ "husky": "^8.0.1",
130
130
  "is-ci": "^3.0.0",
131
- "jest": "^28.0.0",
132
- "jest-runner-eslint": "^1.0.0",
133
- "lint-staged": "^12.0.0",
131
+ "jest": "^29.0.0",
132
+ "jest-runner-eslint": "^1.1.0",
133
+ "lint-staged": "^13.0.3",
134
134
  "pinst": "^3.0.0",
135
135
  "prettier": "^2.0.5",
136
136
  "rimraf": "^3.0.0",
@@ -141,7 +141,7 @@
141
141
  },
142
142
  "peerDependencies": {
143
143
  "@typescript-eslint/eslint-plugin": "^5.0.0",
144
- "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
144
+ "eslint": "^7.0.0 || ^8.0.0"
145
145
  },
146
146
  "peerDependenciesMeta": {
147
147
  "@typescript-eslint/eslint-plugin": {
@@ -153,6 +153,6 @@
153
153
  },
154
154
  "packageManager": "yarn@3.2.3",
155
155
  "engines": {
156
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
156
+ "node": "^14.15.0 || ^16.10.0 || >=18.0.0"
157
157
  }
158
158
  }
@@ -1,20 +0,0 @@
1
- # Disallow importing Jest (`no-jest-import`)
2
-
3
- The `jest` object is automatically in scope within every test file. The methods
4
- in the `jest` object help create mocks and let you control Jest's overall
5
- behavior. It is therefore completely unnecessary to import in `jest`, as Jest
6
- doesn't export anything in the first place.
7
-
8
- ### Rule details
9
-
10
- This rule reports on any importing of Jest.
11
-
12
- To name a few: `var jest = require('jest');` `const jest = require('jest');`
13
- `import jest from 'jest';` `import {jest as test} from 'jest';`
14
-
15
- There is no correct usage of this code, other than to not import `jest` in the
16
- first place.
17
-
18
- ## Further Reading
19
-
20
- - [The Jest Object](https://facebook.github.io/jest/docs/en/jest-object.html)
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _utils = require("./utils");
9
-
10
- var _default = (0, _utils.createRule)({
11
- name: __filename,
12
- meta: {
13
- type: 'problem',
14
- docs: {
15
- description: 'Disallow importing Jest',
16
- category: 'Best Practices',
17
- recommended: 'error'
18
- },
19
- messages: {
20
- unexpectedImport: `Jest is automatically in scope. Do not import "jest", as Jest doesn't export anything.`
21
- },
22
- schema: []
23
- },
24
- defaultOptions: [],
25
-
26
- create(context) {
27
- return {
28
- 'ImportDeclaration[source.value="jest"]'(node) {
29
- context.report({
30
- node,
31
- messageId: 'unexpectedImport'
32
- });
33
- },
34
-
35
- 'CallExpression[callee.name="require"][arguments.0.value="jest"]'(node) {
36
- context.report({
37
- loc: node.arguments[0].loc,
38
- messageId: 'unexpectedImport',
39
- node
40
- });
41
- }
42
-
43
- };
44
- }
45
-
46
- });
47
-
48
- exports.default = _default;