1 | 'use strict';
|
2 |
|
3 | const { getDocsUrl } = require('./util');
|
4 |
|
5 | module.exports = {
|
6 | meta: {
|
7 | docs: {
|
8 | url: getDocsUrl(__filename),
|
9 | },
|
10 | fixable: 'code',
|
11 | },
|
12 | create(context) {
|
13 | return {
|
14 | CallExpression(node) {
|
15 | const propertyName = node.callee.property && node.callee.property.name;
|
16 | if (propertyName === 'toMatchSnapshot') {
|
17 | context.report({
|
18 | fix(fixer) {
|
19 | return [
|
20 | fixer.replaceText(
|
21 | node.callee.property,
|
22 | 'toMatchInlineSnapshot'
|
23 | ),
|
24 | ];
|
25 | },
|
26 | message: 'Use toMatchInlineSnapshot() instead',
|
27 | node: node.callee.property,
|
28 | });
|
29 | } else if (propertyName === 'toThrowErrorMatchingSnapshot') {
|
30 | context.report({
|
31 | fix(fixer) {
|
32 | return [
|
33 | fixer.replaceText(
|
34 | node.callee.property,
|
35 | 'toThrowErrorMatchingInlineSnapshot'
|
36 | ),
|
37 | ];
|
38 | },
|
39 | message: 'Use toThrowErrorMatchingInlineSnapshot() instead',
|
40 | node: node.callee.property,
|
41 | });
|
42 | }
|
43 | },
|
44 | };
|
45 | },
|
46 | };
|