Skip to content

Commit 47ae4ff

Browse files
committed
chore(ci): disable no-missing-gap-space rule for specific test files
- Updated ESLint configuration to turn off the no-missing-gap-space rule for visual test files and example files. - Adjusted various components to comply with the new layout requirements, ensuring proper gap spacing is maintained. Signed-off-by: Cory Rylan <crylan@nvidia.com>
1 parent df74628 commit 47ae4ff

11 files changed

Lines changed: 71 additions & 26 deletions

File tree

‎projects/core/eslint.config.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ export default [
2929
'@nvidia-elements/lint/no-missing-popover-trigger': ['error']
3030
}
3131
},
32+
{
33+
files: ['src/**/*.test.visual.ts'],
34+
rules: {
35+
'@nvidia-elements/lint/no-missing-gap-space': ['off']
36+
}
37+
},
3238
{
3339
files: [
3440
'src/format-datetime/format-datetime.ts',

‎projects/internals/patterns/src/editor.examples.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const FileBrowser = {
7171
</nve-page-panel-content>
7272
</nve-page-panel>
7373
74-
<mainnve-layout="column full">
74+
<mainnve-layout="column full gap:none">
7575
<nve-toolbarcontainer="full">
7676
<nve-tabsbehavior-select>
7777
<nve-tabs-itemselected>lidar_config.py</nve-tabs-item>
@@ -169,7 +169,7 @@ export const DiffView = {
169169
<nve-buttonslot="suffix">Merge</nve-button>
170170
</nve-toolbar>
171171
172-
<mainnve-layout="column">
172+
<mainnve-layout="column gap:none">
173173
<nve-toolbarcontainer="full" style="--background: var(--nve-sys-layer-canvas-accent-background)">
174174
<divslot="prefix" nve-layout="row gap:sm align:vertical-center">
175175
<nve-icon-buttonicon-name="branch" size="sm" container="flat"></nve-icon-button>
@@ -345,7 +345,7 @@ export const ReadOnly = {
345345
</nve-page-panel-content>
346346
</nve-page-panel>
347347
348-
<mainnve-layout="column" style="height: 100%">
348+
<mainnve-layout="column gap:none" style="height: 100%">
349349
<nve-toolbarcontainer="full">
350350
<nve-tabsbehavior-select>
351351
<nve-tabs-itemselected>robot_config.yaml</nve-tabs-item>

‎projects/internals/patterns/src/templates.examples.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ export const CodeEditor = {
832832
</nve-tree>
833833
</nve-page-panel-content>
834834
</nve-page-panel>
835-
<mainnve-layout="column full">
835+
<mainnve-layout="column full gap:none">
836836
<nve-toolbarcontainer="full">
837837
<nve-tabsbehavior-select>
838838
<nve-tabs-itemselected>lidar_config.py</nve-tabs-item>

‎projects/internals/tools/src/playground/service.test.ts‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,18 @@ describe('PlaygroundService', () => {
1717
constenv=process.env.ELEMENTS_ENV;
1818
process.env.ELEMENTS_ENV='mcp';
1919
constresult=awaitPlaygroundService.validate({
20-
template: '<nve-button nve-layout="column">hello there</nve-button>'
20+
template: '<nve-button nve-layout="column gap:sm">hello there</nve-button>'
2121
});
2222
expect(Array.isArray(result)).toBe(true);
23-
expect(result.length).toBe(2);
23+
expect(result.length).toBe(1);
2424
expect(result[0].message).toContain(
2525
'Unexpected use of restricted attribute "nve-layout" on <nve-button>. Remove the attribute.'
2626
);
2727
expect(result[0].message).toContain('Supported attributes:');
2828
expect(result[0].line).toBe(1);
2929
expect(result[0].column).toBe(13);
3030
expect(result[0].endLine).toBe(1);
31-
expect(result[0].endColumn).toBe(32);
32-
expect(result[1].message).toBe(
33-
'Layout "column" is missing gap spacing. Add a gap value such as "xs", "sm", "md", "lg", "xl"'
34-
);
31+
expect(result[0].endColumn).toBe(39);
3532
expect((PlaygroundService.validateasToolMethod<unknown>).metadata.name).toBe('validate');
3633
expect((PlaygroundService.validateasToolMethod<unknown>).metadata.command).toBe('validate');
3734
expect((PlaygroundService.validateasToolMethod<unknown>).metadata.description).toBe(
@@ -136,13 +133,13 @@ describe('PlaygroundService', () => {
136133
constcreateTool=tools.find(tool=>tool.metadata.name==='create');
137134

138135
constresult=(awaitcreateTool?.({
139-
template: '<nve-button nve-layout="column">hello</nve-button>',
136+
template: '<nve-button nve-layout="column gap:sm">hello</nve-button>',
140137
start: false
141138
}))asToolOutput<{message: string}[]>;
142139

143140
expect(result.status).toBe('error');
144141
expect(result.message).toBe('Template validation failed');
145-
expect(result.result).toHaveLength(2);
142+
expect(result.result).toHaveLength(1);
146143
expect(result.result?.[0]?.message).toContain(
147144
'Unexpected use of restricted attribute "nve-layout" on <nve-button>. Remove the attribute.'
148145
);

‎projects/lint/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default [
7878
|`@nvidia-elements/lint/no-invalid-event-listeners`| Disallow inline event handler attributes in HTML. | HTML |`error`|
7979
|`@nvidia-elements/lint/no-invalid-invoker-triggers`| Disallow use of invoker trigger attributes on non-button nve-* elements. | HTML |`error`|
8080
|`@nvidia-elements/lint/no-missing-control-label`| Require form controls to have an accessible label. | HTML |`error`|
81-
|`@nvidia-elements/lint/no-missing-gap-space`| Require gap spacing on rowand column layouts. | HTML |`off`|
81+
|`@nvidia-elements/lint/no-missing-gap-space`| Require gap spacing on row, column, and grid layouts. | HTML |`error`|
8282
|`@nvidia-elements/lint/no-missing-icon-name`| Require icon elements to have an icon name attribute. | HTML |`error`|
8383
|`@nvidia-elements/lint/no-missing-popover-trigger`| Require popover elements to have a corresponding trigger element. | HTML |`error`|
8484
|`@nvidia-elements/lint/no-missing-slotted-elements`| Disallow use of missing slotted elements. | HTML |`error`|

‎projects/lint/src/eslint/rules/no-missing-gap-space.test.ts‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('noMissingGapSpace', () => {
5454
expect(noMissingGapSpace.meta.type).toBe('problem');
5555
expect(noMissingGapSpace.meta.hasSuggestions).toBe(true);
5656
expect(noMissingGapSpace.meta.docs).toBeDefined();
57-
expect(noMissingGapSpace.meta.docs.description).toBe('Require gap spacing on rowand column layouts.');
57+
expect(noMissingGapSpace.meta.docs.description).toBe('Require gap spacing on row, column, and grid layouts.');
5858
expect(noMissingGapSpace.meta.docs.category).toBe('Best Practice');
5959
expect(noMissingGapSpace.meta.docs.recommended).toBe(true);
6060
expect(noMissingGapSpace.meta.docs.url).toContain('/docs/lint/');
@@ -93,7 +93,18 @@ describe('noMissingGapSpace', () => {
9393
valid: ['row','column','grid'].flatMap(layout=>
9494
GAP_OPTIONAL_VALUES.map(value=>`<div nve-layout="${layout}${value}"></div>`)
9595
),
96-
invalid: []
96+
invalid: [
97+
{
98+
code: '<div nve-layout="grid"></div>',
99+
errors: [
100+
{
101+
messageId: 'missing-gap-space',
102+
data: {layout: 'grid'},
103+
suggestions: gapSuggestions('grid')
104+
}
105+
]
106+
}
107+
]
97108
});
98109
});
99110

@@ -134,6 +145,24 @@ describe('noMissingGapSpace', () => {
134145
});
135146
});
136147

148+
it('should quote unquoted layout values in suggestions',()=>{
149+
tester.run('should quote unquoted layout values in suggestions',rule,{
150+
valid: [],
151+
invalid: [
152+
{
153+
code: '<div nve-layout=row></div>',
154+
errors: [
155+
{
156+
messageId: 'missing-gap-space',
157+
data: {layout: 'row'},
158+
suggestions: gapSuggestions('row')
159+
}
160+
]
161+
}
162+
]
163+
});
164+
});
165+
137166
it('should report missing gap on column layout',()=>{
138167
tester.run('should report missing gap on column layout',rule,{
139168
valid: [],

‎projects/lint/src/eslint/rules/no-missing-gap-space.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ function reportGapViolation({
4343
layoutAttr: HtmlAttribute;
4444
value: string;
4545
}){
46+
const[startWrapper,endWrapper]=
47+
layoutAttr.startWrapper&&layoutAttr.endWrapper
48+
? [layoutAttr.startWrapper.value,layoutAttr.endWrapper.value]
49+
: ['"','"'];
50+
4651
context.report({
4752
node: layoutAttr,
4853
messageId: 'missing-gap-space',
@@ -53,7 +58,7 @@ function reportGapViolation({
5358
fix: (fixer: Rule.RuleFixer)=>
5459
fixer.replaceText(
5560
layoutAttrasunknownasRule.Node,
56-
`nve-layout=${layoutAttr.startWrapper?.value}${suggestedLayout(value,size)}${layoutAttr.endWrapper?.value}`
61+
`nve-layout=${startWrapper}${suggestedLayout(value,size)}${endWrapper}`
5762
)
5863
}))
5964
});
@@ -64,7 +69,7 @@ const rule = {
6469
type: 'problem'asconst,
6570
hasSuggestions: true,
6671
docs: {
67-
description: 'Require gap spacing on rowand column layouts.',
72+
description: 'Require gap spacing on row, column, and grid layouts.',
6873
category: 'Best Practice',
6974
recommended: true,
7075
url: `${__ELEMENTS_PAGES_BASE_URL__}/docs/lint/`

‎projects/site/src/_internal/search/search.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ export class DocsSearch extends LitElement {
471471

472472
#renderSearchResult(result: SearchResult){
473473
returnhtml`
474-
<ahref="${this.baseUrl}${result.url}" nve-layout="column pad-top:xs">
474+
<ahref="${this.baseUrl}${result.url}" nve-layout="pad-top:xs">
475475
<divnve-layout="row gap:sm pad-top:xs pad-left:xs">
476476
<nve-iconname="${result.icon}" size="md" style="${result.style}"></nve-icon>
477477
<divnve-layout="column gap:xs">

‎projects/site/src/docs/foundations/themes/color.11ty.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,17 @@ function getColorScale(color) {
9494
);
9595
}
9696
return/* html */`
97-
<div nve-layout="column pad-bottom:xl" docs-full-width>
97+
<div nve-layout="pad-bottom:xl" docs-full-width>
9898
<h2 nve-text="body">${color.replace('ref-color-','')}</h2>
99-
<div nve-layout="row" style="width: 100%">
100-
<div nve-layout="column" style="padding-top: 25px">${Array.from(Array(12).keys())
99+
<div nve-layout="row full">
100+
<div nve-layout="pad-top:xl">${Array.from(Array(12).keys())
101101
.map(
102102
i=>
103103
/* html */`<p nve-text="body" nve-layout="column align:center pad:xs" style="height: 40px">${i+1}00</p>`
104104
)
105105
.join('')}</div>
106-
<div nve-layout="column" style="width: 100%"><p nve-text="body center" nve-layout="column align:center pad:xs" style="width: 100%">light</p><div nve-theme="root light" style="width: 100%" colors="">${tokens.join('')}</div></div>
107-
<div nve-layout="column" style="width: 100%"><p nve-text="body center" nve-layout="column align:center pad:xs" style="width: 100%">dark</p><div nve-theme="root dark" style="width: 100%" colors="">${tokens.join('')}</div></div>
106+
<div nve-layout="column full"><p nve-text="body center" nve-layout="column align:center pad:xs" style="width: 100%">light</p><div nve-theme="root light" style="width: 100%" colors="">${tokens.join('')}</div></div>
107+
<div nve-layout="column full"><p nve-text="body center" nve-layout="column align:center pad:xs" style="width: 100%">dark</p><div nve-theme="root dark" style="width: 100%" colors="">${tokens.join('')}</div></div>
108108
</div>
109109
</div>`;
110110
}

‎projects/site/src/docs/lint/index.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ export default [
162162
</nve-grid-row>
163163
<nve-grid-row>
164164
<nve-grid-cell><code nve-text="code">@nvidia-elements/lint/no-missing-gap-space</code></nve-grid-cell>
165-
<nve-grid-cell>Require gap spacing on rowand column layouts.</nve-grid-cell>
165+
<nve-grid-cell>Require gap spacing on row, column, and grid layouts.</nve-grid-cell>
166166
<nve-grid-cell>HTML</nve-grid-cell>
167-
<nve-grid-cell><code nve-text="code">off</code></nve-grid-cell>
167+
<nve-grid-cell><code nve-text="code">error</code></nve-grid-cell>
168168
</nve-grid-row>
169169
<nve-grid-row>
170170
<nve-grid-cell><code nve-text="code">@nvidia-elements/lint/no-missing-icon-name</code></nve-grid-cell>

0 commit comments

Comments
 (0)