Deprecate LintResults.toString() (at edit time; continue to support at run time), provide helper function formatLintResults, remove outdated grunt/gulp samples, improve typing.
Some checks failed
Checkers / linkcheck (push) Has been cancelled
Checkers / spellcheck (push) Has been cancelled
CI / build (20, macos-latest) (push) Has been cancelled
CI / build (20, ubuntu-latest) (push) Has been cancelled
CI / build (20, windows-latest) (push) Has been cancelled
CI / build (22, macos-latest) (push) Has been cancelled
CI / build (22, ubuntu-latest) (push) Has been cancelled
CI / build (22, windows-latest) (push) Has been cancelled
CI / build (24, macos-latest) (push) Has been cancelled
CI / build (24, ubuntu-latest) (push) Has been cancelled
CI / build (24, windows-latest) (push) Has been cancelled
CI / pnpm (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
TestRepos / build (latest, ubuntu-latest) (push) Has been cancelled
UpdateTestRepos / update (push) Has been cancelled

This commit is contained in:
David Anson 2025-09-08 21:09:35 -07:00
parent 2a06f0a871
commit 616c3f2c22
18 changed files with 161 additions and 207 deletions

View file

@ -522,6 +522,7 @@ function lintContent(
"config": null
});
// Function to run for each rule
/** @type {LintError[]} */
const results = [];
/**
* @param {Rule} rule Rule.
@ -1194,9 +1195,9 @@ export function readConfigSync(file, parsers, fs) {
/**
* Normalizes the fields of a RuleOnErrorFixInfo instance.
*
* @param {RuleOnErrorFixInfo} fixInfo RuleOnErrorFixInfo instance.
* @param {FixInfo} fixInfo RuleOnErrorFixInfo instance.
* @param {number} [lineNumber] Line number.
* @returns {RuleOnErrorFixInfoNormalized} Normalized RuleOnErrorFixInfo instance.
* @returns {FixInfoNormalized} Normalized RuleOnErrorFixInfo instance.
*/
function normalizeFixInfo(fixInfo, lineNumber = 0) {
return {
@ -1211,7 +1212,7 @@ function normalizeFixInfo(fixInfo, lineNumber = 0) {
* Applies the specified fix to a Markdown content line.
*
* @param {string} line Line of Markdown content.
* @param {RuleOnErrorFixInfo} fixInfo RuleOnErrorFixInfo instance.
* @param {FixInfo} fixInfo FixInfo instance.
* @param {string} [lineEnding] Line ending to use.
* @returns {string | null} Fixed content or null if deleted.
*/
@ -1227,7 +1228,7 @@ export function applyFix(line, fixInfo, lineEnding = "\n") {
* Applies as many of the specified fixes as possible to Markdown content.
*
* @param {string} input Lines of Markdown content.
* @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances.
* @param {LintError[]} errors LintError instances.
* @returns {string} Fixed content.
*/
export function applyFixes(input, errors) {
@ -1424,16 +1425,6 @@ export function getVersion() {
* @property {string} [insertText] Text to insert (after deleting).
*/
/**
* RuleOnErrorInfo with all optional properties present.
*
* @typedef {Object} RuleOnErrorFixInfoNormalized
* @property {number} lineNumber Line number (1-based).
* @property {number} editColumn Column of the fix (1-based).
* @property {number} deleteCount Count of characters to delete.
* @property {string} insertText Text to insert (after deleting).
*/
/**
* Rule definition.
*
@ -1492,19 +1483,10 @@ export function getVersion() {
* @typedef {Array} Plugin
*/
/**
* Function to pretty-print lint results.
*
* @callback ToStringCallback
* @param {boolean} [ruleAliases] True to use rule aliases.
* @returns {string} Pretty-printed results.
*/
/**
* Lint results.
*
* @typedef {Object.<string, LintError[]>} LintResults
* @property {ToStringCallback} toString String representation.
*/
/**
@ -1517,8 +1499,8 @@ export function getVersion() {
* @property {string} ruleInformation Link to more information.
* @property {string} errorDetail Detail about the error.
* @property {string} errorContext Context for the error.
* @property {number[]} errorRange Column number (1-based) and length.
* @property {FixInfo} [fixInfo] Fix information.
* @property {number[]|null} errorRange Column number (1-based) and length.
* @property {FixInfo|null} fixInfo Fix information.
*/
/**
@ -1531,6 +1513,16 @@ export function getVersion() {
* @property {string} [insertText] Text to insert (after deleting).
*/
/**
* FixInfo with all optional properties present.
*
* @typedef {Object} FixInfoNormalized
* @property {number} lineNumber Line number (1-based).
* @property {number} editColumn Column of the fix (1-based).
* @property {number} deleteCount Count of characters to delete.
* @property {string} insertText Text to insert (after deleting).
*/
/**
* Called with the result of linting a string or document.
*