eslint-rule-benchmark
Version:
Benchmark ESLint rules with detailed performance metrics for CI and plugin development
39 lines (38 loc) • 957 B
JavaScript
import { lilconfig } from 'lilconfig'
import { jitiLoader } from './jiti-loader.js'
import { jsonLoader } from './json-loader.js'
let explorer = lilconfig('eslint-rule-benchmark', {
searchPlaces: [
'benchmark/config.js',
'benchmark/config.cjs',
'benchmark/config.mjs',
'benchmark/config.ts',
'benchmark/config.cts',
'benchmark/config.mts',
'benchmark/config.json',
],
loaders: {
'.json': jsonLoader,
'.cjs': jitiLoader,
'.mjs': jitiLoader,
'.cts': jitiLoader,
'.mts': jitiLoader,
'.js': jitiLoader,
'.ts': jitiLoader,
},
})
async function loadConfig(configPath) {
let searchDirectory = process.cwd()
if (configPath) {
searchDirectory = configPath
}
let result = await explorer.search(searchDirectory)
if (!result) {
throw new Error(`No config found in: ${searchDirectory}`)
}
return {
config: result.config,
filepath: result.filepath,
}
}
export { loadConfig }