@codelaw/rules-stencil 0.0.0-stage → 0.2.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,75 @@
1
+ ---
2
+ id: stencil/tag-prefix
3
+ title: "Component tags start with the project's prefix"
4
+ languages: [typescript, tsx]
5
+ fix: manual
6
+ fix_reason: "renaming a tag changes every page that uses it"
7
+ stability: preview
8
+ options:
9
+ prefix: { type: string, default: "", description: "the prefix every tag must start with" }
10
+ since: 0.1.0
11
+ ---
12
+
13
+ Every component's `tag` starts with the project's prefix (the `prefix` option); with no prefix set,
14
+ a tag still needs one.
15
+
16
+ **Why:** One prefix keeps a project's elements apart from other libraries'.
17
+
18
+ ```codelaw
19
+ native: stencil/tag-prefix
20
+ ```
21
+
22
+ ## How to fix
23
+
24
+ 1. Rename the tag to start with the project's prefix.
25
+ 2. Update every usage of the element.
26
+
27
+ ## Examples
28
+
29
+ ### TypeScript
30
+
31
+ #### Don't
32
+
33
+ ```ts
34
+ @Component({ tag: 'card' })
35
+ export class Card {
36
+ render() {
37
+ return null;
38
+ }
39
+ }
40
+ ```
41
+
42
+ #### Do
43
+
44
+ ```ts
45
+ @Component({ tag: 'acme-card' })
46
+ export class Card {
47
+ render() {
48
+ return null;
49
+ }
50
+ }
51
+ ```
52
+
53
+ ### TSX
54
+
55
+ #### Don't
56
+
57
+ ```tsx
58
+ @Component({ tag: 'card' })
59
+ export class Card {
60
+ render() {
61
+ return null;
62
+ }
63
+ }
64
+ ```
65
+
66
+ #### Do
67
+
68
+ ```tsx
69
+ @Component({ tag: 'acme-card' })
70
+ export class Card {
71
+ render() {
72
+ return null;
73
+ }
74
+ }
75
+ ```