Skip to content

Commit

Permalink
fix: add review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
viestat committed Jul 1, 2020
1 parent 825687e commit 96eaf9b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/rules/__tests__/no-interpolation-inline-snapshot.test.ts
Expand Up @@ -18,7 +18,9 @@ ruleTester.run('no-interpolation-inline-snapshot', rule, {
'expect(something).not;',
'expect.toHaveAssertions();',
'myObjectWants.toMatchInlineSnapshot({}, `${interpolated}`);',
'myObjectWants.toMatchInlineSnapshot({}, `${interpolated1} ${interpolated2}`);',
'toMatchInlineSnapshot({}, `${interpolated}`);',
'toMatchInlineSnapshot({}, `${interpolated1} ${interpolated2}`);',
'expect(something).toThrowErrorMatchingInlineSnapshot();',
'expect(something).toThrowErrorMatchingInlineSnapshot(`No interpolation`);',
],
Expand Down
34 changes: 17 additions & 17 deletions src/rules/no-interpolation-inline-snapshot.ts
Expand Up @@ -27,25 +27,25 @@ export default createRule({
const { matcher } = parseExpectCall(node);

if (
(matcher?.name !== 'toMatchInlineSnapshot' &&
matcher?.name !== 'toThrowErrorMatchingInlineSnapshot') ||
matcher?.arguments === null
matcher &&
[
'toMatchInlineSnapshot',
'toThrowErrorMatchingInlineSnapshot',
].includes(matcher.name)
) {
return;
// Check all since the optional 'propertyMatchers' argument might be present
matcher.arguments?.forEach(argument => {
if (
argument.type === AST_NODE_TYPES.TemplateLiteral &&
argument.expressions.length > 0
) {
context.report({
messageId: 'noInterpolation',
node: argument,
});
}
});
}

// Check all since the optional 'propertyMatchers' argument might be present
matcher.arguments.forEach(argument => {
if (
argument.type === AST_NODE_TYPES.TemplateLiteral &&
argument.expressions.length > 0
) {
context.report({
messageId: 'noInterpolation',
node: argument,
});
}
});
},
};
},
Expand Down

0 comments on commit 96eaf9b

Please sign in to comment.