Skip to content

Commit

Permalink
Support Agnostic Formatting for Hover Media Queries (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuschick authored Oct 18, 2023
1 parent 4f15d85 commit 2df9902
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stylelint-plugin-defensive-css",
"version": "0.9.1",
"version": "0.9.2",
"description": "A Stylelint plugin to enforce defensive CSS best practices.",
"main": "src/index.js",
"files": [
Expand Down
5 changes: 1 addition & 4 deletions src/rules/use-defensive-css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ function traverseParentRules(parent) {
}

if (parent.parent.type === 'atrule') {
if (
parent.parent.params &&
/\(hover(: hover)?\)/.test(parent.parent.params)
) {
if (parent.parent.params && /hover(: hover)?/.test(parent.parent.params)) {
isWrappedInHoverAtRule = true;
} else {
traverseParentRules(parent.parent);
Expand Down
4 changes: 4 additions & 0 deletions src/rules/use-defensive-css/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ testRule({
code: `@media (hover: hover) { .btn:hover { color: black; } }`,
description: 'Use media query for button hover state.',
},
{
code: `@media ( hover: hover ) { .btn:hover { color: black; } }`,
description: 'Use media query for button hover state with spaces.',
},
{
code: `@media (hover) { .btn:hover { color: black; } }`,
description: 'Use shorthand media query for button hover state.',
Expand Down

0 comments on commit 2df9902

Please sign in to comment.