Resolve remaining TypeScript-based editor warnings in test file.

This commit is contained in:
David Anson 2020-01-11 20:48:00 -08:00
parent 5010acad4b
commit 21b01b2a96
3 changed files with 13 additions and 6 deletions

View file

@ -74,11 +74,12 @@ declare function markdownlintSync(options: Options): {
* Read specified configuration file. * Read specified configuration file.
* *
* @param {string} file Configuration file name. * @param {string} file Configuration file name.
* @param {ConfigurationParser[] | null} parsers Parsing function(s). * @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
* @param {ReadConfigCallback} callback Callback (err, result) function. * function(s).
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
* @returns {void} * @returns {void}
*/ */
declare function readConfig(file: string, parsers: ConfigurationParser[], callback: ReadConfigCallback): void; declare function readConfig(file: string, parsers: ReadConfigCallback | ConfigurationParser[], callback?: ReadConfigCallback): void;
/** /**
* Read specified configuration file synchronously. * Read specified configuration file synchronously.
* *

View file

@ -681,8 +681,9 @@ function parseConfiguration(name, content, parsers) {
* Read specified configuration file. * Read specified configuration file.
* *
* @param {string} file Configuration file name. * @param {string} file Configuration file name.
* @param {ConfigurationParser[] | null} parsers Parsing function(s). * @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
* @param {ReadConfigCallback} callback Callback (err, result) function. * function(s).
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
* @returns {void} * @returns {void}
*/ */
function readConfig(file, parsers, callback) { function readConfig(file, parsers, callback) {

View file

@ -101,6 +101,7 @@ function createTestForFile(file) {
fs.promises.readFile(resultsFile, helpers.utf8Encoding) fs.promises.readFile(resultsFile, helpers.utf8Encoding)
.then( .then(
function fileContents(contents) { function fileContents(contents) {
// @ts-ignore
const errorObjects = JSON.parse(contents); const errorObjects = JSON.parse(contents);
errorObjects.forEach(function forObject(errorObject) { errorObjects.forEach(function forObject(errorObject) {
if (errorObject.ruleInformation) { if (errorObject.ruleInformation) {
@ -113,6 +114,7 @@ function createTestForFile(file) {
fs.promises.readFile(file, helpers.utf8Encoding) fs.promises.readFile(file, helpers.utf8Encoding)
.then( .then(
function fileContents(contents) { function fileContents(contents) {
// @ts-ignore
const lines = contents.split(helpers.newLineRe); const lines = contents.split(helpers.newLineRe);
const results = {}; const results = {};
lines.forEach(function forLine(line, lineNum) { lines.forEach(function forLine(line, lineNum) {
@ -294,6 +296,7 @@ tape("resultFormattingSyncV0", (test) => {
"./test/first_heading_bad_atx.md: 1: MD002" + "./test/first_heading_bad_atx.md: 1: MD002" +
" First heading should be a top level heading"; " First heading should be a top level heading";
test.equal(actualMessage, expectedMessage, "Incorrect message (name)."); test.equal(actualMessage, expectedMessage, "Incorrect message (name).");
// @ts-ignore
actualMessage = actualResult.toString(true); actualMessage = actualResult.toString(true);
expectedMessage = expectedMessage =
"./test/atx_heading_spacing.md: 3: first-heading-h1" + "./test/atx_heading_spacing.md: 3: first-heading-h1" +
@ -2528,6 +2531,7 @@ tape("configBadFile", (test) => {
function callback(err, result) { function callback(err, result) {
test.ok(err, "Did not get an error for bad file."); test.ok(err, "Did not get an error for bad file.");
test.ok(err instanceof Error, "Error not instance of Error."); test.ok(err instanceof Error, "Error not instance of Error.");
// @ts-ignore
test.equal(err.code, "ENOENT", "Error code for bad file not ENOENT."); test.equal(err.code, "ENOENT", "Error code for bad file not ENOENT.");
test.ok(!result, "Got result for bad file."); test.ok(!result, "Got result for bad file.");
test.end(); test.end();
@ -2540,6 +2544,7 @@ tape("configBadChildFile", (test) => {
function callback(err, result) { function callback(err, result) {
test.ok(err, "Did not get an error for bad child file."); test.ok(err, "Did not get an error for bad child file.");
test.ok(err instanceof Error, "Error not instance of Error."); test.ok(err instanceof Error, "Error not instance of Error.");
// @ts-ignore
test.equal(err.code, "ENOENT", test.equal(err.code, "ENOENT",
"Error code for bad child file not ENOENT."); "Error code for bad child file not ENOENT.");
test.ok(!result, "Got result for bad child file."); test.ok(!result, "Got result for bad child file.");
@ -3739,7 +3744,7 @@ tape("customRulesOnErrorInvalidHandled", (test) => {
"function": function onErrorInvalid(params, onError) { "function": function onErrorInvalid(params, onError) {
onError({ onError({
"lineNumber": 13, "lineNumber": 13,
"detail": "N/A" "details": "N/A"
}); });
} }
} }