import type {Preset} from '.' import * as path from 'path' import {definePreset} from './util/standard-schema-preset' const tsxAvailable = () => { try { require.resolve('tsx/cjs') return true } catch { return false } } const tsNodeAvailable = () => { try { require.resolve('ts-node/register/transpile-only') return true } catch { return false } } interface CustomPresetOptions { source?: string export?: string require?: string dev?: boolean } /** * Define your own codegen function, which will receive all options specified. * * Import the `Preset` type from this library to define a strongly-typed preset function: * * @example * export const jsonPrinter: import('eslint-plugin-codegen').Preset<{myCustomProp: string}> = ({meta, options}) => { * const components = meta.glob('**\/*.tsx') // uses 'globSync' from glob package * const json = JSON.stringify({filename: meta.filename, customProp: options.myCustomProp, components}, null, 2) * return `export default ${json}` * } * * // codegen:start {export: jsonPrinter} * * @description * This can be used in other files by specifying the `source` option like: * * * `