@@ -12,8 +12,9 @@ import fg from 'fast-glob'
12
12
import { vueTemplateAddon } from 'unimport/addons'
13
13
import MagicString from 'magic-string'
14
14
import { presets } from '../presets'
15
- import type { ESLintGlobalsPropValue , ESLintrc , ImportExtended , Options } from '../types'
15
+ import type { BiomeLintrc , ESLintGlobalsPropValue , ESLintrc , ImportExtended , Options } from '../types'
16
16
import { generateESLintConfigs } from './eslintrc'
17
+ import { generateBiomeLintConfigs } from './biomelintrc'
17
18
import { resolversAddon } from './resolvers'
18
19
19
20
function resolveGlobsExclude ( root : string , glob : string ) {
@@ -48,6 +49,10 @@ export function createContext(options: Options = {}, root = process.cwd()) {
48
49
eslintrc . filepath = eslintrc . filepath || './.eslintrc-auto-import.json'
49
50
eslintrc . globalsPropValue = eslintrc . globalsPropValue === undefined ? true : eslintrc . globalsPropValue
50
51
52
+ const biomelintrc : BiomeLintrc = options . biomelintrc || { }
53
+ biomelintrc . enabled = biomelintrc . enabled !== undefined
54
+ biomelintrc . filepath = biomelintrc . filepath || './.biomelintrc-auto-import.json'
55
+
51
56
const resolvers = options . resolvers ? [ options . resolvers ] . flat ( 2 ) : [ ]
52
57
53
58
// When "options.injectAtEnd" is undefined or true, it's true.
@@ -177,6 +182,10 @@ ${dts}`.trim()}\n`
177
182
return generateESLintConfigs ( await unimport . getImports ( ) , eslintrc , await parseESLint ( ) )
178
183
}
179
184
185
+ async function generateBiomeLint ( ) {
186
+ return generateBiomeLintConfigs ( await unimport . getImports ( ) )
187
+ }
188
+
180
189
const writeConfigFilesThrottled = throttle ( 500 , writeConfigFiles , { noLeading : false } )
181
190
182
191
async function writeFile ( filePath : string , content = '' ) {
@@ -186,6 +195,8 @@ ${dts}`.trim()}\n`
186
195
187
196
let lastDTS : string | undefined
188
197
let lastESLint : string | undefined
198
+ let lastBiomeLint : string | undefined
199
+
189
200
async function writeConfigFiles ( ) {
190
201
const promises : any [ ] = [ ]
191
202
if ( dts ) {
@@ -215,6 +226,18 @@ ${dts}`.trim()}\n`
215
226
} ) ,
216
227
)
217
228
}
229
+
230
+ if ( biomelintrc . enabled ) {
231
+ promises . push (
232
+ generateBiomeLint ( ) . then ( ( content ) => {
233
+ if ( content !== lastBiomeLint ) {
234
+ lastBiomeLint = content
235
+ return writeFile ( biomelintrc . filepath ! , content )
236
+ }
237
+ } ) ,
238
+ )
239
+ }
240
+
218
241
return Promise . all ( promises )
219
242
}
220
243
0 commit comments