web-components-doctor 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.
Files changed (39) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +173 -0
  3. package/dist/adapters/lit-adapter.d.ts +19 -0
  4. package/dist/adapters/lit-adapter.d.ts.map +1 -0
  5. package/dist/adapters/lit-adapter.js +145 -0
  6. package/dist/adapters/lit-adapter.js.map +1 -0
  7. package/dist/core/rule-factory.d.ts +34 -0
  8. package/dist/core/rule-factory.d.ts.map +1 -0
  9. package/dist/core/rule-factory.js +297 -0
  10. package/dist/core/rule-factory.js.map +1 -0
  11. package/dist/core/types.d.ts +92 -0
  12. package/dist/core/types.d.ts.map +1 -0
  13. package/dist/core/types.js +13 -0
  14. package/dist/core/types.js.map +1 -0
  15. package/dist/descriptors/components.d.ts +21 -0
  16. package/dist/descriptors/components.d.ts.map +1 -0
  17. package/dist/descriptors/components.js +202 -0
  18. package/dist/descriptors/components.js.map +1 -0
  19. package/dist/index.d.ts +37 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +69 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/rules/accessible-component.d.ts +13 -0
  24. package/dist/rules/accessible-component.d.ts.map +1 -0
  25. package/dist/rules/accessible-component.js +15 -0
  26. package/dist/rules/accessible-component.js.map +1 -0
  27. package/dist/rules/no-deprecated.d.ts +13 -0
  28. package/dist/rules/no-deprecated.d.ts.map +1 -0
  29. package/dist/rules/no-deprecated.js +15 -0
  30. package/dist/rules/no-deprecated.js.map +1 -0
  31. package/dist/rules/required-attributes.d.ts +13 -0
  32. package/dist/rules/required-attributes.d.ts.map +1 -0
  33. package/dist/rules/required-attributes.js +15 -0
  34. package/dist/rules/required-attributes.js.map +1 -0
  35. package/dist/rules/valid-attribute-values.d.ts +13 -0
  36. package/dist/rules/valid-attribute-values.d.ts.map +1 -0
  37. package/dist/rules/valid-attribute-values.js +15 -0
  38. package/dist/rules/valid-attribute-values.js.map +1 -0
  39. package/package.json +62 -0
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2026 Adobe. All rights reserved.
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,173 @@
1
+ # web-components-doctor
2
+
3
+ ESLint plugin for [Spectrum Web Components](https://opensource.adobe.com/spectrum-web-components/) consumers. Catches accessibility gaps, deprecated APIs, and invalid attribute usage **at lint time** — shifting left what `window.__swc.warn()` and axe catch at runtime.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install web-components-doctor --save-dev
9
+ ```
10
+
11
+ ## Quick Start (ESLint 9+ flat config)
12
+
13
+ ```js
14
+ // eslint.config.js
15
+ import swc from 'web-components-doctor';
16
+
17
+ export default [
18
+ swc.configs.recommended,
19
+ ];
20
+ ```
21
+
22
+ Or for strict CI enforcement:
23
+
24
+ ```js
25
+ export default [
26
+ swc.configs.strict,
27
+ ];
28
+ ```
29
+
30
+ ## Rules
31
+
32
+ ### `swc/accessible-component`
33
+
34
+ Require accessibility attributes on SWC elements.
35
+
36
+ ```js
37
+ // ❌ Bad
38
+ html`<sp-action-menu></sp-action-menu>`;
39
+ html`<sp-picker></sp-picker>`;
40
+
41
+ // ✅ Good
42
+ html`<sp-action-menu label="More actions"></sp-action-menu>`;
43
+ html`<sp-picker aria-label="Select option"></sp-picker>`;
44
+ ```
45
+
46
+ | Element | Required (at least one of) |
47
+ |---|---|
48
+ | `<sp-action-menu>` | `label`, `aria-label`, `aria-labelledby` |
49
+ | `<sp-avatar>` | `label`, `is-decorative` |
50
+ | `<sp-clear-button>` | `label` |
51
+ | `<sp-dialog-wrapper>` | `headline` |
52
+ | `<sp-picker>` | `label`, `aria-label`, `aria-labelledby` |
53
+ | `<sp-progress-bar>` | `label`, `aria-label`, `aria-labelledby` |
54
+ | `<sp-progress-circle>` | `label`, `aria-label`, `aria-labelledby` |
55
+ | `<sp-status-light>` | `label`, `aria-label`, `aria-labelledby` |
56
+ | `<sp-tabs>` | `accessible-label`, `aria-label`, `aria-labelledby` |
57
+
58
+ ### `swc/no-deprecated`
59
+
60
+ Flag deprecated attributes and attribute values.
61
+
62
+ ```js
63
+ // ❌ Bad
64
+ html`<sp-button variant="cta">Click</sp-button>`;
65
+ html`<sp-overlay allow-outside-click></sp-overlay>`;
66
+
67
+ // ✅ Good
68
+ html`<sp-button variant="accent">Click</sp-button>`;
69
+ html`<sp-overlay></sp-overlay>`;
70
+ ```
71
+
72
+ | Deprecated | Replacement |
73
+ |---|---|
74
+ | `<sp-button variant="cta">` | `variant="accent"` |
75
+ | `<sp-button variant="overBackground">` | `static-color="white" treatment="outline"` |
76
+ | `<sp-button href="...">` | Use native `<a>` element |
77
+ | `<sp-overlay allow-outside-click>` | Remove attribute |
78
+ | `<sp-status-light variant="accent">` | `"neutral"` or `"info"` |
79
+ | `<sp-status-light disabled>` | Remove attribute |
80
+
81
+ ### `swc/required-attributes`
82
+
83
+ Enforce presence of configuration attributes.
84
+
85
+ ```js
86
+ // ❌ Bad
87
+ html`<sp-theme></sp-theme>`;
88
+ html`<overlay-trigger>content</overlay-trigger>`;
89
+
90
+ // ✅ Good
91
+ html`<sp-theme color="light" scale="medium" system="spectrum"></sp-theme>`;
92
+ html`<overlay-trigger triggered-by="click hover">content</overlay-trigger>`;
93
+ ```
94
+
95
+ ### `swc/valid-attribute-values`
96
+
97
+ Catch invalid enum values at lint time.
98
+
99
+ ```js
100
+ // ❌ Bad
101
+ html`<sp-theme color="lightest"></sp-theme>`;
102
+ html`<sp-button variant="danger">Click</sp-button>`;
103
+
104
+ // ✅ Good
105
+ html`<sp-theme color="light"></sp-theme>`;
106
+ html`<sp-button variant="accent">Click</sp-button>`;
107
+ ```
108
+
109
+ ## Architecture
110
+
111
+ This plugin is **data-driven**. Rules are generated from component descriptors rather than hand-written per component:
112
+
113
+ ```
114
+ src/
115
+ ├── adapters/ # Template syntax parsers (Lit today, JSX/HTML next)
116
+ │ └── lit-adapter.ts # Extracts elements from html`` tagged templates
117
+ ├── core/
118
+ │ ├── types.ts # Normalized IR (ParsedElement, descriptors)
119
+ │ └── rule-factory.ts # Generates ESLint rules from descriptors
120
+ ├── descriptors/
121
+ │ └── components.ts # Component accessibility/deprecation metadata
122
+ ├── rules/ # Thin wrappers: factory(descriptors)
123
+ └── index.ts # Plugin entry with recommended/strict configs
124
+ ```
125
+
126
+ ### Adding a new component
127
+
128
+ Add an entry to `src/descriptors/components.ts`:
129
+
130
+ ```typescript
131
+ 'sp-new-component': {
132
+ tagName: 'sp-new-component',
133
+ accessibility: {
134
+ requireOneOf: ['label', 'aria-label', 'aria-labelledby'],
135
+ },
136
+ validAttributeValues: {
137
+ variant: ['primary', 'secondary'],
138
+ },
139
+ }
140
+ ```
141
+
142
+ No new rule code needed — the rule factory picks it up automatically.
143
+
144
+ ### Adding a new template syntax (e.g. JSX)
145
+
146
+ Create a new adapter in `src/adapters/` that returns `ParsedElement[]` from the relevant AST node type. The rule logic is template-agnostic.
147
+
148
+ ## Configs
149
+
150
+ | Config | Severity | Use case |
151
+ |---|---|---|
152
+ | `swc.configs.recommended` | `warn` | Incremental adoption, developer experience |
153
+ | `swc.configs.strict` | `error` | CI enforcement, blocking on violations |
154
+
155
+ ## Dynamic values
156
+
157
+ The plugin **skips** attributes with dynamic template expressions since they can't be statically verified:
158
+
159
+ ```js
160
+ // No warning — value is dynamic
161
+ html`<sp-action-menu label=${this.label}></sp-action-menu>`;
162
+ ```
163
+
164
+ ## Related
165
+
166
+ - [Spectrum Web Components](https://opensource.adobe.com/spectrum-web-components/) — the component library
167
+ - [eslint-plugin-lit-a11y](https://github.com/open-wc/open-wc/tree/master/packages/eslint-plugin-lit-a11y) — generic Lit accessibility rules
168
+ - [axe-core](https://github.com/dequelabs/axe-core) — runtime accessibility testing
169
+ - [Alex Hayton's eslint-plugin-spectrum-web-components-lit](https://github.com/AlexHayton/eslint-plugin-spectrum-web-components-lit) — the original inspiration
170
+
171
+ ## License
172
+
173
+ Apache-2.0
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import type { Rule } from 'eslint';
13
+ import type { ParsedElement } from '../core/types.js';
14
+ /**
15
+ * Extract all SWC elements from a Lit `html` tagged template expression.
16
+ * Returns an empty array if the node is not a Lit template.
17
+ */
18
+ export declare function extractElementsFromTemplate(node: Rule.Node): ParsedElement[];
19
+ //# sourceMappingURL=lit-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lit-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/lit-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAiKtE;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,aAAa,EAAE,CAa5E"}
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import { parseFragment } from 'parse5';
13
+ /** Placeholder inserted where template expressions (${...}) appear. */
14
+ const EXPR_PLACEHOLDER = '\u200B__SWC_EXPR__\u200B';
15
+ const LIT_HTML_TAGS = new Set(['html']);
16
+ /**
17
+ * Check whether an ESTree node is a Lit `html` tagged template expression.
18
+ */
19
+ function isLitHtmlTemplate(node) {
20
+ if (node.type !== 'TaggedTemplateExpression')
21
+ return false;
22
+ const te = node;
23
+ const { tag } = te;
24
+ if (tag.type === 'Identifier' && LIT_HTML_TAGS.has(tag.name ?? '')) {
25
+ return true;
26
+ }
27
+ if (tag.type === 'MemberExpression' &&
28
+ tag.property?.name &&
29
+ LIT_HTML_TAGS.has(tag.property.name)) {
30
+ return true;
31
+ }
32
+ return false;
33
+ }
34
+ /**
35
+ * Reconstruct the template text from quasis, inserting placeholders for expressions.
36
+ */
37
+ function getTemplateText(node) {
38
+ const te = node;
39
+ return te.quasi.quasis
40
+ .map((quasi, i) => {
41
+ const text = quasi.value.raw;
42
+ if (i < te.quasi.quasis.length - 1) {
43
+ return text + EXPR_PLACEHOLDER;
44
+ }
45
+ return text;
46
+ })
47
+ .join('');
48
+ }
49
+ /**
50
+ * Parse an attribute name that may have Lit binding prefixes.
51
+ */
52
+ function parseAttributeName(raw) {
53
+ if (raw.startsWith('.'))
54
+ return { name: raw.slice(1), bindingType: '.' };
55
+ if (raw.startsWith('?'))
56
+ return { name: raw.slice(1), bindingType: '?' };
57
+ if (raw.startsWith('@'))
58
+ return { name: raw.slice(1), bindingType: '@' };
59
+ return { name: raw };
60
+ }
61
+ /**
62
+ * Convert a parse5 document fragment into our normalized ParsedElement[].
63
+ * Only returns elements whose tag names start with `sp-` or are `overlay-trigger`.
64
+ */
65
+ function extractFromParse5(fragment) {
66
+ const results = [];
67
+ function walk(nodes) {
68
+ const localResults = [];
69
+ for (const node of nodes) {
70
+ if (node.nodeName === '#text')
71
+ continue;
72
+ if (node.nodeName === '#comment')
73
+ continue;
74
+ const tagName = node.tagName ?? node.nodeName;
75
+ const childElements = node.childNodes ? walk(node.childNodes) : [];
76
+ const isSwcElement = tagName.startsWith('sp-') || tagName === 'overlay-trigger';
77
+ if (!isSwcElement) {
78
+ localResults.push(...childElements);
79
+ continue;
80
+ }
81
+ const attributes = new Map();
82
+ if (node.attrs) {
83
+ for (const attr of node.attrs) {
84
+ const { name, bindingType } = parseAttributeName(attr.name);
85
+ const isDynamic = attr.value.includes(EXPR_PLACEHOLDER);
86
+ attributes.set(name, {
87
+ value: isDynamic ? null : attr.value,
88
+ isDynamic,
89
+ bindingType,
90
+ });
91
+ }
92
+ }
93
+ let hasTextContent = false;
94
+ if (node.childNodes) {
95
+ for (const child of node.childNodes) {
96
+ if (child.nodeName === '#text') {
97
+ const text = child.value ?? '';
98
+ const stripped = text.replace(/\u200B__SWC_EXPR__\u200B/g, '').trim();
99
+ if (stripped.length > 0) {
100
+ hasTextContent = true;
101
+ break;
102
+ }
103
+ }
104
+ }
105
+ }
106
+ localResults.push({
107
+ tagName,
108
+ attributes,
109
+ children: childElements,
110
+ hasTextContent,
111
+ loc: node.sourceCodeLocation
112
+ ? {
113
+ startOffset: node.sourceCodeLocation.startOffset,
114
+ endOffset: node.sourceCodeLocation.endOffset,
115
+ startLine: node.sourceCodeLocation.startLine,
116
+ startCol: node.sourceCodeLocation.startCol,
117
+ }
118
+ : undefined,
119
+ });
120
+ }
121
+ return localResults;
122
+ }
123
+ const nodes = fragment.childNodes;
124
+ results.push(...walk(nodes));
125
+ return results;
126
+ }
127
+ /**
128
+ * Extract all SWC elements from a Lit `html` tagged template expression.
129
+ * Returns an empty array if the node is not a Lit template.
130
+ */
131
+ export function extractElementsFromTemplate(node) {
132
+ if (!isLitHtmlTemplate(node))
133
+ return [];
134
+ const templateText = getTemplateText(node);
135
+ try {
136
+ const fragment = parseFragment(templateText, {
137
+ sourceCodeLocationInfo: true,
138
+ });
139
+ return extractFromParse5(fragment);
140
+ }
141
+ catch {
142
+ return [];
143
+ }
144
+ }
145
+ //# sourceMappingURL=lit-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lit-adapter.js","sourceRoot":"","sources":["../../src/adapters/lit-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAIvC,uEAAuE;AACvE,MAAM,gBAAgB,GAAG,0B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AC,SAAS;wBAC5C,SAAS,EAAE,IAAI,CAAC,kBAAkB,CAAC,SAAS;wBAC5C,QAAQ,EAAE,IAAI,CAAC,kBAAkB,CAAC,QAAQ;qBAC3C;oBACH,CAAC,CAAC,SAAS;aACd,CAAC,CAAC;QACL,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,KAAK,GAAI,QAAoD,CAAC,UAAU,CAAC;IAC/E,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAe;IACzD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAExC,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAE3C,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,aAAa,CAAC,YAAY,EAAE;YAC3C,sBAAsB,EAAE,IAAI;SAC7B,CAAC,CAAC;QACH,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import type { Rule } from 'eslint';
13
+ import type { ComponentDescriptorMap } from './types.js';
14
+ type RuleModule = Rule.RuleModule;
15
+ /**
16
+ * Creates the `accessible-component` rule that checks all components
17
+ * against their accessibility descriptors.
18
+ */
19
+ export declare function createAccessibleComponentRule(descriptors: ComponentDescriptorMap): RuleModule;
20
+ /**
21
+ * Creates the `no-deprecated` rule that flags deprecated attributes
22
+ * and attribute values across all described components.
23
+ */
24
+ export declare function createNoDeprecatedRule(descriptors: ComponentDescriptorMap): RuleModule;
25
+ /**
26
+ * Creates the `required-attributes` rule.
27
+ */
28
+ export declare function createRequiredAttributesRule(descriptors: ComponentDescriptorMap): RuleModule;
29
+ /**
30
+ * Creates the `valid-attribute-values` rule.
31
+ */
32
+ export declare function createValidAttributeValuesRule(descriptors: ComponentDescriptorMap): RuleModule;
33
+ export {};
34
+ //# sourceMappingURL=rule-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-factory.d.ts","sourceRoot":"","sources":["../../src/core/rule-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAEV,sBAAsB,EAIvB,MAAM,YAAY,CAAC;AAGpB,KAAK,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;AAmClC;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,sBAAsB,GAClC,UAAU,CAoGZ;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,sBAAsB,GAClC,UAAU,CAoEZ;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,sBAAsB,GAClC,UAAU,CAyCZ;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,sBAAsB,GAClC,UAAU,CAmDZ"}