canicode 0.12.3 → 0.12.4
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/CHANGELOG.md +172 -0
- package/README.md +46 -65
- package/dist/cli/index.js +46 -11
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -11
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +46 -11
- package/dist/mcp/server.js.map +1 -1
- package/package.json +3 -1
- package/skills/canicode-roundtrip/helpers-bootstrap.js +1 -1
- package/skills/canicode-roundtrip/helpers-installer.js +1 -1
- package/skills/cursor/canicode-roundtrip/helpers-bootstrap.js +1 -1
- package/skills/cursor/canicode-roundtrip/helpers-installer.js +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import 'crypto';
|
|
|
6
6
|
import { homedir } from 'os';
|
|
7
7
|
|
|
8
8
|
// package.json
|
|
9
|
-
var version = "0.12.
|
|
9
|
+
var version = "0.12.4";
|
|
10
10
|
var SeveritySchema = z.enum([
|
|
11
11
|
"blocking",
|
|
12
12
|
"risk",
|
|
@@ -2993,6 +2993,10 @@ var deepNesting = defineRule({
|
|
|
2993
2993
|
function isOnGrid(value, gridBase) {
|
|
2994
2994
|
return value % gridBase === 0;
|
|
2995
2995
|
}
|
|
2996
|
+
function hasOwnBoundVariables(obj) {
|
|
2997
|
+
const bv = obj["boundVariables"];
|
|
2998
|
+
return bv !== void 0 && bv !== null && Object.keys(bv).length > 0;
|
|
2999
|
+
}
|
|
2996
3000
|
var rawValueDef = {
|
|
2997
3001
|
id: "raw-value",
|
|
2998
3002
|
name: "Raw Value",
|
|
@@ -3007,6 +3011,7 @@ var rawValueCheck = (node, context) => {
|
|
|
3007
3011
|
if (!hasStyleReference(node, "fill") && !hasBoundVariable(node, "fills")) {
|
|
3008
3012
|
for (const fill of node.fills) {
|
|
3009
3013
|
const fillObj = fill;
|
|
3014
|
+
if (hasOwnBoundVariables(fillObj)) continue;
|
|
3010
3015
|
if (fillObj["type"] === "SOLID" && fillObj["color"]) {
|
|
3011
3016
|
const c = fillObj["color"];
|
|
3012
3017
|
const hex = `#${Math.round((c["r"] ?? 0) * 255).toString(16).padStart(2, "0")}${Math.round((c["g"] ?? 0) * 255).toString(16).padStart(2, "0")}${Math.round((c["b"] ?? 0) * 255).toString(16).padStart(2, "0")}`.toUpperCase();
|
|
@@ -3041,9 +3046,10 @@ var rawValueCheck = (node, context) => {
|
|
|
3041
3046
|
}
|
|
3042
3047
|
}
|
|
3043
3048
|
if (node.effects && Array.isArray(node.effects) && node.effects.length > 0) {
|
|
3044
|
-
if (!hasStyleReference(node, "effect")) {
|
|
3049
|
+
if (!hasStyleReference(node, "effect") && !hasBoundVariable(node, "effects")) {
|
|
3045
3050
|
for (const effect of node.effects) {
|
|
3046
3051
|
const effectObj = effect;
|
|
3052
|
+
if (hasOwnBoundVariables(effectObj)) continue;
|
|
3047
3053
|
if (effectObj["type"] === "DROP_SHADOW" || effectObj["type"] === "INNER_SHADOW") {
|
|
3048
3054
|
const shadowType = effectObj["type"] === "DROP_SHADOW" ? "drop shadow" : "inner shadow";
|
|
3049
3055
|
const offset = effectObj["offset"];
|
|
@@ -3074,6 +3080,7 @@ var rawValueCheck = (node, context) => {
|
|
|
3074
3080
|
}
|
|
3075
3081
|
const spacingKeys = ["paddingLeft", "paddingRight", "paddingTop", "paddingBottom", "itemSpacing"];
|
|
3076
3082
|
for (const key of spacingKeys) {
|
|
3083
|
+
if (key === "itemSpacing" && node.primaryAxisAlignItems === "SPACE_BETWEEN") continue;
|
|
3077
3084
|
const value = node[key];
|
|
3078
3085
|
if (value !== void 0 && value > 0 && !hasBoundVariable(node, key)) {
|
|
3079
3086
|
const label = key === "itemSpacing" ? "gap" : key.replace("padding", "padding-").toLowerCase();
|
|
@@ -3106,14 +3113,15 @@ var irregularSpacingCheck = (node, context, options) => {
|
|
|
3106
3113
|
const spacingEntries = [];
|
|
3107
3114
|
for (const key of ["paddingLeft", "paddingRight", "paddingTop", "paddingBottom"]) {
|
|
3108
3115
|
const v = node[key];
|
|
3109
|
-
if (v !== void 0 && v > 0) spacingEntries.push({ value: v, subType: "padding" });
|
|
3116
|
+
if (v !== void 0 && v > 0) spacingEntries.push({ key, value: v, subType: "padding" });
|
|
3110
3117
|
}
|
|
3111
|
-
if (node.itemSpacing !== void 0 && node.itemSpacing > 0) {
|
|
3112
|
-
spacingEntries.push({ value: node.itemSpacing, subType: "gap" });
|
|
3118
|
+
if (node.itemSpacing !== void 0 && node.itemSpacing > 0 && node.primaryAxisAlignItems !== "SPACE_BETWEEN") {
|
|
3119
|
+
spacingEntries.push({ key: "itemSpacing", value: node.itemSpacing, subType: "gap" });
|
|
3113
3120
|
}
|
|
3114
3121
|
const commonValues = [1, 2];
|
|
3115
3122
|
for (const entry of spacingEntries) {
|
|
3116
3123
|
if (commonValues.includes(entry.value)) continue;
|
|
3124
|
+
if (hasBoundVariable(node, entry.key)) continue;
|
|
3117
3125
|
if (!isOnGrid(entry.value, gridBase)) {
|
|
3118
3126
|
return {
|
|
3119
3127
|
ruleId: irregularSpacingDef.id,
|
|
@@ -3495,17 +3503,28 @@ var variantStructureMismatch = defineRule({
|
|
|
3495
3503
|
var CODE_CONNECT_SETUP_KEY = "unmapped-component:setup-detected";
|
|
3496
3504
|
var CODE_CONNECT_MAPPINGS_KEY = "unmapped-component:mappings";
|
|
3497
3505
|
var SEEN_MAIN_IDS_KEY = "unmapped-component:seen-main-ids";
|
|
3506
|
+
function browserCwd() {
|
|
3507
|
+
return typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : null;
|
|
3508
|
+
}
|
|
3498
3509
|
function codeConnectIsSetUp(context) {
|
|
3499
3510
|
return getAnalysisState(context, CODE_CONNECT_SETUP_KEY, () => {
|
|
3500
|
-
|
|
3511
|
+
const cwd = browserCwd();
|
|
3512
|
+
if (cwd === null) return false;
|
|
3513
|
+
return existsSync(join(cwd, "figma.config.json"));
|
|
3501
3514
|
});
|
|
3502
3515
|
}
|
|
3503
3516
|
function codeConnectMappings(context) {
|
|
3504
|
-
return getAnalysisState(
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3517
|
+
return getAnalysisState(context, CODE_CONNECT_MAPPINGS_KEY, () => {
|
|
3518
|
+
const cwd = browserCwd();
|
|
3519
|
+
if (cwd === null) {
|
|
3520
|
+
return {
|
|
3521
|
+
mappedNodeIds: /* @__PURE__ */ new Set(),
|
|
3522
|
+
scannedFiles: [],
|
|
3523
|
+
skipReason: "no-config"
|
|
3524
|
+
};
|
|
3525
|
+
}
|
|
3526
|
+
return parseCodeConnectMappings(cwd);
|
|
3527
|
+
});
|
|
3509
3528
|
}
|
|
3510
3529
|
function seenMainIds(context) {
|
|
3511
3530
|
return getAnalysisState(context, SEEN_MAIN_IDS_KEY, () => /* @__PURE__ */ new Set());
|