mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Update dependencies: eslint to 8.5.0, eslint-plugin-jsdoc to 37.4.0.
This commit is contained in:
parent
fd24b9552b
commit
528758e962
3 changed files with 19 additions and 15 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
const { filterTokens } = require("markdownlint-rule-helpers");
|
||||
const eslint = require("eslint");
|
||||
const cliEngine = new eslint.CLIEngine({});
|
||||
const eslintInstance = new eslint.ESLint();
|
||||
const linter = new eslint.Linter();
|
||||
const languageJavaScript = /js|javascript/i;
|
||||
|
||||
|
|
@ -28,23 +28,27 @@ module.exports = {
|
|||
"names": [ "lint-javascript" ],
|
||||
"description": "Rule that lints JavaScript code",
|
||||
"tags": [ "test", "lint", "javascript" ],
|
||||
"asynchronous": true,
|
||||
"function": (params, onError) => {
|
||||
filterTokens(params, "fence", (fence) => {
|
||||
if (languageJavaScript.test(fence.info)) {
|
||||
let config = cliEngine.getConfigForFile(params.name);
|
||||
config = cleanJsdocRulesFromEslintConfig(config);
|
||||
const results = linter.verify(fence.content, config);
|
||||
results.forEach((result) => {
|
||||
const lineNumber = fence.lineNumber + result.line;
|
||||
onError({
|
||||
"lineNumber": lineNumber,
|
||||
"detail": result.message,
|
||||
"context": params.lines[lineNumber - 1]
|
||||
return eslintInstance.calculateConfigForFile(params.name)
|
||||
.then((config) => {
|
||||
config = cleanJsdocRulesFromEslintConfig(config);
|
||||
const results = linter.verify(fence.content, config);
|
||||
results.forEach((result) => {
|
||||
const lineNumber = fence.lineNumber + result.line;
|
||||
onError({
|
||||
"lineNumber": lineNumber,
|
||||
"detail": result.message,
|
||||
"context": params.lines[lineNumber - 1]
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
});
|
||||
// Unused:
|
||||
// Unsupported:
|
||||
// filterTokens("code_block"), language unknown
|
||||
// filterTokens("code_inline"), too brief
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue