/**
 * based on @link https://github.com/sveltejs/eslint-plugin-svelte3/blob/master/src/processor_options.js
 */ import type { Linter , SourceCode } from 'eslint' ; import type { ESLintMdxSettings , ProcessorOptions } from './types' ; export const processorOptions = { } as ProcessorOptions ; const linterPath = Object . keys ( require . cache ) . find ( path => /([/\\])eslint\1lib(?:\1linter){2}\.js$/ . test ( path ) ) ; if ( ! linterPath ) { throw new Error ( 'Could not find ESLint Linter in require cache' ) ; } export interface LinterConfig extends Linter . Config { extractConfig ? ( filename ? ) : Linter . Config ; } const ESLinter = ( require ( linterPath ) as typeof import ( 'eslint' ) ) . Linter ; const { verify } = ESLinter . prototype ; ESLinter . prototype . verify = function ( code , config , options ? ) { const settings = ( ( config && ( typeof config . extractConfig === 'function' ? config . extractConfig ( typeof options === 'undefined' || typeof options === 'string' ? options : options . filename ) : config ) . settings ) || { } ) as ESLintMdxSettings ; processorOptions . lintCodeBlocks = settings [ 'mdx/code-blocks' ] === true ; processorOptions . languageMapper = settings [ 'mdx/language-mapper' ] ; return verify . call ( this , code , config , options as Linter . LintOptions ) ; } ;