File tree Expand file tree Collapse file tree 5 files changed +284
-7
lines changed Expand file tree Collapse file tree 5 files changed +284
-7
lines changed Original file line number Diff line number Diff line change 36
36
},
37
37
"peerDependencies" : {
38
38
"eslint" : " ^9.0.0" ,
39
- "eslint-plugin-format" : " *"
39
+ "eslint-plugin-format" : " *" ,
40
+ "eslint-plugin-import-x" : " *"
40
41
},
41
42
"peerDependenciesMeta" : {
42
43
"eslint-plugin-format" : {
43
44
"optional" : true
45
+ },
46
+ "eslint-plugin-import-x" : {
47
+ "optional" : true
44
48
}
45
49
},
46
50
"dependencies" : {
Original file line number Diff line number Diff line change @@ -3,15 +3,27 @@ import type { Linter } from 'eslint'
3
3
import type { NuxtESLintConfigOptions } from '../types'
4
4
import { resolveOptions } from '../utils'
5
5
6
- export default function imports ( options : NuxtESLintConfigOptions ) : Linter . Config [ ] {
6
+ export default async function imports ( options : NuxtESLintConfigOptions ) : Promise < Linter . Config [ ] > {
7
7
const resolved = resolveOptions ( options )
8
8
9
+ if ( resolved . features . import === false ) {
10
+ return [ ]
11
+ }
12
+
13
+ const importOptions = resolved . features . import === true
14
+ ? { }
15
+ : resolved . features . import || { }
16
+
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ const plugin : any = importOptions . package === 'eslint-plugin-import-x'
19
+ ? ( await import ( 'eslint-plugin-import-x' ) ) . default
20
+ : pluginImportLite
21
+
9
22
return [
10
23
{
11
24
name : 'nuxt/import/rules' ,
12
25
plugins : {
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- import : pluginImportLite as any ,
26
+ import : plugin ,
15
27
} ,
16
28
rules : {
17
29
'import/consistent-type-specifier-style' : [ 'error' , 'top-level' ] ,
Original file line number Diff line number Diff line change @@ -50,6 +50,13 @@ export interface NuxtESLintFeaturesOptions {
50
50
*/
51
51
tooling ?: boolean | ToolingOptions
52
52
53
+ /**
54
+ * Enable the import plugin
55
+ *
56
+ * @default true
57
+ */
58
+ import ?: boolean | ImportPluginOptions
59
+
53
60
/**
54
61
* Enable stylistic ESLint rules for formatting and code style check
55
62
*
@@ -91,6 +98,18 @@ export interface NuxtESLintFeaturesOptions {
91
98
}
92
99
}
93
100
101
+ export interface ImportPluginOptions {
102
+ /**
103
+ * The import plugin to use
104
+ *
105
+ * We did not ship `eslint-plugin-import-x` as dependency,
106
+ * if you want to use it, you need to install it manually.
107
+ *
108
+ * @default 'eslint-plugin-import-lite'
109
+ */
110
+ package ?: 'eslint-plugin-import-lite' | 'eslint-plugin-import-x'
111
+ }
112
+
94
113
export interface NuxtESLintConfigOptions {
95
114
features ?: NuxtESLintFeaturesOptions
96
115
Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ export function resolveOptions(
81
81
tooling : false ,
82
82
formatters : false ,
83
83
nuxt : { } ,
84
+ import : { } ,
84
85
...config . features ,
85
86
} ,
86
87
dirs,
You can’t perform that action at this time.
0 commit comments