chore(deps): migrate to eslint 9 (#2443)

This commit is contained in:
Benjamin Canac
2024-10-24 10:30:37 +02:00
committed by GitHub
parent b29fcd2650
commit cae4f0c4a8
177 changed files with 2034 additions and 1289 deletions

View File

@@ -18,10 +18,10 @@
const colorMode = useColorMode()
const isDark = computed({
get () {
get() {
return colorMode.value === 'dark'
},
set () {
set() {
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
}
})

View File

@@ -54,7 +54,6 @@
import { upperFirst, camelCase, kebabCase } from 'scule'
import { useShikiHighlighter } from '~/composables/useShikiHighlighter'
// eslint-disable-next-line vue/no-dupe-keys
const props = defineProps({
slug: {
type: String,
@@ -89,7 +88,7 @@ const props = defineProps({
default: () => []
},
options: {
type: Array as PropType<{ name: string; values: string[]; restriction: 'expected' | 'included' | 'excluded' | 'only' }[]>,
type: Array as PropType<{ name: string, values: string[], restriction: 'expected' | 'included' | 'excluded' | 'only' }[]>,
default: () => []
},
backgroundClass: {
@@ -114,7 +113,6 @@ const props = defineProps({
}
})
// eslint-disable-next-line vue/no-dupe-keys
const baseProps = reactive({ ...props.baseProps })
const componentProps = reactive({ ...props.props })
@@ -158,13 +156,13 @@ const generateOptions = (key: string, schema: { kind: string, schema: [], type:
const schemaOptions = Object.values(schema?.schema || {})
if (key.toLowerCase() === 'size' && schemaOptions?.length > 0) {
const baseSizeOrder = { 'xs': 1, 'sm': 2, 'md': 3, 'lg': 4, 'xl': 5 }
const baseSizeOrder = { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 }
schemaOptions.sort((a: string, b: string) => {
const aBase = a.match(/[a-zA-Z]+/)[0].toLowerCase()
const bBase = b.match(/[a-zA-Z]+/)[0].toLowerCase()
const aBase = a.match(/[a-z]+/i)[0].toLowerCase()
const bBase = b.match(/[a-z]+/i)[0].toLowerCase()
const aNum = parseInt(a.match(/\d+/)?.[0]) || 1
const bNum = parseInt(b.match(/\d+/)?.[0]) || 1
const aNum = Number.parseInt(a.match(/\d+/)?.[0]) || 1
const bNum = Number.parseInt(b.match(/\d+/)?.[0]) || 1
if (aBase === bBase) {
return aBase === 'xs' ? bNum - aNum : aNum - bNum
@@ -214,7 +212,6 @@ const propsToSelect = computed(() => Object.keys(componentProps).map((key) => {
}
}).filter(Boolean))
// eslint-disable-next-line vue/no-dupe-keys
const code = computed(() => {
let code = `\`\`\`html
<template>
@@ -253,7 +250,7 @@ const code = computed(() => {
return code
})
function renderObject (obj: any) {
function renderObject(obj: any) {
if (Array.isArray(obj)) {
return `[${obj.map(renderObject).join(', ')}]`
}
@@ -272,6 +269,7 @@ function renderObject (obj: any) {
const { data: ast } = await useAsyncData(`${name}-ast-${JSON.stringify({ props: componentProps, slots: props.slots, code: props.code })}`, async () => {
let formatted = ''
try {
// @ts-ignore
formatted = await $prettier.format(code.value, {
trailingComma: 'none',
semi: false,

View File

@@ -18,7 +18,6 @@ const props = defineProps({
const route = useRoute()
const highlighter = useShikiHighlighter()
// eslint-disable-next-line vue/no-dupe-keys
const slug = props.slug || route.params.slug[route.params.slug.length - 1]
const camelName = camelCase(slug)
const name = `U${upperFirst(camelName)}`

View File

@@ -36,7 +36,7 @@ defineProps({
}
})
function startsWithCapital (word) {
function startsWithCapital(word) {
if (word.charAt(0).startsWith('"')) {
return false
}

View File

@@ -13,7 +13,7 @@ const links = [{
<UBreadcrumb :links="links" :divider="null" :ui="{ ol: 'gap-x-3' }">
<template #icon="{ link, index, isActive }">
<UAvatar
:alt="(index + 1 ).toString()"
:alt="(index + 1).toString()"
:ui="{
background: isActive ? 'bg-primary-500 dark:bg-primary-400' : undefined,
placeholder: isActive ? 'text-white dark:text-gray-900' : !!link.to ? 'group-hover:text-gray-700 dark:group-hover:text-gray-200' : ''

View File

@@ -18,19 +18,21 @@ const actions = [
]
const groups = computed(() =>
[commandPaletteRef.value?.query ? {
key: 'users',
commands: users
} : {
key: 'recent',
label: 'Recent searches',
commands: users.slice(0, 1)
}, {
[commandPaletteRef.value?.query
? {
key: 'users',
commands: users
}
: {
key: 'recent',
label: 'Recent searches',
commands: users.slice(0, 1)
}, {
key: 'actions',
commands: actions
}].filter(Boolean))
function onSelect (option) {
function onSelect(option) {
if (option.click) {
option.click()
} else if (option.to) {

View File

@@ -71,7 +71,7 @@ const ui = {
:autoselect="false"
command-attribute="title"
:fuse="{
fuseOptions: { keys: ['title', 'category'] },
fuseOptions: { keys: ['title', 'category'] }
}"
placeholder="Search docs"
/>

View File

@@ -7,7 +7,7 @@ const { y: windowY } = useWindowScroll()
const isOpen = ref(false)
const virtualElement = ref({ getBoundingClientRect: () => ({}) })
function onContextMenu () {
function onContextMenu() {
const top = unref(y) - unref(windowY)
const left = unref(x)

View File

@@ -7,7 +7,7 @@ const { y: windowY } = useWindowScroll()
const isOpen = ref(false)
const virtualElement = ref({ getBoundingClientRect: () => ({}) })
function onContextMenu () {
function onContextMenu() {
const top = unref(y) - unref(windowY)
const left = unref(x)

View File

@@ -7,7 +7,7 @@ const { y: windowY } = useWindowScroll()
const isOpen = ref(false)
const virtualElement = ref({ getBoundingClientRect: () => ({}) })
function onContextMenu () {
function onContextMenu() {
const top = unref(y) - unref(windowY)
const left = unref(x)

View File

@@ -7,7 +7,7 @@ const { y: windowY } = useWindowScroll()
const isOpen = ref(false)
const virtualElement = ref({ getBoundingClientRect: () => ({}) })
function onContextMenu () {
function onContextMenu() {
const top = unref(y) - unref(windowY)
const left = unref(x)

View File

@@ -11,11 +11,11 @@ const ranges = [
]
const selected = ref({ start: sub(new Date(), { days: 14 }), end: new Date() })
function isRangeSelected (duration: Duration) {
function isRangeSelected(duration: Duration) {
return isSameDay(selected.value.start, sub(new Date(), duration)) && isSameDay(selected.value.end, new Date())
}
function selectRange (duration: Duration) {
function selectRange(duration: Duration) {
selected.value = { start: sub(new Date(), duration), end: new Date() }
}
</script>

View File

@@ -13,7 +13,7 @@ const validate = (state: any): FormError[] => {
return errors
}
async function onSubmit (event: FormSubmitEvent<any>) {
async function onSubmit(event: FormSubmitEvent<any>) {
// Do something with data
console.log(event.data)
}

View File

@@ -53,7 +53,7 @@ type Schema = z.infer<typeof schema>
const form = ref()
async function onSubmit (event: FormSubmitEvent<Schema>) {
async function onSubmit(event: FormSubmitEvent<Schema>) {
// Do something with event.data
console.log(event.data)
}

View File

@@ -14,7 +14,7 @@ const state = reactive({
password: undefined
})
async function onSubmit (event: FormSubmitEvent<any>) {
async function onSubmit(event: FormSubmitEvent<any>) {
// Do something with event.data
console.log(event.data)
}

View File

@@ -13,12 +13,12 @@ const validate = (state: any): FormError[] => {
return errors
}
async function onSubmit (event: FormSubmitEvent<any>) {
async function onSubmit(event: FormSubmitEvent<any>) {
// Do something with data
console.log(event.data)
}
async function onError (event: FormErrorEvent) {
async function onError(event: FormErrorEvent) {
const element = document.getElementById(event.errors[0].id)
element?.focus()
element?.scrollIntoView({ behavior: 'smooth', block: 'center' })

View File

@@ -14,7 +14,7 @@ const state = reactive({
type Schema = Infer<typeof schema>
async function onSubmit (event: FormSubmitEvent<Schema>) {
async function onSubmit(event: FormSubmitEvent<Schema>) {
console.log(event.data)
}
</script>

View File

@@ -14,7 +14,7 @@ const state = reactive({
password: ''
})
async function onSubmit (event: FormSubmitEvent<Schema>) {
async function onSubmit(event: FormSubmitEvent<Schema>) {
// Do something with event.data
console.log(event.data)
}

View File

@@ -16,7 +16,7 @@ const state = reactive({
password: undefined
})
async function onSubmit (event: FormSubmitEvent<Schema>) {
async function onSubmit(event: FormSubmitEvent<Schema>) {
// Do something with event.data
console.log(event.data)
}

View File

@@ -14,7 +14,7 @@ const state = reactive({
password: undefined
})
async function onSubmit (event: FormSubmitEvent<Schema>) {
async function onSubmit(event: FormSubmitEvent<Schema>) {
// Do something with data
console.log(event.data)
}

View File

@@ -2,7 +2,7 @@
const loading = ref(false)
const selected = ref()
async function search (q: string) {
async function search(q: string) {
loading.value = true
const users: any[] = await $fetch('https://jsonplaceholder.typicode.com/users', { params: { q } })

View File

@@ -8,7 +8,7 @@ defineProps({
const emit = defineEmits(['success'])
function onSuccess () {
function onSuccess() {
emit('success')
}
</script>

View File

@@ -5,11 +5,11 @@ const toast = useToast()
const modal = useModal()
const count = ref(0)
function openModal () {
function openModal() {
count.value += 1
modal.open(ModalExampleComponent, {
count: count.value,
onSuccess () {
onSuccess() {
toast.add({
title: 'Success !',
id: 'modal-success'

View File

@@ -1,7 +1,7 @@
<script setup lang="ts">
const toast = useToast()
function onCallback () {
function onCallback() {
alert('Notification expired!')
}
</script>

View File

@@ -1,7 +1,7 @@
<script setup lang="ts">
const toast = useToast()
function onClick () {
function onClick() {
alert('Clicked!')
}
</script>

View File

@@ -11,7 +11,7 @@ const items = ref(Array(50))
:to="(page: number) => ({
query: { page },
// Hash is specified here to prevent the page from scrolling to the top
hash: '#links',
hash: '#links'
})"
/>
</template>

View File

@@ -3,10 +3,10 @@ const temp = ref(35)
const color = computed(() => {
switch (true) {
case temp.value < 10: return 'blue'
case temp.value < 20: return 'amber'
case temp.value < 30: return 'orange'
default: return 'red'
case temp.value < 10: return 'blue'
case temp.value < 20: return 'amber'
case temp.value < 30: return 'orange'
default: return 'red'
}
})
</script>

View File

@@ -37,7 +37,7 @@ const labels = computed({
}
})
function hashCode (str) {
function hashCode(str) {
let hash = 0
for (let i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash)
@@ -45,7 +45,7 @@ function hashCode (str) {
return hash
}
function intToRGB (i) {
function intToRGB(i) {
const c = (i & 0x00FFFFFF)
.toString(16)
.toUpperCase()
@@ -53,7 +53,7 @@ function intToRGB (i) {
return '00000'.substring(0, 6 - c.length) + c
}
function generateColorFromString (str) {
function generateColorFromString(str) {
return intToRGB(hashCode(str))
}
</script>

View File

@@ -38,7 +38,7 @@ const labels = computed({
const showCreateOption = (query, results) => {
const lowercaseQuery = String.prototype.toLowerCase.apply(query || '')
return lowercaseQuery.length >= 3 && !results.find(option => {
return lowercaseQuery.length >= 3 && !results.find((option) => {
return String.prototype.toLowerCase.apply(option['name'] || '') === lowercaseQuery
})
}

View File

@@ -2,7 +2,7 @@
const loading = ref(false)
const selected = ref([])
async function search (q: string) {
async function search(q: string) {
loading.value = true
const users: any[] = await $fetch('https://jsonplaceholder.typicode.com/users', { params: { q } })

View File

@@ -1,5 +1,4 @@
<script lang="ts" setup>
const props = defineProps({
count: {
type: Number,
@@ -8,7 +7,7 @@ const props = defineProps({
})
const emits = defineEmits<{
close: [];
close: []
}>()
</script>
@@ -27,4 +26,4 @@ const emits = defineEmits<{
<Placeholder class="h-full" />
</UCard>
</USlideover>
</template>
</template>

View File

@@ -3,7 +3,7 @@ import { SlideoverExampleComponent } from '#components'
const slideover = useSlideover()
const count = ref(0)
function openSlideover () {
function openSlideover() {
count.value += 1
slideover.open(SlideoverExampleComponent, {
count: count.value,

View File

@@ -19,13 +19,13 @@ const columns = [{
}]
const selectedColumns = ref(columns)
const columnsTable = computed(() => columns.filter((column) => selectedColumns.value.includes(column)))
const columnsTable = computed(() => columns.filter(column => selectedColumns.value.includes(column)))
// Selected Rows
const selectedRows = ref([])
function select (row) {
const index = selectedRows.value.findIndex((item) => item.id === row.id)
function select(row) {
const index = selectedRows.value.findIndex(item => item.id === row.id)
if (index === -1) {
selectedRows.value.push(row)
} else {
@@ -92,10 +92,10 @@ const { data: todos, status } = await useLazyAsyncData<{
}[]>('todos', () => ($fetch as any)(`https://jsonplaceholder.typicode.com/todos${searchStatus.value}`, {
query: {
q: search.value,
'_page': page.value,
'_limit': pageCount.value,
'_sort': sort.value.column,
'_order': sort.value.direction
_page: page.value,
_limit: pageCount.value,
_sort: sort.value.column,
_order: sort.value.direction
}
}), {
default: () => [],

View File

@@ -31,8 +31,8 @@ const people = [{
role: 'Owner'
}]
function select (row) {
const index = selected.value.findIndex((item) => item.id === row.id)
function select(row) {
const index = selected.value.findIndex(item => item.id === row.id)
if (index === -1) {
selected.value.push(row)
} else {

View File

@@ -34,53 +34,55 @@ const pending = ref(true)
/* https://codepen.io/jenning/pen/YzNmzaV */
.loader {
--color: rgb(var(--color-primary-400));
--size-mid: 6vmin;
--size-dot: 1.5vmin;
--size-bar: 0.4vmin;
--size-square: 3vmin;
--color: rgb(var(--color-primary-400));
--size-mid: 6vmin;
--size-dot: 1.5vmin;
--size-bar: 0.4vmin;
--size-square: 3vmin;
display: block;
position: relative;
width: 50%;
display: grid;
place-items: center;
display: block;
position: relative;
width: 50%;
display: grid;
place-items: center;
}
.loader::before,
.loader::after {
content: '';
box-sizing: border-box;
position: absolute;
content: '';
box-sizing: border-box;
position: absolute;
}
/**
loader --6
loader --6
**/
.loader.--6::before {
width: var(--size-square);
height: var(--size-square);
background-color: var(--color);
top: calc(50% - var(--size-square));
left: calc(50% - var(--size-square));
animation: loader-6 2.4s cubic-bezier(0, 0, 0.24, 1.21) infinite;
width: var(--size-square);
height: var(--size-square);
background-color: var(--color);
top: calc(50% - var(--size-square));
left: calc(50% - var(--size-square));
animation: loader-6 2.4s cubic-bezier(0, 0, 0.24, 1.21) infinite;
}
@keyframes loader-6 {
0%, 100% {
transform: none;
}
25% {
transform: translateX(100%);
}
0%,
100% {
transform: none;
}
50% {
transform: translateX(100%) translateY(100%);
}
25% {
transform: translateX(100%);
}
75% {
transform: translateY(100%);
}
50% {
transform: translateX(100%) translateY(100%);
}
75% {
transform: translateY(100%);
}
}
</style>

View File

@@ -53,7 +53,7 @@ const people = [{
role: 'Member'
}]
const items = (row) => [
const items = row => [
[{
label: 'Edit',
icon: 'i-heroicons-pencil-square-20-solid',

View File

@@ -13,7 +13,7 @@ const items = [{
content: 'Finally, this is the content for Tab3'
}]
function onChange (index) {
function onChange(index) {
const item = items[index]
alert(`${item.label} was clicked!`)

View File

@@ -10,11 +10,11 @@ const items = [{
const accountForm = reactive({ name: 'Benjamin', username: 'benjamincanac' })
const passwordForm = reactive({ currentPassword: '', newPassword: '' })
function onSubmitAccount () {
function onSubmitAccount() {
console.log('Submitted form:', accountForm)
}
function onSubmitPassword () {
function onSubmitPassword() {
console.log('Submitted form:', passwordForm)
}
</script>

View File

@@ -12,7 +12,7 @@ const items = [{
const accountForm = reactive({ name: 'Benjamin', username: 'benjamincanac' })
const passwordForm = reactive({ currentPassword: '', newPassword: '' })
function onSubmit (form) {
function onSubmit(form) {
console.log('Submitted form:', form)
}
</script>

View File

@@ -17,15 +17,15 @@ const route = useRoute()
const router = useRouter()
const selected = computed({
get () {
const index = items.findIndex((item) => item.label === route.query.tab)
get() {
const index = items.findIndex(item => item.label === route.query.tab)
if (index === -1) {
return 0
}
return index
},
set (value) {
set(value) {
// Hash is specified here to prevent the page from scrolling to the top
router.replace({ query: { tab: items[value].label }, hash: '#control-the-selected-index' })
}