mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
wip
This commit is contained in:
parent
0117a71138
commit
29fd76ff8e
12 changed files with 48 additions and 174 deletions
|
|
@ -26,4 +26,4 @@ export type RuleOnError = import("./markdownlint.mjs").RuleOnError;
|
|||
export type RuleOnErrorFixInfo = import("./markdownlint.mjs").RuleOnErrorFixInfo;
|
||||
export type RuleOnErrorInfo = import("./markdownlint.mjs").RuleOnErrorInfo;
|
||||
export type RuleParams = import("./markdownlint.mjs").RuleParams;
|
||||
export { applyFix, applyFixes, formatLintError, getVersion, parseLintErrorString } from "./markdownlint.mjs";
|
||||
export { applyFix, applyFixes, getVersion } from "./markdownlint.mjs";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// @ts-check
|
||||
|
||||
export { applyFix, applyFixes, formatLintError, getVersion, parseLintErrorString } from "./markdownlint.mjs";
|
||||
export { applyFix, applyFixes, getVersion } from "./markdownlint.mjs";
|
||||
export { resolveModule } from "./resolve-module.cjs";
|
||||
|
||||
/** @typedef {import("./markdownlint.mjs").Configuration} Configuration */
|
||||
|
|
|
|||
|
|
@ -76,21 +76,6 @@ export function applyFix(line: string, fixInfo: FixInfo, lineEnding?: string): s
|
|||
* @returns {string} Fixed content.
|
||||
*/
|
||||
export function applyFixes(input: string, errors: LintError[]): string;
|
||||
/**
|
||||
* TBD
|
||||
*
|
||||
* @param {string} source Source file name or identifier.
|
||||
* @param {LintError} lintError Lint error.
|
||||
* @returns {string} Lint error string.
|
||||
*/
|
||||
export function formatLintError(source: string, lintError: LintError): string;
|
||||
/**
|
||||
* TBD
|
||||
*
|
||||
* @param {string} lintErrorString Lint error string.
|
||||
* @returns {Object|null} Lint error (if valid).
|
||||
*/
|
||||
export function parseLintErrorString(lintErrorString: string): any | null;
|
||||
/**
|
||||
* Gets the (semantic) version of the library.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1304,44 +1304,6 @@ export function applyFixes(input, errors) {
|
|||
return lines.filter((line) => line !== null).join(lineEnding);
|
||||
}
|
||||
|
||||
/**
|
||||
* TBD
|
||||
*
|
||||
* @param {string} source Source file name or identifier.
|
||||
* @param {LintError} lintError Lint error.
|
||||
* @returns {string} Lint error string.
|
||||
*/
|
||||
export function formatLintError(source, lintError) {
|
||||
const { lineNumber, ruleNames, ruleDescription, errorDetail, errorContext, errorRange } = lintError;
|
||||
const ruleName = ruleNames.join("/");
|
||||
const description = ruleDescription +
|
||||
(errorDetail ? ` [${errorDetail}]` : "") +
|
||||
(errorContext ? ` [Context: "${errorContext}"]` : "");
|
||||
const column = (errorRange && errorRange[0]) || 0;
|
||||
const columnText = column ? `:${column}` : "";
|
||||
return `${source}:${lineNumber}${columnText} ${ruleName} ${description}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* TBD
|
||||
*
|
||||
* @param {string} lintErrorString Lint error string.
|
||||
* @returns {Object|null} Lint error (if valid).
|
||||
*/
|
||||
export function parseLintErrorString(lintErrorString) {
|
||||
const matchRe = /^([^:]+):\s*(\d+)(?::(\d+))?:?\s(\S+)\s(.+)$/;
|
||||
const match = matchRe.exec(lintErrorString);
|
||||
return match ?
|
||||
{
|
||||
"source": match[1],
|
||||
"line": match[2],
|
||||
"column": match[3],
|
||||
"rule": match[4],
|
||||
"message": match[5]
|
||||
} :
|
||||
null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the (semantic) version of the library.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue