Skip to content

Commit 14e4427

Browse files
authored
chore: migrate to eslint (#111)
* chore: migrate to eslint * chore: ignore `vue/one-component-per-file` * chore: fix ts error
1 parent 5fafe8c commit 14e4427

38 files changed

+2246
-744
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist
2+
node_modules
3+
examples/vite-ssr
4+
tests/e2e/vite-ssr

.eslintrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
node: true,
6+
},
7+
extends: '@antfu/eslint-config',
8+
rules: {
9+
'vue/one-component-per-file': 'off'
10+
},
11+
}

.github/workflows/export-sizes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
node-version: ${{ matrix.node-version }}
2020
registry-url: https://registry.npmjs.org/
21-
cache: "pnpm"
21+
cache: pnpm
2222
- uses: antfu/export-size-action@v1
2323
with:
2424
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release
33
on:
44
push:
55
tags:
6-
- "v*"
6+
- 'v*'
77

88
jobs:
99
release:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
test:
11-
if: "!contains(github.event.head_commit.message, 'ci skip')"
11+
if: '!contains(github.event.head_commit.message, ''ci skip'')'
1212

1313
strategy:
1414
matrix:

.prettierrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/nuxt3/app.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<script setup lang="ts">
2-
import { useHead } from "#head"
2+
import { useHead } from '#head'
33
44
useHead({
5-
title: "Title",
6-
titleTemplate: (title) => `${title} | Title Site`,
5+
title: 'Title',
6+
titleTemplate: title => `${title} | Title Site`,
77
})
88
</script>
9+
910
<template>
1011
<div>
1112
<NuxtPage />

examples/nuxt3/components/ModifyTitle.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
const props = defineProps<{
33
title: string
44
}>()
5-
await new Promise((resolve) => setTimeout(resolve, 1000))
5+
await new Promise(resolve => setTimeout(resolve, 1000))
66
77
useHead({
88
title: computed(() => props.title),
99
})
1010
</script>
11+
1112
<template>
1213
<div>final title test</div>
1314
</template>

examples/nuxt3/nuxt.config.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
import { defineNuxtConfig } from "nuxt/config"
2-
import { fileURLToPath } from "url"
3-
import { addPlugin } from "@nuxt/kit"
4-
import { resolve } from "pathe"
1+
import { fileURLToPath } from 'url'
2+
import { defineNuxtConfig } from 'nuxt/config'
3+
import { addPlugin } from '@nuxt/kit'
4+
import { resolve } from 'pathe'
55

6-
const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url))
7-
const rootDir = fileURLToPath(new URL("../../", import.meta.url))
6+
const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
7+
const rootDir = fileURLToPath(new URL('../../', import.meta.url))
88

99
// https://v3.nuxtjs.org/api/configuration/nuxt.config
1010
export default defineNuxtConfig({
1111
alias: {
12-
"@vueuse/head": `${rootDir}/src`,
12+
'@vueuse/head': `${rootDir}/src`,
1313
},
1414
app: {
1515
head: {
16-
title: "default title",
16+
title: 'default title',
1717
},
1818
},
1919
workspaceDir: rootDir,
2020
hooks: {
21-
"modules:before": async ({ nuxt }) => {
21+
'modules:before': async ({ nuxt }) => {
2222
const newModules = nuxt.options._modules
2323
// remove the nuxt meta (head) module
2424
for (const k in newModules) {
25-
if (typeof newModules[k] === "function") {
26-
if ((await newModules[k].getMeta()).name === "meta") {
25+
if (typeof newModules[k] === 'function') {
26+
if ((await newModules[k].getMeta()).name === 'meta') {
2727
// we can't use an undefined key so use a duplicate
28-
newModules[k] = "@nuxt/telemetry"
28+
newModules[k] = '@nuxt/telemetry'
2929
}
3030
}
3131
}
3232
nuxt.options._modules = newModules
3333
},
34-
"modules:done"({ nuxt }) {
34+
'modules:done': function ({ nuxt }) {
3535
// Replace #head alias
36-
nuxt.options.alias["#head"] = runtimeDir
36+
nuxt.options.alias['#head'] = runtimeDir
3737

38-
addPlugin({ src: resolve(runtimeDir, "plugin") }, { append: true })
38+
addPlugin({ src: resolve(runtimeDir, 'plugin') }, { append: true })
3939

4040
nuxt.options.build.transpile.push(runtimeDir)
4141
},

examples/nuxt3/pages/index.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
<script lang="ts" setup>
2-
import { useHead } from "#head"
2+
import { useHead } from '#head'
33
44
const page = ref({
5-
title: "Home",
6-
description: "Home page description",
7-
image: "https://nuxtjs.org/meta_400.png",
5+
title: 'Home',
6+
description: 'Home page description',
7+
image: 'https://nuxtjs.org/meta_400.png',
88
})
99
1010
useHead({
1111
title: computed(() => `${page.value.title} | Nuxt`),
1212
meta: [
1313
{
14-
name: "description",
14+
name: 'description',
1515
content: computed(() => page.value.description),
1616
},
1717
{
18-
property: "og:image",
18+
property: 'og:image',
1919
content: computed(() => page.value.image),
2020
},
2121
],
2222
})
2323
</script>
24+
2425
<template>
2526
<div>
2627
<h1>Index</h1>
27-
<nuxt-link to="/second">second page</nuxt-link>
28+
<nuxt-link to="/second">
29+
second page
30+
</nuxt-link>
2831
</div>
2932
</template>

0 commit comments

Comments
 (0)