From 76cb29ec649fbb3605f6c6de292584a6cb4c0723 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 3 Sep 2026 06:06:03 +0000 Subject: [PATCH 1/2] chore(lint): cover select slot exception and drop dead branch Adds hasSlot coverage for the nve-select exception and removes the unreachable tagName === 'default' recommendation branch. Line coverage rises from 88.88% to 100% and branch coverage from 75% to 100%. No public API change. Signed-off-by: Cursor Agent --- projects/lint/src/eslint/internals/slots.test.ts | 2 ++ projects/lint/src/eslint/internals/slots.ts | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/projects/lint/src/eslint/internals/slots.test.ts b/projects/lint/src/eslint/internals/slots.test.ts index 2691dd277f..0b853e91b2 100644 --- a/projects/lint/src/eslint/internals/slots.test.ts +++ b/projects/lint/src/eslint/internals/slots.test.ts @@ -16,6 +16,8 @@ describe('noUnexpectedSlotValue', () => { expect(hasSlot('nve-badge', '')).toBe(true); expect(hasSlot('nve-tabs-group', 'overview')).toBe(true); expect(hasSlot('nve-tabs-group', 'details')).toBe(true); + expect(hasSlot('nve-select', 'prefix')).toBe(true); + expect(hasSlot('nve-select', '')).toBe(true); }); }); diff --git a/projects/lint/src/eslint/internals/slots.ts b/projects/lint/src/eslint/internals/slots.ts index 58b2496eda..5ddacb7071 100644 --- a/projects/lint/src/eslint/internals/slots.ts +++ b/projects/lint/src/eslint/internals/slots.ts @@ -25,13 +25,8 @@ export function isKnownElement(tagName: string) { export function getRecommendedSlotName(slot: string, tagName: string) { const element = elements.find(el => el.name === tagName); const slots = element?.manifest?.slots?.map(s => s.name)?.filter(s => s !== undefined) ?? []; - const hasUnnamedSlot = slots.find(s => s === ''); let recommendedSlot = slots[0]; - if (tagName === 'default' && hasUnnamedSlot) { - recommendedSlot = ''; - } - const potentialMatch = slots.find(s => s.includes(slot)); if (potentialMatch) { recommendedSlot = potentialMatch; From d6681089181ef2ac430670ffeeb9fc595b418d5f Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 3 Sep 2026 14:13:33 +0000 Subject: [PATCH 2/2] fix(lint): suggest removing slot="default" when unnamed slot is not first The unnamed-slot special case in getRecommendedSlotName never ran. It tested tagName instead of the slot argument, and read hasUnnamedSlot with find, which returns the empty string and is therefore falsy. nve-alert lists icon, prefix, actions and content before its unnamed slot, so slot="default" on an nve-alert child was reported with a suggestion to replace it with slot="icon" rather than remove it. Signed-off-by: Cursor Agent --- .../lint/src/eslint/internals/slots.test.ts | 6 +++++- projects/lint/src/eslint/internals/slots.ts | 6 ++++++ .../rules/no-unexpected-slot-value.test.ts | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/projects/lint/src/eslint/internals/slots.test.ts b/projects/lint/src/eslint/internals/slots.test.ts index 0b853e91b2..b2f5b18f31 100644 --- a/projects/lint/src/eslint/internals/slots.test.ts +++ b/projects/lint/src/eslint/internals/slots.test.ts @@ -16,7 +16,7 @@ describe('noUnexpectedSlotValue', () => { expect(hasSlot('nve-badge', '')).toBe(true); expect(hasSlot('nve-tabs-group', 'overview')).toBe(true); expect(hasSlot('nve-tabs-group', 'details')).toBe(true); - expect(hasSlot('nve-select', 'prefix')).toBe(true); + expect(hasSlot('nve-select', 'option-1')).toBe(true); expect(hasSlot('nve-select', '')).toBe(true); }); }); @@ -27,4 +27,8 @@ describe('getRecommendedSlotName', () => { expect(getRecommendedSlotName('default', 'nve-card')).toBe(''); expect(getRecommendedSlotName('icon', 'nve-badge')).toBe('prefix-icon'); }); + + it('should recommend the unnamed slot when it is not listed first', () => { + expect(getRecommendedSlotName('default', 'nve-alert')).toBe(''); + }); }); diff --git a/projects/lint/src/eslint/internals/slots.ts b/projects/lint/src/eslint/internals/slots.ts index 5ddacb7071..cf6bbda077 100644 --- a/projects/lint/src/eslint/internals/slots.ts +++ b/projects/lint/src/eslint/internals/slots.ts @@ -25,8 +25,14 @@ export function isKnownElement(tagName: string) { export function getRecommendedSlotName(slot: string, tagName: string) { const element = elements.find(el => el.name === tagName); const slots = element?.manifest?.slots?.map(s => s.name)?.filter(s => s !== undefined) ?? []; + const hasUnnamedSlot = slots.includes(''); let recommendedSlot = slots[0]; + // the unnamed slot is not always listed first, so slot="default" must map to it explicitly + if (slot === 'default' && hasUnnamedSlot) { + recommendedSlot = ''; + } + const potentialMatch = slots.find(s => s.includes(slot)); if (potentialMatch) { recommendedSlot = potentialMatch; diff --git a/projects/lint/src/eslint/rules/no-unexpected-slot-value.test.ts b/projects/lint/src/eslint/rules/no-unexpected-slot-value.test.ts index befa13cba4..ccb99781fd 100644 --- a/projects/lint/src/eslint/rules/no-unexpected-slot-value.test.ts +++ b/projects/lint/src/eslint/rules/no-unexpected-slot-value.test.ts @@ -113,6 +113,23 @@ describe('noUnexpectedSlotValue', () => { ] } ] + }, + { + // nve-alert lists named slots before its unnamed slot + code: '
', + errors: [ + { + messageId: 'unexpected-slot-value', + data: { slotName: 'default', tagName: 'div', parentTagName: 'nve-alert' }, + suggestions: [ + { + messageId: 'suggest-remove-slot-value', + data: { slotName: 'default', alternative: '' }, + output: '
' + } + ] + } + ] } ] });