@canonical/summon-component 0.29.0 → 0.31.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 (153) hide show
  1. package/README.md +14 -26
  2. package/{src/index.ts → dist/esm/index.js} +5 -8
  3. package/dist/esm/index.js.map +1 -0
  4. package/dist/esm/lit/generator.js +152 -0
  5. package/dist/esm/lit/generator.js.map +1 -0
  6. package/dist/esm/lit/index.js +5 -0
  7. package/dist/esm/lit/index.js.map +1 -0
  8. package/dist/esm/lit/types.js +5 -0
  9. package/dist/esm/lit/types.js.map +1 -0
  10. package/dist/esm/react/generator.js +129 -0
  11. package/dist/esm/react/generator.js.map +1 -0
  12. package/dist/esm/react/index.js +5 -0
  13. package/dist/esm/react/index.js.map +1 -0
  14. package/dist/esm/react/types.js +5 -0
  15. package/dist/esm/react/types.js.map +1 -0
  16. package/dist/esm/shared/createComponentPathPrompt.js +23 -0
  17. package/dist/esm/shared/createComponentPathPrompt.js.map +1 -0
  18. package/dist/esm/shared/createTemplateContext.js +20 -0
  19. package/dist/esm/shared/createTemplateContext.js.map +1 -0
  20. package/dist/esm/shared/file-operations/appendExportToParentIndex.js +25 -0
  21. package/dist/esm/shared/file-operations/appendExportToParentIndex.js.map +1 -0
  22. package/dist/esm/shared/file-operations/dryRunWithFileState.js +25 -0
  23. package/dist/esm/shared/file-operations/dryRunWithFileState.js.map +1 -0
  24. package/{src/shared/file-operations/index.ts → dist/esm/shared/file-operations/index.js} +1 -0
  25. package/dist/esm/shared/file-operations/index.js.map +1 -0
  26. package/dist/esm/shared/file-operations/removeExportFromParentIndex.js +13 -0
  27. package/dist/esm/shared/file-operations/removeExportFromParentIndex.js.map +1 -0
  28. package/dist/esm/shared/file-operations/removeLineFromFile.js +19 -0
  29. package/dist/esm/shared/file-operations/removeLineFromFile.js.map +1 -0
  30. package/dist/esm/shared/index.js +11 -0
  31. package/dist/esm/shared/index.js.map +1 -0
  32. package/dist/esm/shared/loadTemplate.js +56 -0
  33. package/dist/esm/shared/loadTemplate.js.map +1 -0
  34. package/dist/esm/shared/packageName.js +11 -0
  35. package/dist/esm/shared/packageName.js.map +1 -0
  36. package/dist/esm/shared/sharedPrompts.js +28 -0
  37. package/dist/esm/shared/sharedPrompts.js.map +1 -0
  38. package/dist/esm/shared/string-helpers/getComponentName.js +8 -0
  39. package/dist/esm/shared/string-helpers/getComponentName.js.map +1 -0
  40. package/dist/esm/shared/string-helpers/getParentDir.js +8 -0
  41. package/dist/esm/shared/string-helpers/getParentDir.js.map +1 -0
  42. package/{src/shared/string-helpers/index.ts → dist/esm/shared/string-helpers/index.js} +1 -0
  43. package/dist/esm/shared/string-helpers/index.js.map +1 -0
  44. package/dist/esm/shared/types.js +5 -0
  45. package/dist/esm/shared/types.js.map +1 -0
  46. package/dist/esm/shared/validateComponentPath.js +27 -0
  47. package/dist/esm/shared/validateComponentPath.js.map +1 -0
  48. package/dist/esm/svelte/generator.js +165 -0
  49. package/dist/esm/svelte/generator.js.map +1 -0
  50. package/dist/esm/svelte/index.js +5 -0
  51. package/dist/esm/svelte/index.js.map +1 -0
  52. package/dist/esm/svelte/types.js +5 -0
  53. package/dist/esm/svelte/types.js.map +1 -0
  54. package/dist/types/index.d.ts +87 -0
  55. package/dist/types/index.d.ts.map +1 -0
  56. package/dist/types/lit/generator.d.ts +52 -0
  57. package/dist/types/lit/generator.d.ts.map +1 -0
  58. package/{src/lit/index.ts → dist/types/lit/index.d.ts} +1 -1
  59. package/dist/types/lit/index.d.ts.map +1 -0
  60. package/{src/lit/types.ts → dist/types/lit/types.d.ts} +1 -2
  61. package/dist/types/lit/types.d.ts.map +1 -0
  62. package/dist/types/react/generator.d.ts +28 -0
  63. package/dist/types/react/generator.d.ts.map +1 -0
  64. package/{src/react/index.ts → dist/types/react/index.d.ts} +1 -1
  65. package/dist/types/react/index.d.ts.map +1 -0
  66. package/{src/react/types.ts → dist/types/react/types.d.ts} +1 -2
  67. package/dist/types/react/types.d.ts.map +1 -0
  68. package/dist/types/shared/createComponentPathPrompt.d.ts +12 -0
  69. package/dist/types/shared/createComponentPathPrompt.d.ts.map +1 -0
  70. package/dist/types/shared/createTemplateContext.d.ts +9 -0
  71. package/dist/types/shared/createTemplateContext.d.ts.map +1 -0
  72. package/dist/types/shared/file-operations/appendExportToParentIndex.d.ts +8 -0
  73. package/dist/types/shared/file-operations/appendExportToParentIndex.d.ts.map +1 -0
  74. package/dist/types/shared/file-operations/dryRunWithFileState.d.ts +7 -0
  75. package/dist/types/shared/file-operations/dryRunWithFileState.d.ts.map +1 -0
  76. package/dist/types/shared/file-operations/index.d.ts +4 -0
  77. package/dist/types/shared/file-operations/index.d.ts.map +1 -0
  78. package/dist/types/shared/file-operations/removeExportFromParentIndex.d.ts +7 -0
  79. package/dist/types/shared/file-operations/removeExportFromParentIndex.d.ts.map +1 -0
  80. package/dist/types/shared/file-operations/removeLineFromFile.d.ts +7 -0
  81. package/dist/types/shared/file-operations/removeLineFromFile.d.ts.map +1 -0
  82. package/{src/shared/index.ts → dist/types/shared/index.d.ts} +2 -1
  83. package/dist/types/shared/index.d.ts.map +1 -0
  84. package/dist/types/shared/loadTemplate.d.ts +20 -0
  85. package/dist/types/shared/loadTemplate.d.ts.map +1 -0
  86. package/dist/types/shared/packageName.d.ts +11 -0
  87. package/dist/types/shared/packageName.d.ts.map +1 -0
  88. package/dist/types/shared/sharedPrompts.d.ts +7 -0
  89. package/dist/types/shared/sharedPrompts.d.ts.map +1 -0
  90. package/{src/shared/string-helpers/getComponentName.ts → dist/types/shared/string-helpers/getComponentName.d.ts} +2 -5
  91. package/dist/types/shared/string-helpers/getComponentName.d.ts.map +1 -0
  92. package/{src/shared/string-helpers/getParentDir.ts → dist/types/shared/string-helpers/getParentDir.d.ts} +2 -5
  93. package/dist/types/shared/string-helpers/getParentDir.d.ts.map +1 -0
  94. package/dist/types/shared/string-helpers/index.d.ts +4 -0
  95. package/dist/types/shared/string-helpers/index.d.ts.map +1 -0
  96. package/dist/types/shared/types.d.ts +34 -0
  97. package/dist/types/shared/types.d.ts.map +1 -0
  98. package/dist/types/shared/validateComponentPath.d.ts +9 -0
  99. package/dist/types/shared/validateComponentPath.d.ts.map +1 -0
  100. package/dist/types/svelte/generator.d.ts +52 -0
  101. package/dist/types/svelte/generator.d.ts.map +1 -0
  102. package/{src/svelte/index.ts → dist/types/svelte/index.d.ts} +1 -1
  103. package/dist/types/svelte/index.d.ts.map +1 -0
  104. package/{src/svelte/types.ts → dist/types/svelte/types.d.ts} +3 -4
  105. package/dist/types/svelte/types.d.ts.map +1 -0
  106. package/package.json +21 -10
  107. package/CHANGELOG.md +0 -245
  108. package/CONVENTIONS.md +0 -184
  109. package/biome.json +0 -6
  110. package/src/index.test.ts +0 -514
  111. package/src/lit/generator.ts +0 -190
  112. package/src/react/generator.ts +0 -176
  113. package/src/shared/createComponentPathPrompt.ts +0 -28
  114. package/src/shared/createTemplateContext.ts +0 -29
  115. package/src/shared/file-operations/appendExportToParentIndex.test.ts +0 -82
  116. package/src/shared/file-operations/appendExportToParentIndex.ts +0 -40
  117. package/src/shared/file-operations/dryRunWithFileState.ts +0 -28
  118. package/src/shared/file-operations/removeExportFromParentIndex.test.ts +0 -52
  119. package/src/shared/file-operations/removeExportFromParentIndex.ts +0 -21
  120. package/src/shared/file-operations/removeLineFromFile.test.ts +0 -66
  121. package/src/shared/file-operations/removeLineFromFile.ts +0 -29
  122. package/src/shared/loadTemplate.test.ts +0 -100
  123. package/src/shared/loadTemplate.ts +0 -70
  124. package/src/shared/sharedPrompts.ts +0 -30
  125. package/src/shared/string-helpers/getComponentName.test.ts +0 -18
  126. package/src/shared/string-helpers/getParentDir.test.ts +0 -16
  127. package/src/shared/types.ts +0 -36
  128. package/src/shared/validateComponentPath.test.ts +0 -40
  129. package/src/shared/validateComponentPath.ts +0 -16
  130. package/src/svelte/generator.ts +0 -224
  131. package/src/testing/integration/generators-undo.test.ts +0 -200
  132. package/tsconfig.json +0 -9
  133. package/vitest.config.ts +0 -18
  134. /package/{src → dist/esm}/templates/lit/component.ts.ejs +0 -0
  135. /package/{src → dist/esm}/templates/lit/index.ts.ejs +0 -0
  136. /package/{src → dist/esm}/templates/lit/stories.ts.ejs +0 -0
  137. /package/{src → dist/esm}/templates/lit/styles.css.ejs +0 -0
  138. /package/{src → dist/esm}/templates/lit/tests.ts.ejs +0 -0
  139. /package/{src → dist/esm}/templates/lit/types.ts.ejs +0 -0
  140. /package/{src → dist/esm}/templates/react/component.tsx.ejs +0 -0
  141. /package/{src → dist/esm}/templates/react/index.ts.ejs +0 -0
  142. /package/{src → dist/esm}/templates/react/ssr.test.tsx.ejs +0 -0
  143. /package/{src → dist/esm}/templates/react/stories.tsx.ejs +0 -0
  144. /package/{src → dist/esm}/templates/react/test.tsx.ejs +0 -0
  145. /package/{src → dist/esm}/templates/react/types.ts.ejs +0 -0
  146. /package/{src → dist/esm}/templates/shared/styles.css.ejs +0 -0
  147. /package/{src → dist/esm}/templates/svelte/component.svelte.ejs +0 -0
  148. /package/{src → dist/esm}/templates/svelte/index.ts.ejs +0 -0
  149. /package/{src → dist/esm}/templates/svelte/ssr.test.ts.ejs +0 -0
  150. /package/{src → dist/esm}/templates/svelte/stories.svelte.ejs +0 -0
  151. /package/{src → dist/esm}/templates/svelte/stories.ts.ejs +0 -0
  152. /package/{src → dist/esm}/templates/svelte/test.ts.ejs +0 -0
  153. /package/{src → dist/esm}/templates/svelte/types.ts.ejs +0 -0
