Skip to content

Commit 4b5d65c

Browse files
committedAug 22, 2024··
fix(eslint-config): do not eagerly import ts-eslint parser, close #485
1 parent bbd812e commit 4b5d65c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
 

‎packages/eslint-config/src/flat/configs/typescript.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import type { Linter } from 'eslint'
44
import type { NuxtESLintConfigOptions } from '@nuxt/eslint-config/flat'
55
import { resolveOptions } from '../utils'
66

7+
export { parserTs, pluginTs }
8+
79
export default function typescript(options: NuxtESLintConfigOptions): Linter.Config[] {
810
const resolved = resolveOptions(options)
911

‎packages/eslint-config/src/flat/configs/vue.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import * as parserVue from 'vue-eslint-parser'
2-
import parserTs from '@typescript-eslint/parser'
3-
42
// @ts-expect-error missing types
53
import pluginVue from 'eslint-plugin-vue'
64
import type { Linter } from 'eslint'
@@ -10,10 +8,14 @@ import { removeUndefined, resolveOptions } from '../utils'
108
// imported from 'eslint-plugin-vue/lib/utils/inline-non-void-elements.json'
119
const INLINE_ELEMENTS = ['a', 'abbr', 'audio', 'b', 'bdi', 'bdo', 'canvas', 'cite', 'code', 'data', 'del', 'dfn', 'em', 'i', 'iframe', 'ins', 'kbd', 'label', 'map', 'mark', 'noscript', 'object', 'output', 'picture', 'q', 'ruby', 's', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'svg', 'time', 'u', 'var', 'video']
1210

13-
export default function vue(options: NuxtESLintConfigOptions): Linter.Config[] {
11+
export default async function vue(options: NuxtESLintConfigOptions): Promise<Linter.Config[]> {
1412
const resolved = resolveOptions(options)
1513
const hasTs = resolved.features.typescript !== false
1614

15+
const parser = hasTs
16+
? await import('./typescript').then(mod => mod.parserTs)
17+
: undefined
18+
1719
const {
1820
indent = 2,
1921
commaDangle = 'always-multiline',
@@ -30,7 +32,7 @@ export default function vue(options: NuxtESLintConfigOptions): Linter.Config[] {
3032
parserOptions: {
3133
ecmaVersion: 'latest',
3234
extraFileExtensions: ['.vue'],
33-
parser: hasTs ? parserTs : undefined,
35+
parser,
3436
sourceType: 'module',
3537
ecmaFeatures: {
3638
jsx: true,

1 commit comments

Comments
 (1)

Revadike commented on Aug 22, 2024

@Revadike

Thanks!

Please sign in to comment.