Skip to content

Commit

Permalink
feat: add configuration as an optional argument for formatText
Browse files Browse the repository at this point in the history
  • Loading branch information
sabhas committed Nov 8, 2022
1 parent cee30d0 commit c210699
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/format/formatText.ts
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 1 addition & 1 deletion src/format/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c210699

Please sign in to comment.