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 3636 },
3737 "peerDependencies" : {
3838 "eslint" : " ^9.0.0" ,
39- "eslint-plugin-format" : " *"
39+ "eslint-plugin-format" : " *" ,
40+ "eslint-plugin-import-x" : " *"
4041 },
4142 "peerDependenciesMeta" : {
4243 "eslint-plugin-format" : {
4344 "optional" : true
45+ },
46+ "eslint-plugin-import-x" : {
47+ "optional" : true
4448 }
4549 },
4650 "dependencies" : {
Original file line number Diff line number Diff line change @@ -3,15 +3,27 @@ import type { Linter } from 'eslint'
33import type { NuxtESLintConfigOptions } from '../types'
44import { resolveOptions } from '../utils'
55
6- export default function imports ( options : NuxtESLintConfigOptions ) : Linter . Config [ ] {
6+ export default async function imports ( options : NuxtESLintConfigOptions ) : Promise < Linter . Config [ ] > {
77 const resolved = resolveOptions ( options )
88
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+
922 return [
1023 {
1124 name : 'nuxt/import/rules' ,
1225 plugins : {
13- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14- import : pluginImportLite as any ,
26+ import : plugin ,
1527 } ,
1628 rules : {
1729 '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 {
5050 */
5151 tooling ?: boolean | ToolingOptions
5252
53+ /**
54+ * Enable the import plugin
55+ *
56+ * @default true
57+ */
58+ import ?: boolean | ImportPluginOptions
59+
5360 /**
5461 * Enable stylistic ESLint rules for formatting and code style check
5562 *
@@ -91,6 +98,18 @@ export interface NuxtESLintFeaturesOptions {
9198 }
9299}
93100
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+
94113export interface NuxtESLintConfigOptions {
95114 features ?: NuxtESLintFeaturesOptions
96115
Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ export function resolveOptions(
8181 tooling : false ,
8282 formatters : false ,
8383 nuxt : { } ,
84+ import : { } ,
8485 ...config . features ,
8586 } ,
8687 dirs,
You can’t perform that action at this time.
0 commit comments