@textlint/kernel
Version:
textlint kernel is core logic by pure JavaScript.
55 lines • 1.75 kB
TypeScript
import type { TextlintRuleContextReportFunctionArgs, TextlintRuleError, TextlintRuleErrorPaddingLocation, TextlintSourceCode } from "@textlint/types";
import { TxtNode } from "@textlint/ast-node-types";
export interface ReportMessage {
ruleId: string;
node: any;
severity: number;
ruleError: TextlintRuleError;
}
export type SourceLocationPaddingIR = TextlintRuleErrorPaddingLocation | {
line: number;
column: number;
};
/**
* Adjust `fix` command range
* if `fix.isAbsolute` is not absolute position, adjust the position from the `node`.
*/
export declare const resolveFixCommandLocation: ({ node, ruleError }: {
node: TxtNode;
ruleError: TextlintRuleError;
}) => {
fix?: undefined;
} | {
fix: {
range: readonly [startIndex: number, endIndex: number];
text: string;
};
};
/**
* Resolved Location's loc is 1-based line and column
* It aims to compat to output of textlint.
* Internally, textlint use 0-based column value, but output is 1-based column.
*/
export type PublicOutputLocationResult = {
range: readonly [startIndex: number, endIndex: number];
loc: {
start: {
line: number;
column: number;
};
end: {
line: number;
column: number;
};
};
};
/**
* resolve `padding`(includes deprecated `index`, `column`, `line`) to absolute location
* padding + node's start position
* also, line and column in loc will be 1-based index values
* @param args
*/
export declare const resolveLocation: (args: {
source: TextlintSourceCode;
} & Pick<TextlintRuleContextReportFunctionArgs, "node" | "ruleError" | "ruleId">) => PublicOutputLocationResult;
//# sourceMappingURL=source-location.d.ts.map