Skip to content

Commit

Permalink
declaration-block-trailing-semicolon: Do not report non-rule declarat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
srawlins committed May 6, 2020
1 parent 0376cf9 commit bae6a95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Expand Up @@ -25,6 +25,10 @@ testRule(rule, {
code: 'a { color: red; &:hover { color: pink; }}',
description: 'nesting with first-level decl',
},
{
code: 'background: white',
description: 'not a rule',
},
],

reject: [
Expand Down Expand Up @@ -77,6 +81,10 @@ testRule(rule, {
code: 'a { background: orange; color: pink }',
description: 'multi-line declaration block without trailing semicolon',
},
{
code: 'background: white;',
description: 'not a rule',
},
],

reject: [
Expand Down
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 !== 'rule' && decl.parent.type !== 'atrule') {
return;
}

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

0 comments on commit bae6a95

Please sign in to comment.