@longzai-intelligence-oxlint/design-rules-plugin 0.1.23 → 0.1.25
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/index.js +3 -3
- package/package.json +11 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=/(?:bg|text|border|fill|stroke|ring|outline|from|to|via|caret|accent|decoration|shadow)-\[(?:#[0-9a-fA-F]{3,8}|(?:rgb|rgba|hsl|hsla|oklch)\([^)]*\))\]/g;function r(e){let t=e.trim();return t.startsWith(`//`)||t.startsWith(`*`)||t.startsWith(`/*`)||t.startsWith(`<!--`)}const i=e({meta:{type:`problem`,docs:{description:`禁止在 className 中硬编码颜色,强制使用设计令牌语义色(如 bg-primary)`}},createOnce(e){return{Program(t){let i=e.sourceCode.text.split(`
|
|
2
|
-
`);for(let a=0;a<i.length;a+=1){if(r(
|
|
3
|
-
`);for(let r=0;r<n.length;r+=1){if(o(
|
|
4
|
-
`);for(let r=0;r<n.length;r+=1){if(u(
|
|
2
|
+
`);for(let a=0;a<i.length;a+=1){let o=i[a];if(o===void 0||r(o))continue;n.lastIndex=0;let s=n.exec(o);s&&e.report({node:t,message:`禁止硬编码颜色 "${s[0]}":请使用设计令牌语义色(如 bg-primary / text-muted-foreground),见 foundations/color 规范。`})}}}}}),a=/\b(?:p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|gap|gap-x|gap-y|w|h|min-w|min-h|max-w|max-h|space-x|space-y|inset|top|right|bottom|left)-\[\d+(?:\.\d+)?(?:px|rem|em)\]/g;function o(e){let t=e.trim();return t.startsWith(`//`)||t.startsWith(`*`)||t.startsWith(`/*`)||t.startsWith(`<!--`)}const s=e({meta:{type:`problem`,docs:{description:`禁止在 className 中使用任意值间距,强制使用间距刻度(如 p-6 / gap-2)`}},createOnce(e){return{Program(t){let n=e.sourceCode.text.split(`
|
|
3
|
+
`);for(let r=0;r<n.length;r+=1){let i=n[r];if(i===void 0||o(i))continue;a.lastIndex=0;let s=a.exec(i);s&&e.report({node:t,message:`禁止任意值间距 "${s[0]}":请使用间距刻度(如 p-6 / gap-2)或语义别名,见 foundations/spacing 规范。`})}}}}}),c=/\bz-\[\d+\]/g,l=/zIndex\s*:\s*\d+/g;function u(e){let t=e.trim();return t.startsWith(`//`)||t.startsWith(`*`)||t.startsWith(`/*`)||t.startsWith(`<!--`)}const d=e({meta:{type:`problem`,docs:{description:`禁止硬编码 z-index,强制使用层级令牌(如 z-dropdown / z-modal / z-toast)`}},createOnce(e){return{Program(t){let n=e.sourceCode.text.split(`
|
|
4
|
+
`);for(let r=0;r<n.length;r+=1){let i=n[r];if(i===void 0||u(i))continue;c.lastIndex=0;let a=c.exec(i);if(a){e.report({node:t,message:`禁止魔法 z-index "${a[0]}":请使用层级令牌(如 z-dropdown / z-modal / z-toast),见 foundations/elevation 规范。`});continue}l.lastIndex=0;let o=l.exec(i);o&&e.report({node:t,message:`禁止硬编码 zIndex "${o[0]}":请使用层级令牌(如 z-dropdown / z-modal / z-toast),见 foundations/elevation 规范。`})}}}}}),f=t({meta:{name:`@longzai-intelligence-oxlint/design-rules-plugin`},rules:{"no-hardcoded-color":i,"no-hardcoded-spacing":s,"no-magic-z-index":d}});export{f as default,f as designRulesPlugin,i as noHardcodedColorRule,s as noHardcodedSpacingRule,d as noMagicZIndexRule};
|
package/package.json
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-oxlint/design-rules-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
|
+
"description": "Longzai Intelligence oxlint 设计规范规则插件",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"design",
|
|
7
|
+
"longzai-intelligence",
|
|
8
|
+
"oxlint",
|
|
9
|
+
"rules",
|
|
10
|
+
"tokens"
|
|
11
|
+
],
|
|
4
12
|
"license": "UNLICENSED",
|
|
5
13
|
"files": [
|
|
6
14
|
"dist"
|
|
@@ -35,8 +43,8 @@
|
|
|
35
43
|
"typecheck:test": "lzi-tsgo typecheck tsconfig/test.json"
|
|
36
44
|
},
|
|
37
45
|
"dependencies": {
|
|
38
|
-
"@longzai-intelligence-oxlint/core": "0.1.
|
|
39
|
-
"@longzai-intelligence-oxlint/utils": "0.1.
|
|
46
|
+
"@longzai-intelligence-oxlint/core": "0.1.25",
|
|
47
|
+
"@longzai-intelligence-oxlint/utils": "0.1.25",
|
|
40
48
|
"@oxlint/plugins": "^1.74.0"
|
|
41
49
|
},
|
|
42
50
|
"devDependencies": {
|