stylelint-plugin-defensive-css 0.10.0 → 0.10.2
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
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stylelint-plugin-defensive-css",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "A Stylelint plugin to enforce defensive CSS best practices.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
"stylelint": "^14.0.0 || ^15.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@commitlint/cli": "^
|
|
39
|
-
"@commitlint/config-conventional": "^
|
|
38
|
+
"@commitlint/cli": "^18.2.0",
|
|
39
|
+
"@commitlint/config-conventional": "^18.1.0",
|
|
40
40
|
"eslint": "^8.35.0",
|
|
41
41
|
"husky": "^8.0.0",
|
|
42
42
|
"jest": "^29.4.3",
|
|
43
43
|
"jest-cli": "^29.4.3",
|
|
44
44
|
"jest-preset-stylelint": "^6.1.0",
|
|
45
|
-
"lint-staged": "^
|
|
46
|
-
"prettier": "^
|
|
47
|
-
"prettier-eslint": "^
|
|
45
|
+
"lint-staged": "^15.0.2",
|
|
46
|
+
"prettier": "^3.0.3",
|
|
47
|
+
"prettier-eslint": "^16.1.2",
|
|
48
48
|
"stylelint": "^15.2.0"
|
|
49
49
|
},
|
|
50
50
|
"lint-staged": {
|
|
@@ -6,25 +6,25 @@ const ruleName = 'plugin/use-defensive-css';
|
|
|
6
6
|
|
|
7
7
|
const ruleMessages = stylelint.utils.ruleMessages(ruleName, {
|
|
8
8
|
accidentalHover() {
|
|
9
|
-
return 'To prevent accidental hover states on mobile devices, wrap
|
|
9
|
+
return 'To prevent accidental hover states on mobile devices, wrap `:hover` selectors inside a `@media (hover: hover) { ...your styles }` query. Learn more: https://defensivecss.dev/tip/hover-media/';
|
|
10
10
|
},
|
|
11
11
|
backgroundRepeat() {
|
|
12
|
-
return '
|
|
12
|
+
return 'Whenever setting a background image, be sure to explicitly define a `background-repeat` value. Learn more: https://defensivecss.dev/tip/bg-repeat/';
|
|
13
13
|
},
|
|
14
14
|
customPropertyFallbacks() {
|
|
15
|
-
return '
|
|
15
|
+
return 'Provide a fallback value for a custom property like `var(--your-custom-property, #000000)` to prevent issues in the event the custom property is not defined. Learn more: https://defensivecss.dev/tip/css-variable-fallback/';
|
|
16
16
|
},
|
|
17
17
|
flexWrapping() {
|
|
18
|
-
return '
|
|
19
|
-
},
|
|
20
|
-
scrollbarGutter() {
|
|
21
|
-
return `Containers with an auto or scroll 'overflow' must also have a 'scrollbar-gutter' property defined.`;
|
|
18
|
+
return 'Whenever setting an element to `display: flex` a `flex-wrap` value must be defined. Set `flex-wrap: nowrap` for the default behavior. Learn more: https://defensivecss.dev/tip/flexbox-wrapping/';
|
|
22
19
|
},
|
|
23
20
|
scrollChaining() {
|
|
24
|
-
return
|
|
21
|
+
return 'To prevent scroll chaining between contexts, any container with a scrollable overflow must have a `overscroll-behavior` value defined. Learn more: https://defensivecss.dev/tip/scroll-chain/';
|
|
22
|
+
},
|
|
23
|
+
scrollbarGutter() {
|
|
24
|
+
return 'To prevent potential layout shifts, any container with a scrollable overflow must have a `scrollbar-gutter` value defined. Learn more: https://defensivecss.dev/tip/scrollbar-gutter/';
|
|
25
25
|
},
|
|
26
26
|
vendorPrefixWGrouping() {
|
|
27
|
-
return `
|
|
27
|
+
return `To prevent invalid rules in unsupported environments, split each vendor prefix into its own, individual rule. Learn more: https://defensivecss.dev/tip/grouping-selectors/`;
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -198,65 +198,65 @@ const ruleFunction = (_, options) => {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
/*
|
|
202
|
-
if (options?.['
|
|
201
|
+
/* SCROLL CHAINING */
|
|
202
|
+
if (options?.['scroll-chaining']) {
|
|
203
203
|
if (
|
|
204
204
|
overflowProperties.includes(decl.prop) &&
|
|
205
205
|
(decl.value.includes('auto') || decl.value.includes('scroll'))
|
|
206
206
|
) {
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
scrollChainingProps.hasOverflow = true;
|
|
208
|
+
scrollChainingProps.nodeToReport = decl;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
if (decl.prop.includes('
|
|
212
|
-
|
|
211
|
+
if (decl.prop.includes('overscroll-behavior')) {
|
|
212
|
+
scrollChainingProps.hasOverscrollBehavior = true;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
if (isLastStyleDeclaration) {
|
|
216
216
|
if (
|
|
217
|
-
|
|
218
|
-
!
|
|
217
|
+
scrollChainingProps.hasOverflow &&
|
|
218
|
+
!scrollChainingProps.hasOverscrollBehavior
|
|
219
219
|
) {
|
|
220
220
|
stylelint.utils.report({
|
|
221
|
-
message: ruleMessages.
|
|
222
|
-
node:
|
|
221
|
+
message: ruleMessages.scrollChaining(),
|
|
222
|
+
node: scrollChainingProps.nodeToReport,
|
|
223
223
|
result,
|
|
224
224
|
ruleName,
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
|
|
228
|
+
scrollChainingProps = { ...defaultScrollChainingProps };
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
/*
|
|
233
|
-
if (options?.['
|
|
232
|
+
/* SCROLLBAR GUTTER */
|
|
233
|
+
if (options?.['scrollbar-gutter']) {
|
|
234
234
|
if (
|
|
235
235
|
overflowProperties.includes(decl.prop) &&
|
|
236
236
|
(decl.value.includes('auto') || decl.value.includes('scroll'))
|
|
237
237
|
) {
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
scrollbarGutterProps.hasOverflow = true;
|
|
239
|
+
scrollbarGutterProps.nodeToReport = decl;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
if (decl.prop.includes('
|
|
243
|
-
|
|
242
|
+
if (decl.prop.includes('scrollbar-gutter')) {
|
|
243
|
+
scrollbarGutterProps.hasScrollbarGutter = true;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
if (isLastStyleDeclaration) {
|
|
247
247
|
if (
|
|
248
|
-
|
|
249
|
-
!
|
|
248
|
+
scrollbarGutterProps.hasOverflow &&
|
|
249
|
+
!scrollbarGutterProps.hasScrollbarGutter
|
|
250
250
|
) {
|
|
251
251
|
stylelint.utils.report({
|
|
252
|
-
message: ruleMessages.
|
|
253
|
-
node:
|
|
252
|
+
message: ruleMessages.scrollbarGutter(),
|
|
253
|
+
node: scrollbarGutterProps.nodeToReport,
|
|
254
254
|
result,
|
|
255
255
|
ruleName,
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
|
|
259
|
+
scrollbarGutterProps = { ...defaultScrollbarGutterProps };
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
|