Skip to content

Commit

Permalink
Fix False Positive Vendor Prefix Error (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuschick authored Dec 28, 2023
1 parent eb0f6cd commit 7af73b7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.10.2",
"version": "0.10.3",
"description": "A Stylelint plugin to enforce defensive CSS best practices.",
"main": "src/index.js",
"files": [
Expand Down
15 changes: 15 additions & 0 deletions src/rules/use-defensive-css/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,21 @@ testRule({
config: [true, { 'vendor-prefix-grouping': true }],
plugins: ['./index.js'],
accept: [
{
code: `.menu-item {
&.menu-item-has-children::after,
&.menu-item-has-grandchildren::after {
content: '';
position: absolute;
top: 24px;
right: 30px;
width: 18px;
height: 18px;
background-size: contain;
}
}`,
description: 'Nested scss with no prefixes defined.',
},
{
code: `input::-webkit-input-placeholder { color: #222; } input::-moz-placeholder { color: #222; }`,
description:
Expand Down
4 changes: 3 additions & 1 deletion src/utils/findVendorPrefixes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const expression = /-[moz|ms|o|webkit|]+-/g;
const expression = /-\b(moz|ms|o|webkit)\b-/g;

function findVendorPrefixes(selector) {
console.log(selector);
if (!selector) return false;

let prefixesFound = [...selector.trim().matchAll(expression)];
console.log(prefixesFound);
return prefixesFound.length > 1;
}

Expand Down

0 comments on commit 7af73b7

Please sign in to comment.