package/CHANGELOG.md DELETED
@@ -1,245 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [0.29.0](https://github.com/canonical/pragma/compare/v0.29.0-experimental.0...v0.29.0) (2026-07-03)
7
-
8
- **Note:** Version bump only for package @canonical/summon-component
9
-
10
-
11
-
12
-
13
-
14
- # [0.29.0-experimental.0](https://github.com/canonical/pragma/compare/v0.28.0...v0.29.0-experimental.0) (2026-06-24)
15
-
16
- **Note:** Version bump only for package @canonical/summon-component
17
-
18
-
19
-
20
-
21
-
22
- # [0.28.0](https://github.com/canonical/pragma/compare/v0.27.1-experimental.0...v0.28.0) (2026-06-16)
23
-
24
-
25
- ### Bug Fixes
26
-
27
- * **summon-component:** Fix Svelte component output failing type-checking ([#642](https://github.com/canonical/pragma/issues/642)) ([1331c96](https://github.com/canonical/pragma/commit/1331c963a5691f20b826bbb8b081ab283bde8584))
28
-
29
-
30
- ### Features
31
-
32
- * **pragma:** trace, MCP resources, summon template loading, framework config ([#645](https://github.com/canonical/pragma/issues/645)) ([4f0a341](https://github.com/canonical/pragma/commit/4f0a341a050facbf3a87419ed7a9b3c29c0a9ade)), closes [#1](https://github.com/canonical/pragma/issues/1) [#551](https://github.com/canonical/pragma/issues/551) [#569](https://github.com/canonical/pragma/issues/569) [#641](https://github.com/canonical/pragma/issues/641) [#641](https://github.com/canonical/pragma/issues/641)
33
-
34
-
35
-
36
-
37
-
38
- ## [0.27.1-experimental.0](https://github.com/canonical/pragma/compare/v0.28.0-experimental.0...v0.27.1-experimental.0) (2026-05-21)
39
-
40
-
41
- ### Bug Fixes
42
-
43
- * **release:** unblock lerna 9 publish (access via publishConfig) ([#637](https://github.com/canonical/pragma/issues/637)) ([acc1185](https://github.com/canonical/pragma/commit/acc1185b43290c1edd88da25c000f7d9494caee6))
44
-
45
-
46
-
47
-
48
-
49
- # [0.27.0](https://github.com/canonical/pragma/compare/v0.26.0...v0.27.0) (2026-04-29)
50
-
51
- **Note:** Version bump only for package @canonical/summon-component
52
-
53
-
54
-
55
-
56
-
57
- # [0.26.0](https://github.com/canonical/pragma/compare/v0.25.0...v0.26.0) (2026-04-24)
58
-
59
- **Note:** Version bump only for package @canonical/summon-component
60
-
61
-
62
-
63
-
64
-
65
- # [0.25.0](https://github.com/canonical/pragma/compare/v0.24.0...v0.25.0) (2026-04-17)
66
-
67
- **Note:** Version bump only for package @canonical/summon-component
68
-
69
-
70
-
71
-
72
-
73
- # [0.24.0](https://github.com/canonical/pragma/compare/v0.23.0...v0.24.0) (2026-04-13)
74
-
75
- **Note:** Version bump only for package @canonical/summon-component
76
-
77
-
78
-
79
-
80
-
81
- # [0.23.0](https://github.com/canonical/pragma/compare/v0.22.1...v0.23.0) (2026-04-07)
82
-
83
- **Note:** Version bump only for package @canonical/summon-component
84
-
85
-
86
-
87
-
88
-
89
- # [0.22.0](https://github.com/canonical/pragma/compare/v0.22.0-experimental.0...v0.22.0) (2026-04-03)
90
-
91
- **Note:** Version bump only for package @canonical/summon-component
92
-
93
-
94
-
95
-
96
-
97
- # [0.21.0](https://github.com/canonical/pragma/compare/v0.20.1...v0.21.0) (2026-04-01)
98
-
99
- **Note:** Version bump only for package @canonical/summon-component
100
-
101
-
102
-
103
-
104
-
105
- # [0.20.0](https://github.com/canonical/pragma/compare/v0.19.0...v0.20.0) (2026-03-26)
106
-
107
- **Note:** Version bump only for package @canonical/summon-component
108
-
109
-
110
-
111
-
112
-
113
- # [0.19.0](https://github.com/canonical/pragma/compare/v0.18.0...v0.19.0) (2026-03-26)
114
-
115
-
116
- ### Bug Fixes
117
-
118
- * **summon-component:** duplication of "generated by" comment ([#495](https://github.com/canonical/pragma/issues/495)) ([c52a374](https://github.com/canonical/pragma/commit/c52a374a85a9f703d0ff04b3fc3fd6d18370c458))
119
-
120
-
121
- ### Features
122
-
123
- * **react-ds-global:** announcement component ([#554](https://github.com/canonical/pragma/issues/554)) ([e5434d0](https://github.com/canonical/pragma/commit/e5434d05421090cb77c227ccaa6025983c9a292c))
124
- * **task,summon-core:** extract @canonical/task, restructure summon as @canonical/summon-core (v0.1-P1+P2) ([#484](https://github.com/canonical/pragma/issues/484)) ([1493baf](https://github.com/canonical/pragma/commit/1493baf6b28a9d5cbd7e4e13009f105945df72a9))
125
- * **task:** add undo interpreter and --undo flag across CLI ([#538](https://github.com/canonical/pragma/issues/538)) ([8c2fff5](https://github.com/canonical/pragma/commit/8c2fff58eb4e5527e4ca2aa1bd7e9f42b3cf70ee))
126
-
127
-
128
-
129
-
130
-
131
- # [0.18.0](https://github.com/canonical/pragma/compare/v0.17.1...v0.18.0) (2026-03-11)
132
-
133
- **Note:** Version bump only for package @canonical/summon-component
134
-
135
-
136
-
137
-
138
-
139
- ## [0.17.1](https://github.com/canonical/pragma/compare/v0.17.0...v0.17.1) (2026-03-04)
140
-
141
- **Note:** Version bump only for package @canonical/summon-component
142
-
143
-
144
-
145
-
146
-
147
- # [0.17.0](https://github.com/canonical/pragma/compare/v0.16.0...v0.17.0) (2026-03-04)
148
-
149
-
150
- ### Features
151
-
152
- * **summon:** summon component webcomponents ([#448](https://github.com/canonical/pragma/issues/448)) ([ae5d33d](https://github.com/canonical/pragma/commit/ae5d33d052f7c05be292e6a565cf371f47868274))
153
-
154
-
155
-
156
-
157
-
158
- # [0.16.0](https://github.com/canonical/pragma/compare/v0.16.0-experimental.1...v0.16.0) (2026-03-03)
159
-
160
- **Note:** Version bump only for package @canonical/summon-component
161
-
162
-
163
-
164
-
165
-
166
- # [0.16.0-experimental.1](https://github.com/canonical/pragma/compare/v0.16.0-experimental.0...v0.16.0-experimental.1) (2026-03-03)
167
-
168
- **Note:** Version bump only for package @canonical/summon-component
169
-
170
-
171
-
172
-
173
-
174
- # [0.16.0-experimental.0](https://github.com/canonical/pragma/compare/v0.15.1...v0.16.0-experimental.0) (2026-02-24)
175
-
176
-
177
- ### Features
178
-
179
- * **svelte-ds-app-launchpad:** upstream Chip component and update styles ([#423](https://github.com/canonical/pragma/issues/423)) ([26d1047](https://github.com/canonical/pragma/commit/26d104771a0df4ece538bd268b2141c30267b60c))
180
-
181
-
182
-
183
-
184
-
185
- ## [0.15.1](https://github.com/canonical/pragma/compare/v0.15.0...v0.15.1) (2026-02-23)
186
-
187
- **Note:** Version bump only for package @canonical/summon-component
188
-
189
-
190
-
191
-
192
-
193
- # [0.15.0](https://github.com/canonical/pragma/compare/v0.15.0-experimental.0...v0.15.0) (2026-02-20)
194
-
195
-
196
- ### Bug Fixes
197
-
198
- * **react-ds-global:** Fixes transitional export patterns for components ([#426](https://github.com/canonical/pragma/issues/426)) ([db8a1db](https://github.com/canonical/pragma/commit/db8a1dba10419153f6be82ffee570c9db929dff7))
199
-
200
-
201
-
202
-
203
-
204
- # [0.15.0-experimental.0](https://github.com/canonical/pragma/compare/v0.14.0...v0.15.0-experimental.0) (2026-02-17)
205
-
206
-
207
- ### Features
208
-
209
- * **svelte-generator:** update Svelte component templates ([#422](https://github.com/canonical/pragma/issues/422)) ([f1fb13f](https://github.com/canonical/pragma/commit/f1fb13fa08463b844e611ae5cd0f94a06b13ff30))
210
-
211
-
212
-
213
-
214
-
215
- # [0.14.0](https://github.com/canonical/pragma/compare/v0.13.0...v0.14.0) (2026-02-16)
216
-
217
- **Note:** Version bump only for package @canonical/summon-component
218
-
219
-
220
-
221
-
222
-
223
- # [0.13.0](https://github.com/canonical/pragma/compare/v0.13.0-experimental.0...v0.13.0) (2026-02-10)
224
-
225
- **Note:** Version bump only for package @canonical/summon-component
226
-
227
-
228
-
229
-
230
-
231
- # [0.12.0](https://github.com/canonical/pragma/compare/v0.12.0-experimental.0...v0.12.0) (2026-02-06)
232
-
233
- **Note:** Version bump only for package @canonical/summon-component
234
-
235
-
236
-
237
-
238
-
239
- # [0.12.0-experimental.0](https://github.com/canonical/pragma/compare/v0.11.0...v0.12.0-experimental.0) (2026-01-26)
240
-
241
-
242
- ### Features
243
-
244
- * **components:** Ft components ([#393](https://github.com/canonical/pragma/issues/393)) ([abbe615](https://github.com/canonical/pragma/commit/abbe6150c52deefffb7e9e7fbfee8a3b6ffb94c6))
245
- * **summon:** new codegen ([#388](https://github.com/canonical/pragma/issues/388)) ([bcd1f35](https://github.com/canonical/pragma/commit/bcd1f350fd8799a580511e783a4292911fd5cc33))
package/CONVENTIONS.md DELETED
@@ -1,184 +0,0 @@
1
- # Component Conventions
2
-
3
- > Generated by `@canonical/summon-component` v0.1.0
4
- > Last updated: 2026-03-08
5
-
6
- ## Taxonomy Key
7
-
8
- | Prefix | Domain | Description |
9
- |--------|--------|-------------|
10
- | `C1` | Framework | Supported frameworks and their constraints |
11
- | `C2` | Structure | Directory layout and file organization |
12
- | `C3` | Naming | Component, file, and directory casing |
13
- | `C4` | Files | Required file patterns per component |
14
- | `C5` | Exports | Barrel files and public API surface |
15
- | `C6` | Styles | CSS patterns, theming, shared primitives |
16
- | `C7` | Testing | Test types, patterns, runner |
17
- | `C8` | Storybook | Story format, co-location, variants |
18
- | `C9` | Types | Props definition and strict mode |
19
- | `C10` | SSR | Server-side rendering support |
20
-
21
- ---
22
-
23
- ## C1 — Framework
24
-
25
- | ID | Rule | Gate |
26
- |----|------|------|
27
- | C1.1 | Components target exactly one of: React, Svelte, or Web Components (Lit) | framework ∈ {react, svelte, lit} |
28
- | C1.2 | React components live in `src/react/` | directory = `src/react/` |
29
- | C1.3 | Svelte components live in `src/svelte/` | directory = `src/svelte/` |
30
- | C1.4 | Web Components live in `src/lit/` | directory = `src/lit/` |
31
-
32
- ### Framework Matrix
33
-
34
- | Framework | Directory | Component Ext | Story Ext |
35
- |-----------|-----------|---------------|-----------|
36
- | React | `src/react/` | `.tsx` | `.stories.tsx` |
37
- | Svelte | `src/svelte/` | `.svelte` | `.stories.svelte` + `.stories.ts` |
38
- | Web Components (Lit) | `src/lit/` | `.ts` | `.stories.ts` |
39
-
40
- ---
41
-
42
- ## C2 — Structure
43
-
44
- | ID | Rule | Gate |
45
- |----|------|------|
46
- | C2.1 | Each component has its own directory named in PascalCase | directory is PascalCase |
47
- | C2.2 | Component directory contains implementation, test, story, index, types, and styles | required files present |
48
- | C2.3 | SSR test file is separate from unit test file | `*.ssr.test.*` exists separately |
49
-
50
- ### Component Directory Layout
51
-
52
- ```
53
- <ComponentName>/
54
- ├── <ComponentName>.tsx # C4.1 Implementation
55
- ├── <ComponentName>.test.tsx # C4.2 Unit tests
56
- ├── <ComponentName>.stories.tsx # C4.3 Storybook stories
57
- ├── <ComponentName>.ssr.test.tsx # C4.4 SSR tests
58
- ├── index.ts # C4.5 Re-export barrel
59
- ├── types.ts # C4.6 Component types
60
- └── styles.css # C4.7 Component styles
61
- ```
62
-
63
- ---
64
-
65
- ## C3 — Naming
66
-
67
- | ID | Rule | Gate |
68
- |----|------|------|
69
- | C3.1 | Component names use PascalCase | name matches `/^[A-Z][a-zA-Z0-9]*$/` |
70
- | C3.2 | File names use PascalCase matching the component name | filename = ComponentName + ext |
71
- | C3.3 | Directory names use PascalCase matching the component name | dirname = ComponentName |
72
- | C3.4 | Package-level exports use `index.ts` barrel files | `index.ts` exists |
73
-
74
- ---
75
-
76
- ## C4 — Files
77
-
78
- | ID | Rule | Gate |
79
- |----|------|------|
80
- | C4.1 | Implementation file: `<Name>.tsx` / `.svelte` / `.ts` | file exists |
81
- | C4.2 | Unit test file: `<Name>.test.tsx` / `.test.ts` | file exists |
82
- | C4.3 | Story file: `<Name>.stories.tsx` / `.stories.ts` / `.stories.svelte` | file exists |
83
- | C4.4 | SSR test file: `<Name>.ssr.test.tsx` / `.ssr.test.ts` | file exists |
84
- | C4.5 | Barrel file: `index.ts` re-exports component and types | file exists |
85
- | C4.6 | Types file: `types.ts` defines component props | file exists |
86
- | C4.7 | Styles file: `styles.css` (optional but conventional) | file exists if styled |
87
-
88
- ---
89
-
90
- ## C5 — Exports
91
-
92
- | ID | Rule | Gate |
93
- |----|------|------|
94
- | C5.1 | Components are exported from package via barrel files | `src/index.ts` exports component |
95
- | C5.2 | Props types are exported alongside components | types re-exported from index |
96
- | C5.3 | Component index re-exports from implementation and types | `index.ts` has both exports |
97
-
98
- ### Export Pattern
99
-
100
- ```typescript
101
- // packages/<pkg>/src/index.ts
102
- export { MyComponent } from "./MyComponent/index.js";
103
- export type { MyComponentProps } from "./MyComponent/types.js";
104
- ```
105
-
106
- ---
107
-
108
- ## C6 — Styles
109
-
110
- | ID | Rule | Gate |
111
- |----|------|------|
112
- | C6.1 | Theming uses CSS custom properties | custom properties used |
113
- | C6.2 | Styles are component-scoped via CSS files | styles in `styles.css` |
114
- | C6.3 | Component file imports its styles | import statement present |
115
- | C6.4 | Shared primitives from `@canonical/styles` | shared import used |
116
-
117
- ---
118
-
119
- ## C7 — Testing
120
-
121
- | ID | Rule | Gate |
122
- |----|------|------|
123
- | C7.1 | Unit tests co-located with components | test file in component dir |
124
- | C7.2 | Test pattern: `*.test.tsx` / `*.test.ts` (singular) | pattern matches |
125
- | C7.3 | SSR tests in separate `*.ssr.test.*` files | SSR file separate |
126
- | C7.4 | Test runner is Vitest | vitest configured |
127
- | C7.5 | DOM testing uses `@testing-library/*` | testing-library in deps |
128
-
129
- ---
130
-
131
- ## C8 — Storybook
132
-
133
- | ID | Rule | Gate |
134
- |----|------|------|
135
- | C8.1 | Stories co-located with components | story file in component dir |
136
- | C8.2 | Stories use CSF3 (Component Story Format 3) | CSF3 syntax |
137
- | C8.3 | Every component has a default story and all variant stories | default + variants present |
138
- | C8.4 | Storybook config in `.storybook/` at package level | `.storybook/` dir exists |
139
-
140
- ---
141
-
142
- ## C9 — Types
143
-
144
- | ID | Rule | Gate |
145
- |----|------|------|
146
- | C9.1 | Props defined in dedicated `types.ts` file | `types.ts` exists |
147
- | C9.2 | All public types exported from `index.ts` | types re-exported |
148
- | C9.3 | Strict TypeScript enabled (`strict: true`) | strict mode on |
149
-
150
- ---
151
-
152
- ## C10 — SSR
153
-
154
- | ID | Rule | Gate |
155
- |----|------|------|
156
- | C10.1 | Components support server-side rendering | SSR test passes |
157
- | C10.2 | SSR tests verify hydration correctness | hydration tested |
158
- | C10.3 | React uses `renderToString` / `renderToPipeableStream` | correct SSR API |
159
- | C10.4 | Svelte uses `render` from `svelte/server` | correct SSR API |
160
- | C10.5 | Lit uses `@lit-labs/ssr` | correct SSR API |
161
-
162
- ---
163
-
164
- ## Quick Gate Checklist
165
-
166
- Use this as a pass/fail gate for new components:
167
-
168
- ```
169
- [ ] C1.1 Framework is React, Svelte, or Web Components
170
- [ ] C2.1 Component has its own PascalCase directory
171
- [ ] C3.1 Component name is PascalCase
172
- [ ] C4.1 Implementation file exists
173
- [ ] C4.2 Unit test file exists
174
- [ ] C4.3 Story file exists
175
- [ ] C4.5 index.ts barrel file exists
176
- [ ] C4.6 types.ts file exists
177
- [ ] C5.1 Component exported from package barrel
178
- [ ] C6.2 Styles are component-scoped
179
- [ ] C7.4 Vitest is the test runner
180
- [ ] C8.2 Stories use CSF3 format
181
- [ ] C9.1 Props in dedicated types.ts
182
- [ ] C9.3 Strict TypeScript enabled
183
- [ ] C10.1 Component supports SSR
184
- ```
package/biome.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "extends": ["@canonical/biome-config"],
3
- "files": {
4
- "includes": ["generators"]
5
- }
6
- }