@textlint/source-code-fixer
Version:
Apply @textlint/kernel lint result to text.
36 lines • 1.53 kB
TypeScript
import type { TextlintMessage } from "@textlint/types";
/**
* It is limited version of TextlintSourceCode
*/
export type SimpleTextSourceCode = {
text: string;
hasBOM: boolean;
};
export type SourceCodeFixerResult = {
fixed: boolean;
messages: TextlintMessage[];
applyingMessages: TextlintMessage[];
remainingMessages: TextlintMessage[];
output: string;
};
/**
* Applies the fixes to text and return string
* use applyFixes If you want to use primitive function,
*/
export declare function applyFixesToText(text: string, messages: TextlintMessage[]): string;
/**
* Applies the fixes specified by the messages to the given text. Tries to be
* smart about the fixes and won't apply fixes over the same area in the text.
* @param sourceCode The source code to apply the changes to.
* @param messages The array of messages reported by textlint.
* @returns An object containing the fixed text and any unfixed messages.
*/
export declare function applyFixesToSourceCode(sourceCode: SimpleTextSourceCode, messages: TextlintMessage[]): SourceCodeFixerResult;
/**
* revert text using applyingMessages
* @param sourceCode The source code to apply the changes to.
* @param applyingMessages The array of TextLintMessage reported by SourceCodeFixer#applyFixes
* @returns An object containing the fixed text and any unfixed messages.
*/
export declare function revertSourceCode(sourceCode: SimpleTextSourceCode, applyingMessages: TextlintMessage[]): string;
//# sourceMappingURL=source-code-fixer.d.ts.map