This commit is contained in:
David Anson 2025-08-27 21:15:27 -07:00
parent 284bf0335f
commit cfe46ea322
2 changed files with 11 additions and 7 deletions

View file

@ -108,9 +108,15 @@ function validateRuleList(ruleList, synchronous) {
* @returns {LintResults} New LintResults instance.
*/
function newResults(ruleList) {
const lintResults = {};
// eslint-disable-next-line jsdoc/require-jsdoc
/**
* Returns the string representation of a LintResults instance.
*
* @param {boolean} useAlias True if rule alias should be used instead of name.
* @returns {string} String representation of the instance.
*/
function toString(useAlias) {
// eslint-disable-next-line consistent-this, no-invalid-this, unicorn/no-this-assignment
const lintResults = this;
let ruleNameToRule = null;
const results = [];
const keys = Object.keys(lintResults);
@ -161,6 +167,7 @@ function newResults(ruleList) {
}
return results.join("\n");
}
const lintResults = {};
Object.defineProperty(lintResults, "toString", { "value": toString });
// @ts-ignore
return lintResults;
@ -515,7 +522,7 @@ function lintContent(
"config": null
});
// Function to run for each rule
let results = [];
const results = [];
/**
* @param {Rule} rule Rule.
* @returns {Promise<void> | null} Promise.

View file

@ -626,7 +626,7 @@ test("frontMatterResultVersion3", (t) => new Promise((resolve) => {
});
}));
test("convertToResultVersionN", async (t) => {
test("convertToResultVersionN", async(t) => {
t.plan(6);
const options = {
"files": [
@ -644,15 +644,12 @@ test("convertToResultVersionN", async (t) => {
lintPromise({ ...options, "resultVersion": 1 }),
lintPromise({ ...options, "resultVersion": 0 })
]);
const v2 = convertToResultVersion2(version3);
t.deepEqual(v2, version2);
t.is(v2.toString(), version2.toString());
const v1 = convertToResultVersion1(version3);
t.deepEqual(v1, version1);
t.is(v1.toString(), version1.toString());
const v0 = convertToResultVersion0(version3);
t.deepEqual(v0, version0);
t.is(v0.toString(), version0.toString());