source: frontend/node_modules/eslint-plugin-jest/lib/rules/prefer-called-with.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _utils = require("./utils");
9
10var _default = (0, _utils.createRule)({
11 name: __filename,
12 meta: {
13 docs: {
14 category: 'Best Practices',
15 description: 'Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`',
16 recommended: false
17 },
18 messages: {
19 preferCalledWith: 'Prefer {{name}}With(/* expected args */)'
20 },
21 type: 'suggestion',
22 schema: []
23 },
24 defaultOptions: [],
25
26 create(context) {
27 return {
28 CallExpression(node) {
29 if (!(0, _utils.isExpectCall)(node)) {
30 return;
31 }
32
33 const {
34 modifier,
35 matcher
36 } = (0, _utils.parseExpectCall)(node); // Could check resolves/rejects here but not a likely idiom.
37
38 if (matcher && !modifier) {
39 if (['toBeCalled', 'toHaveBeenCalled'].includes(matcher.name)) {
40 context.report({
41 data: {
42 name: matcher.name
43 },
44 // todo: rename to 'matcherName'
45 messageId: 'preferCalledWith',
46 node: matcher.node.property
47 });
48 }
49 }
50 }
51
52 };
53 }
54
55});
56
57exports.default = _default;
Note: See TracBrowser for help on using the repository browser.