1
1
import process from 'node:process'
2
- import type { ConfigItem , OptionsComponentExts , OptionsOverrides , OptionsTypeScriptParserOptions , OptionsTypeScriptWithTypes } from '../types'
2
+ import type { FlatConfigItem , OptionsComponentExts , OptionsOverrides , OptionsTypeScriptParserOptions , OptionsTypeScriptWithTypes } from '../types'
3
3
import { GLOB_SRC } from '../globs'
4
- import { parserTs , pluginAntfu , pluginImport , pluginTs } from '../plugins'
5
- import { renameRules , toArray } from '../utils'
4
+ import { pluginAntfu } from '../plugins'
5
+ import { interopDefault , renameRules , toArray } from '../utils'
6
6
7
- export function typescript (
7
+ export async function typescript (
8
8
options ?: OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions ,
9
- ) : ConfigItem [ ] {
9
+ ) : Promise < FlatConfigItem [ ] > {
10
10
const {
11
11
componentExts = [ ] ,
12
12
overrides = { } ,
13
13
parserOptions = { } ,
14
14
} = options ?? { }
15
15
16
- const typeAwareRules : ConfigItem [ 'rules' ] = {
16
+ const typeAwareRules : FlatConfigItem [ 'rules' ] = {
17
17
'dot-notation' : 'off' ,
18
18
'no-implied-eval' : 'off' ,
19
19
'no-throw-literal' : 'off' ,
@@ -39,13 +39,20 @@ export function typescript(
39
39
? toArray ( options . tsconfigPath )
40
40
: undefined
41
41
42
+ const [
43
+ pluginTs ,
44
+ parserTs ,
45
+ ] = await Promise . all ( [
46
+ interopDefault ( import ( '@typescript-eslint/eslint-plugin' ) ) ,
47
+ interopDefault ( import ( '@typescript-eslint/parser' ) ) ,
48
+ ] as const )
49
+
42
50
return [
43
51
{
44
52
// Install the plugins without globs, so they can be configured separately.
45
53
name : 'antfu:typescript:setup' ,
46
54
plugins : {
47
55
antfu : pluginAntfu ,
48
- import : pluginImport ,
49
56
ts : pluginTs as any ,
50
57
} ,
51
58
} ,
0 commit comments