@@ -12,8 +12,9 @@ import fg from 'fast-glob'
1212import { vueTemplateAddon } from 'unimport/addons'
1313import MagicString from 'magic-string'
1414import { presets } from '../presets'
15- import type { ESLintGlobalsPropValue , ESLintrc , ImportExtended , Options } from '../types'
15+ import type { BiomeLintrc , ESLintGlobalsPropValue , ESLintrc , ImportExtended , Options } from '../types'
1616import { generateESLintConfigs } from './eslintrc'
17+ import { generateBiomeLintConfigs } from './biomelintrc'
1718import { resolversAddon } from './resolvers'
1819
1920function resolveGlobsExclude ( root : string , glob : string ) {
@@ -48,6 +49,10 @@ export function createContext(options: Options = {}, root = process.cwd()) {
4849 eslintrc . filepath = eslintrc . filepath || './.eslintrc-auto-import.json'
4950 eslintrc . globalsPropValue = eslintrc . globalsPropValue === undefined ? true : eslintrc . globalsPropValue
5051
52+ const biomelintrc : BiomeLintrc = options . biomelintrc || { }
53+ biomelintrc . enabled = biomelintrc . enabled !== undefined
54+ biomelintrc . filepath = biomelintrc . filepath || './.biomelintrc-auto-import.json'
55+
5156 const resolvers = options . resolvers ? [ options . resolvers ] . flat ( 2 ) : [ ]
5257
5358 // When "options.injectAtEnd" is undefined or true, it's true.
@@ -177,6 +182,10 @@ ${dts}`.trim()}\n`
177182 return generateESLintConfigs ( await unimport . getImports ( ) , eslintrc , await parseESLint ( ) )
178183 }
179184
185+ async function generateBiomeLint ( ) {
186+ return generateBiomeLintConfigs ( await unimport . getImports ( ) )
187+ }
188+
180189 const writeConfigFilesThrottled = throttle ( 500 , writeConfigFiles , { noLeading : false } )
181190
182191 async function writeFile ( filePath : string , content = '' ) {
@@ -186,6 +195,8 @@ ${dts}`.trim()}\n`
186195
187196 let lastDTS : string | undefined
188197 let lastESLint : string | undefined
198+ let lastBiomeLint : string | undefined
199+
189200 async function writeConfigFiles ( ) {
190201 const promises : any [ ] = [ ]
191202 if ( dts ) {
@@ -215,6 +226,18 @@ ${dts}`.trim()}\n`
215226 } ) ,
216227 )
217228 }
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+
218241 return Promise . all ( promises )
219242 }
220243
0 commit comments