@canonical/code-standards 0.1.1 → 0.1.3
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/data/css.ttl +4 -4
- package/data/icons.ttl +14 -14
- package/data/packaging.ttl +1 -1
- package/data/react.ttl +4 -4
- package/docs/css.md +4 -1
- package/docs/icons.md +6 -3
- package/docs/packaging.md +1 -1
- package/docs/react.md +4 -1
- package/package.json +1 -1
- package/skills/add-standard/SKILL.md +5 -0
package/data/css.ttl
CHANGED
|
@@ -272,13 +272,13 @@ cs:CSSComponentNamingConvention a cs:CodeStandard ;
|
|
|
272
272
|
cs:hasCategory cs:CSSCategory ;
|
|
273
273
|
cs:description "Component CSS class names must be the kebab-case version of the component's PascalCase name." ;
|
|
274
274
|
cs:do [
|
|
275
|
-
cs:description "Convert PascalCase component names to kebab-case for CSS classes:
|
|
275
|
+
cs:description """Convert PascalCase component names to kebab-case for CSS classes:
|
|
276
276
|
- `MyComponent` -> `.ds.my-component`
|
|
277
277
|
- `UserProfile` -> `.ds.user-profile`
|
|
278
|
-
- `Button` -> `.ds.button`"
|
|
278
|
+
- `Button` -> `.ds.button`"""
|
|
279
279
|
] ;
|
|
280
280
|
cs:dont [
|
|
281
|
-
cs:description "Use PascalCase or other formats in CSS class names:
|
|
281
|
+
cs:description """Use PascalCase or other formats in CSS class names:
|
|
282
282
|
- `.ds.MyComponent` (Bad: Not kebab-case)
|
|
283
|
-
- `.ds.user_profile` (Bad: Not kebab-case)"
|
|
283
|
+
- `.ds.user_profile` (Bad: Not kebab-case)"""
|
|
284
284
|
] .
|
package/data/icons.ttl
CHANGED
|
@@ -310,8 +310,8 @@ cs:IconMaskUsage a cs:CodeStandard ;
|
|
|
310
310
|
cs:hasCategory cs:IconsCategory ;
|
|
311
311
|
cs:description "Icons may use SVG masks to negate or partially negate paths, enabling advanced visual effects such as cutouts and overlays." ;
|
|
312
312
|
cs:do [
|
|
313
|
-
cs:description "Use SVG <mask> elements to create negative space or overlays in icons.
|
|
314
|
-
Example" ;
|
|
313
|
+
cs:description """Use SVG <mask> elements to create negative space or overlays in icons.
|
|
314
|
+
Example""" ;
|
|
315
315
|
cs:language "svg" ;
|
|
316
316
|
cs:code """
|
|
317
317
|
<svg width='16' height='16' xmlns='http://www.w3.org/2000/svg'>
|
|
@@ -328,8 +328,8 @@ Example" ;
|
|
|
328
328
|
"""
|
|
329
329
|
] ;
|
|
330
330
|
cs:do [
|
|
331
|
-
cs:description "Use <rect> with fill="white" to define the mask area, and <path> with fill="black" to subtract shapes.
|
|
332
|
-
Example" ;
|
|
331
|
+
cs:description """Use <rect> with fill="white" to define the mask area, and <path> with fill="black" to subtract shapes.
|
|
332
|
+
Example""" ;
|
|
333
333
|
cs:language "svg" ;
|
|
334
334
|
cs:code """
|
|
335
335
|
<mask id="mask">
|
|
@@ -339,8 +339,8 @@ Example" ;
|
|
|
339
339
|
"""
|
|
340
340
|
] ;
|
|
341
341
|
cs:do [
|
|
342
|
-
cs:description "Use opacity on mask paths to achieve partial negation (e.g., faded or semi-transparent cutouts).
|
|
343
|
-
Example" ;
|
|
342
|
+
cs:description """Use opacity on mask paths to achieve partial negation (e.g., faded or semi-transparent cutouts).
|
|
343
|
+
Example""" ;
|
|
344
344
|
cs:language "svg" ;
|
|
345
345
|
cs:code """
|
|
346
346
|
<mask id="progress-mask">
|
|
@@ -350,16 +350,16 @@ Example" ;
|
|
|
350
350
|
"""
|
|
351
351
|
] ;
|
|
352
352
|
cs:do [
|
|
353
|
-
cs:description "Reference the mask in the icon's main shape using mask="url(#mask-id)".
|
|
354
|
-
Example" ;
|
|
353
|
+
cs:description """Reference the mask in the icon's main shape using mask="url(#mask-id)".
|
|
354
|
+
Example""" ;
|
|
355
355
|
cs:language "svg" ;
|
|
356
356
|
cs:code """
|
|
357
357
|
<circle fill='currentColor' cx='8' cy='8' r='7' mask="url(#mask-id)"/>
|
|
358
358
|
"""
|
|
359
359
|
] ;
|
|
360
360
|
cs:dont [
|
|
361
|
-
cs:description "Use masks without clear purpose or visual benefit.
|
|
362
|
-
Example" ;
|
|
361
|
+
cs:description """Use masks without clear purpose or visual benefit.
|
|
362
|
+
Example""" ;
|
|
363
363
|
cs:language "svg" ;
|
|
364
364
|
cs:code """
|
|
365
365
|
<!-- Bad: Mask used but has no effect -->
|
|
@@ -370,8 +370,8 @@ Example" ;
|
|
|
370
370
|
"""
|
|
371
371
|
] ;
|
|
372
372
|
cs:dont [
|
|
373
|
-
cs:description "use non-semantic mask ids or omit mask references in the main shape.
|
|
374
|
-
Example" ;
|
|
373
|
+
cs:description """use non-semantic mask ids or omit mask references in the main shape.
|
|
374
|
+
Example""" ;
|
|
375
375
|
cs:language "svg" ;
|
|
376
376
|
cs:code """
|
|
377
377
|
<!-- Bad: Non-semantic mask id -->
|
|
@@ -382,8 +382,8 @@ Example" ;
|
|
|
382
382
|
"""
|
|
383
383
|
] ;
|
|
384
384
|
cs:dont [
|
|
385
|
-
cs:description "rely on masks for simple icons that do not require negative space or overlays.
|
|
386
|
-
Example" ;
|
|
385
|
+
cs:description """rely on masks for simple icons that do not require negative space or overlays.
|
|
386
|
+
Example""" ;
|
|
387
387
|
cs:language "svg" ;
|
|
388
388
|
cs:code """
|
|
389
389
|
<!-- Bad: Mask used for a simple shape -->
|
package/data/packaging.ttl
CHANGED
|
@@ -635,7 +635,7 @@ import { resolveConfig } from "#config";
|
|
|
635
635
|
"""
|
|
636
636
|
] ;
|
|
637
637
|
cs:do [
|
|
638
|
-
cs:description "Use `moduleResolution: "nodenext"` (or `"node16"` / `"bundler"`) in `tsconfig.json` so TypeScript resolves subpath imports via `resolvePackageJsonImports` (enabled by default with these settings)" ;
|
|
638
|
+
cs:description """Use `moduleResolution: "nodenext"` (or `"node16"` / `"bundler"`) in `tsconfig.json` so TypeScript resolves subpath imports via `resolvePackageJsonImports` (enabled by default with these settings)""" ;
|
|
639
639
|
cs:language "json" ;
|
|
640
640
|
cs:code """
|
|
641
641
|
{
|
package/data/react.ttl
CHANGED
|
@@ -275,16 +275,16 @@ cs:ComponentNaming a cs:CodeStandard ;
|
|
|
275
275
|
cs:hasCategory cs:ReactCategory ;
|
|
276
276
|
cs:description "Components must use PascalCase naming and be descriptive of their purpose." ;
|
|
277
277
|
cs:do [
|
|
278
|
-
cs:description "Use PascalCase and descriptive names for components:
|
|
278
|
+
cs:description """Use PascalCase and descriptive names for components:
|
|
279
279
|
UserProfile
|
|
280
280
|
NavigationBar
|
|
281
|
-
SearchResultList"
|
|
281
|
+
SearchResultList"""
|
|
282
282
|
] ;
|
|
283
283
|
cs:dont [
|
|
284
|
-
cs:description "Use non-PascalCase or unclear names:
|
|
284
|
+
cs:description """Use non-PascalCase or unclear names:
|
|
285
285
|
userProfile
|
|
286
286
|
navigation_bar
|
|
287
|
-
searchresultlist"
|
|
287
|
+
searchresultlist"""
|
|
288
288
|
] .
|
|
289
289
|
|
|
290
290
|
# Hook Naming Standard
|
package/docs/css.md
CHANGED
|
@@ -177,7 +177,10 @@ Omit the `.ds` namespace from component selectors.
|
|
|
177
177
|
|
|
178
178
|
## css/selectors/naming-convention
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
Convert PascalCase component names to kebab-case for CSS classes:
|
|
181
|
+
- `MyComponent` -> `.ds.my-component`
|
|
182
|
+
- `UserProfile` -> `.ds.user-profile`
|
|
183
|
+
- `Button` -> `.ds.button`
|
|
181
184
|
|
|
182
185
|
### Do
|
|
183
186
|
|
package/docs/icons.md
CHANGED
|
@@ -134,7 +134,8 @@ Use multiple `<g>` elements or an `id` that does not match the filename.
|
|
|
134
134
|
|
|
135
135
|
## icons/svg/mask-usage
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
Use SVG <mask> elements to create negative space or overlays in icons.
|
|
138
|
+
Example
|
|
138
139
|
|
|
139
140
|
### Do
|
|
140
141
|
|
|
@@ -154,7 +155,8 @@ Example
|
|
|
154
155
|
</svg>
|
|
155
156
|
```
|
|
156
157
|
|
|
157
|
-
Use <rect> with fill=
|
|
158
|
+
Use <rect> with fill="white" to define the mask area, and <path> with fill="black" to subtract shapes.
|
|
159
|
+
Example
|
|
158
160
|
```svg
|
|
159
161
|
<mask id="mask">
|
|
160
162
|
<rect width="16" height="16" fill="white"/>
|
|
@@ -171,7 +173,8 @@ Example
|
|
|
171
173
|
</mask>
|
|
172
174
|
```
|
|
173
175
|
|
|
174
|
-
Reference the mask in the icon's main shape using mask=
|
|
176
|
+
Reference the mask in the icon's main shape using mask="url(#mask-id)".
|
|
177
|
+
Example
|
|
175
178
|
```svg
|
|
176
179
|
<circle fill='currentColor' cx='8' cy='8' r='7' mask="url(#mask-id)"/>
|
|
177
180
|
```
|
package/docs/packaging.md
CHANGED
|
@@ -393,7 +393,7 @@ import { PragmaError } from "#error";
|
|
|
393
393
|
import { resolveConfig } from "#config";
|
|
394
394
|
```
|
|
395
395
|
|
|
396
|
-
Use `moduleResolution:
|
|
396
|
+
Use `moduleResolution: "nodenext"` (or `"node16"` / `"bundler"`) in `tsconfig.json` so TypeScript resolves subpath imports via `resolvePackageJsonImports` (enabled by default with these settings)
|
|
397
397
|
```json
|
|
398
398
|
{
|
|
399
399
|
"compilerOptions": {
|
package/docs/react.md
CHANGED
|
@@ -171,7 +171,10 @@ Add redundant prefixes to domain-level files.
|
|
|
171
171
|
|
|
172
172
|
## react/component/naming
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
Use PascalCase and descriptive names for components:
|
|
175
|
+
UserProfile
|
|
176
|
+
NavigationBar
|
|
177
|
+
SearchResultList
|
|
175
178
|
|
|
176
179
|
### Do
|
|
177
180
|
|
package/package.json
CHANGED