stylelint-plugin-defensive-css 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/package.json +1 -1
- package/src/utils/findVendorPrefixes.js +4 -2
package/README.md
CHANGED
|
@@ -29,8 +29,17 @@ npm i stylelint-plugin-defensive-css --save-dev
|
|
|
29
29
|
yarn add stylelint-plugin-defensive-css --dev
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
With the plugin installed, the
|
|
33
|
-
|
|
32
|
+
With the plugin installed, the rule(s) can be added to the project's Stylelint
|
|
33
|
+
configuration.
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"plugins": ["stylelint-plugin-defensive-css"],
|
|
38
|
+
"rules": {
|
|
39
|
+
"plugin/use-defensive-css": [true, { "severity": "warning" }]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
34
43
|
|
|
35
44
|
## Rules / Options
|
|
36
45
|
|
package/package.json
CHANGED
|
@@ -3,6 +3,8 @@ const expression = /-\b(moz|ms|o|webkit)\b-/g;
|
|
|
3
3
|
export function findVendorPrefixes(selector) {
|
|
4
4
|
if (!selector) return false;
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const prefixesFound = [...selector.trim().matchAll(expression)];
|
|
7
|
+
const prefixes = new Set(prefixesFound.map((prefix) => prefix[1]));
|
|
8
|
+
|
|
9
|
+
return prefixes.size > 1;
|
|
8
10
|
}
|