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,
|
"node": true,
|
||||||
"es6": true
|
"es6": true
|
||||||
},
|
},
|
||||||
"extends": "eslint:all",
|
"plugins": [
|
||||||
|
"jsdoc"
|
||||||
|
],
|
||||||
|
"extends": [
|
||||||
|
"eslint:all",
|
||||||
|
"plugin:jsdoc/recommended"
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"jsdoc": {
|
||||||
|
"preferredTypes": {
|
||||||
|
"object": "Object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"array-bracket-spacing": ["error", "always"],
|
"array-bracket-spacing": ["error", "always"],
|
||||||
"array-element-newline": "off",
|
"array-element-newline": "off",
|
||||||
|
@ -50,6 +63,12 @@
|
||||||
"sort-keys": "off",
|
"sort-keys": "off",
|
||||||
"space-before-function-paren": ["error", "never"],
|
"space-before-function-paren": ["error", "never"],
|
||||||
"vars-on-top": "off",
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
lib/markdownlint.d.ts
vendored
2
lib/markdownlint.d.ts
vendored
|
@ -75,7 +75,7 @@ declare function markdownlintSync(options: Options): {
|
||||||
*
|
*
|
||||||
* @param {string} file Configuration file name.
|
* @param {string} file Configuration file name.
|
||||||
* @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
|
* @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
|
||||||
* function(s).
|
* function(s).
|
||||||
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -682,7 +682,7 @@ function parseConfiguration(name, content, parsers) {
|
||||||
*
|
*
|
||||||
* @param {string} file Configuration file name.
|
* @param {string} file Configuration file name.
|
||||||
* @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
|
* @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
|
||||||
* function(s).
|
* function(s).
|
||||||
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
"c8": "~7.0.0",
|
"c8": "~7.0.0",
|
||||||
"cpy-cli": "~3.0.0",
|
"cpy-cli": "~3.0.0",
|
||||||
"eslint": "~6.7.2",
|
"eslint": "~6.7.2",
|
||||||
|
"eslint-plugin-jsdoc": "~20.3.1",
|
||||||
"glob": "~7.1.6",
|
"glob": "~7.1.6",
|
||||||
"js-yaml": "~3.13.1",
|
"js-yaml": "~3.13.1",
|
||||||
"markdown-it-for-inline": "~0.1.1",
|
"markdown-it-for-inline": "~0.1.1",
|
||||||
|
|
|
@ -8,6 +8,17 @@ const cliEngine = new eslint.CLIEngine({});
|
||||||
const linter = new eslint.Linter();
|
const linter = new eslint.Linter();
|
||||||
const languageJavaScript = /js|javascript/i;
|
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 = {
|
module.exports = {
|
||||||
"names": [ "lint-javascript" ],
|
"names": [ "lint-javascript" ],
|
||||||
"description": "Rule that lints JavaScript code",
|
"description": "Rule that lints JavaScript code",
|
||||||
|
@ -15,7 +26,8 @@ module.exports = {
|
||||||
"function": (params, onError) => {
|
"function": (params, onError) => {
|
||||||
filterTokens(params, "fence", (fence) => {
|
filterTokens(params, "fence", (fence) => {
|
||||||
if (languageJavaScript.test(fence.info)) {
|
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);
|
const results = linter.verify(fence.content, config);
|
||||||
results.forEach((result) => {
|
results.forEach((result) => {
|
||||||
const lineNumber = fence.lineNumber + result.line;
|
const lineNumber = fence.lineNumber + result.line;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue