@md-code/component-uniqueness 0.1.4 → 0.3.0
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 +17 -0
- package/LICENSE +202 -0
- package/README.md +21 -3
- package/dist/config.d.ts +50 -0
- package/dist/config.js +402 -0
- package/dist/constants.d.ts +55 -0
- package/dist/constants.js +86 -0
- package/dist/decision-maker.d.ts +39 -0
- package/dist/decision-maker.js +119 -0
- package/dist/filter/child-element.d.ts +3 -0
- package/dist/filter/child-element.js +17 -0
- package/dist/filter/missing-component.d.ts +10 -0
- package/dist/filter/missing-component.js +96 -0
- package/dist/filter/no-structure.d.ts +3 -0
- package/dist/filter/no-structure.js +16 -0
- package/dist/filter/usages.d.ts +3 -0
- package/dist/filter/usages.js +14 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +244 -0
- package/dist/lib-registry.d.ts +4 -0
- package/dist/lib-registry.js +376 -0
- package/dist/logger.d.ts +7 -0
- package/dist/logger.js +70 -0
- package/dist/main.d.ts +25 -0
- package/dist/main.js +666 -0
- package/dist/matcher/a11y.d.ts +19 -0
- package/dist/matcher/a11y.js +311 -0
- package/dist/matcher/behavior.d.ts +10 -0
- package/dist/matcher/behavior.js +32 -0
- package/dist/matcher/css-matching.d.ts +18 -0
- package/dist/matcher/css-matching.js +159 -0
- package/dist/matcher/framework/index.d.ts +2 -0
- package/dist/matcher/framework/index.js +37 -0
- package/dist/matcher/framework/react.d.ts +12 -0
- package/dist/matcher/framework/react.js +70 -0
- package/dist/matcher/index.d.ts +64 -0
- package/dist/matcher/index.js +38 -0
- package/dist/matcher/name.d.ts +15 -0
- package/dist/matcher/name.js +154 -0
- package/dist/matcher/structure.d.ts +22 -0
- package/dist/matcher/structure.js +329 -0
- package/dist/matcher/styles.d.ts +20 -0
- package/dist/matcher/styles.js +49 -0
- package/dist/normalize/candidate.d.ts +3 -0
- package/dist/normalize/candidate.js +21 -0
- package/dist/normalize/dom.d.ts +22 -0
- package/dist/normalize/dom.js +180 -0
- package/dist/normalize/external-html.d.ts +5 -0
- package/dist/normalize/external-html.js +40 -0
- package/dist/normalize/framework.d.ts +20 -0
- package/dist/normalize/framework.js +130 -0
- package/dist/normalize/resolver.d.ts +7 -0
- package/dist/normalize/resolver.js +28 -0
- package/dist/normalize/style-resolver.d.ts +7 -0
- package/dist/normalize/style-resolver.js +28 -0
- package/dist/normalize/style.d.ts +15 -0
- package/dist/normalize/style.js +174 -0
- package/dist/normalize/words.d.ts +3 -0
- package/dist/normalize/words.js +40 -0
- package/dist/package.json +88 -0
- package/dist/playgrounds/angular.d.ts +7 -0
- package/dist/playgrounds/angular.js +9 -0
- package/dist/playgrounds/framework-entrypoint.d.ts +10 -0
- package/dist/playgrounds/framework-entrypoint.js +102 -0
- package/dist/playgrounds/framework.d.ts +10 -0
- package/dist/playgrounds/framework.js +102 -0
- package/dist/playgrounds/react.d.ts +14 -0
- package/dist/playgrounds/react.js +1288 -0
- package/dist/playgrounds/scss.d.ts +6 -0
- package/dist/playgrounds/scss.js +9 -0
- package/dist/playgrounds/style-entrypoint.d.ts +13 -0
- package/dist/playgrounds/style-entrypoint.js +82 -0
- package/dist/playgrounds/style.d.ts +13 -0
- package/dist/playgrounds/style.js +82 -0
- package/dist/playgrounds/styled-components.d.ts +7 -0
- package/dist/playgrounds/styled-components.js +190 -0
- package/dist/playgrounds/tailwind.d.ts +15 -0
- package/dist/playgrounds/tailwind.js +256 -0
- package/dist/playgrounds/vue.d.ts +7 -0
- package/dist/playgrounds/vue.js +9 -0
- package/dist/report/asks.d.ts +27 -0
- package/dist/report/asks.js +28 -0
- package/dist/report/cli-report.d.ts +7 -0
- package/dist/report/cli-report.js +187 -0
- package/dist/report/codes/index.d.ts +37 -0
- package/dist/report/codes/index.js +31 -0
- package/dist/report/errorTypes/index.d.ts +92 -0
- package/dist/report/errorTypes/index.js +186 -0
- package/dist/report/evidence.d.ts +2 -0
- package/dist/report/evidence.js +8 -0
- package/dist/report/explain.d.ts +27 -0
- package/dist/report/explain.js +76 -0
- package/dist/report/index.d.ts +2 -0
- package/dist/report/index.js +24 -0
- package/dist/report/matchers/a11y/model.d.ts +20 -0
- package/dist/report/matchers/a11y/model.js +14 -0
- package/dist/report/matchers/a11y/text.d.ts +2 -0
- package/dist/report/matchers/a11y/text.js +22 -0
- package/dist/report/matchers/behavior/model.d.ts +20 -0
- package/dist/report/matchers/behavior/model.js +12 -0
- package/dist/report/matchers/behavior/text.d.ts +2 -0
- package/dist/report/matchers/behavior/text.js +22 -0
- package/dist/report/matchers/framework/model.d.ts +10 -0
- package/dist/report/matchers/framework/model.js +39 -0
- package/dist/report/matchers/framework/text.d.ts +2 -0
- package/dist/report/matchers/framework/text.js +26 -0
- package/dist/report/matchers/index.d.ts +5 -0
- package/dist/report/matchers/index.js +97 -0
- package/dist/report/matchers/name/model.d.ts +20 -0
- package/dist/report/matchers/name/model.js +30 -0
- package/dist/report/matchers/name/text.d.ts +2 -0
- package/dist/report/matchers/name/text.js +17 -0
- package/dist/report/matchers/set-model.d.ts +31 -0
- package/dist/report/matchers/set-model.js +42 -0
- package/dist/report/matchers/structure/model.d.ts +10 -0
- package/dist/report/matchers/structure/model.js +58 -0
- package/dist/report/matchers/structure/text.d.ts +2 -0
- package/dist/report/matchers/structure/text.js +40 -0
- package/dist/report/matchers/styles/model.d.ts +11 -0
- package/dist/report/matchers/styles/model.js +36 -0
- package/dist/report/matchers/styles/text.d.ts +2 -0
- package/dist/report/matchers/styles/text.js +40 -0
- package/dist/report/user-report/build/bundle.d.ts +3 -0
- package/dist/report/user-report/build/bundle.js +185 -0
- package/dist/report/user-report/build/bundle.prebuilt.js +955 -0
- package/dist/report/user-report/data/collect.d.ts +68 -0
- package/dist/report/user-report/data/collect.js +150 -0
- package/dist/report/user-report/data/folders.d.ts +3 -0
- package/dist/report/user-report/data/folders.js +73 -0
- package/dist/report/user-report/data/groups.d.ts +13 -0
- package/dist/report/user-report/data/groups.js +76 -0
- package/dist/report/user-report/data/links.d.ts +39 -0
- package/dist/report/user-report/data/links.js +222 -0
- package/dist/report/user-report/data/snapshot.d.ts +9 -0
- package/dist/report/user-report/data/snapshot.js +180 -0
- package/dist/report/user-report/data/source.d.ts +13 -0
- package/dist/report/user-report/data/source.js +58 -0
- package/dist/report/user-report/data/word.d.ts +3 -0
- package/dist/report/user-report/data/word.js +32 -0
- package/dist/report/user-report/html/shell.d.ts +2 -0
- package/dist/report/user-report/html/shell.js +27 -0
- package/dist/report/user-report/index.d.ts +7 -0
- package/dist/report/user-report/index.js +47 -0
- package/dist/report/vocabulary/evidence.d.ts +48 -0
- package/dist/report/vocabulary/evidence.js +66 -0
- package/dist/report/vocabulary/format.d.ts +4 -0
- package/dist/report/vocabulary/format.js +20 -0
- package/dist/report/vocabulary/labels.d.ts +134 -0
- package/dist/report/vocabulary/labels.js +87 -0
- package/dist/report/vocabulary/phrases.d.ts +20 -0
- package/dist/report/vocabulary/phrases.js +34 -0
- package/dist/self-catalog.d.ts +4 -0
- package/dist/self-catalog.js +179 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +125 -0
- package/package.json +86 -71
- package/config.js +0 -372
- package/decision-maker.js +0 -109
- package/filter/drop-child-element.js +0 -14
- package/filter/drop-no-structure.js +0 -13
- package/filter/drop-usages.js +0 -13
- package/filter/missing-component.js +0 -100
- package/index.js +0 -184
- package/logger.js +0 -44
- package/main.js +0 -584
- package/matcher/a11y.js +0 -65
- package/matcher/behavior.js +0 -31
- package/matcher/framework/index.js +0 -15
- package/matcher/framework/react.js +0 -25
- package/matcher/index.js +0 -36
- package/matcher/name.js +0 -132
- package/matcher/structure.js +0 -242
- package/normalize/candidate.js +0 -22
- package/normalize/dom.js +0 -187
- package/normalize/framework.js +0 -110
- package/normalize/style-resolver.js +0 -24
- package/normalize/style.js +0 -175
- package/normalize/words.js +0 -40
- package/playgrounds/angular.js +0 -11
- package/playgrounds/framework-entrypoint.js +0 -90
- package/playgrounds/react.js +0 -998
- package/playgrounds/scss.js +0 -7
- package/playgrounds/style-entrypoint.js +0 -78
- package/playgrounds/styled-components.js +0 -138
- package/playgrounds/tailwind.js +0 -186
- package/playgrounds/vue.js +0 -11
- package/plugin.js +0 -3
- package/report.js +0 -162
- package/utils.js +0 -92
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_THRESHOLDS = exports.DEFAULT_WEIGHTS = exports.clamp01 = exports.resolveThresholds = exports.resolveWeights = exports.bestOf = exports.decide = void 0;
|
|
4
|
+
const a11y_1 = require("./matcher/a11y");
|
|
5
|
+
const dom_js_1 = require("./normalize/dom.js");
|
|
6
|
+
const DEFAULT_WEIGHTS = {
|
|
7
|
+
name: 0.10,
|
|
8
|
+
structure: 0.4,
|
|
9
|
+
styles: 0.15,
|
|
10
|
+
behavior: 0.15,
|
|
11
|
+
a11y: 0.1,
|
|
12
|
+
framework: 0.1,
|
|
13
|
+
};
|
|
14
|
+
exports.DEFAULT_WEIGHTS = DEFAULT_WEIGHTS;
|
|
15
|
+
const DEFAULT_THRESHOLDS = {
|
|
16
|
+
duplicate: 0.4,
|
|
17
|
+
similar: 0.2,
|
|
18
|
+
};
|
|
19
|
+
exports.DEFAULT_THRESHOLDS = DEFAULT_THRESHOLDS;
|
|
20
|
+
const clamp01 = (x) => Math.max(0, Math.min(1, x));
|
|
21
|
+
exports.clamp01 = clamp01;
|
|
22
|
+
const resolveWeights = (opts) => {
|
|
23
|
+
const w = (opts && opts.weights) || {};
|
|
24
|
+
return {
|
|
25
|
+
name: w.name ?? DEFAULT_WEIGHTS.name,
|
|
26
|
+
structure: w.structure ?? DEFAULT_WEIGHTS.structure,
|
|
27
|
+
styles: w.styles ?? DEFAULT_WEIGHTS.styles,
|
|
28
|
+
behavior: w.behavior ?? DEFAULT_WEIGHTS.behavior,
|
|
29
|
+
a11y: w.a11y ?? DEFAULT_WEIGHTS.a11y,
|
|
30
|
+
framework: w.framework ?? DEFAULT_WEIGHTS.framework,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
exports.resolveWeights = resolveWeights;
|
|
34
|
+
const resolveThresholds = (opts) => {
|
|
35
|
+
const t = (opts && opts.thresholds) || {};
|
|
36
|
+
return {
|
|
37
|
+
duplicate: t.duplicate ?? DEFAULT_THRESHOLDS.duplicate,
|
|
38
|
+
similar: t.similar ?? DEFAULT_THRESHOLDS.similar,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.resolveThresholds = resolveThresholds;
|
|
42
|
+
const applicableOf = (candidate) => ({
|
|
43
|
+
name: false,
|
|
44
|
+
behavior: candidate.framework.events.length > 0,
|
|
45
|
+
a11y: (0, a11y_1.tokensOf)(candidate, "a11y").size > 0,
|
|
46
|
+
structure: !!candidate.dom.tree && (Object.keys(candidate.dom.tree.css).length > 0 || !dom_js_1.NON_SEMANTIC_TAGS.has(candidate.dom.tree.tag)),
|
|
47
|
+
styles: !!candidate.dom.tree,
|
|
48
|
+
framework: candidate.framework.props.length > 0 || candidate.framework.events.length > 0,
|
|
49
|
+
});
|
|
50
|
+
const applicableWeights = (weights, applicable) => Object.fromEntries(Object.entries(weights).map(([key, w]) => [key, applicable[key] === false ? 0 : w]));
|
|
51
|
+
const decide = (candidate, canon, ctx) => {
|
|
52
|
+
const o = ctx || {};
|
|
53
|
+
const flagged = Object.fromEntries(Object.entries(o.signals || {}).filter(([, s]) => s && s.applicable === false).map(([key]) => [key, false]));
|
|
54
|
+
const weights = applicableWeights(resolveWeights(o), { ...(candidate.partial ? applicableOf(candidate) : {}), ...flagged });
|
|
55
|
+
const thresholds = resolveThresholds(o);
|
|
56
|
+
const signals = {};
|
|
57
|
+
for (const key of ["name", "structure", "styles", "behavior", "a11y", "framework"]) {
|
|
58
|
+
const s = o.signals && o.signals[key];
|
|
59
|
+
signals[key] = { score: s ? clamp01(s.score) : 0, evidence: s && s.evidence ? s.evidence : {} };
|
|
60
|
+
}
|
|
61
|
+
const totalW = weights.name + weights.structure + weights.styles + weights.behavior + weights.a11y + weights.framework;
|
|
62
|
+
const weighted = weights.name * signals.name.score +
|
|
63
|
+
weights.structure * signals.structure.score +
|
|
64
|
+
weights.styles * signals.styles.score +
|
|
65
|
+
weights.behavior * signals.behavior.score +
|
|
66
|
+
weights.a11y * signals.a11y.score +
|
|
67
|
+
weights.framework * signals.framework.score;
|
|
68
|
+
const confidence = totalW === 0 ? 0 : clamp01(weighted / totalW);
|
|
69
|
+
let isDuplicate = false;
|
|
70
|
+
let tier = null;
|
|
71
|
+
if (confidence >= thresholds.duplicate) {
|
|
72
|
+
isDuplicate = true;
|
|
73
|
+
tier = "duplicate";
|
|
74
|
+
}
|
|
75
|
+
else if (confidence >= thresholds.similar) {
|
|
76
|
+
tier = "similar";
|
|
77
|
+
}
|
|
78
|
+
// A duplicate is the SAME component, not two components that happen to share
|
|
79
|
+
// a design system. When the structure signal is applicable but its tree
|
|
80
|
+
// coverage is weak (less than half of the larger tree corresponds), shared
|
|
81
|
+
// styles / behavior / a11y must not carry the pair to a duplicate verdict:
|
|
82
|
+
// pixel-identical widgets that announce different things, or filter panels
|
|
83
|
+
// with different contents, are similar at most.
|
|
84
|
+
const structureEvidence = signals.structure.evidence || {};
|
|
85
|
+
const structureWeak = o.signals && o.signals.structure && o.signals.structure.applicable !== false && typeof structureEvidence.similarity === "number" && structureEvidence.similarity < 0.5;
|
|
86
|
+
if (isDuplicate && structureWeak) {
|
|
87
|
+
isDuplicate = false;
|
|
88
|
+
tier = confidence >= thresholds.similar ? "similar" : null;
|
|
89
|
+
}
|
|
90
|
+
// Two widgets that ANNOUNCE different things are not the same component,
|
|
91
|
+
// however identical they look: a collapse toggle (aria-pressed) and a menu
|
|
92
|
+
// disclosure (aria-expanded + aria-controls) with different accessible names
|
|
93
|
+
// serve different purposes. When both sides carry explicit accessibility
|
|
94
|
+
// markup and the semantic announcement comparison is weak, the pair is at
|
|
95
|
+
// most similar — shared pixels do not overrule a different screen-reader
|
|
96
|
+
// contract.
|
|
97
|
+
const a11yEvidence = signals.a11y.evidence || {};
|
|
98
|
+
const a11yContradicts = a11yEvidence.form === "semantic" && Array.isArray(a11yEvidence.candidateAnnouncements) && a11yEvidence.candidateAnnouncements.length > 0 && Array.isArray(a11yEvidence.canonicalAnnouncements) && a11yEvidence.canonicalAnnouncements.length > 0 && (a11yEvidence.a11ySimilarity ?? 1) < 0.5;
|
|
99
|
+
if (isDuplicate && a11yContradicts) {
|
|
100
|
+
isDuplicate = false;
|
|
101
|
+
tier = confidence >= thresholds.similar ? "similar" : null;
|
|
102
|
+
}
|
|
103
|
+
const parts = ["name", "structure", "styles", "behavior", "a11y", "framework"].map((key) => `${key} ${signals[key].score.toFixed(2)}`);
|
|
104
|
+
const reason = `confidence ${confidence.toFixed(2)} (${parts.join(", ")})`;
|
|
105
|
+
return {
|
|
106
|
+
isDuplicate,
|
|
107
|
+
confidence,
|
|
108
|
+
tier,
|
|
109
|
+
reason,
|
|
110
|
+
signals,
|
|
111
|
+
thresholds,
|
|
112
|
+
weights,
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
exports.decide = decide;
|
|
116
|
+
const nodeCount = (node) => (node ? 1 + (node.children || []).reduce((sum, child) => sum + nodeCount(child), 0) : 0);
|
|
117
|
+
const tagCount = (match) => nodeCount(match.canon.dom && match.canon.dom.tree);
|
|
118
|
+
const bestOf = (matches) => [...matches].sort((a, b) => b.decision.confidence - a.decision.confidence || tagCount(a) - tagCount(b) || a.canon.name.localeCompare(b.canon.name))[0] || null;
|
|
119
|
+
exports.bestOf = bestOf;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.test = exports.name = void 0;
|
|
4
|
+
const test = (match) => {
|
|
5
|
+
if (match.tier === "name" || match.tier === "name-fuzzy" || match.tier === "jsx-block")
|
|
6
|
+
return null;
|
|
7
|
+
if (match.app.partial)
|
|
8
|
+
return null;
|
|
9
|
+
const appEls = (match.app.elementProps || []).length;
|
|
10
|
+
const canonEls = (match.canon.elementProps || []).length;
|
|
11
|
+
if (canonEls > 0 && appEls > 3 * canonEls) {
|
|
12
|
+
return `app has ${appEls} elements vs canonical's ${canonEls} — match is on a child element, not the component itself`;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
exports.test = test;
|
|
17
|
+
exports.name = "drop-child-element";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const DEFAULT_MIN_CLUSTER = 3;
|
|
2
|
+
declare const MIN_PAIRWISE_STRUCTURE = 0.4;
|
|
3
|
+
declare const suggestName: (appNames: any, canonName?: any) => any;
|
|
4
|
+
declare const findMissingComponents: (matches: any, { minCluster }?: {
|
|
5
|
+
minCluster?: number;
|
|
6
|
+
}) => {
|
|
7
|
+
clusters: any[];
|
|
8
|
+
remaining: any;
|
|
9
|
+
};
|
|
10
|
+
export { findMissingComponents, suggestName, DEFAULT_MIN_CLUSTER, MIN_PAIRWISE_STRUCTURE, };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MIN_PAIRWISE_STRUCTURE = exports.DEFAULT_MIN_CLUSTER = exports.suggestName = exports.findMissingComponents = void 0;
|
|
4
|
+
const words_js_1 = require("../normalize/words.js");
|
|
5
|
+
const structure_js_1 = require("../matcher/structure.js");
|
|
6
|
+
const DEFAULT_MIN_CLUSTER = 3;
|
|
7
|
+
exports.DEFAULT_MIN_CLUSTER = DEFAULT_MIN_CLUSTER;
|
|
8
|
+
const MIN_PAIRWISE_STRUCTURE = 0.4;
|
|
9
|
+
exports.MIN_PAIRWISE_STRUCTURE = MIN_PAIRWISE_STRUCTURE;
|
|
10
|
+
const MIN_PAIR_FLOOR = 0.3;
|
|
11
|
+
const CANON_CONF_FLOOR = 0.25;
|
|
12
|
+
const pascalCase = (words) => words.map((w) => w[0].toUpperCase() + w.slice(1).toLowerCase()).join("");
|
|
13
|
+
const suggestName = (appNames, canonName = null) => {
|
|
14
|
+
if (canonName) {
|
|
15
|
+
const counts = new Map();
|
|
16
|
+
const order = [];
|
|
17
|
+
for (const name of appNames) {
|
|
18
|
+
for (const w of (0, words_js_1.pascalWords)(name)) {
|
|
19
|
+
const k = w.toLowerCase();
|
|
20
|
+
if (!counts.has(k)) {
|
|
21
|
+
counts.set(k, 0);
|
|
22
|
+
order.push(k);
|
|
23
|
+
}
|
|
24
|
+
counts.set(k, counts.get(k) + 1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const common = order.filter((k) => counts.get(k) >= Math.ceil(appNames.length * 0.6));
|
|
28
|
+
const meaningful = common.filter((k) => !words_js_1.GENERIC_WORDS.has(k));
|
|
29
|
+
if (meaningful.length > 0) {
|
|
30
|
+
return pascalCase([meaningful[0], ...(0, words_js_1.pascalWords)(canonName).slice(0, 2)]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (canonName)
|
|
34
|
+
return `Shared${canonName}`;
|
|
35
|
+
return "SharedComponent";
|
|
36
|
+
};
|
|
37
|
+
exports.suggestName = suggestName;
|
|
38
|
+
const pairwiseAverage = (apps) => {
|
|
39
|
+
let total = 0;
|
|
40
|
+
let pairs = 0;
|
|
41
|
+
for (let i = 0; i < apps.length; i += 1) {
|
|
42
|
+
for (let j = i + 1; j < apps.length; j += 1) {
|
|
43
|
+
const s = (0, structure_js_1.matchStructure)(apps[i], apps[j]);
|
|
44
|
+
total += s.score;
|
|
45
|
+
pairs += 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return pairs === 0 ? 0 : total / pairs;
|
|
49
|
+
};
|
|
50
|
+
const pairwiseAllAbove = (apps, floor) => {
|
|
51
|
+
for (let i = 0; i < apps.length; i += 1)
|
|
52
|
+
for (let j = i + 1; j < apps.length; j += 1)
|
|
53
|
+
if ((0, structure_js_1.matchStructure)(apps[i], apps[j]).score < floor)
|
|
54
|
+
return false;
|
|
55
|
+
return true;
|
|
56
|
+
};
|
|
57
|
+
const resolveClusterMembers = (group) => {
|
|
58
|
+
const strong = group.filter((m) => m.decision.confidence >= CANON_CONF_FLOOR);
|
|
59
|
+
const apps = [...new Map(strong.map((m) => [m.app.name, m.app])).values()];
|
|
60
|
+
if (apps.length >= 2 && pairwiseAllAbove(apps, MIN_PAIR_FLOOR))
|
|
61
|
+
return strong;
|
|
62
|
+
const dups = strong.filter((m) => m.decision.tier === "duplicate");
|
|
63
|
+
const dupApps = [...new Map(dups.map((m) => [m.app.name, m.app])).values()];
|
|
64
|
+
return dups.length >= 2 && pairwiseAllAbove(dupApps, MIN_PAIR_FLOOR) ? dups : null;
|
|
65
|
+
};
|
|
66
|
+
const findMissingComponents = (matches, { minCluster = DEFAULT_MIN_CLUSTER } = {}) => {
|
|
67
|
+
const byCanon = new Map();
|
|
68
|
+
for (const match of matches) {
|
|
69
|
+
const key = match.canon.name;
|
|
70
|
+
if (!byCanon.has(key))
|
|
71
|
+
byCanon.set(key, []);
|
|
72
|
+
byCanon.get(key).push(match);
|
|
73
|
+
}
|
|
74
|
+
const clusters = [];
|
|
75
|
+
for (const [canonName, group] of byCanon) {
|
|
76
|
+
const members = resolveClusterMembers(group);
|
|
77
|
+
if (!members)
|
|
78
|
+
continue;
|
|
79
|
+
if (new Set(members.map((m) => m.app.name)).size < minCluster)
|
|
80
|
+
continue;
|
|
81
|
+
clusters.push({
|
|
82
|
+
name: suggestName(members.map((m) => m.app.name), canonName),
|
|
83
|
+
canon: group[0].canon,
|
|
84
|
+
matches: [...members].sort((a, b) => b.decision.confidence - a.decision.confidence),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
clusters.sort((a, b) => b.matches.length - a.matches.length || a.name.localeCompare(b.name));
|
|
88
|
+
const clusteredKeys = new Set();
|
|
89
|
+
for (const c of clusters) {
|
|
90
|
+
for (const m of c.matches)
|
|
91
|
+
clusteredKeys.add(m.app.name + "::" + m.canon.name);
|
|
92
|
+
}
|
|
93
|
+
const remaining = matches.filter((m) => !clusteredKeys.has(m.app.name + "::" + m.canon.name));
|
|
94
|
+
return { clusters, remaining };
|
|
95
|
+
};
|
|
96
|
+
exports.findMissingComponents = findMissingComponents;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.test = exports.name = void 0;
|
|
4
|
+
const test = (match) => {
|
|
5
|
+
if (!match.app.partial)
|
|
6
|
+
return null;
|
|
7
|
+
const structure = match.decision.signals && match.decision.signals.structure;
|
|
8
|
+
if (!structure)
|
|
9
|
+
return null;
|
|
10
|
+
if (structure.score <= 0) {
|
|
11
|
+
return "partial shares no structure with the canonical — match is driven only by framework/a11y/behavior";
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
exports.test = test;
|
|
16
|
+
exports.name = "drop-no-structure";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.test = exports.name = void 0;
|
|
4
|
+
const test = (match) => {
|
|
5
|
+
if ((match.app.usesCanonical || []).includes(match.canon.name)) {
|
|
6
|
+
return `${match.app.name} renders ${match.canon.name} (composition, not a duplicate)`;
|
|
7
|
+
}
|
|
8
|
+
if ((match.canon.usesCanonical || []).includes(match.app.name)) {
|
|
9
|
+
return `${match.canon.name} renders ${match.app.name} (composition, not a duplicate)`;
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
exports.test = test;
|
|
14
|
+
exports.name = "drop-usages";
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { RULE_NAME, RULE_SHORT } from "./config";
|
|
2
|
+
export declare const meta: {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const rules: {
|
|
7
|
+
"component-uniqueness": {
|
|
8
|
+
meta: {
|
|
9
|
+
type: string;
|
|
10
|
+
docs: {
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
messages: {
|
|
14
|
+
duplicateComponent: string;
|
|
15
|
+
rawHtml: string;
|
|
16
|
+
partOfComponent: string;
|
|
17
|
+
};
|
|
18
|
+
schema: {
|
|
19
|
+
type: string;
|
|
20
|
+
properties: {
|
|
21
|
+
registry: {
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
24
|
+
registryPath: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
catalog: {
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
exportPath: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
catalogPath: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
includeDynamic: {
|
|
39
|
+
type: string;
|
|
40
|
+
};
|
|
41
|
+
dynamicCatalog: {
|
|
42
|
+
type: string;
|
|
43
|
+
};
|
|
44
|
+
dynamicCatalogPath: {
|
|
45
|
+
type: string;
|
|
46
|
+
};
|
|
47
|
+
rawHtml: {
|
|
48
|
+
type: string;
|
|
49
|
+
};
|
|
50
|
+
parts: {
|
|
51
|
+
type: string;
|
|
52
|
+
};
|
|
53
|
+
tsconfig: {
|
|
54
|
+
type: string;
|
|
55
|
+
};
|
|
56
|
+
weights: {
|
|
57
|
+
type: string;
|
|
58
|
+
};
|
|
59
|
+
thresholds: {
|
|
60
|
+
type: string;
|
|
61
|
+
};
|
|
62
|
+
componentsFolder: {
|
|
63
|
+
type: string;
|
|
64
|
+
};
|
|
65
|
+
compareAll: {
|
|
66
|
+
type: string;
|
|
67
|
+
};
|
|
68
|
+
proposeFromLib: {
|
|
69
|
+
type: string;
|
|
70
|
+
description: string;
|
|
71
|
+
};
|
|
72
|
+
include: {
|
|
73
|
+
type: string;
|
|
74
|
+
};
|
|
75
|
+
exclude: {
|
|
76
|
+
type: string;
|
|
77
|
+
};
|
|
78
|
+
exts: {
|
|
79
|
+
type: string;
|
|
80
|
+
};
|
|
81
|
+
ignoreDirs: {
|
|
82
|
+
type: string;
|
|
83
|
+
};
|
|
84
|
+
rootMarkers: {
|
|
85
|
+
type: string;
|
|
86
|
+
};
|
|
87
|
+
cache: {
|
|
88
|
+
type: string;
|
|
89
|
+
};
|
|
90
|
+
root: {
|
|
91
|
+
type: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
additionalProperties: boolean;
|
|
95
|
+
}[];
|
|
96
|
+
};
|
|
97
|
+
create(context: any): {
|
|
98
|
+
"Program:exit"?: undefined;
|
|
99
|
+
} | {
|
|
100
|
+
"Program:exit": () => void;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export { RULE_NAME };
|
|
105
|
+
export { RULE_SHORT };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.RULE_SHORT = exports.RULE_NAME = exports.rules = exports.meta = void 0;
|
|
27
|
+
const path = __importStar(require("node:path"));
|
|
28
|
+
const config_1 = require("./config");
|
|
29
|
+
Object.defineProperty(exports, "RULE_NAME", { enumerable: true, get: function () { return config_1.RULE_NAME; } });
|
|
30
|
+
Object.defineProperty(exports, "RULE_SHORT", { enumerable: true, get: function () { return config_1.RULE_SHORT; } });
|
|
31
|
+
const self_catalog_1 = require("./self-catalog");
|
|
32
|
+
const framework_js_1 = require("./playgrounds/framework.js");
|
|
33
|
+
const candidate_js_1 = require("./normalize/candidate.js");
|
|
34
|
+
const matcher_1 = require("./matcher");
|
|
35
|
+
const framework_1 = require("./matcher/framework");
|
|
36
|
+
const decision_maker_1 = require("./decision-maker");
|
|
37
|
+
const main_1 = require("./main");
|
|
38
|
+
const lib_registry_1 = require("./lib-registry");
|
|
39
|
+
const frameworkMatcher = (0, framework_1.getFrameworkMatcher)("react");
|
|
40
|
+
const isComponentBinding = (node) => {
|
|
41
|
+
if (!node || node.type !== "Identifier")
|
|
42
|
+
return false;
|
|
43
|
+
if (!/^[A-Z]/.test(node.name))
|
|
44
|
+
return false;
|
|
45
|
+
let parent = node.parent;
|
|
46
|
+
while (parent) {
|
|
47
|
+
if (parent.type === "TSInterfaceDeclaration")
|
|
48
|
+
return false;
|
|
49
|
+
if (parent.type === "TSTypeAliasDeclaration")
|
|
50
|
+
return false;
|
|
51
|
+
if (parent.type === "TSModuleDeclaration")
|
|
52
|
+
return false;
|
|
53
|
+
if (parent.type === "ExportNamedDeclaration" || parent.type === "ExportDefaultDeclaration")
|
|
54
|
+
break;
|
|
55
|
+
parent = parent.parent;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
};
|
|
59
|
+
const normalizedCanons = new WeakMap();
|
|
60
|
+
const normalizeCanon = (canon, config) => {
|
|
61
|
+
if (!normalizedCanons.has(canon))
|
|
62
|
+
normalizedCanons.set(canon, (0, candidate_js_1.buildCandidate)(canon, config));
|
|
63
|
+
return normalizedCanons.get(canon);
|
|
64
|
+
};
|
|
65
|
+
const createRule = () => {
|
|
66
|
+
return {
|
|
67
|
+
meta: {
|
|
68
|
+
type: "problem",
|
|
69
|
+
docs: {
|
|
70
|
+
description: "Flag components that duplicate a canonical component, and raw HTML elements that should use the canonical packages.",
|
|
71
|
+
},
|
|
72
|
+
messages: {
|
|
73
|
+
duplicateComponent: "Component \"{{name}}\" duplicates the canonical \"{{canonName}}\" ({{reason}}).{{libHint}}",
|
|
74
|
+
rawHtml: "Raw <{{tag}}> outside the canonical packages → replace with `{{component}}` from {{path}} ({{reason}}).",
|
|
75
|
+
partOfComponent: "This <{{tag}}> block in {{owner}} duplicates `{{component}}` from {{path}} ({{reason}}).",
|
|
76
|
+
},
|
|
77
|
+
schema: [
|
|
78
|
+
{
|
|
79
|
+
type: "object",
|
|
80
|
+
properties: {
|
|
81
|
+
registry: { type: "string" },
|
|
82
|
+
registryPath: { type: "string" },
|
|
83
|
+
catalog: { type: "array" },
|
|
84
|
+
exportPath: {
|
|
85
|
+
type: "string",
|
|
86
|
+
description: "Where the catalog is written, relative to `root`. Default `reports/component-catalog.json`.",
|
|
87
|
+
},
|
|
88
|
+
catalogPath: { type: "string", description: "Deprecated alias of `exportPath`." },
|
|
89
|
+
includeDynamic: { type: "boolean" },
|
|
90
|
+
dynamicCatalog: { type: "array" },
|
|
91
|
+
dynamicCatalogPath: { type: "string" },
|
|
92
|
+
rawHtml: { type: "boolean" },
|
|
93
|
+
parts: { type: "boolean" },
|
|
94
|
+
tsconfig: { type: "string" },
|
|
95
|
+
weights: { type: "object" },
|
|
96
|
+
thresholds: { type: "object" },
|
|
97
|
+
componentsFolder: { type: "array" },
|
|
98
|
+
compareAll: { type: "boolean" },
|
|
99
|
+
proposeFromLib: {
|
|
100
|
+
type: "boolean",
|
|
101
|
+
description: "When a duplicate is found, also check the project's installed dependencies (read dynamically from package.json) for an export with the same name and suggest it in the message. Skipped for libs the file already imports (the local component is likely extending the lib, not duplicating it). Default false.",
|
|
102
|
+
},
|
|
103
|
+
include: { type: "array" },
|
|
104
|
+
exclude: { type: "array" },
|
|
105
|
+
exts: { type: "array" },
|
|
106
|
+
ignoreDirs: { type: "array" },
|
|
107
|
+
rootMarkers: { type: "array" },
|
|
108
|
+
cache: { type: "boolean" },
|
|
109
|
+
root: { type: "string" },
|
|
110
|
+
},
|
|
111
|
+
additionalProperties: false,
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
create(context) {
|
|
116
|
+
const options = context.options && context.options[0] ? context.options[0] : {};
|
|
117
|
+
const config = (0, config_1.normalizeOptions)(options);
|
|
118
|
+
const filename = context.filename || (context.getFilename ? context.getFilename() : "");
|
|
119
|
+
const relPath = path.relative(config.root, filename).split(path.sep).join("/");
|
|
120
|
+
const isInComponentsFolder = (0, config_1.inComponentsFolder)(relPath, config.componentsFolder);
|
|
121
|
+
if ((0, config_1.isIgnored)(relPath, isInComponentsFolder ? [] : config.include, config.exclude))
|
|
122
|
+
return {};
|
|
123
|
+
const registry = (0, config_1.loadRegistry)(config);
|
|
124
|
+
// Self-maintain the on-disk catalog (per-file mtime+size cache in
|
|
125
|
+
// os.tmpdir()). Fast path (~0ms) when nothing changed.
|
|
126
|
+
if (config.cache !== false)
|
|
127
|
+
(0, self_catalog_1.refreshCatalog)(config);
|
|
128
|
+
const catalogComponents = (((0, config_1.loadCatalog)(config) || {}).components) || [];
|
|
129
|
+
const canonNames = [...new Set(catalogComponents.map((c) => c.name))];
|
|
130
|
+
// proposeFromLib: inventory of the project's installed dependency
|
|
131
|
+
// exports, so a duplicate report can suggest "use `Accordion` from
|
|
132
|
+
// `radix-ui`". Built lazily once per lint; cached in os.tmpdir()
|
|
133
|
+
// and invalidated when package.json changes.
|
|
134
|
+
let libRegistry = null;
|
|
135
|
+
const libHint = (name, sourceText) => {
|
|
136
|
+
if (!config.proposeFromLib)
|
|
137
|
+
return "";
|
|
138
|
+
if (!libRegistry)
|
|
139
|
+
libRegistry = (0, lib_registry_1.buildLibRegistry)(config.root);
|
|
140
|
+
if (libRegistry.size === 0)
|
|
141
|
+
return "";
|
|
142
|
+
const imports = (0, lib_registry_1.fileImportSpecifiers)(sourceText);
|
|
143
|
+
const suggestions = (0, lib_registry_1.suggestFromLib)(name, libRegistry, imports);
|
|
144
|
+
if (suggestions.length === 0)
|
|
145
|
+
return "";
|
|
146
|
+
const list = suggestions.map((s) => `\`${s.name}\` from \`${s.lib}\``).join(", ");
|
|
147
|
+
return ` Consider using ${list} instead of a local implementation.`;
|
|
148
|
+
};
|
|
149
|
+
const checkDuplicates = () => {
|
|
150
|
+
let parsed;
|
|
151
|
+
let liveText = null;
|
|
152
|
+
try {
|
|
153
|
+
// Parse the LIVE source (the editor buffer), not the disk
|
|
154
|
+
// state: on save the ESLint extension lints the buffer via
|
|
155
|
+
// lintText, and the file on disk may not match it yet.
|
|
156
|
+
const sourceCode = context.sourceCode || (context.getSourceCode ? context.getSourceCode() : null);
|
|
157
|
+
liveText = sourceCode === null ? null : typeof sourceCode === "string" ? sourceCode : typeof sourceCode.text === "string" ? sourceCode.text : null;
|
|
158
|
+
if (liveText !== null)
|
|
159
|
+
(0, framework_js_1.setLiveSource)(filename, liveText, config);
|
|
160
|
+
parsed = (0, framework_js_1.parseComponents)(filename, canonNames, config);
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const normalizeComp = (comp) => (0, candidate_js_1.buildCandidate)(comp, config);
|
|
166
|
+
for (const comp of parsed) {
|
|
167
|
+
if (!comp.isExported)
|
|
168
|
+
continue;
|
|
169
|
+
const candidate = normalizeComp({ ...comp, path: relPath });
|
|
170
|
+
const pairs = [];
|
|
171
|
+
for (const canon of catalogComponents) {
|
|
172
|
+
if (canon.name === candidate.name)
|
|
173
|
+
continue;
|
|
174
|
+
if (!(0, config_1.canSeeCanon)(relPath, canon.path, config.componentsFolder, config.compareAll))
|
|
175
|
+
continue;
|
|
176
|
+
const normCanon = normalizeCanon(canon, config);
|
|
177
|
+
const signals = (0, matcher_1.matchSignals)(candidate, normCanon, { canonNames, frameworkMatcher });
|
|
178
|
+
const decision = (0, decision_maker_1.decide)(candidate, normCanon, { signals, weights: config.weights, thresholds: config.thresholds });
|
|
179
|
+
pairs.push({ canon: normCanon, signals, decision });
|
|
180
|
+
}
|
|
181
|
+
pairs.sort((a, b) => b.decision.confidence - a.decision.confidence);
|
|
182
|
+
for (const p of pairs) {
|
|
183
|
+
if (!p.decision.isDuplicate)
|
|
184
|
+
continue;
|
|
185
|
+
const { kept } = (0, main_1.applyFilters)([{ app: candidate, canon: p.canon, decision: p.decision, tier: p.decision.tier, reason: p.decision.reason }]);
|
|
186
|
+
if (kept.length === 0)
|
|
187
|
+
continue;
|
|
188
|
+
const line = comp.line || 1;
|
|
189
|
+
context.report({
|
|
190
|
+
loc: { start: { line, column: 0 }, end: { line, column: 0 } },
|
|
191
|
+
messageId: "duplicateComponent",
|
|
192
|
+
data: { name: candidate.name, canonName: p.canon.name, reason: p.decision.reason, libHint: libHint(candidate.name, liveText) },
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (config.rawHtml && !isInComponentsFolder) {
|
|
197
|
+
const canons = catalogComponents.map((canon) => normalizeCanon(canon, config));
|
|
198
|
+
let elements = [];
|
|
199
|
+
try {
|
|
200
|
+
elements = (0, framework_js_1.parseElements)(filename, canonNames, config);
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
elements = [];
|
|
204
|
+
}
|
|
205
|
+
for (const element of elements) {
|
|
206
|
+
const candidate = (0, candidate_js_1.buildElementCandidate)(element, config);
|
|
207
|
+
if (!candidate)
|
|
208
|
+
continue;
|
|
209
|
+
const best = (0, decision_maker_1.bestOf)((0, main_1.matchPairs)([{ ...candidate, path: relPath }], canons, config));
|
|
210
|
+
if (!best)
|
|
211
|
+
continue;
|
|
212
|
+
context.report({
|
|
213
|
+
loc: { start: { line: element.line, column: element.column }, end: { line: element.line, column: element.column } },
|
|
214
|
+
messageId: "rawHtml",
|
|
215
|
+
data: { tag: element.name, component: best.canon.name, path: best.canon.path, reason: best.decision.reason },
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (config.parts) {
|
|
220
|
+
const canons = catalogComponents.map((canon) => normalizeCanon(canon, config));
|
|
221
|
+
for (const { part, best } of (0, main_1.findParts)(filename, relPath, canons, config, new Set(canonNames))) {
|
|
222
|
+
context.report({
|
|
223
|
+
loc: { start: { line: part.line, column: part.column }, end: { line: part.endLine, column: 0 } },
|
|
224
|
+
messageId: "partOfComponent",
|
|
225
|
+
data: { owner: part.owner, tag: part.rootTag, component: best.canon.name, path: best.canon.path, reason: best.decision.reason },
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
return {
|
|
231
|
+
"Program:exit": checkDuplicates,
|
|
232
|
+
};
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
const rule = createRule();
|
|
237
|
+
const pkg = __importStar(require("./package.json"));
|
|
238
|
+
exports.meta = {
|
|
239
|
+
name: pkg.name,
|
|
240
|
+
version: pkg.version,
|
|
241
|
+
};
|
|
242
|
+
exports.rules = {
|
|
243
|
+
"component-uniqueness": rule,
|
|
244
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const buildLibRegistry: (root: any) => Map<any, any>;
|
|
2
|
+
declare const fileImportSpecifiers: (sourceText: any) => Set<unknown>;
|
|
3
|
+
declare const suggestFromLib: (candidateName: any, libRegistry: any, fileImports?: Set<unknown>, max?: number) => any[];
|
|
4
|
+
export { buildLibRegistry, fileImportSpecifiers, suggestFromLib };
|