Skip to content

Commit

Permalink
fix(VSlider): render label slot
Browse files Browse the repository at this point in the history
fixes #18251
  • Loading branch information
KaelWD committed Sep 14, 2023
1 parent f314cd1 commit eb07336
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 17 deletions.
1 change: 1 addition & 0 deletions eslint-local-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ module.exports = {
'jest-global-imports': require('./scripts/rules/jest-global-imports'),
'cypress-types-reference': require('./scripts/rules/cypress-types-reference'),
'sort-imports': require('./scripts/rules/sort-imports'),
'no-nullish-coalescing-in-condition': require('./scripts/rules/no-nullish-coalescing-in-condition'),
}
1 change: 1 addition & 0 deletions packages/vuetify/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
// 'vue/html-closing-bracket-spacing': 'off',
// 'local-rules/no-render-string-reference': 'error',
'local-rules/no-components-index': 'error',
'local-rules/no-nullish-coalescing-in-condition': 'error',

'no-restricted-imports': ['error', {
paths: [{
Expand Down
17 changes: 9 additions & 8 deletions packages/vuetify/src/components/VRangeSlider/VRangeSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,15 @@ export const VRangeSlider = genericComponent<VSliderSlots>()({
...slots,
prepend: hasPrepend ? slotProps => (
<>
{ slots.label?.(slotProps) ?? props.label
? (
<VLabel
class="v-slider__label"
text={ props.label }
/>
) : undefined
}
{ slots.label?.(slotProps) ?? (
props.label
? (
<VLabel
class="v-slider__label"
text={ props.label }
/>
) : undefined
)}

{ slots.prepend?.(slotProps) }
</>
Expand Down
19 changes: 10 additions & 9 deletions packages/vuetify/src/components/VSlider/VSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,16 @@ export const VSlider = genericComponent<VSliderSlots>()({
...slots,
prepend: hasPrepend ? slotProps => (
<>
{ slots.label?.(slotProps) ?? props.label
? (
<VLabel
id={ slotProps.id.value }
class="v-slider__label"
text={ props.label }
/>
) : undefined
}
{ slots.label?.(slotProps) ?? (
props.label
? (
<VLabel
id={ slotProps.id.value }
class="v-slider__label"
text={ props.label }
/>
) : undefined
)}

{ slots.prepend?.(slotProps) }
</>
Expand Down
29 changes: 29 additions & 0 deletions scripts/rules/no-nullish-coalescing-in-condition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
create (context) {
const sourceCode = context.getSourceCode()

function isParenthesised (node) {
const previousToken = sourceCode.getTokenBefore(node)
const nextToken = sourceCode.getTokenAfter(node)

return Boolean(previousToken && nextToken) &&
previousToken.value === '(' && previousToken.range[1] <= node.range[0] &&
nextToken.value === ')' && nextToken.range[0] >= node.range[1]
}

return {
ConditionalExpression (node) {
if (
node.test.type === 'LogicalExpression' &&
node.test.operator === '??' &&
!isParenthesised(node.test)
) {
context.report({
node: node.test,
message: 'Do not use nullish coalescing in ternary conditions',
})
}
},
}
},
}

0 comments on commit eb07336

Please sign in to comment.