diff --git a/src/@lint-md/cli.d.ts b/src/@lint-md/cli.d.ts index 473bcac..a19aa99 100644 --- a/src/@lint-md/cli.d.ts +++ b/src/@lint-md/cli.d.ts @@ -1,15 +1,35 @@ declare module '@lint-md/cli' { + export type RuleLevel = 0 | 1 | 2 | 'off' | 'warn' | 'error' + + export interface CliConfig { + excludeFiles?: string[] + rules?: Record + } + + export interface CliLintResult { + path: string + file: string + errors: LintMdError[] + } + + export interface LintMdError { + level: string + type: string + text: string + start: { line: number; column: number } + end: { line: number; column: number } + } + export class Lint { - constructor(files: string[], config: any) + constructor(files: string[], config: CliConfig) start(): Promise showResult(): void printOverview(): void countError(): { error: number; warning: number } - errorFiles: any[] + errorFiles: CliLintResult[] } - export type CliConfig = any } declare module '@lint-md/cli/lib/index' { - export { Lint, CliConfig } from '@lint-md/cli' + export { Lint, CliConfig, CliLintResult, LintMdError, RuleLevel } from '@lint-md/cli' } diff --git a/src/lint-md-action.ts b/src/lint-md-action.ts index c1c1d69..ee5e0d2 100644 --- a/src/lint-md-action.ts +++ b/src/lint-md-action.ts @@ -9,7 +9,7 @@ import * as fs from 'fs' import * as path from 'path' import * as core from '@actions/core' -import { Lint, CliConfig } from '@lint-md/cli/lib/index' +import { Lint, CliConfig, CliLintResult } from '@lint-md/cli/lib/index' export class LintMdAction { private readonly basePath!: string @@ -31,7 +31,7 @@ export class LintMdAction { .map(res => path.resolve(this.basePath, res)) } - getConfig() { + getConfig(): CliConfig { const configPath = path.resolve(this.basePath, core.getInput('configFile')) if (!fs.existsSync(configPath)) { core.warning('The user does not have a configuration file to pass in, we will use the default configuration instead...') @@ -94,7 +94,7 @@ export class LintMdAction { } } - getErrors() { + getErrors(): CliLintResult[] { return this.linter.errorFiles } }