diff --git a/src/format/formatText.ts b/src/format/formatText.ts index b33807e..2b666cf 100644 --- a/src/format/formatText.ts +++ b/src/format/formatText.ts @@ -1,7 +1,8 @@ +import { LintConfig } from '../types' import { getLintConfig } from '../utils' import { processText } from './shared' -export const formatText = async (text: string) => { - const config = await getLintConfig() +export const formatText = async (text: string, configuration?: LintConfig) => { + const config = configuration || (await getLintConfig()) return processText(text, config) } diff --git a/src/format/shared.ts b/src/format/shared.ts index 3918987..76702f1 100644 --- a/src/format/shared.ts +++ b/src/format/shared.ts @@ -30,7 +30,7 @@ export const processLine = (config: LintConfig, line: string): string => { config.lineLintRules .filter((r) => !!r.fix) .forEach((rule) => { - processedLine = rule.fix!(line) + processedLine = rule.fix!(line, config) }) return processedLine