stablekit.ts 0.5.2 → 0.5.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/dist/stylelint.cjs +6 -3
- package/dist/stylelint.d.cts +2 -1
- package/dist/stylelint.d.ts +2 -1
- package/dist/stylelint.js +6 -3
- package/package.json +1 -1
package/dist/stylelint.cjs
CHANGED
|
@@ -51,14 +51,17 @@ function createFunctionalTokenPlugin(prefixes) {
|
|
|
51
51
|
function createDescendantColorPlugin() {
|
|
52
52
|
const dataAttrWithDescendant = /\[data-[^\]]+\]\s+[.#\w]/;
|
|
53
53
|
const colorApplyPattern = /\btext-(?!xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl|left|right|center|justify|wrap|nowrap|ellipsis|clip|truncate)\w/;
|
|
54
|
-
const message = `
|
|
54
|
+
const message = `Visual property on a descendant inside a data-attribute selector. Set visual properties on the [data-*] container and let children inherit via currentColor.`;
|
|
55
55
|
const rule = (enabled) => {
|
|
56
56
|
return (root, result) => {
|
|
57
57
|
if (!enabled) return;
|
|
58
58
|
root.walkRules((ruleNode) => {
|
|
59
59
|
if (!dataAttrWithDescendant.test(ruleNode.selector)) return;
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const visualProps = /^(color|background|background-color|border-color|outline-color|fill|stroke|opacity|box-shadow|text-shadow)$/;
|
|
61
|
+
ruleNode.walkDecls((decl) => {
|
|
62
|
+
if (visualProps.test(decl.prop)) {
|
|
63
|
+
result.warn(message, { node: decl });
|
|
64
|
+
}
|
|
62
65
|
});
|
|
63
66
|
ruleNode.walkAtRules("apply", (atRule) => {
|
|
64
67
|
if (colorApplyPattern.test(atRule.params)) {
|
package/dist/stylelint.d.cts
CHANGED
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
* in scoped selectors like `.badge[data-status="paid"]`, not in
|
|
19
19
|
* utilities that can spread via @apply or className.
|
|
20
20
|
*
|
|
21
|
-
* 4. Don't set
|
|
21
|
+
* 4. Don't set visual properties on descendants inside data-attribute selectors.
|
|
22
22
|
* `.card[data-status="error"] .icon { color: red }` is wrong —
|
|
23
23
|
* set color on the container and let children inherit via currentColor.
|
|
24
|
+
* Also catches background, border-color, opacity, box-shadow, etc.
|
|
24
25
|
*
|
|
25
26
|
* 5. Don't animate layout properties (width, height, margin, padding,
|
|
26
27
|
* top/right/bottom/left). These trigger reflow on every frame.
|
package/dist/stylelint.d.ts
CHANGED
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
* in scoped selectors like `.badge[data-status="paid"]`, not in
|
|
19
19
|
* utilities that can spread via @apply or className.
|
|
20
20
|
*
|
|
21
|
-
* 4. Don't set
|
|
21
|
+
* 4. Don't set visual properties on descendants inside data-attribute selectors.
|
|
22
22
|
* `.card[data-status="error"] .icon { color: red }` is wrong —
|
|
23
23
|
* set color on the container and let children inherit via currentColor.
|
|
24
|
+
* Also catches background, border-color, opacity, box-shadow, etc.
|
|
24
25
|
*
|
|
25
26
|
* 5. Don't animate layout properties (width, height, margin, padding,
|
|
26
27
|
* top/right/bottom/left). These trigger reflow on every frame.
|
package/dist/stylelint.js
CHANGED
|
@@ -27,14 +27,17 @@ function createFunctionalTokenPlugin(prefixes) {
|
|
|
27
27
|
function createDescendantColorPlugin() {
|
|
28
28
|
const dataAttrWithDescendant = /\[data-[^\]]+\]\s+[.#\w]/;
|
|
29
29
|
const colorApplyPattern = /\btext-(?!xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl|left|right|center|justify|wrap|nowrap|ellipsis|clip|truncate)\w/;
|
|
30
|
-
const message = `
|
|
30
|
+
const message = `Visual property on a descendant inside a data-attribute selector. Set visual properties on the [data-*] container and let children inherit via currentColor.`;
|
|
31
31
|
const rule = (enabled) => {
|
|
32
32
|
return (root, result) => {
|
|
33
33
|
if (!enabled) return;
|
|
34
34
|
root.walkRules((ruleNode) => {
|
|
35
35
|
if (!dataAttrWithDescendant.test(ruleNode.selector)) return;
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const visualProps = /^(color|background|background-color|border-color|outline-color|fill|stroke|opacity|box-shadow|text-shadow)$/;
|
|
37
|
+
ruleNode.walkDecls((decl) => {
|
|
38
|
+
if (visualProps.test(decl.prop)) {
|
|
39
|
+
result.warn(message, { node: decl });
|
|
40
|
+
}
|
|
38
41
|
});
|
|
39
42
|
ruleNode.walkAtRules("apply", (atRule) => {
|
|
40
43
|
if (colorApplyPattern.test(atRule.params)) {
|
package/package.json
CHANGED