Skip to content

Commit

Permalink
chore: move to eslint9 (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux authored Apr 17, 2024
1 parent bccbae2 commit e7be1aa
Show file tree
Hide file tree
Showing 49 changed files with 1,060 additions and 603 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

20 changes: 0 additions & 20 deletions .eslintrc.cjs

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"eslint.experimental.useFlatConfig": true,
}
6 changes: 3 additions & 3 deletions docs/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineAppConfig({
}
},
seo: {
siteName: 'NuxtHub',
siteName: 'NuxtHub'
},
header: {
links: [{
Expand All @@ -34,12 +34,12 @@ export default defineAppConfig({
icon: 'i-heroicons-star',
label: 'Star on GitHub',
to: 'https://github.com/nuxt-hub/core',
target: '_blank',
target: '_blank'
}, {
icon: 'i-simple-icons-nuxtdotjs',
label: 'NuxtHub Admin',
to: 'https://admin.hub.nuxt.com',
target: '_blank',
target: '_blank'
}]
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/components/UInputCopy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
defineProps({
value: {
type: String,
required: true,
required: true
},
size: {
type: String,
Expand Down
5 changes: 2 additions & 3 deletions docs/components/content/Alert.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

<script setup lang="ts">
import type uiColors from '#ui-colors'
const props = defineProps({
title: { type: String, required: true},
title: { type: String, required: true },
icon: { type: String, default: '' },
color: { type: String as PropType<(typeof uiColors)[number]>, required: true },
to: { type: String, default: '' },
to: { type: String, default: '' }
})
const target = computed(() => (props.to?.startsWith('https://') ? '_blank' : ''))
Expand Down
4 changes: 2 additions & 2 deletions docs/error.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { NuxtError } from '#app'
import type { ParsedContent } from '@nuxt/content/dist/runtime/types'
import type { NuxtError } from '#app'
useSeoMeta({
title: 'Page not found',
Expand All @@ -23,7 +23,7 @@ useHead({
const { data: navigation } = await useAsyncData('navigation', () => fetchContentNavigation())
const { data: files } = useLazyFetch<ParsedContent[]>('/api/search.json', {
default: () => [],
server: false,
server: false
})
provide('navigation', navigation.value?.[0]?.children || [])
Expand Down
6 changes: 3 additions & 3 deletions docs/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ export default defineNuxtConfig({
hooks: {
// Define `@nuxt/ui` components as global to use them in `.md` (feel free to add those you need)
'components:extend': (components) => {
const globals = components.filter((c) => ['UButton', 'UIcon'].includes(c.pascalName))
const globals = components.filter(c => ['UButton', 'UIcon'].includes(c.pascalName))

globals.forEach((c) => c.global = true)
globals.forEach(c => c.global = true)
}
},
ui: {
icons: ['heroicons', 'ph', 'simple-icons']
},
routeRules: {
'/api/search.json': { prerender: true },
'/api/search.json': { prerender: true }
},
nitro: {
prerender: {
Expand Down
4 changes: 2 additions & 2 deletions docs/nuxt.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default defineNuxtSchema({
icon: 'i-mdi-web',
default: []
})
},
}
}),
header: group({
title: 'Header',
Expand Down Expand Up @@ -142,7 +142,7 @@ export default defineNuxtSchema({
icon: 'i-mdi-link-variant',
default: []
})
},
}
}),
footer: group({
title: 'Footer',
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const links = computed(() => [toc?.bottom?.edit && {
icon: 'i-heroicons-pencil-square',
label: 'Edit this page',
to: `${toc.bottom.edit}/${page?.value?._file}`,
target: '_blank',
target: '_blank'
}, ...(toc?.bottom?.links || [])].filter(Boolean))
</script>

Expand Down
3 changes: 2 additions & 1 deletion docs/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import mediumZoom from 'medium-zoom'
import { joinURL } from 'ufo'
const { data: page } = await useAsyncData('index', () => queryContent('/').findOne())
const { url } = useSiteConfig()
Expand All @@ -14,7 +15,7 @@ useSeoMeta({
})
onMounted(() => {
mediumZoom('[data-zoom-src]', {
margin: 5,
margin: 5
})
})
</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/server/api/search.json.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { serverQueryContent } from '#content/server'

export default eventHandler(async (event) => {
return serverQueryContent(event).where({ _type: 'markdown', navigation: { $ne: false } }).find()
})
})
24 changes: 24 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// @ts-check
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'

export default createConfigForNuxt({
features: {
tooling: true,
stylistic: {
quoteProps: 'as-needed',
commaDangle: 'never',
braceStyle: '1tbs'
}
},
dirs: {
src: [
'./playground',
'./docs'
]
}
}).overrideRules({
'@typescript-eslint/no-explicit-any': 'off',
'vue/max-attributes-per-line': 'off',
'vue/no-v-html': 'off',
'vue/multi-word-component-names': 'off'
})
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@
},
"devDependencies": {
"@nuxt/devtools": "^1.1.5",
"@nuxt/eslint-config": "^0.2.0",
"@nuxt/eslint-config": "^0.3.7",
"@nuxt/module-builder": "^0.5.5",
"@nuxt/schema": "^3.11.2",
"@nuxt/test-utils": "^3.12.0",
"@nuxt/test-utils": "^3.12.1",
"@types/node": "^20.12.7",
"changelogen": "^0.5.5",
"eslint": "^8.57.0",
"eslint": "^9.0.0",
"nuxt": "^3.11.2",
"typescript": "^5.4.4",
"vitest": "^1.4.0",
"wrangler": "^3.48.0"
"typescript": "^5.4.5",
"vitest": "^1.5.0",
"wrangler": "^3.51.0"
}
}
4 changes: 2 additions & 2 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"dependencies": {
"@iconify-json/simple-icons": "^1.1.99",
"@kgierke/nuxt-basic-auth": "^1.5.0",
"@nuxt/ui": "^2.15.1",
"@nuxt/ui": "^2.15.2",
"@nuxthub/core": "latest",
"drizzle-orm": "^0.30.7",
"drizzle-orm": "^0.30.8",
"nuxt": "^3.11.2"
},
"devDependencies": {
Expand Down
9 changes: 4 additions & 5 deletions playground/pages/blob.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const uploadRef = ref()
const toast = useToast()
const { data: files } = await useFetch('/api/blob')
async function addFile () {
async function addFile() {
if (!newFilesValue.value.length) {
toast.add({ title: 'Missing files.', color: 'red' })
return
Expand All @@ -16,7 +16,7 @@ async function addFile () {
try {
const formData = new FormData()
newFilesValue.value.forEach((file) => formData.append('files', file))
newFilesValue.value.forEach(file => formData.append('files', file))
const uploadedFiles = await $fetch('/api/blob', {
method: 'PUT',
body: formData
Expand All @@ -31,7 +31,7 @@ async function addFile () {
loading.value = false
}
function onFileSelect (e: any) {
function onFileSelect(e: any) {
const target = e.target
// clone FileList so the reference does not clear due to following target clear
Expand All @@ -43,9 +43,8 @@ function onFileSelect (e: any) {
addFile()
}
async function deleteFile (pathname: string) {
async function deleteFile(pathname: string) {
try {
// @ts-ignore
await $fetch(`/api/blob/${pathname}`, { method: 'DELETE' })
files.value = files.value!.filter(t => t.pathname !== pathname)
toast.add({ title: `File "${pathname}" deleted.` })
Expand Down
8 changes: 4 additions & 4 deletions playground/pages/database.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const newTodoInput = ref(null)
const toast = useToast()
const { data: todos } = await useFetch('/api/todos')
async function addTodo () {
if (!newTodo.value.trim()) { return }
async function addTodo() {
if (!newTodo.value.trim()) return
loading.value = true
Expand All @@ -32,7 +32,7 @@ async function addTodo () {
loading.value = false
}
async function toggleTodo (todo) {
async function toggleTodo(todo) {
todo.completed = Number(!todo.completed)
await useFetch(`/api/todos/${todo.id}`, {
method: 'PATCH',
Expand All @@ -42,7 +42,7 @@ async function toggleTodo (todo) {
})
}
async function deleteTodo (todo) {
async function deleteTodo(todo) {
await useFetch(`/api/todos/${todo.id}`, { method: 'DELETE' })
todos.value = todos.value.filter(t => t.id !== todo.id)
toast.add({ title: `Todo "${todo.title}" deleted.` })
Expand Down
11 changes: 5 additions & 6 deletions playground/pages/kv.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const editedEntryValue = ref(null)
const toast = useToast()
const { data: entries } = await useFetch('/api/kv')
async function addEntry () {
async function addEntry() {
const key = newEntryKey.value.trim().replace(/\s/g, '-')
const value = newEntryValue.value.trim()
if (!key || !value) { return }
if (!key || !value) return
loading.value = true
Expand Down Expand Up @@ -43,12 +43,12 @@ async function addEntry () {
loading.value = false
}
function editEntry (entry) {
function editEntry(entry) {
editedEntryValue.value = entry.value
editedEntryKey.value = entry.key
}
async function updateEntry () {
async function updateEntry() {
const entry = await $fetch('/api/kv', {
method: 'PUT',
body: {
Expand All @@ -66,7 +66,7 @@ async function updateEntry () {
editedEntryValue.value = null
}
async function deleteEntry (entry) {
async function deleteEntry(entry) {
await $fetch(`/api/kv/${entry.key}`, { method: 'DELETE' })
entries.value = entries.value.filter(t => t.key !== entry.key)
toast.add({ title: `Entry "${entry.key}" deleted.` })
Expand Down Expand Up @@ -109,7 +109,6 @@ async function deleteEntry (entry) {
>
<span class="flex-1 font-medium">{{ entry.key }}</span>
<div class="flex-1 flex items-center">
<span v-if="editedEntryKey !== entry.key" class="flex-1 font-medium">{{ entry.value }}</span>
<UInput
Expand Down
1 change: 0 additions & 1 deletion playground/server/api/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default eventHandler(async () => {
await kv.set('react:next', { version: 2016 })
await kv.set('react:gatsby', { version: 2015 })


return kv.keys()
// const db = hubDatabase()
// return useProjectKV(projectUrl).getKeys()
Expand Down
3 changes: 2 additions & 1 deletion playground/server/utils/db.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'
import { drizzle } from 'drizzle-orm/d1'

export { sql } from 'drizzle-orm'

const todos = sqliteTable('todos', {
id: integer('id').primaryKey(),
title: text('title').notNull(),
completed: integer('completed').notNull().default(0),
createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
createdAt: integer('created_at', { mode: 'timestamp' }).notNull()
})

export const tables = {
Expand Down
Loading

0 comments on commit e7be1aa

Please sign in to comment.