Skip to content

Commit

Permalink
chore(lint): consistent JSX curly spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Mar 8, 2023
1 parent ba11898 commit 97b22d2
Show file tree
Hide file tree
Showing 96 changed files with 814 additions and 335 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
'@typescript-eslint',
'sonarjs',
'react',
'eslint-plugin-local-rules',
],
rules: {
'no-var': 'error',
Expand Down Expand Up @@ -200,6 +201,16 @@ module.exports = {

// https://github.com/yannickcr/eslint-plugin-react/issues/2415
// 'react/jsx-curly-spacing': ['error', { when: 'always', spacing: { objectLiterals: 'never' } }],
'local-rules/jsx-condition-key': 'error',
'local-rules/jsx-curly-spacing': ['error', {
when: 'always',
spacing: {
objectLiterals: 'never',
arrayLiterals: 'never',
multilineClose: 'never',
},
children: true,
}],

'react/jsx-equals-spacing': 'error',
'react/jsx-first-prop-new-line': 'error',
Expand Down
5 changes: 2 additions & 3 deletions eslint-local-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
const path = require('path')

module.exports = {
'no-render-string-reference': {
create: require('./scripts/no-render-string-reference'),
},
'no-render-string-reference': require('./scripts/rules/no-render-string-reference'),
'jsx-condition-key': {
create (context) {
return {
Expand Down Expand Up @@ -58,6 +56,7 @@ module.exports = {
}
},
},
'jsx-curly-spacing': require('./scripts/rules/jsx-curly-spacing'),
'jest-global-imports': {
meta: {
fixable: 'code',
Expand Down
4 changes: 0 additions & 4 deletions packages/vuetify/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ module.exports = {
__VUETIFY_VERSION__: true,
__REQUIRED_VUE__: true,
},
plugins: [
'eslint-plugin-local-rules',
],
extends: [
// 'plugin:import/typescript', // slow, only enable if needed
],
Expand All @@ -19,7 +16,6 @@ module.exports = {
// 'vue/html-self-closing': 'off',
// 'vue/html-closing-bracket-spacing': 'off',
// 'local-rules/no-render-string-reference': 'error',
'local-rules/jsx-condition-key': 'error',

'no-restricted-imports': ['error', {
paths: [{
Expand Down
12 changes: 6 additions & 6 deletions packages/vuetify/src/components/VAlert/VAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const VAlert = genericComponent<VAlertSlots>()({
]}
style={ textColorStyles.value }
/>
) }
)}

{ hasPrepend && (
<VDefaultsProvider
Expand All @@ -193,18 +193,18 @@ export const VAlert = genericComponent<VAlertSlots>()({
}
</div>
</VDefaultsProvider>
) }
)}

<div class="v-alert__content">
{ hasTitle && (
<VAlertTitle key="title">
{ slots.title ? slots.title() : props.title }
</VAlertTitle>
) }
)}

{ hasText && (
slots.text ? slots.text() : props.text
) }
)}

{ slots.default?.() }
</div>
Expand All @@ -213,7 +213,7 @@ export const VAlert = genericComponent<VAlertSlots>()({
<div key="append" class="v-alert__append">
{ slots.append() }
</div>
) }
)}

{ hasClose && (
<VDefaultsProvider
Expand All @@ -230,7 +230,7 @@ export const VAlert = genericComponent<VAlertSlots>()({
{ slots.close?.({ props: closeProps.value }) ?? <VBtn { ...closeProps.value } /> }
</div>
</VDefaultsProvider>
) }
)}
</props.tag>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ describe('VAlert', () => {
it('supports default color props', () => {
cy.mount(() => (
<>
{defaultColors.map((color, idx) => (
{ defaultColors.map((color, idx) => (
<VAlert color={ color } text={ idx.toString() }>
{ color } alert
</VAlert>
)) }
))}
</>
))
.get('.v-alert')
Expand Down
10 changes: 5 additions & 5 deletions packages/vuetify/src/components/VAutocomplete/VAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export const VAutocomplete = genericComponent<new <
>
{ !displayItems.value.length && !props.hideNoData && (slots['no-data']?.() ?? (
<VListItem title={ t(props.noDataText) } />
)) }
))}

{ slots['prepend-item']?.() }

Expand All @@ -340,11 +340,11 @@ export const VAutocomplete = genericComponent<new <
},
}}
</VListItem>
)) }
))}

{ slots['append-item']?.() }
</VList>
) }
)}
</VMenu>

