Skip to content

Commit

Permalink
Fix false positives for objects in declaration-block-trailing-semicol…
Browse files Browse the repository at this point in the history
…on (#4749)
  • Loading branch information
srawlins committed May 16, 2020
1 parent 8870cef commit 38968c7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/rules/declaration-block-trailing-semicolon/__tests__/index.js
Expand Up @@ -171,3 +171,28 @@ testRule({
},
],
});

testRule({
ruleName,
config: ['always'],
syntax: 'css-in-js',
fix: true,

accept: [
{
code: 'const C = () => { return <a style={{ color: "red" }}></a> }',
description: 'css-in-js object',
},
],

reject: [
{
code: 'const C = styled.a`color: red`;',
fixed: 'const C = styled.a`color: red;`;',
description: 'css-in-js template literal',
message: messages.expected,
line: 1,
column: 29,
},
],
});
4 changes: 4 additions & 0 deletions lib/rules/declaration-block-trailing-semicolon/index.js
Expand Up @@ -42,6 +42,10 @@ function rule(expectation, _, context) {
});

root.walkDecls((decl) => {
if (decl.parent.type === 'object') {
return;
}

if (decl !== decl.parent.last) {
return;
}
Expand Down

0 comments on commit 38968c7

Please sign in to comment.