@canonical/code-standards 0.1.0 → 0.1.2
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/.github/PULL_REQUEST_TEMPLATE.md +13 -0
- package/.github/workflows/ci.yml +40 -0
- package/biome.json +6 -0
- package/bun.lock +200 -0
- package/data/code.ttl +208 -167
- package/data/css.ttl +110 -91
- package/data/icons.ttl +186 -150
- package/data/packaging.ttl +428 -170
- package/data/react.ttl +306 -244
- package/data/rust.ttl +563 -467
- package/data/storybook.ttl +108 -90
- package/data/styling.ttl +40 -40
- package/data/tsdoc.ttl +111 -86
- package/data/turtle.ttl +89 -68
- package/definitions/CodeStandard.ttl +28 -20
- package/docs/code.md +37 -327
- package/docs/css.md +24 -20
- package/docs/icons.md +41 -42
- package/docs/index.md +2 -1
- package/docs/packaging.md +643 -0
- package/docs/react.md +58 -59
- package/docs/rust.md +92 -158
- package/docs/storybook.md +18 -20
- package/docs/styling.md +8 -8
- package/docs/tsdoc.md +16 -16
- package/docs/turtle.md +15 -15
- package/package.json +16 -2
- package/skills/add-standard/SKILL.md +83 -47
- package/src/scripts/generate-docs.ts +95 -13
- package/src/scripts/index.ts +4 -2
- package/tsconfig.json +8 -0
package/docs/storybook.md
CHANGED
|
@@ -8,9 +8,8 @@ Component documentation must primarily come from TSDoc comments on the component
|
|
|
8
8
|
|
|
9
9
|
### Do
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Use TSDoc comments for primary documentation.
|
|
12
12
|
```typescript
|
|
13
|
-
|
|
14
13
|
// ContextualMenu/types.ts
|
|
15
14
|
export interface ContextualMenuProps extends HTMLAttributes<HTMLDivElement> {
|
|
16
15
|
/** The element that triggers the contextual menu */
|
|
@@ -34,7 +33,7 @@ const ContextualMenu = ({
|
|
|
34
33
|
|
|
35
34
|
### Don't
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
Add documentation in Storybook parameters when TSDoc is sufficient.
|
|
38
37
|
```typescript
|
|
39
38
|
export const Default: Story = {
|
|
40
39
|
parameters: {
|
|
@@ -55,9 +54,8 @@ Decorators must be used to wrap stories in common context providers or layout el
|
|
|
55
54
|
|
|
56
55
|
### Do
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
Use decorators for static context or layout wrapping.
|
|
59
58
|
```typescript
|
|
60
|
-
|
|
61
59
|
// storybook/decorators.tsx
|
|
62
60
|
|
|
63
61
|
export const theme = (Story: StoryFn<typeof Component>) => (
|
|
@@ -92,7 +90,7 @@ export default meta;
|
|
|
92
90
|
|
|
93
91
|
### Don't
|
|
94
92
|
|
|
95
|
-
|
|
93
|
+
Use function-based stories for static wrapping that could be done with decorators.
|
|
96
94
|
```typescript
|
|
97
95
|
// Bad: Using function-based story for static wrapping
|
|
98
96
|
export const WithTheme = (args: ComponentProps) => (
|
|
@@ -110,7 +108,7 @@ Story documentation must focus on usage patterns and variations, not implementat
|
|
|
110
108
|
|
|
111
109
|
### Do
|
|
112
110
|
|
|
113
|
-
|
|
111
|
+
Document usage patterns and variations.
|
|
114
112
|
```typescript
|
|
115
113
|
export const WithCustomTrigger: Story = {
|
|
116
114
|
args: {
|
|
@@ -128,7 +126,7 @@ export const WithCustomTrigger: Story = {
|
|
|
128
126
|
|
|
129
127
|
### Don't
|
|
130
128
|
|
|
131
|
-
|
|
129
|
+
Document implementation details or internal behavior.
|
|
132
130
|
```typescript
|
|
133
131
|
export const Default: Story = {
|
|
134
132
|
parameters: {
|
|
@@ -152,7 +150,7 @@ Stories must use one of three formats, each serving specific needs:
|
|
|
152
150
|
|
|
153
151
|
### Do
|
|
154
152
|
|
|
155
|
-
|
|
153
|
+
Use the format that matches your specific use case.
|
|
156
154
|
```typescript
|
|
157
155
|
// CSF3: For standard component variations through args
|
|
158
156
|
type Story = StoryObj<typeof meta>;
|
|
@@ -191,7 +189,7 @@ Primary.args = { variant: "primary" };
|
|
|
191
189
|
|
|
192
190
|
### Don't
|
|
193
191
|
|
|
194
|
-
|
|
192
|
+
Use a format that doesn't match your use case.
|
|
195
193
|
```typescript
|
|
196
194
|
// Bad: Using function format for simple args variation
|
|
197
195
|
export const SimpleButton = () => (
|
|
@@ -219,7 +217,7 @@ Stories must import their component as 'Component' to maintain a consistent, gen
|
|
|
219
217
|
|
|
220
218
|
### Do
|
|
221
219
|
|
|
222
|
-
|
|
220
|
+
Import the component generically as 'Component'.
|
|
223
221
|
```typescript
|
|
224
222
|
import Component from "./SkipLink.js";
|
|
225
223
|
|
|
@@ -237,7 +235,7 @@ export const Default: Story = {
|
|
|
237
235
|
|
|
238
236
|
### Don't
|
|
239
237
|
|
|
240
|
-
|
|
238
|
+
Import the component using its specific name.
|
|
241
239
|
```typescript
|
|
242
240
|
import SkipLink from "./SkipLink.js";
|
|
243
241
|
|
|
@@ -255,7 +253,7 @@ Story names must be descriptive and follow a consistent pattern. Use PascalCase
|
|
|
255
253
|
|
|
256
254
|
### Do
|
|
257
255
|
|
|
258
|
-
|
|
256
|
+
Use clear, descriptive names that indicate the variation.
|
|
259
257
|
```typescript
|
|
260
258
|
export const WithCustomStyles: Story = {
|
|
261
259
|
args: {
|
|
@@ -274,7 +272,7 @@ export const WithCustomStyles: Story = {
|
|
|
274
272
|
|
|
275
273
|
### Don't
|
|
276
274
|
|
|
277
|
-
|
|
275
|
+
Use technical or implementation-focused names.
|
|
278
276
|
```typescript
|
|
279
277
|
export const TestCase1: Story = { // Bad: Non-descriptive name
|
|
280
278
|
args: {
|
|
@@ -292,7 +290,7 @@ Stories must be organized into logical groups that demonstrate related features
|
|
|
292
290
|
|
|
293
291
|
### Do
|
|
294
292
|
|
|
295
|
-
|
|
293
|
+
Group related features with clear, descriptive names.
|
|
296
294
|
```typescript
|
|
297
295
|
// Basic usage
|
|
298
296
|
export const Default: Story = {
|
|
@@ -321,7 +319,7 @@ export const CustomText: Story = {
|
|
|
321
319
|
|
|
322
320
|
### Don't
|
|
323
321
|
|
|
324
|
-
|
|
322
|
+
Use unclear names or mix unrelated features in a single story.
|
|
325
323
|
```typescript
|
|
326
324
|
// Bad: Unclear what this story demonstrates
|
|
327
325
|
export const Variant1: Story = {
|
|
@@ -343,7 +341,7 @@ Stories that test component behavior must use the `play` function to simulate us
|
|
|
343
341
|
|
|
344
342
|
### Do
|
|
345
343
|
|
|
346
|
-
|
|
344
|
+
Use play functions to test interactive behavior.
|
|
347
345
|
```typescript
|
|
348
346
|
export const InteractionTest: Story = {
|
|
349
347
|
args: {
|
|
@@ -360,7 +358,7 @@ export const InteractionTest: Story = {
|
|
|
360
358
|
|
|
361
359
|
### Don't
|
|
362
360
|
|
|
363
|
-
|
|
361
|
+
Test implementation details or internal state.
|
|
364
362
|
```typescript
|
|
365
363
|
export const InternalTest: Story = {
|
|
366
364
|
play: async ({ component }) => {
|
|
@@ -378,7 +376,7 @@ Stories that exist solely for testing or visual coverage but don't represent val
|
|
|
378
376
|
|
|
379
377
|
### Do
|
|
380
378
|
|
|
381
|
-
|
|
379
|
+
Hide test-only stories that don't represent valid usage.
|
|
382
380
|
```typescript
|
|
383
381
|
export const FocusedState: Story = {
|
|
384
382
|
args: {
|
|
@@ -395,7 +393,7 @@ export const FocusedState: Story = {
|
|
|
395
393
|
|
|
396
394
|
### Don't
|
|
397
395
|
|
|
398
|
-
|
|
396
|
+
Show implementation details or test states in documentation.
|
|
399
397
|
```typescript
|
|
400
398
|
export const InternalTestState: Story = {
|
|
401
399
|
args: {
|
package/docs/styling.md
CHANGED
|
@@ -8,7 +8,7 @@ Themes are collections of semantic tokens that provide consistent styling across
|
|
|
8
8
|
|
|
9
9
|
### Do
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Define a theme as a complete set of semantic tokens.
|
|
12
12
|
```
|
|
13
13
|
{
|
|
14
14
|
"theme": {
|
|
@@ -28,7 +28,7 @@ Themes are collections of semantic tokens that provide consistent styling across
|
|
|
28
28
|
|
|
29
29
|
### Don't
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Mix implementation details into theme definitions.
|
|
32
32
|
```
|
|
33
33
|
{
|
|
34
34
|
"theme": {
|
|
@@ -48,7 +48,7 @@ Design tokens must be created for all design decisions in a component. See css/p
|
|
|
48
48
|
|
|
49
49
|
### Do
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
Create component tokens that reference semantic tokens for design decisions.
|
|
52
52
|
```
|
|
53
53
|
{
|
|
54
54
|
"button": {
|
|
@@ -62,7 +62,7 @@ Design tokens must be created for all design decisions in a component. See css/p
|
|
|
62
62
|
|
|
63
63
|
### Don't
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
Use raw values for design decisions.
|
|
66
66
|
```
|
|
67
67
|
{
|
|
68
68
|
"button": {
|
|
@@ -85,7 +85,7 @@ Design tokens must be scoped according to their type:
|
|
|
85
85
|
|
|
86
86
|
### Do
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
Define primitive tokens in global scope.
|
|
89
89
|
```
|
|
90
90
|
{
|
|
91
91
|
"color": {
|
|
@@ -101,7 +101,7 @@ Design tokens must be scoped according to their type:
|
|
|
101
101
|
|
|
102
102
|
### Don't
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
Define primitive tokens in theme scope.
|
|
105
105
|
```
|
|
106
106
|
{
|
|
107
107
|
"theme": {
|
|
@@ -130,7 +130,7 @@ Design tokens follow a strict hierarchy:
|
|
|
130
130
|
|
|
131
131
|
### Do
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
Define semantic tokens that map to primitive tokens.
|
|
134
134
|
```
|
|
135
135
|
{
|
|
136
136
|
"color": {
|
|
@@ -146,7 +146,7 @@ Design tokens follow a strict hierarchy:
|
|
|
146
146
|
|
|
147
147
|
### Don't
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
Skip the semantic layer by mapping component tokens directly to primitives.
|
|
150
150
|
```
|
|
151
151
|
{
|
|
152
152
|
"button": {
|
package/docs/tsdoc.md
CHANGED
|
@@ -8,7 +8,7 @@ File-level and export-level TSDoc serve fundamentally different purposes. Export
|
|
|
8
8
|
|
|
9
9
|
### Do
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
In single-export files, document only at the export level — the API contract belongs on the symbol.
|
|
12
12
|
```typescript
|
|
13
13
|
// resolveDefinition.ts — single export, no file-level block needed
|
|
14
14
|
/** Resolve definition locations for a CSS custom property. */
|
|
@@ -17,7 +17,7 @@ export default function resolveDefinition(cssVar: string, graph: TokenGraph) {
|
|
|
17
17
|
}
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
In multi-export files, use a file-level block to explain the module's architectural purpose — why these exports are grouped.
|
|
21
21
|
```typescript
|
|
22
22
|
// types.ts — multiple exports, file-level explains cohesion
|
|
23
23
|
/**
|
|
@@ -31,7 +31,7 @@ export interface UsageRuleContext { /* ... */ }
|
|
|
31
31
|
export interface FileRuleContext { /* ... */ }
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Use export-level TSDoc to describe the API contract: what the symbol does, its parameters, return value, and any side effects.
|
|
35
35
|
```typescript
|
|
36
36
|
/**
|
|
37
37
|
* Check: css/missing-fallback — var() without a fallback on an unregistered property.
|
|
@@ -46,7 +46,7 @@ export default function checkMissingFallback(ctx: UsageRuleContext, results: Dia
|
|
|
46
46
|
|
|
47
47
|
### Don't
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
Add a file-level block in a single-export file that restates what the export-level doc already says.
|
|
50
50
|
```typescript
|
|
51
51
|
// Bad: file-level repeats the export's own description
|
|
52
52
|
/** Resolve definitions for CSS custom property usages. */
|
|
@@ -55,7 +55,7 @@ export default function checkMissingFallback(ctx: UsageRuleContext, results: Dia
|
|
|
55
55
|
export default function resolveDefinition() { /* ... */ }
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
Use file-level docs to describe *what* an export does — that belongs on the export itself.
|
|
59
59
|
```typescript
|
|
60
60
|
// Bad: file-level describes the function instead of the module's role
|
|
61
61
|
/** Build a completion item for a CSS variable. */
|
|
@@ -63,7 +63,7 @@ export default function resolveDefinition() { /* ... */ }
|
|
|
63
63
|
export default function buildCompletionItem(name: string) { /* ... */ }
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
Omit file-level docs on multi-export modules where the grouping rationale is non-obvious.
|
|
67
67
|
```typescript
|
|
68
68
|
// Bad: reader cannot tell why these live together
|
|
69
69
|
export function isCompletionRequest(req: WorkerRequest) { /* ... */ }
|
|
@@ -79,7 +79,7 @@ The `@module` TSDoc tag must appear only on barrel files such as `index.ts`. Ord
|
|
|
79
79
|
|
|
80
80
|
### Do
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
Use `@module` on a barrel file that defines a package or folder-level API.
|
|
83
83
|
```typescript
|
|
84
84
|
/**
|
|
85
85
|
* Public protocol API.
|
|
@@ -88,7 +88,7 @@ The `@module` TSDoc tag must appear only on barrel files such as `index.ts`. Ord
|
|
|
88
88
|
export { createRequest, matchResponse } from './index.js';
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
Document an ordinary source file at the exported symbol instead of using `@module`.
|
|
92
92
|
```typescript
|
|
93
93
|
/** Build a completion item for a CSS variable. */
|
|
94
94
|
export default function buildCompletionItem(name: string) {
|
|
@@ -98,7 +98,7 @@ export default function buildCompletionItem(name: string) {
|
|
|
98
98
|
|
|
99
99
|
### Don't
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
Add `@module` to a single-purpose implementation file.
|
|
102
102
|
```typescript
|
|
103
103
|
/**
|
|
104
104
|
* Build a completion item.
|
|
@@ -109,7 +109,7 @@ export default function buildCompletionItem(name: string) {
|
|
|
109
109
|
}
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
Use file-level `@module` tags as a substitute for export documentation.
|
|
113
113
|
```typescript
|
|
114
114
|
/** @module helpers/formatCurrency */
|
|
115
115
|
export default function formatCurrency(value: number) {
|
|
@@ -125,7 +125,7 @@ TSDoc comments must be self-contained — a reader should fully understand the d
|
|
|
125
125
|
|
|
126
126
|
### Do
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
Explain the concept inline so the reader needs nothing else
|
|
129
129
|
```typescript
|
|
130
130
|
/**
|
|
131
131
|
* Encode a string as a percent-encoded URI component.
|
|
@@ -138,7 +138,7 @@ export function encodeComponent(value: string): string {
|
|
|
138
138
|
}
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
Add an external link as a supplementary reference after a self-sufficient explanation
|
|
142
142
|
```typescript
|
|
143
143
|
/**
|
|
144
144
|
* Compare two semantic version strings.
|
|
@@ -154,7 +154,7 @@ export function compareVersions(a: string, b: string): number {
|
|
|
154
154
|
}
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
Reference a GitHub issue for additional context when the comment already explains the behaviour
|
|
158
158
|
```typescript
|
|
159
159
|
/**
|
|
160
160
|
* Truncate session tokens to 64 characters before storage.
|
|
@@ -172,7 +172,7 @@ export function truncateToken(token: string): string {
|
|
|
172
172
|
|
|
173
173
|
### Don't
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
Point the reader to an external resource instead of explaining the behaviour
|
|
176
176
|
```typescript
|
|
177
177
|
/**
|
|
178
178
|
* Encode a URI component.
|
|
@@ -185,7 +185,7 @@ export function encodeComponent(value: string): string {
|
|
|
185
185
|
}
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
Reference a wiki or internal doc as a substitute for inline explanation
|
|
189
189
|
```typescript
|
|
190
190
|
/**
|
|
191
191
|
* Truncate session tokens before storage.
|
|
@@ -198,7 +198,7 @@ export function truncateToken(token: string): string {
|
|
|
198
198
|
}
|
|
199
199
|
```
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
Leave the reader unable to understand the symbol without following a link
|
|
202
202
|
```typescript
|
|
203
203
|
/**
|
|
204
204
|
* Compare two semantic version strings.
|
package/docs/turtle.md
CHANGED
|
@@ -14,21 +14,21 @@ This convention allows a single prefix to serve both definitions and data, with
|
|
|
14
14
|
|
|
15
15
|
### Do
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Use PascalCase for class names.
|
|
18
18
|
```turtle
|
|
19
19
|
ds:Component a owl:Class .
|
|
20
20
|
ds:UIBlock a owl:Class .
|
|
21
21
|
ds:ModifierFamily a owl:Class .
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
Use camelCase for property names.
|
|
25
25
|
```turtle
|
|
26
26
|
ds:name a owl:DatatypeProperty .
|
|
27
27
|
ds:hasProperty a owl:ObjectProperty .
|
|
28
28
|
ds:parentComponent a owl:ObjectProperty .
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Use lowercase (with dots or hyphens as separators) for instance identifiers.
|
|
32
32
|
```turtle
|
|
33
33
|
ds:global.component.button a ds:Component .
|
|
34
34
|
ds:global.modifier_family.importance a ds:ModifierFamily .
|
|
@@ -36,19 +36,19 @@ ds:global.modifier_family.importance a ds:ModifierFamily .
|
|
|
36
36
|
|
|
37
37
|
### Don't
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Use lowercase for class names.
|
|
40
40
|
```turtle
|
|
41
41
|
# Bad: Class names should be PascalCase
|
|
42
42
|
ds:component a owl:Class .
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Use PascalCase for instance identifiers.
|
|
46
46
|
```turtle
|
|
47
47
|
# Bad: Instance names should be lowercase
|
|
48
48
|
ds:GlobalComponentButton a ds:Component .
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
Use PascalCase or uppercase for property names.
|
|
52
52
|
```turtle
|
|
53
53
|
# Bad: Property names should be camelCase
|
|
54
54
|
ds:HasProperty a owl:ObjectProperty .
|
|
@@ -65,7 +65,7 @@ The namespace URI should be a base URI without a fragment or trailing path segme
|
|
|
65
65
|
|
|
66
66
|
### Do
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Use a single prefix for both definitions and data.
|
|
69
69
|
```turtle
|
|
70
70
|
# In both definitions/ and data/ files:
|
|
71
71
|
@prefix ds: <https://ds.canonical.com/> .
|
|
@@ -81,7 +81,7 @@ ds:global.component.button a ds:Component ;
|
|
|
81
81
|
|
|
82
82
|
### Don't
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
Use separate prefixes for ontology and data when a unified prefix is preferred.
|
|
85
85
|
```turtle
|
|
86
86
|
# Bad: Unnecessarily complex when unified prefix suffices
|
|
87
87
|
@prefix dso: <https://ds.canonical.com/ontology#> .
|
|
@@ -103,7 +103,7 @@ This separation allows tools to distinguish between schema and instance data, en
|
|
|
103
103
|
|
|
104
104
|
### Do
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
Place ontology definitions (classes, properties, datatypes) in the `definitions/` directory.
|
|
107
107
|
```turtle
|
|
108
108
|
# definitions/ontology.ttl
|
|
109
109
|
@prefix ds: <https://ds.canonical.com/> .
|
|
@@ -116,7 +116,7 @@ ds:name a owl:DatatypeProperty ;
|
|
|
116
116
|
rdfs:range xsd:string .
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
Place instance data in the `data/` directory.
|
|
120
120
|
```turtle
|
|
121
121
|
# data/global/component/button.ttl
|
|
122
122
|
@prefix ds: <https://ds.canonical.com/> .
|
|
@@ -127,14 +127,14 @@ ds:global.component.button a ds:Component ;
|
|
|
127
127
|
|
|
128
128
|
### Don't
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
Mix class definitions and instance data in the same file.
|
|
131
131
|
```turtle
|
|
132
132
|
# Bad: Mixing schema and data
|
|
133
133
|
ds:Component a owl:Class .
|
|
134
134
|
ds:global.component.button a ds:Component .
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
Place instance data in the `definitions/` directory.
|
|
138
138
|
```
|
|
139
139
|
# Bad: Data file in definitions
|
|
140
140
|
definitions/
|
|
@@ -149,7 +149,7 @@ Every Turtle file must declare all prefixes used within the file at the top of t
|
|
|
149
149
|
|
|
150
150
|
### Do
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
Declare all prefixes at the top of the file.
|
|
153
153
|
```turtle
|
|
154
154
|
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
|
155
155
|
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
|
@@ -163,14 +163,14 @@ ds:Component a owl:Class ;
|
|
|
163
163
|
|
|
164
164
|
### Don't
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
Declare the same prefix multiple times.
|
|
167
167
|
```turtle
|
|
168
168
|
# Bad: Duplicate prefix declaration
|
|
169
169
|
@prefix ds: <https://ds.canonical.com/> .
|
|
170
170
|
@prefix ds: <https://ds.canonical.com/> .
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
Use prefixes without declaring them.
|
|
174
174
|
```turtle
|
|
175
175
|
# Bad: Missing prefix declaration for ds:
|
|
176
176
|
ds:Component a owl:Class .
|
package/package.json
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/code-standards",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Code standards ontology and documentation generator",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
7
|
+
"build": "echo 'No build step yet' && exit 0",
|
|
8
|
+
"check": "biome check && tsc --noEmit",
|
|
9
|
+
"check:fix": "biome check --write",
|
|
10
|
+
"check:ts": "tsc --noEmit",
|
|
11
|
+
"test": "vitest run",
|
|
12
|
+
"docs": "bun src/scripts/generate-docs.ts",
|
|
13
|
+
"docs:check": "bun run docs && git diff --exit-code docs/"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@biomejs/biome": "^2.4.6",
|
|
17
|
+
"@canonical/biome-config": "^0.17.1",
|
|
18
|
+
"@canonical/typescript-config": "^0.17.1",
|
|
19
|
+
"@types/bun": "latest",
|
|
20
|
+
"typescript": "^5.9.3",
|
|
21
|
+
"vitest": "^4.0.18"
|
|
8
22
|
}
|
|
9
23
|
}
|