@sixbell-telco/eslint-plugin-sdk 0.0.0-stage → 0.1.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.
@@ -0,0 +1,461 @@
1
+ /**
2
+ * Template rules: Angular templates (`.html`, or inline templates through the angular-eslint
3
+ * processor) checked against the SDK manifest.
4
+ */
5
+ import { getTemplateParserServices } from '@angular-eslint/utils';
6
+ import { closest, declarationsFor, isDomBinding, isForeignDirectiveName, KNOWN_DIRECTIVE_INPUTS, manifestFor } from '../manifest.mjs';
7
+
8
+ /**
9
+ * @typedef {import('eslint').Rule.RuleContext} RuleContext
10
+ * @typedef {import('eslint').Rule.ReportFixer} ReportFixer
11
+ * @typedef {import('../types.js').ManifestIndex} ManifestIndex
12
+ * @typedef {import('../types.js').ManifestDeclaration} ManifestDeclaration
13
+ * @typedef {import('../types.js').ManifestInput} ManifestInput
14
+ * @typedef {import('../types.js').TemplateElement} TemplateElement
15
+ * @typedef {import('../types.js').TemplateSpan} TemplateSpan
16
+ * @typedef {import('../types.js').TemplateTextAttribute} TemplateTextAttribute
17
+ * @typedef {import('../types.js').TemplateBoundAttribute} TemplateBoundAttribute
18
+ * @typedef {{ convertNodeSourceSpanToLoc(span: TemplateSpan): import('eslint').AST.SourceLocation }} TemplateServices
19
+ * @typedef {{ Element(element: TemplateElement): void }} TemplateVisitors
20
+ */
21
+
22
+ /** @param {string} name */
23
+ const docs = (name) => `https://github.com/EnghouseGlobal/nw-sx-web-libs-ui-kit/blob/develop/projects/eslint-plugin-sdk/README.md#${name}`;
24
+ const KIT_ELEMENT = /^st-/;
25
+ /** @param {string} name */
26
+ const isCamel = (name) => /[A-Z]/.test(name);
27
+
28
+ /**
29
+ * The template parser services; the cast is the boundary between ESLint's and angular-eslint's context types.
30
+ * @param {RuleContext} context
31
+ * @returns {TemplateServices}
32
+ */
33
+ const servicesOf = (context) => /** @type {TemplateServices} */ (/** @type {unknown} */ (getTemplateParserServices(/** @type {any} */ (context))));
34
+
35
+ /**
36
+ * Visitors that need the manifest; none when the SDK manifest cannot be found.
37
+ * @param {RuleContext} context
38
+ * @param {(index: ManifestIndex, services: TemplateServices) => TemplateVisitors} visitors
39
+ * @returns {TemplateVisitors | {}}
40
+ */
41
+ function withManifest(context, visitors) {
42
+ const index = manifestFor(context);
43
+ return index ? visitors(index, servicesOf(context)) : {};
44
+ }
45
+
46
+ /** @param {ManifestDeclaration[]} declarations */
47
+ const inputsOf = (declarations) => declarations.flatMap((d) => d.inputs ?? []);
48
+ /** @param {ManifestDeclaration[]} declarations */
49
+ const outputsOf = (declarations) => declarations.flatMap((d) => d.outputs ?? []);
50
+
51
+ /** @param {string | true} reason */
52
+ const deprecationText = (reason) => (reason === true ? 'see the SDK changelog' : reason);
53
+
54
+ export const unknownElement = {
55
+ meta: {
56
+ type: /** @type {const} */ ('problem'),
57
+ docs: { description: 'Disallow `st-*` elements that the installed SDK does not declare', url: docs('unknown-element') },
58
+ schema: [],
59
+ messages: {
60
+ unknown: '<{{name}}> is not a component of @sixbell-telco/sdk {{version}}.{{suggestion}}',
61
+ },
62
+ },
63
+ /** @param {RuleContext} context */
64
+ create(context) {
65
+ return withManifest(context, (index, services) => ({
66
+ Element(element) {
67
+ if (!KIT_ELEMENT.test(element.name) || index.elementNames.includes(element.name)) return;
68
+ const match = closest(element.name, index.elementNames);
69
+ context.report({
70
+ loc: services.convertNodeSourceSpanToLoc(element.startSourceSpan ?? element.sourceSpan),
71
+ messageId: 'unknown',
72
+ data: { name: element.name, version: index.manifest.version, suggestion: match ? ` Did you mean <${match}>?` : '' },
73
+ });
74
+ },
75
+ }));
76
+ },
77
+ };
78
+
79
+ export const unknownInput = {
80
+ meta: {
81
+ type: /** @type {const} */ ('problem'),
82
+ docs: { description: 'Disallow inputs and outputs that a kit component does not have', url: docs('unknown-input') },
83
+ schema: [],
84
+ messages: {
85
+ input: '<{{element}}> has no input "{{name}}".{{suggestion}} Inputs: {{known}}.',
86
+ output: '<{{element}}> has no output "{{name}}".{{suggestion}} Outputs: {{known}}.',
87
+ },
88
+ },
89
+ /** @param {RuleContext} context */
90
+ create(context) {
91
+ return withManifest(context, (index, services) => ({
92
+ Element(element) {
93
+ if (!KIT_ELEMENT.test(element.name)) return;
94
+ const declarations = declarationsFor(index, element);
95
+ if (!declarations.length) return;
96
+ const inputs = inputsOf(declarations).map((i) => i.name);
97
+ const outputs = outputsOf(declarations).map((o) => o.name);
98
+ const models = inputsOf(declarations)
99
+ .filter((i) => i.twoWay)
100
+ .map((i) => `${i.name}Change`);
101
+ /**
102
+ * @param {{ keySpan?: TemplateSpan, sourceSpan: TemplateSpan }} node
103
+ * @param {'input' | 'output'} messageId
104
+ * @param {string} name
105
+ * @param {string[]} known
106
+ */
107
+ const report = (node, messageId, name, known) => {
108
+ const match = closest(name, known);
109
+ context.report({
110
+ loc: services.convertNodeSourceSpanToLoc(node.keySpan ?? node.sourceSpan),
111
+ messageId,
112
+ data: { element: element.name, name, suggestion: match ? ` Did you mean "${match}"?` : '', known: known.join(', ') || 'none' },
113
+ });
114
+ };
115
+ // Bound inputs ([x]) are left to the Angular type checker, which knows every directive
116
+ // the component imports. Static camelCase attributes are not type-checked, so they are
117
+ // checked here, except names another directive may own.
118
+ /** @param {string} name */
119
+ const foreign = (name) => KNOWN_DIRECTIVE_INPUTS.has(name) || isForeignDirectiveName(name, context);
120
+ // Another directive on the element (an attribute or bound input with a directive name) may
121
+ // own any other name; then only a near-typo of a kit name is reported. Unknown bound inputs
122
+ // alone do not count: the type checker reports those. Known Angular and CDK directives
123
+ // (formControlName, routerLink ...) have fixed inputs, so they do not count either.
124
+ const otherDirective = [...element.attributes, ...element.inputs].some(
125
+ (a) => isCamel(a.name) && !KNOWN_DIRECTIVE_INPUTS.has(a.name) && isForeignDirectiveName(a.name, context),
126
+ );
127
+ /**
128
+ * @param {string} name
129
+ * @param {string[]} known
130
+ */
131
+ const owned = (name, known) => foreign(name) || (otherDirective && !closest(name, known, 2));
132
+ for (const attribute of element.attributes) {
133
+ // Static HTML attributes are lowercase; a camelCase one is meant as an input.
134
+ if (!isCamel(attribute.name) || inputs.includes(attribute.name) || owned(attribute.name, inputs)) continue;
135
+ report(attribute, 'input', attribute.name, inputs);
136
+ }
137
+ const knownOutputs = [...outputs, ...models];
138
+ for (const output of element.outputs) {
139
+ // DOM events are lowercase (click, keydown); a camelCase one is meant as an output.
140
+ if (!isCamel(output.name) || knownOutputs.includes(output.name) || owned(output.name, knownOutputs)) continue;
141
+ report(output, 'output', output.name, knownOutputs);
142
+ }
143
+ },
144
+ }));
145
+ },
146
+ };
147
+
148
+ /**
149
+ * The literal string a binding passes to an input (`[variant]="'danger'"`), when it is one.
150
+ * @param {TemplateBoundAttribute} node
151
+ * @returns {string | null}
152
+ */
153
+ function literalValue(node) {
154
+ const value = /** @type {{ ast?: unknown } | undefined} */ (node.value);
155
+ const ast = /** @type {{ constructor?: { name?: string }, value?: unknown } | undefined} */ (value?.ast ?? value);
156
+ if (ast && ast.constructor?.name === 'LiteralPrimitive' && typeof ast.value === 'string') return ast.value;
157
+ return null;
158
+ }
159
+
160
+ export const invalidInputValue = {
161
+ meta: {
162
+ type: /** @type {const} */ ('problem'),
163
+ docs: { description: 'Disallow a value outside an input’s allowed values', url: docs('invalid-input-value') },
164
+ schema: [],
165
+ messages: { invalid: '"{{value}}" is not a value of <{{element}}> {{name}}. Allowed: {{allowed}}.{{suggestion}}' },
166
+ },
167
+ /** @param {RuleContext} context */
168
+ create(context) {
169
+ return withManifest(context, (index, services) => ({
170
+ Element(element) {
171
+ const declarations = declarationsFor(index, element);
172
+ if (!declarations.length) return;
173
+ const byName = new Map(inputsOf(declarations).map((i) => [i.name, i]));
174
+ /**
175
+ * @param {{ name: string, valueSpan?: TemplateSpan, sourceSpan: TemplateSpan }} node
176
+ * @param {string | null} value
177
+ */
178
+ const check = (node, value) => {
179
+ const input = byName.get(node.name);
180
+ if (!input?.values || value === null || input.values.includes(value)) return;
181
+ const match = closest(value, input.values);
182
+ context.report({
183
+ loc: services.convertNodeSourceSpanToLoc(node.valueSpan ?? node.sourceSpan),
184
+ messageId: 'invalid',
185
+ data: {
186
+ value,
187
+ element: element.name,
188
+ name: node.name,
189
+ allowed: input.values.join(', '),
190
+ suggestion: match ? ` Did you mean "${match}"?` : '',
191
+ },
192
+ });
193
+ };
194
+ for (const attribute of element.attributes) check(attribute, attribute.value);
195
+ for (const input of element.inputs) if (!isDomBinding(input)) check(input, literalValue(input));
196
+ },
197
+ }));
198
+ },
199
+ };
200
+
201
+ export const deprecatedInput = {
202
+ meta: {
203
+ type: /** @type {const} */ ('suggestion'),
204
+ docs: { description: 'Flag inputs the SDK marks as deprecated', url: docs('deprecated-input') },
205
+ schema: [],
206
+ messages: { deprecated: '<{{element}}> {{name}} is deprecated: {{reason}}' },
207
+ },
208
+ /** @param {RuleContext} context */
209
+ create(context) {
210
+ return withManifest(context, (index, services) => ({
211
+ Element(element) {
212
+ const declarations = declarationsFor(index, element);
213
+ if (!declarations.length) return;
214
+ const byName = new Map(inputsOf(declarations).map((i) => [i.name, i]));
215
+ for (const node of [...element.attributes, ...element.inputs]) {
216
+ const input = byName.get(node.name);
217
+ if (!input?.deprecated) continue;
218
+ context.report({
219
+ loc: services.convertNodeSourceSpanToLoc(node.keySpan ?? node.sourceSpan),
220
+ messageId: 'deprecated',
221
+ data: { element: element.name, name: node.name, reason: deprecationText(input.deprecated) },
222
+ });
223
+ }
224
+ },
225
+ }));
226
+ },
227
+ };
228
+
229
+ /**
230
+ * Utility classes of a deprecated token mapped to their replacement (`shadow-main` -> `shadow-overlay`).
231
+ * @param {ManifestIndex} index
232
+ * @returns {Map<string, string>}
233
+ */
234
+ export function deprecatedUtilities(index) {
235
+ /** @type {Map<string, string>} */
236
+ const map = new Map();
237
+ const colorUtilities = index.manifest.colorUtilities ?? [];
238
+ for (const token of index.tokens.values()) {
239
+ const replacement = token.deprecated && index.tokens.get(token.deprecated.replacement);
240
+ if (!replacement) continue;
241
+ if (token.utility && replacement.utility) map.set(token.utility, replacement.utility);
242
+ if (token.group === 'color' && replacement.group === 'color') {
243
+ for (const prefix of colorUtilities) map.set(`${prefix}-${token.suffix}`, `${prefix}-${replacement.suffix}`);
244
+ }
245
+ }
246
+ return map;
247
+ }
248
+
249
+ /**
250
+ * `hover:!shadow-main/50` -> { prefix: 'hover:!', utility: 'shadow-main', suffix: '/50' }
251
+ * @param {string} token
252
+ * @returns {{ prefix: string, utility: string, suffix: string } | null}
253
+ */
254
+ const splitClass = (token) => {
255
+ const match = /^((?:[^:]+:)*!?)([a-z][a-z0-9-]*)((?:\/[\w.]+)?!?)$/.exec(token);
256
+ return match ? { prefix: match[1], utility: match[2], suffix: match[3] } : null;
257
+ };
258
+
259
+ /**
260
+ * @typedef {{ token: string, start: number, prefix: string, utility: string | null, suffix: string }} ClassToken
261
+ */
262
+
263
+ /**
264
+ * Each class token of a static class attribute, with its offset in the source and its utility.
265
+ * @param {RuleContext} context
266
+ * @param {TemplateTextAttribute & { valueSpan: TemplateSpan }} attribute
267
+ * @returns {ClassToken[]}
268
+ */
269
+ function classTokens(context, attribute) {
270
+ const source = context.sourceCode.getText();
271
+ let offset = attribute.valueSpan.start.offset;
272
+ const raw = source.slice(offset, attribute.valueSpan.end.offset);
273
+ if (raw[0] === '"' || raw[0] === "'") offset += 1;
274
+ return [...attribute.value.matchAll(/\S+/g)].map((match) => {
275
+ const parts = splitClass(match[0]);
276
+ return {
277
+ token: match[0],
278
+ start: offset + (match.index ?? 0),
279
+ prefix: parts?.prefix ?? '',
280
+ utility: parts?.utility ?? null,
281
+ suffix: parts?.suffix ?? '',
282
+ };
283
+ });
284
+ }
285
+
286
+ /**
287
+ * The static `class` attribute of an element, when it has a value span.
288
+ * @param {TemplateElement} element
289
+ * @returns {(TemplateTextAttribute & { valueSpan: TemplateSpan }) | undefined}
290
+ */
291
+ const classAttributeOf = (element) => {
292
+ const attribute = element.attributes.find((a) => a.name === 'class');
293
+ return attribute?.valueSpan ? /** @type {TemplateTextAttribute & { valueSpan: TemplateSpan }} */ (attribute) : undefined;
294
+ };
295
+
296
+ /**
297
+ * Autofixes only in real .html files: in an inline template the offsets of the extracted text
298
+ * differ from the .ts source wherever the string has escapes.
299
+ * @param {RuleContext} context
300
+ */
301
+ const canFix = (context) => (context.physicalFilename ?? context.filename).endsWith('.html');
302
+
303
+ export const deprecatedToken = {
304
+ meta: {
305
+ type: /** @type {const} */ ('suggestion'),
306
+ fixable: /** @type {const} */ ('code'),
307
+ docs: { description: 'Replace utilities of deprecated theme tokens with their role tokens', url: docs('deprecated-token') },
308
+ schema: [],
309
+ messages: { deprecated: '{{old}} uses a deprecated theme token; use {{next}}.' },
310
+ },
311
+ /** @param {RuleContext} context */
312
+ create(context) {
313
+ return withManifest(context, (index, services) => {
314
+ const replacements = deprecatedUtilities(index);
315
+ const fixable = canFix(context);
316
+ return {
317
+ Element(element) {
318
+ const attribute = classAttributeOf(element);
319
+ if (!attribute) return;
320
+ for (const entry of classTokens(context, attribute)) {
321
+ const next = entry.utility && replacements.get(entry.utility);
322
+ if (!next) continue;
323
+ const replacement = `${entry.prefix}${next}${entry.suffix}`;
324
+ /** @type {ReportFixer} */
325
+ const fix = (fixer) => fixer.replaceTextRange([entry.start, entry.start + entry.token.length], replacement);
326
+ context.report({
327
+ loc: services.convertNodeSourceSpanToLoc(attribute.valueSpan),
328
+ messageId: 'deprecated',
329
+ data: { old: entry.token, next: replacement },
330
+ ...(fixable ? { fix } : {}),
331
+ });
332
+ }
333
+ },
334
+ };
335
+ });
336
+ },
337
+ };
338
+
339
+ /**
340
+ * DaisyUI component classes and the kit component that replaces each. A class is only reported
341
+ * when the installed SDK declares the replacement. `table` and `collapse` are left out: they are
342
+ * also plain Tailwind utilities.
343
+ * @type {Record<string, string>}
344
+ */
345
+ const DAISY_COMPONENTS = {
346
+ btn: 'st-button',
347
+ badge: 'st-badge',
348
+ alert: 'st-alert',
349
+ card: 'st-card',
350
+ modal: 'st-dialog',
351
+ input: 'st-input',
352
+ select: 'st-select',
353
+ textarea: 'st-textarea',
354
+ toggle: 'st-toggle',
355
+ checkbox: 'st-checkbox',
356
+ radio: 'st-radio',
357
+ range: 'st-range',
358
+ tabs: 'st-tab',
359
+ tab: 'st-tab',
360
+ steps: 'st-wizard',
361
+ step: 'st-wizard',
362
+ dropdown: 'st-dropdown',
363
+ menu: 'st-dropdown-menu',
364
+ tooltip: 'st-tooltip',
365
+ avatar: 'st-avatar',
366
+ progress: 'st-progress',
367
+ divider: 'st-divider',
368
+ link: 'st-link',
369
+ navbar: 'st-navbar',
370
+ };
371
+
372
+ /** Angular's BindingType.Class: `[class.badge]="on"`. */
373
+ const CLASS_BINDING = 2;
374
+
375
+ export const noDaisyuiComponent = {
376
+ meta: {
377
+ type: /** @type {const} */ ('problem'),
378
+ docs: { description: 'Use the kit component instead of a DaisyUI component class', url: docs('no-daisyui-component') },
379
+ schema: [],
380
+ messages: { component: '"{{token}}" is DaisyUI\'s {{base}} component; use <{{selector}}> from {{entryPoint}} instead.' },
381
+ },
382
+ /** @param {RuleContext} context */
383
+ create(context) {
384
+ return withManifest(context, (index, services) => {
385
+ /** @type {Map<string, ManifestDeclaration>} */
386
+ const bySelector = new Map();
387
+ for (const declaration of index.manifest.declarations) if (declaration.selector) bySelector.set(declaration.selector, declaration);
388
+ return {
389
+ Element(element) {
390
+ if (KIT_ELEMENT.test(element.name)) return;
391
+ const attribute = classAttributeOf(element);
392
+ /** @type {{ token: string, utility: string | null, span: TemplateSpan }[]} */
393
+ const entries = [
394
+ ...(attribute ? classTokens(context, attribute).map((t) => ({ token: t.token, utility: t.utility, span: attribute.valueSpan })) : []),
395
+ ...element.inputs
396
+ .filter((i) => i.__originalType === CLASS_BINDING)
397
+ .map((i) => ({ token: i.name, utility: i.name, span: i.keySpan ?? i.sourceSpan })),
398
+ ];
399
+ // The bare component class is enough: a DaisyUI modifier (badge-success) does nothing without it.
400
+ /** @type {Set<string>} */
401
+ const reported = new Set();
402
+ for (const entry of entries) {
403
+ const base = entry.utility && Object.hasOwn(DAISY_COMPONENTS, entry.utility) ? entry.utility : null;
404
+ const declaration = base ? bySelector.get(DAISY_COMPONENTS[base]) : undefined;
405
+ if (!base || !declaration || reported.has(base)) continue;
406
+ reported.add(base);
407
+ context.report({
408
+ loc: services.convertNodeSourceSpanToLoc(entry.span),
409
+ messageId: 'component',
410
+ data: { token: entry.token, base, selector: declaration.selector ?? '', entryPoint: declaration.entryPoint },
411
+ });
412
+ }
413
+ },
414
+ };
415
+ });
416
+ },
417
+ };
418
+
419
+ /**
420
+ * Utilities the kit rules forbid, with what to use instead and an optional exact replacement.
421
+ * @type {Record<string, { use: string, replace?: string }>}
422
+ */
423
+ const BANNED_UTILITIES = {
424
+ 'transition-all': { use: 'list the properties that change (transition-colors, transition-opacity, transition-[transform,opacity])' },
425
+ 'outline-none': { use: 'outline-hidden, and keep a focus-visible style', replace: 'outline-hidden' },
426
+ };
427
+
428
+ export const bannedUtility = {
429
+ meta: {
430
+ type: /** @type {const} */ ('problem'),
431
+ fixable: /** @type {const} */ ('code'),
432
+ docs: { description: 'Disallow utilities the kit forbids (transition-all, outline-none)', url: docs('banned-utility') },
433
+ schema: [],
434
+ messages: { banned: '"{{token}}" is not allowed in kit UI: {{use}}.' },
435
+ },
436
+ /** @param {RuleContext} context */
437
+ create(context) {
438
+ const fixable = canFix(context);
439
+ return {
440
+ /** @param {TemplateElement} element */
441
+ Element(element) {
442
+ const attribute = classAttributeOf(element);
443
+ if (!attribute) return;
444
+ const services = servicesOf(context);
445
+ for (const entry of classTokens(context, attribute)) {
446
+ const banned = entry.utility && Object.hasOwn(BANNED_UTILITIES, entry.utility) ? BANNED_UTILITIES[entry.utility] : null;
447
+ if (!banned) continue;
448
+ const next = banned.replace ? `${entry.prefix}${banned.replace}${entry.suffix}` : null;
449
+ /** @type {ReportFixer | undefined} */
450
+ const fix = next && fixable ? (fixer) => fixer.replaceTextRange([entry.start, entry.start + entry.token.length], next) : undefined;
451
+ context.report({
452
+ loc: services.convertNodeSourceSpanToLoc(attribute.valueSpan),
453
+ messageId: 'banned',
454
+ data: { token: entry.token, use: banned.use },
455
+ ...(fix ? { fix } : {}),
456
+ });
457
+ }
458
+ },
459
+ };
460
+ },
461
+ };
package/src/types.d.ts ADDED
@@ -0,0 +1,122 @@
1
+ /** Types for the JavaScript sources of this package (checked with `checkJs`, see tsconfig.tools.json). */
2
+
3
+ /** An input of a kit declaration, as `@sixbell-telco/sdk/manifest.json` lists it. */
4
+ export interface ManifestInput {
5
+ name: string;
6
+ property?: string;
7
+ type: string;
8
+ values?: string[];
9
+ required?: boolean;
10
+ default?: string;
11
+ transform?: string;
12
+ bareAttribute?: boolean;
13
+ twoWay?: boolean;
14
+ description?: string;
15
+ deprecated?: string | true;
16
+ hostDirective?: string;
17
+ }
18
+
19
+ export interface ManifestOutput {
20
+ name: string;
21
+ property?: string;
22
+ type: string;
23
+ description?: string;
24
+ deprecated?: string | true;
25
+ hostDirective?: string;
26
+ }
27
+
28
+ export interface ManifestDeclaration {
29
+ name: string;
30
+ kind: 'component' | 'directive' | 'pipe';
31
+ entryPoint: string;
32
+ selector?: string;
33
+ pipe?: string;
34
+ source: string;
35
+ description?: string;
36
+ deprecated?: string | true;
37
+ inputs?: ManifestInput[];
38
+ outputs?: ManifestOutput[];
39
+ slots?: { select: string }[];
40
+ stories?: string[];
41
+ }
42
+
43
+ export interface ManifestToken {
44
+ name: string;
45
+ group: string;
46
+ suffix: string;
47
+ utility?: string;
48
+ deprecated?: { replacement: string };
49
+ }
50
+
51
+ export interface Manifest {
52
+ $schema: number;
53
+ package: string;
54
+ version: string;
55
+ entryPoints: { name: string; declarations: string[] }[];
56
+ declarations: ManifestDeclaration[];
57
+ colorUtilities?: string[];
58
+ tokens: ManifestToken[];
59
+ }
60
+
61
+ /** The manifest with the lookups the rules need. */
62
+ export interface ManifestIndex {
63
+ source: string;
64
+ manifest: Manifest;
65
+ matcher: import('@angular-eslint/bundled-angular-compiler').SelectorMatcher<ManifestDeclaration>;
66
+ elementNames: string[];
67
+ entryPoints: Set<string>;
68
+ tokens: Map<string, ManifestToken>;
69
+ }
70
+
71
+ /** A source span of the Angular template AST (offsets into the template text). */
72
+ export interface TemplateSpan {
73
+ start: { offset: number };
74
+ end: { offset: number };
75
+ }
76
+
77
+ /** The template AST nodes of @angular-eslint/template-parser that the rules read. */
78
+ export interface TemplateTextAttribute {
79
+ name: string;
80
+ value: string;
81
+ sourceSpan: TemplateSpan;
82
+ keySpan?: TemplateSpan;
83
+ valueSpan?: TemplateSpan;
84
+ }
85
+
86
+ export interface TemplateBoundAttribute {
87
+ name: string;
88
+ /** ESLint overwrites `type` with the node name; Angular's BindingType is kept here. */
89
+ __originalType?: number;
90
+ type: number | string;
91
+ value: unknown;
92
+ sourceSpan: TemplateSpan;
93
+ keySpan?: TemplateSpan;
94
+ valueSpan?: TemplateSpan;
95
+ }
96
+
97
+ export interface TemplateBoundEvent {
98
+ name: string;
99
+ sourceSpan: TemplateSpan;
100
+ keySpan?: TemplateSpan;
101
+ }
102
+
103
+ export interface TemplateElement {
104
+ name: string;
105
+ attributes: TemplateTextAttribute[];
106
+ inputs: TemplateBoundAttribute[];
107
+ outputs: TemplateBoundEvent[];
108
+ sourceSpan: TemplateSpan;
109
+ startSourceSpan?: TemplateSpan;
110
+ }
111
+
112
+ /** The parts of an ESLint rule context the rules use, with this plugin's settings. */
113
+ export interface SdkSettings {
114
+ sixbellSdk?: {
115
+ manifest?: string | Manifest;
116
+ knownAttributes?: string[];
117
+ /** Root the app-convention rules read app files from (translation.json, themes.json, federation.config.js); default: ESLint's cwd. */
118
+ appRoot?: string;
119
+ /** host or child; default: detected from federation.config.js exposes. */
120
+ appKind?: 'host' | 'child';
121
+ };
122
+ }