mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-18 15:00:13 +01:00
Make resultVersion 3 (report multiple errors per line, include fixInfo) the default.
This commit is contained in:
parent
9b3fd3d16b
commit
9310713da1
9 changed files with 44 additions and 31 deletions
|
|
@ -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
|
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
|
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
|
Passing a `resultVersion` of `3` corresponds to the detailed version `2` format
|
||||||
with additional information about how to fix automatically-fixable errors. In this
|
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
|
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
|
##### options.markdownItPlugins
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,7 @@
|
||||||
"config": {
|
"config": {
|
||||||
"MD013": false
|
"MD013": false
|
||||||
},
|
},
|
||||||
"handleRuleFailures": true,
|
"handleRuleFailures": true
|
||||||
"resultVersion": 3
|
|
||||||
};
|
};
|
||||||
allLintErrors = window.markdownlint.sync(options).content;
|
allLintErrors = window.markdownlint.sync(options).content;
|
||||||
violations.innerHTML = allLintErrors.map(function mapResult(result) {
|
violations.innerHTML = allLintErrors.map(function mapResult(result) {
|
||||||
|
|
|
||||||
|
|
@ -1808,7 +1808,7 @@ function lintInput(options, synchronous, callback) {
|
||||||
var handleRuleFailures = !!options.handleRuleFailures;
|
var handleRuleFailures = !!options.handleRuleFailures;
|
||||||
var noInlineConfig = !!options.noInlineConfig;
|
var noInlineConfig = !!options.noInlineConfig;
|
||||||
var resultVersion = (options.resultVersion === undefined) ?
|
var resultVersion = (options.resultVersion === undefined) ?
|
||||||
2 : options.resultVersion;
|
3 : options.resultVersion;
|
||||||
var md = markdownIt({ "html": true });
|
var md = markdownIt({ "html": true });
|
||||||
var markdownItPlugins = options.markdownItPlugins || [];
|
var markdownItPlugins = options.markdownItPlugins || [];
|
||||||
markdownItPlugins.forEach(function forPlugin(plugin) {
|
markdownItPlugins.forEach(function forPlugin(plugin) {
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,6 @@ options = {
|
||||||
"frontMatter": /---/,
|
"frontMatter": /---/,
|
||||||
"handleRuleFailures": false,
|
"handleRuleFailures": false,
|
||||||
"noInlineConfig": false,
|
"noInlineConfig": false,
|
||||||
"resultVersion": 3,
|
|
||||||
"markdownItPlugins": [ [ require("markdown-it-sub") ] ]
|
"markdownItPlugins": [ [ require("markdown-it-sub") ] ]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -773,7 +773,7 @@ function lintInput(options, synchronous, callback) {
|
||||||
const handleRuleFailures = !!options.handleRuleFailures;
|
const handleRuleFailures = !!options.handleRuleFailures;
|
||||||
const noInlineConfig = !!options.noInlineConfig;
|
const noInlineConfig = !!options.noInlineConfig;
|
||||||
const resultVersion = (options.resultVersion === undefined) ?
|
const resultVersion = (options.resultVersion === undefined) ?
|
||||||
2 : options.resultVersion;
|
3 : options.resultVersion;
|
||||||
const md = markdownIt({ "html": true });
|
const md = markdownIt({ "html": true });
|
||||||
const markdownItPlugins = options.markdownItPlugins || [];
|
const markdownItPlugins = options.markdownItPlugins || [];
|
||||||
markdownItPlugins.forEach(function forPlugin(plugin) {
|
markdownItPlugins.forEach(function forPlugin(plugin) {
|
||||||
|
|
|
||||||
|
|
@ -901,7 +901,8 @@ test.cb("customRulesOnErrorLazy", (t) => {
|
||||||
"ruleInformation": null,
|
"ruleInformation": null,
|
||||||
"errorDetail": null,
|
"errorDetail": null,
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": [ 1, 1 ]
|
"errorRange": [ 1, 1 ],
|
||||||
|
"fixInfo": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -943,8 +944,7 @@ test.cb("customRulesOnErrorModified", (t) => {
|
||||||
],
|
],
|
||||||
"strings": {
|
"strings": {
|
||||||
"string": "# Heading\n"
|
"string": "# Heading\n"
|
||||||
},
|
}
|
||||||
"resultVersion": 3
|
|
||||||
};
|
};
|
||||||
markdownlint(options, function callback(err, actualResult) {
|
markdownlint(options, function callback(err, actualResult) {
|
||||||
t.falsy(err);
|
t.falsy(err);
|
||||||
|
|
@ -1002,7 +1002,8 @@ test.cb("customRulesOnErrorInvalidHandled", (t) => {
|
||||||
"errorDetail": "This rule threw an exception: " +
|
"errorDetail": "This rule threw an exception: " +
|
||||||
"Property 'lineNumber' of onError parameter is incorrect.",
|
"Property 'lineNumber' of onError parameter is incorrect.",
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": null
|
"errorRange": null,
|
||||||
|
"fixInfo": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -1042,7 +1043,8 @@ test("customRulesOnErrorInvalidHandledSync", (t) => {
|
||||||
"errorDetail": "This rule threw an exception: " +
|
"errorDetail": "This rule threw an exception: " +
|
||||||
"Property 'lineNumber' of onError parameter is incorrect.",
|
"Property 'lineNumber' of onError parameter is incorrect.",
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": null
|
"errorRange": null,
|
||||||
|
"fixInfo": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -1125,7 +1127,8 @@ test.cb("customRulesLintJavaScript", (t) => {
|
||||||
"ruleInformation": null,
|
"ruleInformation": null,
|
||||||
"errorDetail": "Unexpected var, use let or const instead.",
|
"errorDetail": "Unexpected var, use let or const instead.",
|
||||||
"errorContext": "var x = 0;",
|
"errorContext": "var x = 0;",
|
||||||
"errorRange": null
|
"errorRange": null,
|
||||||
|
"fixInfo": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"lineNumber": 12,
|
"lineNumber": 12,
|
||||||
|
|
@ -1134,7 +1137,8 @@ test.cb("customRulesLintJavaScript", (t) => {
|
||||||
"ruleInformation": null,
|
"ruleInformation": null,
|
||||||
"errorDetail": "Unexpected console statement.",
|
"errorDetail": "Unexpected console statement.",
|
||||||
"errorContext": "console.log(x);",
|
"errorContext": "console.log(x);",
|
||||||
"errorRange": null
|
"errorRange": null,
|
||||||
|
"fixInfo": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -1160,7 +1164,8 @@ test.cb("customRulesValidateJson", (t) => {
|
||||||
"ruleInformation": null,
|
"ruleInformation": null,
|
||||||
"errorDetail": "Unexpected end of JSON input",
|
"errorDetail": "Unexpected end of JSON input",
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": null
|
"errorRange": null,
|
||||||
|
"fixInfo": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -1312,7 +1317,11 @@ test("customRulesAsyncReadFiles", (t) => {
|
||||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md047`,
|
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md047`,
|
||||||
"errorDetail": null,
|
"errorDetail": null,
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": [ 9, 1 ]
|
"errorRange": [ 9, 1 ],
|
||||||
|
"fixInfo": {
|
||||||
|
"editColumn": 10,
|
||||||
|
"insertText": "\n"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"lineNumber": 1,
|
"lineNumber": 1,
|
||||||
|
|
@ -1321,7 +1330,8 @@ test("customRulesAsyncReadFiles", (t) => {
|
||||||
"ruleInformation": "https://example.com/asyncRule1",
|
"ruleInformation": "https://example.com/asyncRule1",
|
||||||
"errorDetail": "detail1",
|
"errorDetail": "detail1",
|
||||||
"errorContext": "context1",
|
"errorContext": "context1",
|
||||||
"errorRange": [ 2, 3 ]
|
"errorRange": [ 2, 3 ],
|
||||||
|
"fixInfo": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"lineNumber": 1,
|
"lineNumber": 1,
|
||||||
|
|
@ -1330,7 +1340,8 @@ test("customRulesAsyncReadFiles", (t) => {
|
||||||
"ruleInformation": null,
|
"ruleInformation": null,
|
||||||
"errorDetail": "detail2",
|
"errorDetail": "detail2",
|
||||||
"errorContext": "context2",
|
"errorContext": "context2",
|
||||||
"errorRange": null
|
"errorRange": null,
|
||||||
|
"fixInfo": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -1377,7 +1388,8 @@ test("customRulesAsyncIgnoresSyncReturn", (t) => {
|
||||||
"ruleInformation": "https://example.com/asyncRule",
|
"ruleInformation": "https://example.com/asyncRule",
|
||||||
"errorDetail": null,
|
"errorDetail": null,
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": null
|
"errorRange": null,
|
||||||
|
"fixInfo": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"lineNumber": 1,
|
"lineNumber": 1,
|
||||||
|
|
@ -1386,7 +1398,11 @@ test("customRulesAsyncIgnoresSyncReturn", (t) => {
|
||||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md047`,
|
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md047`,
|
||||||
"errorDetail": null,
|
"errorDetail": null,
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": [ 9, 1 ]
|
"errorRange": [ 9, 1 ],
|
||||||
|
"fixInfo": {
|
||||||
|
"editColumn": 10,
|
||||||
|
"insertText": "\n"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -1440,7 +1456,8 @@ const stringScenarios = [
|
||||||
"ruleInformation": null,
|
"ruleInformation": null,
|
||||||
"errorDetail": `This rule threw an exception: ${errorMessage}`,
|
"errorDetail": `This rule threw an exception: ${errorMessage}`,
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": null
|
"errorRange": null,
|
||||||
|
"fixInfo": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -1604,7 +1621,8 @@ const stringScenarios = [
|
||||||
"ruleInformation": null,
|
"ruleInformation": null,
|
||||||
"errorDetail": `This rule threw an exception: ${errorMessage}`,
|
"errorDetail": `This rule threw an exception: ${errorMessage}`,
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": null
|
"errorRange": null,
|
||||||
|
"fixInfo": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,7 @@ async function lintTestRepo(t, globPatterns, configPath, ignoreRes) {
|
||||||
console.log(`${t.title}: Linting ${files.length} files...`);
|
console.log(`${t.title}: Linting ${files.length} files...`);
|
||||||
return markdownlintPromise({
|
return markdownlintPromise({
|
||||||
files,
|
files,
|
||||||
config,
|
config
|
||||||
"resultVersion": 3
|
|
||||||
// }).then((results) => {
|
// }).then((results) => {
|
||||||
// // Cross-check MD051/link-fragments results with markdown-link-check
|
// // Cross-check MD051/link-fragments results with markdown-link-check
|
||||||
// const resultFiles = [];
|
// const resultFiles = [];
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,8 @@ test.cb("resultFormattingV2", (t) => {
|
||||||
"config": {
|
"config": {
|
||||||
"MD002": true,
|
"MD002": true,
|
||||||
"MD041": false
|
"MD041": false
|
||||||
}
|
},
|
||||||
|
"resultVersion": 2
|
||||||
};
|
};
|
||||||
markdownlint(options, function callback(err, actualResult) {
|
markdownlint(options, function callback(err, actualResult) {
|
||||||
t.falsy(err);
|
t.falsy(err);
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,7 @@ function createTestForFile(file) {
|
||||||
function lintWithConfig() {
|
function lintWithConfig() {
|
||||||
return markdownlintPromise({
|
return markdownlintPromise({
|
||||||
"files": [ file ],
|
"files": [ file ],
|
||||||
config,
|
config
|
||||||
"resultVersion": 3
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
|
|
@ -54,8 +53,7 @@ function createTestForFile(file) {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
markdownlintPromise({
|
markdownlintPromise({
|
||||||
"files": [ file ],
|
"files": [ file ],
|
||||||
config,
|
config
|
||||||
"resultVersion": 3
|
|
||||||
}),
|
}),
|
||||||
fs.promises.readFile(file, "utf8"),
|
fs.promises.readFile(file, "utf8"),
|
||||||
fs.promises.readFile(fixedFile, "utf8")
|
fs.promises.readFile(fixedFile, "utf8")
|
||||||
|
|
@ -148,8 +146,7 @@ function createTestForFile(file) {
|
||||||
"strings": {
|
"strings": {
|
||||||
"input": corrections
|
"input": corrections
|
||||||
},
|
},
|
||||||
config,
|
config
|
||||||
"resultVersion": 3
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue