canicode 0.3.2 → 0.3.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 +1 -1
- package/dist/cli/index.js +32 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +32 -12
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +30 -11
- package/dist/mcp/server.js.map +1 -1
- package/docs/CUSTOMIZATION.md +1 -1
- package/package.json +1 -1
package/dist/mcp/server.js
CHANGED
|
@@ -147,7 +147,7 @@ var RULE_CONFIGS = {
|
|
|
147
147
|
score: -2,
|
|
148
148
|
enabled: true,
|
|
149
149
|
options: {
|
|
150
|
-
gridBase:
|
|
150
|
+
gridBase: 4
|
|
151
151
|
}
|
|
152
152
|
},
|
|
153
153
|
"magic-number-spacing": {
|
|
@@ -155,7 +155,7 @@ var RULE_CONFIGS = {
|
|
|
155
155
|
score: -4,
|
|
156
156
|
enabled: true,
|
|
157
157
|
options: {
|
|
158
|
-
gridBase:
|
|
158
|
+
gridBase: 4
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
161
|
"raw-shadow": {
|
|
@@ -726,6 +726,12 @@ function transformNode(node) {
|
|
|
726
726
|
if ("layoutPositioning" in node && node.layoutPositioning) {
|
|
727
727
|
base.layoutPositioning = node.layoutPositioning;
|
|
728
728
|
}
|
|
729
|
+
if ("layoutSizingHorizontal" in node && node.layoutSizingHorizontal) {
|
|
730
|
+
base.layoutSizingHorizontal = node.layoutSizingHorizontal;
|
|
731
|
+
}
|
|
732
|
+
if ("layoutSizingVertical" in node && node.layoutSizingVertical) {
|
|
733
|
+
base.layoutSizingVertical = node.layoutSizingVertical;
|
|
734
|
+
}
|
|
729
735
|
if ("primaryAxisAlignItems" in node) {
|
|
730
736
|
base.primaryAxisAlignItems = node.primaryAxisAlignItems;
|
|
731
737
|
}
|
|
@@ -1453,7 +1459,7 @@ ${figmaToken ? ` <script>
|
|
|
1453
1459
|
const res = await fetch('https://api.figma.com/v1/files/' + fileKey + '/comments', {
|
|
1454
1460
|
method: 'POST',
|
|
1455
1461
|
headers: { 'X-FIGMA-TOKEN': FIGMA_TOKEN, 'Content-Type': 'application/json' },
|
|
1456
|
-
body: JSON.stringify({ message: commentBody, client_meta: { node_id: nodeId } }),
|
|
1462
|
+
body: JSON.stringify({ message: commentBody, client_meta: { node_id: nodeId, node_offset: { x: 0, y: 0 } } }),
|
|
1457
1463
|
});
|
|
1458
1464
|
if (!res.ok) throw new Error(await res.text());
|
|
1459
1465
|
btn.textContent = 'Sent \\u2713';
|
|
@@ -1707,6 +1713,12 @@ function createPromptBasedCheck(_cr) {
|
|
|
1707
1713
|
};
|
|
1708
1714
|
}
|
|
1709
1715
|
|
|
1716
|
+
// src/rules/excluded-names.ts
|
|
1717
|
+
var EXCLUDED_NAME_PATTERN = /(badge|close|dismiss|overlay|float|fab|dot|indicator|corner|decoration|tag|status|notification|icon|ico|image|asset|filter|dim|dimmed|bg|background|logo|avatar|divider|separator|nav|navigation|gnb|header|footer|sidebar|toolbar|modal|dialog|popup|toast|tooltip|dropdown|menu|sticky|spinner|loader|cursor|cta|chatbot|thumb|thumbnail|tabbar|tab-bar|statusbar|status-bar)/i;
|
|
1718
|
+
function isExcludedName(name) {
|
|
1719
|
+
return EXCLUDED_NAME_PATTERN.test(name);
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1710
1722
|
// src/rules/layout/index.ts
|
|
1711
1723
|
function isContainerNode(node) {
|
|
1712
1724
|
return node.type === "FRAME" || node.type === "GROUP" || node.type === "COMPONENT";
|
|
@@ -1748,7 +1760,6 @@ var absolutePositionInAutoLayoutDef = {
|
|
|
1748
1760
|
impact: "Element will not respond to sibling changes, may overlap unexpectedly",
|
|
1749
1761
|
fix: "Remove absolute positioning or use proper Auto Layout alignment"
|
|
1750
1762
|
};
|
|
1751
|
-
var INTENTIONAL_ABSOLUTE_PATTERNS = /^(badge|close|dismiss|overlay|float|fab|dot|indicator|corner|decoration|tag|status|notification|x|icon[-_ ]?(close|dismiss|x)|btn[-_ ]?(close|dismiss))/i;
|
|
1752
1763
|
function isSmallRelativeToParent(node, parent) {
|
|
1753
1764
|
const nodeBB = node.absoluteBoundingBox;
|
|
1754
1765
|
const parentBB = parent.absoluteBoundingBox;
|
|
@@ -1762,7 +1773,8 @@ var absolutePositionInAutoLayoutCheck = (node, context) => {
|
|
|
1762
1773
|
if (!context.parent) return null;
|
|
1763
1774
|
if (!hasAutoLayout(context.parent)) return null;
|
|
1764
1775
|
if (node.layoutPositioning !== "ABSOLUTE") return null;
|
|
1765
|
-
if (
|
|
1776
|
+
if (node.type === "VECTOR" || node.type === "BOOLEAN_OPERATION" || node.type === "LINE" || node.type === "ELLIPSE" || node.type === "STAR" || node.type === "REGULAR_POLYGON") return null;
|
|
1777
|
+
if (isExcludedName(node.name)) return null;
|
|
1766
1778
|
if (isSmallRelativeToParent(node, context.parent)) return null;
|
|
1767
1779
|
if (context.parent.type === "COMPONENT") return null;
|
|
1768
1780
|
return {
|
|
@@ -1788,10 +1800,14 @@ var fixedWidthInResponsiveContextCheck = (node, context) => {
|
|
|
1788
1800
|
if (!context.parent) return null;
|
|
1789
1801
|
if (!hasAutoLayout(context.parent)) return null;
|
|
1790
1802
|
if (!isContainerNode(node)) return null;
|
|
1791
|
-
if (node.
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1803
|
+
if (node.layoutSizingHorizontal) {
|
|
1804
|
+
if (node.layoutSizingHorizontal !== "FIXED") return null;
|
|
1805
|
+
} else {
|
|
1806
|
+
if (node.layoutAlign === "STRETCH") return null;
|
|
1807
|
+
if (!node.absoluteBoundingBox) return null;
|
|
1808
|
+
if (node.layoutAlign !== "INHERIT") return null;
|
|
1809
|
+
}
|
|
1810
|
+
if (isExcludedName(node.name)) return null;
|
|
1795
1811
|
return {
|
|
1796
1812
|
ruleId: fixedWidthInResponsiveContextDef.id,
|
|
1797
1813
|
nodeId: node.id,
|
|
@@ -2064,7 +2080,7 @@ var inconsistentSpacingDef = {
|
|
|
2064
2080
|
fix: "Use spacing values from the design system grid (e.g., 8pt increments)"
|
|
2065
2081
|
};
|
|
2066
2082
|
var inconsistentSpacingCheck = (node, context, options) => {
|
|
2067
|
-
const gridBase = options?.["gridBase"] ?? getRuleOption("inconsistent-spacing", "gridBase",
|
|
2083
|
+
const gridBase = options?.["gridBase"] ?? getRuleOption("inconsistent-spacing", "gridBase", 4);
|
|
2068
2084
|
const paddings = [
|
|
2069
2085
|
node.paddingLeft,
|
|
2070
2086
|
node.paddingRight,
|
|
@@ -2106,7 +2122,7 @@ var magicNumberSpacingDef = {
|
|
|
2106
2122
|
fix: "Round spacing to the nearest grid value or use spacing tokens"
|
|
2107
2123
|
};
|
|
2108
2124
|
var magicNumberSpacingCheck = (node, context, options) => {
|
|
2109
|
-
const gridBase = options?.["gridBase"] ?? getRuleOption("magic-number-spacing", "gridBase",
|
|
2125
|
+
const gridBase = options?.["gridBase"] ?? getRuleOption("magic-number-spacing", "gridBase", 4);
|
|
2110
2126
|
const allSpacings = [
|
|
2111
2127
|
node.paddingLeft,
|
|
2112
2128
|
node.paddingRight,
|
|
@@ -2423,6 +2439,7 @@ var defaultNameDef = {
|
|
|
2423
2439
|
};
|
|
2424
2440
|
var defaultNameCheck = (node, context) => {
|
|
2425
2441
|
if (!node.name) return null;
|
|
2442
|
+
if (isExcludedName(node.name)) return null;
|
|
2426
2443
|
if (!isDefaultName(node.name)) return null;
|
|
2427
2444
|
return {
|
|
2428
2445
|
ruleId: defaultNameDef.id,
|
|
@@ -2445,6 +2462,7 @@ var nonSemanticNameDef = {
|
|
|
2445
2462
|
};
|
|
2446
2463
|
var nonSemanticNameCheck = (node, context) => {
|
|
2447
2464
|
if (!node.name) return null;
|
|
2465
|
+
if (isExcludedName(node.name)) return null;
|
|
2448
2466
|
if (!isNonSemanticName(node.name)) return null;
|
|
2449
2467
|
if (!node.children || node.children.length === 0) {
|
|
2450
2468
|
const shapeTypes = ["RECTANGLE", "ELLIPSE", "VECTOR", "LINE", "STAR", "REGULAR_POLYGON"];
|
|
@@ -2513,6 +2531,7 @@ var numericSuffixNameDef = {
|
|
|
2513
2531
|
};
|
|
2514
2532
|
var numericSuffixNameCheck = (node, context) => {
|
|
2515
2533
|
if (!node.name) return null;
|
|
2534
|
+
if (isExcludedName(node.name)) return null;
|
|
2516
2535
|
if (isDefaultName(node.name)) return null;
|
|
2517
2536
|
if (!hasNumericSuffix(node.name)) return null;
|
|
2518
2537
|
return {
|