Skip to content

Commit daffa2c

Browse files
committed
chore(docs): fix markdown lint errors
Signed-off-by: Cory Rylan <crylan@nvidia.com>
1 parent 68e2bcd commit daffa2c

37 files changed

Lines changed: 240 additions & 159 deletions

‎projects/internals/eslint/src/local/example-approved-domains.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { findHtmlTemplate, getTemplateText, hasTag } from './example-helpers.js';
22

3-
const APPROVED_DOMAINS = ['nvidia.com', 'github.com'];
3+
const APPROVED_DOMAINS = ['nvidia.com', 'github.com', 'huggingface.co'];
44
const URL_ATTRIBUTES = ['href', 'src', 'srcset'];
55
const URL_ATTRIBUTE_PATTERN = new RegExp(`\\b(${URL_ATTRIBUTES.join('|')})\\s*=\\s*("([^"]*)"|'([^']*)')`, 'gi');
66

‎projects/site/eslint.config.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,33 @@ export default [
1111
...browserTypescriptConfig,
1212
...appConfig,
1313
...jsonConfig,
14+
{
15+
// These examples intentionally demonstrate incomplete and hypothetical component APIs.
16+
files: ['src/docs/api-design/**/*.md', 'src/docs/internal/guidelines/**/*.md'],
17+
rules: {
18+
'@nvidia-elements/lint/no-missing-control-label': 'off',
19+
'@nvidia-elements/lint/no-missing-slotted-elements': 'off',
20+
'@nvidia-elements/lint/no-unknown-tags': 'off'
21+
}
22+
},
23+
{
24+
// These examples intentionally demonstrate deprecated APIs.
25+
files: ['src/docs/about/migration.md'],
26+
rules: {
27+
'@nvidia-elements/lint/no-deprecated-tags': 'off',
28+
'@nvidia-elements/lint/no-deprecated-attributes': 'off',
29+
'@nvidia-elements/lint/no-deprecated-global-attributes': 'off',
30+
'@nvidia-elements/lint/no-deprecated-popover-attributes': 'off',
31+
'@nvidia-elements/lint/no-deprecated-icon-names': 'off',
32+
'@nvidia-elements/lint/no-unexpected-attribute-value': 'off',
33+
'@nvidia-elements/lint/no-unstyled-typography': 'off',
34+
'@nvidia-elements/lint/no-missing-control-label': 'off',
35+
'@nvidia-elements/lint/no-missing-slotted-elements': 'off',
36+
'@nvidia-elements/lint/no-unexpected-global-attribute-value': 'off',
37+
'@nvidia-elements/lint/no-restricted-container-full': 'off',
38+
'@nvidia-elements/lint/no-unknown-tags': 'off'
39+
}
40+
},
1441
{
1542
files: ['src/_11ty/**/*.js'],
1643
rules: {

‎projects/site/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
"command": "eslint -c ./eslint.config.js --color --cache --cache-location .eslintcache/",
202202
"files": [
203203
"src/**/*.js",
204+
"src/**/*.md",
204205
"src/**/*.ts",
205206
"eslint.config.js"
206207
],

‎projects/site/src/docs/api-design/composition.md‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Elements should default to using composition when possible. This approach is to
1616

1717
```html
1818
<nve-button>
19-
button <nve-icon name="info"></nve-icon>
19+
button <nve-icon name="information-circle"></nve-icon>
2020
</nve-button>
2121
```
2222

@@ -36,7 +36,7 @@ Going further this runs into layout conflicts. If the icon needs to change posit
3636

3737
```html
3838
<nve-button>
39-
<nve-icon name="info"></nve-icon> button
39+
<nve-icon name="information-circle"></nve-icon> button
4040
</nve-button>
4141
```
4242

@@ -64,6 +64,8 @@ Elements should provide reasonable defaults for better developer experience for
6464

6565
The alert can internally provide the default icon style for the status in the system. But as above with the button, the alert element runs the risk of absorbing parts of the icon API. To mitigate this, use a documented named slot as the customization hook.
6666

67+
<!-- eslint-disable @nvidia-elements/lint/no-unexpected-attribute-value -->
68+
6769
```html
6870
<!-- nve-alert template -->
6971
<div>
@@ -80,12 +82,16 @@ The alert can internally provide the default icon style for the status in the sy
8082
</nve-alert>
8183
```
8284

85+
<!-- eslint-enable @nvidia-elements/lint/no-unexpected-attribute-value -->
86+
8387
Slots can provide default content if the consumer supplies no content. Here the template sets an internal icon with a status icon that matches the status of the alert. If the consumer wants to customize the icon, they can project their own icon into the `icon` slot and override the default. This makes `icon` an explicit public slot API, while avoiding a series of icon-specific inherited attributes or properties on the alert.
8488

8589
## Semantic Obfuscation - anti-pattern
8690

8791
When building composition based APIs the developer should push the semantics of the HTML up into the light DOM or the control of the consumer. In this example the card element embeds the h1 heading. This creates an incorrect DOM structure as only one given h1 can exist within the page. This also applies as the page structure should work down from h1-h6.
8892

93+
<!-- eslint-disable @nvidia-elements/lint/no-unexpected-slot-value -->
94+
8995
{% dodont %}
9096

9197
```html
@@ -100,15 +106,15 @@ When building composition based APIs the developer should push the semantics of
100106

101107
<!-- consumer API -->
102108
<nve-card status="warning">
103-
<h2 slot="header">Card Header</h2>
104-
<p>card content</p>
109+
<h2 slot="header" nve-text="heading">Card Header</h2>
110+
<p nve-text="body">card content</p>
105111
</nve-card>
106112
```
107113

108114
```html
109115
<!-- nve-card template -->
110116
<div>
111-
<h1><slot name="header"></slot></h1>
117+
<h1 nve-text="heading"><slot name="header"></slot></h1>
112118
<div>
113119
<slot></slot>
114120
</div>
@@ -118,12 +124,14 @@ When building composition based APIs the developer should push the semantics of
118124
<!-- consumer API -->
119125
<nve-card status="warning">
120126
<div slot="header">Card Header</div>
121-
<p>card content</p>
127+
<p nve-text="body">card content</p>
122128
</nve-card>
123129
```
124130

125131
{% enddodont %}
126132

133+
<!-- eslint-enable @nvidia-elements/lint/no-unexpected-slot-value -->
134+
127135
While composition based APIs may be more verbose at times, they lower the API surface area to learn in the system and help ensure there is a singular way to use the element. Once a consumer learns an element API, that API usage remains predictable and reliable throughout the system.
128136

129137
Consumer apps/plugins can add opinionated abstractions. This can provide a more opinionated terse API in which consumers can always “escape” or access the elements of the base library as needed. It's easier to add abstraction layers, it's much more difficult to pull apart the wrong base abstraction.

‎projects/site/src/docs/api-design/index.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ This document is not intended to define the best practices and API design of hig
2323
<nve-alert status="danger">Don't: a practice to avoid</nve-alert>
2424
<nve-alert status="accent">Tip: helpful details on rationale for a given guideline</nve-alert>
2525
<nve-alert status="warning">details on the risks of not following a guideline</nve-alert>
26-
<nve-alert><nve-icon slot="icon">🏁</nve-icon> Performance: detail about how a guideline impacts performance</nve-alert>
27-
<nve-alert><nve-icon slot="icon">🎓</nve-icon> Learn: resource to learn more about a guideline topic</nve-alert>
28-
<nve-alert><nve-icon slot="icon">🚧</nve-icon> WIP: details on any work in progress guidance</nve-alert>
26+
<nve-alert><nve-icon slot="icon" name="flag"></nve-icon> Performance: detail about how a guideline impacts performance</nve-alert>
27+
<nve-alert><nve-icon slot="icon" name="academic-cap"></nve-icon> Learn: resource to learn more about a guideline topic</nve-alert>
28+
<nve-alert><nve-icon slot="icon" name="traffic-cone"></nve-icon> WIP: details on any work in progress guidance</nve-alert>
2929
</div>
3030

3131
## Terminology
@@ -70,7 +70,7 @@ Consistent element APIs provide consistent developer experience. The recommendat
7070
```html
7171
<!-- HTML/JavaScript -->
7272
<nve-alert status="success">
73-
<p>hello there!</p>
73+
<p nve-text="body">hello there!</p>
7474
</nve-alert>
7575

7676
<script type="module">
@@ -82,22 +82,22 @@ Consistent element APIs provide consistent developer experience. The recommendat
8282

8383
<!-- Angular -->
8484
<nve-alert status="success" [closable]="boolProp" (close)="handle($event)">
85-
<p>hello there!</p>
85+
<p nve-text="body">hello there!</p>
8686
</nve-alert>
8787

8888
<!-- Lit -->
8989
<nve-alert status="success" ?closable=${boolProp} @close=${e => this.handle(e)}>
90-
<p>hello there!</p>
90+
<p nve-text="body">hello there!</p>
9191
</nve-alert>
9292

9393
<!-- Vue -->
9494
<nve-alert status="success" :closable="boolProp" @close="handle">
95-
<p>hello there!</p>
95+
<p nve-text="body">hello there!</p>
9696
</nve-alert>
9797

9898
<!-- React/Preact -->
9999
<nve-alert status="success" closable={this.state.boolProp} onClose={this.handle}>
100-
<p>hello there!</p>
100+
<p nve-text="body">hello there!</p>
101101
</nve-alert>
102102
```
103103

‎projects/site/src/docs/api-design/logs.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ This warning appears when invalid elements are slotted into a component. Example
6060

6161
```html
6262
<nve-tree>
63-
<nve-tree-node></nve-tree-node>
63+
<nve-tree-node>Node</nve-tree-node>
6464
</nve-tree>
6565

6666
<nve-grid-row>
@@ -73,7 +73,7 @@ This warning appears when invalid elements are slotted into a component. Example
7373
```html
7474
<nve-tree>
7575
<div>
76-
<nve-tree-node></nve-tree-node>
76+
<nve-tree-node>Node</nve-tree-node>
7777
</div>
7878
</nve-tree>
7979

@@ -102,11 +102,15 @@ This warning appears when a component tries to reference an element by ID that d
102102

103103
<nve-alert status="danger">Invalid</nve-alert>
104104

105+
<!-- eslint-disable @nvidia-elements/lint/no-missing-popover-trigger -->
106+
105107
```html
106108
<nve-button popovertarget="my-popover">show tooltip</nve-button>
107109
<nve-tooltip id="incorrect-id">tooltip</nve-tooltip>
108110
```
109111

112+
<!-- eslint-enable @nvidia-elements/lint/no-missing-popover-trigger -->
113+
110114
To resolve this warning:
111115

112116
- Ensure the referenced element exists in the DOM

‎projects/site/src/docs/api-design/packaging.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Build outputs should target the latest ES2020+. Build outputs should not compile
4545

4646
<nve-alert status="warning">Warning: avoid alternate build targets as it increases complexity and is unnecessary with modern build tools and browsers.</nve-alert>
4747

48-
<nve-alert><nve-icon slot="icon">🎓</nve-icon> Learn: <a href="https://justinfagnani.com/2019/11/01/how-to-publish-web-components-to-npm/">publishing Web Components</a></nve-alert>
48+
<nve-alert><nve-icon slot="icon" name="academic-cap"></nve-icon> Learn: <a href="https://justinfagnani.com/2019/11/01/how-to-publish-web-components-to-npm/">publishing Web Components</a></nve-alert>
4949

5050
## Entrypoints
5151

@@ -95,8 +95,8 @@ The `package.json` should use a `sideEffects` array that lists registration and
9595

9696
This enables tools like Webpack and Rollup to preserve explicit registration entrypoints while still tree-shaking side-effect-free component modules.
9797

98-
<nve-alert><nve-icon slot="icon">🎓</nve-icon> Learn about <a href="/docs/integrations/lit-library/">Lit Library integration</a></nve-alert>
98+
<nve-alert><nve-icon slot="icon" name="academic-cap"></nve-icon> Learn about <a href="/docs/integrations/lit-library/">Lit Library integration</a></nve-alert>
9999

100-
<nve-alert><nve-icon slot="icon">🎓</nve-icon> Learn: <a href="https://github.com/webcomponents/polyfills/tree/master/packages/scoped-custom-element-registry">scoped element registry</a></nve-alert>
100+
<nve-alert><nve-icon slot="icon" name="academic-cap"></nve-icon> Learn: <a href="https://github.com/webcomponents/polyfills/tree/master/packages/scoped-custom-element-registry">scoped element registry</a></nve-alert>
101101

102-
<nve-alert><nve-icon slot="icon">🎓</nve-icon> Learn: <a href="https://www.youtube.com/watch?v=QmDToR6mLhk">case study</a></nve-alert>
102+
<nve-alert><nve-icon slot="icon" name="academic-cap"></nve-icon> Learn: <a href="https://www.youtube.com/watch?v=QmDToR6mLhk">case study</a></nve-alert>

‎projects/site/src/docs/api-design/properties-attributes.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Properties (`@property`) in Lit enable setting the property on the element via J
3030
```
3131

3232
<nve-alert>
33-
<nve-icon slot="icon">🎓</nve-icon>
33+
<nve-icon slot="icon" name="academic-cap"></nve-icon>
3434
<p nve-text="body">Learn: by default when you set a property, Lit does not update the corresponding attribute in the DOM for performance. If the attribute serves as a style hook example, <code nve-text="code">:host([disabled])</code> then you can add the <code nve-text="code">reflect</code> option to the property decorator.</p>
3535
</nve-alert>
3636

@@ -56,7 +56,7 @@ Properties/Attributes should avoid enabling “impossible states”. Conflicting
5656

5757
{% enddodont %}
5858

59-
<nve-alert><nve-icon slot="icon">🎓</nve-icon> Learn:&nbsp;<a href="https://kentcdodds.com/blog/make-impossible-states-impossible" nve-text="link">make impossible states impossible</a></nve-alert>
59+
<nve-alert><nve-icon slot="icon" name="academic-cap"></nve-icon> Learn:&nbsp;<a href="https://kentcdodds.com/blog/make-impossible-states-impossible" nve-text="link">make impossible states impossible</a></nve-alert>
6060

6161
## Boolean Types
6262

@@ -81,20 +81,20 @@ Boolean property/attribute type behave the same as native HTML element boolean t
8181
While Lit keeps both properties and attributes in sync, do not use complex types like `object` and `array` on the API. Since HTML cannot represent JavaScript objects, Lit must JSON parse attributes and reflect them anytime there is a change to ensure the JavaScript property and HTML attribute are in sync. This can be expensive to parse when using an object or array and cause unexpected behaviors such as lost object references for the user.
8282

8383
<nve-alert status="success">
84-
Use <code>string | number | boolean</code>
84+
Use <code nve-text="code">string | number | boolean</code>
8585
</nve-alert>
8686

8787
<nve-alert status="danger">
88-
Avoid <code>object | array</code>
88+
Avoid <code nve-text="code">object | array</code>
8989
</nve-alert>
9090

9191
Complex types cause compatibility and usability issues as it can require the developer to use JavaScript to render content. This can make it difficult for user-generated content like CMS systems or SSR (Server Side Rendering) to easily render static HTML.
9292

9393
<nve-alert status="warning">
94-
Warning: avoid using <code>@property</code> on built in properties/attributes on the <code>HTMLElement</code> as the decorator overrides the getter/setter and can cause unexpected behavior.&nbsp;<a href="https://github.com/vmware-clarity/core/blob/main/projects/core/build/eslint-rules/reserved-property-names.js" nve-text="link">read more</a>
94+
Warning: avoid using <code nve-text="code">@property</code> on built in properties/attributes on the <code nve-text="code">HTMLElement</code> as the decorator overrides the getter/setter and can cause unexpected behavior.&nbsp;<a href="https://github.com/vmware-clarity/core/blob/main/projects/core/build/eslint-rules/reserved-property-names.js" nve-text="link">read more</a>
9595
</nve-alert>
9696

97-
<nve-alert><nve-icon slot="icon">🎓</nve-icon>
97+
<nve-alert><nve-icon slot="icon" name="academic-cap"></nve-icon>
9898
Learn about <a href="https://developers.google.com/web/fundamentals/web-components/best-practices#attributes-properties" nve-text="link">Web Fundamentals Attributes vs Properties</a>.
9999
</nve-alert>
100100

@@ -147,6 +147,6 @@ export class Sparkline extends LitElement implements DataElement<number[]> {
147147

148148
<nve-alert status="warning">
149149
<p nve-text="relaxed">
150-
Warning: only use <code>DataElement</code> for data structures that have no reasonable declarative HTML representation. If primitive attributes, slots, or child elements can represent the content, prefer those approaches.
150+
Warning: only use <code nve-text="code">DataElement</code> for data structures that have no reasonable declarative HTML representation. If primitive attributes, slots, or child elements can represent the content, prefer those approaches.
151151
</p>
152152
</nve-alert>

‎projects/site/src/docs/api-design/registration.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ Tag names should avoid using verbs or actions within the name. The properties an
3131

3232
{% enddodont %}
3333

34-
<nve-alert><nve-icon slot="icon">🎓</nve-icon> Learn: elements should follow common and established names for existing UI patterns. See &nbsp;<a href="https://open-ui.org" nve-text="link">openui.org</a>&nbsp; for more details on upcoming specs.</nve-alert>
34+
<nve-alert><nve-icon slot="icon" name="academic-cap"></nve-icon> Learn: elements should follow common and established names for existing UI patterns. See &nbsp;<a href="https://open-ui.org" nve-text="link">openui.org</a>&nbsp; for more details on upcoming specs.</nve-alert>
3535

36-
<nve-alert><nve-icon slot="icon">🎓</nve-icon> Learn: learn common component names from the Open UI &nbsp;<a href="https://open-ui.org/research/component-matrix" nve-text="link">component name matrix</a>.</nve-alert>
36+
<nve-alert><nve-icon slot="icon" name="academic-cap"></nve-icon> Learn: learn common component names from the Open UI &nbsp;<a href="https://open-ui.org/research/component-matrix" nve-text="link">component name matrix</a>.</nve-alert>

‎projects/site/src/docs/api-design/slots.md‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Slots provide flexibility for content controlled by the host application that a
2020

2121
```html
2222
<nve-alert status="success">
23-
<p>Hello <strong>There</strong>!</p>
23+
<p nve-text="body">Hello <strong>There</strong>!</p>
2424
</nve-alert>
2525
```
2626

@@ -31,12 +31,12 @@ Slots enable an easy way for component composition and decoupling from precise u
3131
```html
3232
<nve-card>
3333
<nve-card-header>
34-
<h3>Plugin</h3>
34+
<h3 nve-text="heading">Plugin</h3>
3535
<a href="#">Learn More</a>
3636
</nve-card-header>
37-
<nve-card-body>
38-
<p>Cool new plugin features!</p>
39-
</nve-card-body>
37+
<nve-card-content>
38+
<p nve-text="body">Cool new plugin features!</p>
39+
</nve-card-content>
4040
<nve-card-footer>
4141
<nve-button>Enable</nve-button>
4242
</nve-card-footer>
@@ -73,21 +73,21 @@ Composition based APIs also provide flexibility for the host application to choo
7373

7474
```html
7575
<nve-tree>
76-
<nve-tree-item>item</nve-tree-item>
77-
<nve-tree-item>item</nve-tree-item>
78-
<nve-tree-item>item</nve-tree-item>
76+
<nve-tree-node>item</nve-tree-node>
77+
<nve-tree-node>item</nve-tree-node>
78+
<nve-tree-node>item</nve-tree-node>
7979
</nve-tree>
8080
```
8181

8282
```html
8383
<nve-tree>
84-
<nve-tree-item>item</nve-tree-item>
85-
<nve-tree-item>item</nve-tree-item>
86-
<nve-tree-item expanded>
87-
<nve-tree-item>item</nve-tree-item>
88-
<nve-tree-item>item</nve-tree-item>
89-
<nve-tree-item>item</nve-tree-item>
90-
</nve-tree-item>
84+
<nve-tree-node>item</nve-tree-node>
85+
<nve-tree-node>item</nve-tree-node>
86+
<nve-tree-node expanded>
87+
<nve-tree-node>item</nve-tree-node>
88+
<nve-tree-node>item</nve-tree-node>
89+
<nve-tree-node>item</nve-tree-node>
90+
</nve-tree-node>
9191
</nve-tree>
9292
```
9393

@@ -96,14 +96,14 @@ By leveraging composition the host application has full render control in their
9696
```html
9797
<!-- Angular -->
9898
<nve-tree>
99-
<nve-tree-item *ngFor="let item of items">{{item.id}}</nve-tree-item>
99+
<nve-tree-node *ngFor="let item of items">{{item.id}}</nve-tree-node>
100100
</nve-tree>
101101
```
102102

103103
```tsx
104104
// JSX
105105
<nve-tree>
106-
{items.map(item => <nve-tree-item>{item.id}</nve-tree-item>)}
106+
{items.map(item => <nve-tree-node>{item.id}</nve-tree-node>)}
107107
</nve-tree>
108108
```
109109

@@ -113,7 +113,7 @@ This enables full control of conditional rendering of tree nodes as well as more
113113
<!-- Angular, only create nodes if the item meets a certain condition -->
114114
<nve-tree>
115115
<ng-container *ngFor="let item of items">
116-
<nve-tree-item *ngIf="item.active">{{item.id}}</nve-tree-item>
116+
<nve-tree-node *ngIf="item.active">{{item.id}}</nve-tree-node>
117117
</ng-container>
118118
</nve-tree>
119119
```

0 commit comments

Comments
 (0)