-
Notifications
You must be signed in to change notification settings - Fork 66
/
nuxt.ts
49 lines (42 loc) · 1.16 KB
/
nuxt.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { join } from 'pathe'
import nuxtPlugin from '@nuxt/eslint-plugin'
import type { Linter } from 'eslint'
import type { NuxtESLintConfigOptions } from '../types'
import { GLOB_EXTS } from '../constants'
import { resolveOptions } from '../utils'
export default function nuxt(options: NuxtESLintConfigOptions): Linter.FlatConfig[] {
const resolved = resolveOptions(options)
const dirs = resolved.dirs
const fileSingleRoot = [
...(dirs.layouts?.map(layoutsDir => join(layoutsDir, `**/*.${GLOB_EXTS}`)) || []),
...(dirs.pages?.map(pagesDir => join(pagesDir, `**/*.${GLOB_EXTS}`)) || []),
]
const configs: Linter.FlatConfig[] = []
configs.push({
name: 'nuxt/configs',
languageOptions: {
globals: {
// Nuxt's runtime globals
$fetch: 'readonly',
},
},
})
if (fileSingleRoot.length)
configs.push({
name: 'nuxt/vue/single-root',
files: fileSingleRoot,
rules: {
'vue/no-multiple-template-root': 'error',
},
})
configs.push({
name: 'nuxt/rules',
plugins: {
nuxt: nuxtPlugin,
},
rules: {
'nuxt/prefer-import-meta': 'error',
},
})
return configs
}