canicode 0.3.1 → 0.3.2
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 +27 -8
- package/dist/cli/index.js +80 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +67 -3
- package/dist/mcp/server.js.map +1 -1
- package/docs/CUSTOMIZATION.md +273 -0
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -381,6 +381,8 @@ interface RuleEngineOptions {
|
|
|
381
381
|
enabledRules?: RuleId[];
|
|
382
382
|
disabledRules?: RuleId[];
|
|
383
383
|
targetNodeId?: string;
|
|
384
|
+
excludeNodeNames?: string[];
|
|
385
|
+
excludeNodeTypes?: string[];
|
|
384
386
|
}
|
|
385
387
|
/**
|
|
386
388
|
* Rule engine for analyzing Figma files
|
|
@@ -390,6 +392,8 @@ declare class RuleEngine {
|
|
|
390
392
|
private enabledRuleIds;
|
|
391
393
|
private disabledRuleIds;
|
|
392
394
|
private targetNodeId;
|
|
395
|
+
private excludeNamePattern;
|
|
396
|
+
private excludeNodeTypes;
|
|
393
397
|
constructor(options?: RuleEngineOptions);
|
|
394
398
|
/**
|
|
395
399
|
* Analyze a Figma file and return issues
|
package/dist/index.js
CHANGED
|
@@ -601,11 +601,15 @@ var RuleEngine = class {
|
|
|
601
601
|
enabledRuleIds;
|
|
602
602
|
disabledRuleIds;
|
|
603
603
|
targetNodeId;
|
|
604
|
+
excludeNamePattern;
|
|
605
|
+
excludeNodeTypes;
|
|
604
606
|
constructor(options = {}) {
|
|
605
607
|
this.configs = options.configs ?? RULE_CONFIGS;
|
|
606
608
|
this.enabledRuleIds = options.enabledRules ? new Set(options.enabledRules) : null;
|
|
607
609
|
this.disabledRuleIds = new Set(options.disabledRules ?? []);
|
|
608
610
|
this.targetNodeId = options.targetNodeId;
|
|
611
|
+
this.excludeNamePattern = options.excludeNodeNames && options.excludeNodeNames.length > 0 ? new RegExp(`\\b(${options.excludeNodeNames.join("|")})\\b`, "i") : null;
|
|
612
|
+
this.excludeNodeTypes = options.excludeNodeTypes && options.excludeNodeTypes.length > 0 ? new Set(options.excludeNodeTypes) : null;
|
|
609
613
|
}
|
|
610
614
|
/**
|
|
611
615
|
* Analyze a Figma file and return issues
|
|
@@ -659,6 +663,12 @@ var RuleEngine = class {
|
|
|
659
663
|
*/
|
|
660
664
|
traverseAndCheck(node, file, rules, maxDepth, issues, depth, path, parent, siblings) {
|
|
661
665
|
const nodePath = [...path, node.name];
|
|
666
|
+
if (this.excludeNodeTypes && this.excludeNodeTypes.has(node.type)) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
if (this.excludeNamePattern && this.excludeNamePattern.test(node.name)) {
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
662
672
|
const context = {
|
|
663
673
|
file,
|
|
664
674
|
parent,
|
|
@@ -3267,14 +3277,14 @@ var ELIGIBLE_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
|
3267
3277
|
"COMPONENT",
|
|
3268
3278
|
"INSTANCE"
|
|
3269
3279
|
]);
|
|
3270
|
-
var
|
|
3280
|
+
var EXCLUDED_NAME_PATTERN = /\b(icon|ico|badge|indicator|image|asset|chatbot|cta|gnb|navigation|nav|fab|modal|dialog|popup|overlay|toast|snackbar|tooltip|dropdown|menu|sticky|bg|background|divider|separator|logo|avatar|thumbnail|thumb|header|footer|sidebar|toolbar|tabbar|tab-bar|statusbar|status-bar|spinner|loader|cursor|dot|dim|dimmed|filter)\b/i;
|
|
3271
3281
|
function filterConversionCandidates(summaries, documentRoot) {
|
|
3272
3282
|
return summaries.filter((summary) => {
|
|
3273
3283
|
const node = findNode(documentRoot, summary.nodeId);
|
|
3274
3284
|
if (!node) return false;
|
|
3275
3285
|
if (EXCLUDED_NODE_TYPES.has(node.type)) return false;
|
|
3276
3286
|
if (!ELIGIBLE_NODE_TYPES.has(node.type)) return false;
|
|
3277
|
-
if (
|
|
3287
|
+
if (EXCLUDED_NAME_PATTERN.test(node.name)) return false;
|
|
3278
3288
|
const bbox = node.absoluteBoundingBox;
|
|
3279
3289
|
if (bbox && (bbox.width < MIN_WIDTH || bbox.height < MIN_HEIGHT)) return false;
|
|
3280
3290
|
if (!node.children || node.children.length < 3) return false;
|