-
Notifications
You must be signed in to change notification settings - Fork 64
/
disables.ts
42 lines (35 loc) · 1.51 KB
/
disables.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
import { join } from 'pathe'
import type { Linter } from 'eslint'
import { GLOB_EXTS } from '../constants'
import type { NuxtESLintConfigOptions } from '../types'
import { resolveOptions } from '../utils'
export default function disables(options: NuxtESLintConfigOptions): Linter.FlatConfig[] {
const resolved = resolveOptions(options)
const dirs = resolved.dirs
const nestedGlobPattern = `**/*.${GLOB_EXTS}`
const fileRoutes = [...new Set([
// These files must have one-word names as they have a special meaning in Nuxt.
...dirs.src.flatMap(layersDir => [
join(layersDir, `app.${GLOB_EXTS}`),
join(layersDir, `error.${GLOB_EXTS}`),
]) || [],
// Layouts and pages are not used directly by users so they can have one-word names.
...(dirs.layouts.map(layoutsDir => join(layoutsDir, nestedGlobPattern)) || []),
...(dirs.pages.map(pagesDir => join(pagesDir, nestedGlobPattern)) || []),
// These files should have multiple words in their names as they are within subdirectories.
...(dirs.components.map(componentsDir => join(componentsDir, '*', nestedGlobPattern)) || []),
// Prefixed components can have one-word names in file
...(dirs.componentsPrefixed.map(componentsDir => join(componentsDir, nestedGlobPattern)) || []),
])]
const configs: Linter.FlatConfig[] = []
if (fileRoutes.length) {
configs.push({
name: 'nuxt/disables/routes',
files: fileRoutes,
rules: {
'vue/multi-word-component-names': 'off',
},
})
}
return configs
}