diff --git a/README.md b/README.md index de10d605..4cf718aa 100644 --- a/README.md +++ b/README.md @@ -522,12 +522,12 @@ as any additional detail or context that is available. *This is deprecated.* Passing a `resultVersion` of `2` corresponds to a detailed format where each error includes information about the line number, rule names, description, as well as any -additional detail or context that is available. *This is the default.* +additional detail or context that is available. *This is deprecated.* Passing a `resultVersion` of `3` corresponds to the detailed version `2` format with additional information about how to fix automatically-fixable errors. In this mode, all errors that occur on each line are reported (other versions report only -the first error for each rule). +the first error for each rule). *This is the default.* ##### options.markdownItPlugins diff --git a/demo/default.js b/demo/default.js index ebe5e78a..99a54d8c 100644 --- a/demo/default.js +++ b/demo/default.js @@ -52,8 +52,7 @@ "config": { "MD013": false }, - "handleRuleFailures": true, - "resultVersion": 3 + "handleRuleFailures": true }; allLintErrors = window.markdownlint.sync(options).content; violations.innerHTML = allLintErrors.map(function mapResult(result) { diff --git a/demo/markdownlint-browser.js b/demo/markdownlint-browser.js index 6eba21c1..37f5e61e 100644 --- a/demo/markdownlint-browser.js +++ b/demo/markdownlint-browser.js @@ -1808,7 +1808,7 @@ function lintInput(options, synchronous, callback) { var handleRuleFailures = !!options.handleRuleFailures; var noInlineConfig = !!options.noInlineConfig; var resultVersion = (options.resultVersion === undefined) ? - 2 : options.resultVersion; + 3 : options.resultVersion; var md = markdownIt({ "html": true }); var markdownItPlugins = options.markdownItPlugins || []; markdownItPlugins.forEach(function forPlugin(plugin) { diff --git a/example/typescript/type-check.ts b/example/typescript/type-check.ts index fdc73a2d..e30d3913 100644 --- a/example/typescript/type-check.ts +++ b/example/typescript/type-check.ts @@ -92,7 +92,6 @@ options = { "frontMatter": /---/, "handleRuleFailures": false, "noInlineConfig": false, - "resultVersion": 3, "markdownItPlugins": [ [ require("markdown-it-sub") ] ] }; diff --git a/lib/markdownlint.js b/lib/markdownlint.js index d80fbfec..8da66cd4 100644 --- a/lib/markdownlint.js +++ b/lib/markdownlint.js @@ -773,7 +773,7 @@ function lintInput(options, synchronous, callback) { const handleRuleFailures = !!options.handleRuleFailures; const noInlineConfig = !!options.noInlineConfig; const resultVersion = (options.resultVersion === undefined) ? - 2 : options.resultVersion; + 3 : options.resultVersion; const md = markdownIt({ "html": true }); const markdownItPlugins = options.markdownItPlugins || []; markdownItPlugins.forEach(function forPlugin(plugin) { diff --git a/test/markdownlint-test-custom-rules.js b/test/markdownlint-test-custom-rules.js index cc84aa87..9d5eae08 100644 --- a/test/markdownlint-test-custom-rules.js +++ b/test/markdownlint-test-custom-rules.js @@ -901,7 +901,8 @@ test.cb("customRulesOnErrorLazy", (t) => { "ruleInformation": null, "errorDetail": null, "errorContext": null, - "errorRange": [ 1, 1 ] + "errorRange": [ 1, 1 ], + "fixInfo": null } ] }; @@ -943,8 +944,7 @@ test.cb("customRulesOnErrorModified", (t) => { ], "strings": { "string": "# Heading\n" - }, - "resultVersion": 3 + } }; markdownlint(options, function callback(err, actualResult) { t.falsy(err); @@ -1002,7 +1002,8 @@ test.cb("customRulesOnErrorInvalidHandled", (t) => { "errorDetail": "This rule threw an exception: " + "Property 'lineNumber' of onError parameter is incorrect.", "errorContext": null, - "errorRange": null + "errorRange": null, + "fixInfo": null } ] }; @@ -1042,7 +1043,8 @@ test("customRulesOnErrorInvalidHandledSync", (t) => { "errorDetail": "This rule threw an exception: " + "Property 'lineNumber' of onError parameter is incorrect.", "errorContext": null, - "errorRange": null + "errorRange": null, + "fixInfo": null } ] }; @@ -1125,7 +1127,8 @@ test.cb("customRulesLintJavaScript", (t) => { "ruleInformation": null, "errorDetail": "Unexpected var, use let or const instead.", "errorContext": "var x = 0;", - "errorRange": null + "errorRange": null, + "fixInfo": null }, { "lineNumber": 12, @@ -1134,7 +1137,8 @@ test.cb("customRulesLintJavaScript", (t) => { "ruleInformation": null, "errorDetail": "Unexpected console statement.", "errorContext": "console.log(x);", - "errorRange": null + "errorRange": null, + "fixInfo": null } ] }; @@ -1160,7 +1164,8 @@ test.cb("customRulesValidateJson", (t) => { "ruleInformation": null, "errorDetail": "Unexpected end of JSON input", "errorContext": null, - "errorRange": null + "errorRange": null, + "fixInfo": null } ] }; @@ -1312,7 +1317,11 @@ test("customRulesAsyncReadFiles", (t) => { "ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md047`, "errorDetail": null, "errorContext": null, - "errorRange": [ 9, 1 ] + "errorRange": [ 9, 1 ], + "fixInfo": { + "editColumn": 10, + "insertText": "\n" + } }, { "lineNumber": 1, @@ -1321,7 +1330,8 @@ test("customRulesAsyncReadFiles", (t) => { "ruleInformation": "https://example.com/asyncRule1", "errorDetail": "detail1", "errorContext": "context1", - "errorRange": [ 2, 3 ] + "errorRange": [ 2, 3 ], + "fixInfo": null }, { "lineNumber": 1, @@ -1330,7 +1340,8 @@ test("customRulesAsyncReadFiles", (t) => { "ruleInformation": null, "errorDetail": "detail2", "errorContext": "context2", - "errorRange": null + "errorRange": null, + "fixInfo": null } ] }; @@ -1377,7 +1388,8 @@ test("customRulesAsyncIgnoresSyncReturn", (t) => { "ruleInformation": "https://example.com/asyncRule", "errorDetail": null, "errorContext": null, - "errorRange": null + "errorRange": null, + "fixInfo": null }, { "lineNumber": 1, @@ -1386,7 +1398,11 @@ test("customRulesAsyncIgnoresSyncReturn", (t) => { "ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md047`, "errorDetail": null, "errorContext": null, - "errorRange": [ 9, 1 ] + "errorRange": [ 9, 1 ], + "fixInfo": { + "editColumn": 10, + "insertText": "\n" + } } ] }; @@ -1440,7 +1456,8 @@ const stringScenarios = [ "ruleInformation": null, "errorDetail": `This rule threw an exception: ${errorMessage}`, "errorContext": null, - "errorRange": null + "errorRange": null, + "fixInfo": null } ] }; @@ -1604,7 +1621,8 @@ const stringScenarios = [ "ruleInformation": null, "errorDetail": `This rule threw an exception: ${errorMessage}`, "errorContext": null, - "errorRange": null + "errorRange": null, + "fixInfo": null } ] }; diff --git a/test/markdownlint-test-repos.js b/test/markdownlint-test-repos.js index e1e01208..cd213ab9 100644 --- a/test/markdownlint-test-repos.js +++ b/test/markdownlint-test-repos.js @@ -39,8 +39,7 @@ async function lintTestRepo(t, globPatterns, configPath, ignoreRes) { console.log(`${t.title}: Linting ${files.length} files...`); return markdownlintPromise({ files, - config, - "resultVersion": 3 + config // }).then((results) => { // // Cross-check MD051/link-fragments results with markdown-link-check // const resultFiles = []; diff --git a/test/markdownlint-test-result-object.js b/test/markdownlint-test-result-object.js index 026b6bdd..d28e5d00 100644 --- a/test/markdownlint-test-result-object.js +++ b/test/markdownlint-test-result-object.js @@ -255,7 +255,8 @@ test.cb("resultFormattingV2", (t) => { "config": { "MD002": true, "MD041": false - } + }, + "resultVersion": 2 }; markdownlint(options, function callback(err, actualResult) { t.falsy(err); diff --git a/test/markdownlint-test-scenarios.js b/test/markdownlint-test-scenarios.js index 64a71754..b6a38280 100644 --- a/test/markdownlint-test-scenarios.js +++ b/test/markdownlint-test-scenarios.js @@ -44,8 +44,7 @@ function createTestForFile(file) { function lintWithConfig() { return markdownlintPromise({ "files": [ file ], - config, - "resultVersion": 3 + config }); }) .then( @@ -54,8 +53,7 @@ function createTestForFile(file) { Promise.all([ markdownlintPromise({ "files": [ file ], - config, - "resultVersion": 3 + config }), fs.promises.readFile(file, "utf8"), fs.promises.readFile(fixedFile, "utf8") @@ -148,8 +146,7 @@ function createTestForFile(file) { "strings": { "input": corrections }, - config, - "resultVersion": 3 + config }); }) .then(