import { dirname , join , resolve } from 'path' ; import { list } from './utils/fs' ; import { title } from './plugins/title' ; import { canonical } from './plugins/canonical' ; import { description } from './plugins/description' ; import { viewport } from './plugins/viewport' ; import { image } from './plugins/image' ; import { link } from './plugins/link' ; import type { Config , Plugin } from 'seolint' ; const priority = [ 'seolint.config.mjs' , 'seolint.config.cjs' , 'seolint.config.js' , ] ; NOTE see export async function find ( root , start ) { let i = 0 , dir = resolve ( root , start ) ; let files = new Set ( await list ( dir ) ) ; for ( ; i < priority . length ; i ++ ) { if ( files . has ( priority [ i ] ) ) { return join ( dir , priority [ i ] ) ; } } dir = dirname ( dir ) ; if ( dir . startsWith ( root ) ) { return find ( root , dir ) ; } } NOTE export function merge ( base , custom ) { ( custom . presets || [ ] ) . forEach ( x => merge ( base , x ) ) ; if ( custom . plugins ) base . plugins ! . push ( ... custom . plugins ) ; if ( custom . rules ) Object . assign ( base . rules ! , custom . rules ) ; base . inputs = custom . inputs || base . inputs ; base . host = custom . host || base . host ; } export async function load ( root ) { let output = { host : '' , inputs : [ ] , plugins : [ ] , rules : { } , } ; let file = await find ( root , '.' ) ; if ( file ) { let config = await Function ( 'x' , 'return import("file:///"+x)' ) ( file ) ; merge ( output , config . default || config ) ; } ( output . plugins as Plugin < any > [ ] ) . unshift ( title , canonical , description , viewport , image , link ) ; return output ; }