mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add eslint-plugin-jsdoc to lint script, address new violation.
This commit is contained in:
parent
9ac06456d1
commit
e3c93ed65d
5 changed files with 37 additions and 5 deletions
|
@ -6,7 +6,20 @@
|
|||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"extends": "eslint:all",
|
||||
"plugins": [
|
||||
"jsdoc"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:all",
|
||||
"plugin:jsdoc/recommended"
|
||||
],
|
||||
"settings": {
|
||||
"jsdoc": {
|
||||
"preferredTypes": {
|
||||
"object": "Object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"array-bracket-spacing": ["error", "always"],
|
||||
"array-element-newline": "off",
|
||||
|
@ -50,6 +63,12 @@
|
|||
"sort-keys": "off",
|
||||
"space-before-function-paren": ["error", "never"],
|
||||
"vars-on-top": "off",
|
||||
"wrap-regex": "off"
|
||||
"wrap-regex": "off",
|
||||
"jsdoc/check-examples": "error",
|
||||
"jsdoc/check-indentation": "error",
|
||||
"jsdoc/check-syntax": "error",
|
||||
"jsdoc/match-description": "error",
|
||||
"jsdoc/require-description": "error",
|
||||
"jsdoc/require-jsdoc": "off"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
"c8": "~7.0.0",
|
||||
"cpy-cli": "~3.0.0",
|
||||
"eslint": "~6.7.2",
|
||||
"eslint-plugin-jsdoc": "~20.3.1",
|
||||
"glob": "~7.1.6",
|
||||
"js-yaml": "~3.13.1",
|
||||
"markdown-it-for-inline": "~0.1.1",
|
||||
|
|
|
@ -8,6 +8,17 @@ const cliEngine = new eslint.CLIEngine({});
|
|||
const linter = new eslint.Linter();
|
||||
const languageJavaScript = /js|javascript/i;
|
||||
|
||||
// Helper function that removes this project's use of eslint-plugin-jsdoc
|
||||
function cleanJsdocRulesFromEslintConfig(config) {
|
||||
const cleanedConfig = { ...config };
|
||||
for (const rule in config.rules) {
|
||||
if (/^jsdoc\//.test(rule)) {
|
||||
delete cleanedConfig.rules[rule];
|
||||
}
|
||||
}
|
||||
return cleanedConfig;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
"names": [ "lint-javascript" ],
|
||||
"description": "Rule that lints JavaScript code",
|
||||
|
@ -15,7 +26,8 @@ module.exports = {
|
|||
"function": (params, onError) => {
|
||||
filterTokens(params, "fence", (fence) => {
|
||||
if (languageJavaScript.test(fence.info)) {
|
||||
const config = cliEngine.getConfigForFile(params.name);
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue