source: frontend/node_modules/eslint-plugin-jest/lib/rules/no-interpolation-in-snapshots.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.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _experimentalUtils = require("@typescript-eslint/experimental-utils");
9
10var _utils = require("./utils");
11
12var _default = (0, _utils.createRule)({
13 name: __filename,
14 meta: {
15 docs: {
16 category: 'Best Practices',
17 description: 'Disallow string interpolation inside snapshots',
18 recommended: 'error'
19 },
20 messages: {
21 noInterpolation: 'Do not use string interpolation inside of snapshots'
22 },
23 schema: [],
24 type: 'problem'
25 },
26 defaultOptions: [],
27
28 create(context) {
29 return {
30 CallExpression(node) {
31 if (!(0, _utils.isExpectCall)(node)) {
32 return;
33 }
34
35 const {
36 matcher
37 } = (0, _utils.parseExpectCall)(node);
38
39 if (!matcher) {
40 return;
41 }
42
43 if (['toMatchInlineSnapshot', 'toThrowErrorMatchingInlineSnapshot'].includes(matcher.name)) {
44 var _matcher$arguments;
45
46 // Check all since the optional 'propertyMatchers' argument might be present
47 (_matcher$arguments = matcher.arguments) === null || _matcher$arguments === void 0 ? void 0 : _matcher$arguments.forEach(argument => {
48 if (argument.type === _experimentalUtils.AST_NODE_TYPES.TemplateLiteral && argument.expressions.length > 0) {
49 context.report({
50 messageId: 'noInterpolation',
51 node: argument
52 });
53 }
54 });
55 }
56 }
57
58 };
59 }
60
61});
62
63exports.default = _default;
Note: See TracBrowser for help on using the repository browser.