Skip to content

Functions

runFormat(globs: string[], options: FormatOptions): Promise<number>

  • Expands provided globs (directories auto-expand to **/*).
  • Filters files by options.ext or format.extensions defaults.
  • Normalizes whitespace:
    • trims trailing spaces
    • collapses multiple blank lines to a configured max
    • enforces final newline policy
  • Code style for TS/JS:
    • consistent indentation (format.indent)
    • quote style (format.quotes)
    • optional semicolon normalization (format.semi)
  • Modes:
    • check: prints files needing format, returns 1 if any
    • write: writes changes, returns 0
    • default (neither): behaves like check

FormatOptions

ts
export interface FormatOptions {
  write?: boolean
  check?: boolean
  config?: string
  ignorePath?: string
  ext?: string
  verbose?: boolean
}

Return value: Promise<number> — process-like exit code.


runLint(globs: string[], options: LintOptions): Promise<number>

LintOptions

ts
export interface LintOptions {
  fix?: boolean
  dryRun?: boolean
  maxWarnings?: number
  reporter?: 'stylish' | 'json' | 'compact'
  config?: string
  ignorePath?: string
  ext?: string
  cache?: boolean
  verbose?: boolean
}

Return value: Promise<number> — process-like exit code.

Released under the MIT License.