{ selections.value.map((item, index) => {
Expand Down Expand Up @@ -386,13 +386,13 @@ export const VAutocomplete = genericComponent<new <
{ item.title }
{ props.multiple && (index < selections.value.length - 1) && (
<span class="v-autocomplete__selection-comma">,</span>
) }
)}
</span>
)
)}
</div>
)
}) }
})}
</>
),
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ describe('VAutocomplete', () => {

cy.mount(() => (
<VAutocomplete
items={items}
modelValue={selectedItems}
items={ items }
modelValue={ selectedItems }
chips
closableChips
multiple
Expand All @@ -34,8 +34,8 @@ describe('VAutocomplete', () => {

cy.mount(() => (
<VAutocomplete
v-model={selectedItems.value}
items={items.value}
v-model={ selectedItems.value }
items={ items.value }
chips
multiple
closableChips
Expand Down Expand Up @@ -81,8 +81,8 @@ describe('VAutocomplete', () => {

cy.mount(() => (
<VAutocomplete
v-model={selectedItems.value}
items={items.value}
v-model={ selectedItems.value }
items={ items.value }
returnObject
chips
multiple
Expand All @@ -105,8 +105,8 @@ describe('VAutocomplete', () => {

cy.mount(() => (
<VAutocomplete
items={items}
modelValue={selectedItems}
items={ items }
modelValue={ selectedItems }
readonly
/>
))
Expand All @@ -132,8 +132,8 @@ describe('VAutocomplete', () => {
cy.mount(() => (
<VForm readonly>
<VAutocomplete
items={items}
modelValue={selectedItems}
items={ items }
modelValue={ selectedItems }
readonly
/>
</VForm>
Expand All @@ -160,8 +160,8 @@ describe('VAutocomplete', () => {

cy.mount(() => (
<VAutocomplete
items={items}
modelValue={selectedItems}
items={ items }
modelValue={ selectedItems }
hideSelected
multiple
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const stories = {
'Default badge': <VBadge />,
'Icon badge': <VBadge icon="mdi-vuetify" />,
'Offset badge': gridOn(['offsetX', 'offsetY'], offset, (xy, offset) => (
<VBadge {...{ [xy]: offset }} content={ `${offset}` }>
<VBadge { ...{ [xy]: offset } } content={ `${offset}` }>
<VBtn>
{ xy }
</VBtn>
Expand All @@ -47,11 +47,11 @@ describe('VBadge', () => {
it('supports default color props', () => {
cy.mount(() => (
<>
{defaultColors.map((color, idx) => (
{ defaultColors.map((color, idx) => (
<VBadge color={ color } content={ idx.toString() }>
{ color } badge
</VBadge>
)) }
))}
</>
))
.get('.v-badge')
Expand Down Expand Up @@ -94,11 +94,11 @@ describe('VBadge', () => {
it('supports default text color props', () => {
cy.mount(() => (
<>
{defaultColors.map((color, idx) => (
{ defaultColors.map((color, idx) => (
<VBadge textColor={ color } content={ idx.toString() }>
{ color } text badge
</VBadge>
)) }
))}
</>
))
.get('.v-badge')
Expand Down
6 changes: 3 additions & 3 deletions packages/vuetify/src/components/VBanner/VBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ export const VBanner = genericComponent<VBannerSlots>()({
}
</div>
</VDefaultsProvider>
) }
)}

<div class="v-banner__content">
{ hasText && (
<VBannerText key="text">
{ slots.text ? slots.text() : props.text }
</VBannerText>
) }
)}

{ slots.default?.() }
</div>
Expand All @@ -137,7 +137,7 @@ export const VBanner = genericComponent<VBannerSlots>()({
<VBannerActions>
{ slots.actions() }
</VBannerActions>
) }
)}
</props.tag>
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const VBottomNavigation = genericComponent()({
<div class="v-bottom-navigation__content">
{ slots.default() }
</div>
) }
)}
</props.tag>
)
})
Expand Down
6 changes: 3 additions & 3 deletions packages/vuetify/src/components/VBreadcrumbs/VBreadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const VBreadcrumbs = genericComponent<new <T>() => {
}
</div>
</VDefaultsProvider>
) }
)}

{ props.items.map((item, index, array) => (
<>
Expand All @@ -128,9 +128,9 @@ export const VBreadcrumbs = genericComponent<new <T>() => {
default: slots.divider ? () => slots.divider?.({ item, index }) : undefined,
}}
/>
) }
)}
</>
)) }
))}

{ slots.default?.() }
</props.tag>
Expand Down
Loading

0 comments on commit 97b22d2

Please sign in to comment.