diff --git a/package.json b/package.json index 60751b5..a654937 100644 --- a/package.json +++ b/package.json @@ -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": [ diff --git a/src/rules/use-defensive-css/index.js b/src/rules/use-defensive-css/index.js index 9f790ab..3ea4d68 100644 --- a/src/rules/use-defensive-css/index.js +++ b/src/rules/use-defensive-css/index.js @@ -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); diff --git a/src/rules/use-defensive-css/index.test.js b/src/rules/use-defensive-css/index.test.js index f708e17..6736482 100644 --- a/src/rules/use-defensive-css/index.test.js +++ b/src/rules/use-defensive-css/index.test.js @@ -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.',