@lark-apaas/fullstack-presets 1.1.5-beta.19 → 1.1.5-beta.20

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.
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * 自定义 Stylelint 规则:校验 CSS 声明中非法的 hsl() 写法
3
3
  *
4
- * 遍历所有 CSS 声明(包括自定义属性 --*),当值中包含 hsl() 时,
4
+ * 遍历所有 CSS 声明(包括自定义属性 --*),当值以 hsl()/hsla() 开头时,
5
5
  * 使用 css-tree 的词法器验证其是否符合 CSS color 规范。
6
6
  *
7
+ * 注意:只处理纯颜色值声明,不处理复合值(如 box-shadow、background 等)中的 hsl()。
8
+ *
7
9
  * 非法示例:
8
10
  * --color: hsl(100%, 50%, 26%); // hue 不能是百分比
9
11
  * --color: hsl(200 50% 26% 0.5); // alpha 缺少斜杠
@@ -15,6 +17,10 @@
15
17
  * --color: hsl(200 50% 26%); // CSS4 空格写法
16
18
  * --color: hsl(200deg 50% 26%); // 带单位的 hue
17
19
  * --color: hsl(200 50% 26% / 0.5); // CSS4 带 alpha
20
+ *
21
+ * 跳过(不检查)的示例:
22
+ * --shadow: 0px 2px 12px hsl(0 0% 0% / 0.01); // 复合值中的 hsl
23
+ * background: linear-gradient(hsl(...), ...); // 复合值中的 hsl
18
24
  */
19
25
  import stylelint from 'stylelint';
20
26
  export declare const ruleName = "custom/hsl-valid-value";
@@ -40,9 +40,11 @@ exports.meta = exports.messages = exports.ruleName = void 0;
40
40
  /**
41
41
  * 自定义 Stylelint 规则:校验 CSS 声明中非法的 hsl() 写法
42
42
  *
43
- * 遍历所有 CSS 声明(包括自定义属性 --*),当值中包含 hsl() 时,
43
+ * 遍历所有 CSS 声明(包括自定义属性 --*),当值以 hsl()/hsla() 开头时,
44
44
  * 使用 css-tree 的词法器验证其是否符合 CSS color 规范。
45
45
  *
46
+ * 注意:只处理纯颜色值声明,不处理复合值(如 box-shadow、background 等)中的 hsl()。
47
+ *
46
48
  * 非法示例:
47
49
  * --color: hsl(100%, 50%, 26%); // hue 不能是百分比
48
50
  * --color: hsl(200 50% 26% 0.5); // alpha 缺少斜杠
@@ -54,6 +56,10 @@ exports.meta = exports.messages = exports.ruleName = void 0;
54
56
  * --color: hsl(200 50% 26%); // CSS4 空格写法
55
57
  * --color: hsl(200deg 50% 26%); // 带单位的 hue
56
58
  * --color: hsl(200 50% 26% / 0.5); // CSS4 带 alpha
59
+ *
60
+ * 跳过(不检查)的示例:
61
+ * --shadow: 0px 2px 12px hsl(0 0% 0% / 0.01); // 复合值中的 hsl
62
+ * background: linear-gradient(hsl(...), ...); // 复合值中的 hsl
57
63
  */
58
64
  const stylelint_1 = __importDefault(require("stylelint"));
59
65
  const csstree = __importStar(require("css-tree"));
@@ -74,9 +80,9 @@ const rule = primary => {
74
80
  if (!validOptions || !primary)
75
81
  return;
76
82
  root.walkDecls(decl => {
77
- const value = decl.value;
78
- // 只处理包含 hsl( 的声明值
79
- if (!/hsl\(/i.test(value))
83
+ const value = decl.value.trim();
84
+ // 只处理纯 hsl/hsla 颜色值,跳过复合值(如 box-shadow)
85
+ if (!/^hsla?\(/i.test(value))
80
86
  return;
81
87
  try {
82
88
  const ast = csstree.parse(value, { context: 'value' });
@@ -59,7 +59,7 @@ exports.default = {
59
59
  'no-case-declarations': 'off', // 允许在 case 块中使用词法声明
60
60
  'no-empty': 'off', // 允许空的 catch 块
61
61
  // Import 规则
62
- 'import/no-unresolved': 'error', // 检查导入路径是否存在
62
+ 'import/no-unresolved': ['error', { ignore: ['\\?raw$'] }], // 检查导入路径是否存在,忽略 ?raw 查询参数
63
63
  // 其他规则
64
64
  'no-constant-binary-expression': 'off', // 不强制使用常量二进制表达式
65
65
  // React Refresh 相关 - 开发时不影响渲染的检测
@@ -186,7 +186,7 @@ const baseConfig = {
186
186
  'no-useless-escape': 'off',
187
187
  'no-case-declarations': 'off',
188
188
  // Import 规则
189
- 'import/no-unresolved': 'error', // 检查导入路径是否存在
189
+ 'import/no-unresolved': ['error', { ignore: ['\\?raw$'] }], // 检查导入路径是否存在,忽略 ?raw 查询参数
190
190
  // 其他规则
191
191
  'no-constant-binary-expression': 'off', // 不强制使用常量二进制表达式
192
192
  // React Refresh 相关 - 开发时不影响渲染的检测
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-presets",
3
- "version": "1.1.5-beta.19",
3
+ "version": "1.1.5-beta.20",
4
4
  "files": [
5
5
  "lib"
6
6
  ],