gajus/eslint-plugin-jsdoc

`jsdoc/require-param` adds missing parameters multiple times

Open

#770 建立於 2021年7月18日

在 GitHub 查看
 (10 留言) (4 反應) (0 負責人)JavaScript (172 fork)github user discovery
IDE interactionhelp wantedneeds-feedback

倉庫指標

Star
 (1,215 star)
PR 合併指標
 (PR 指標待抓取)

描述

Expected behavior

The jsdoc/require-param should add exactly one new @param tag - one for each missing parameter.

Actual behavior

For each missing parameter, it adds all missing parameters. For n missing parameters, it will add n*n @param tags.

ESLint Config

/** @type {import("eslint").Linter.Config} */
module.exports = {
	env: {
		browser: true,
		es6: true
	},
	root: true,
	parser: "@typescript-eslint/parser",
	plugins: [
		"@typescript-eslint",
		"jsdoc"
	],
	parserOptions: {
		ecmaVersion: 2018,
		sourceType: "module",
		ecmaFeatures: {
			node: true,
			spread: true
		}
	},
	rules: {
		"jsdoc/require-param": "error"
	},
	settings: {
		jsdoc: {
			mode: "typescript"
		}
	},
}

ESLint sample

/**
 * Foo.
 */
function foo(a: number, b: number, c:number):void {
	throw new Error();
}

Output:

/**
 * Foo.
 * @param a
 * @param b
 * @param c
 * @param a
 * @param b
 * @param c
 * @param a
 * @param b
 * @param c
 */
function foo(a: number, b: number, c:number):void {
	throw new Error();
}

Environment

  • Node version: v14.15.4
  • ESLint version v7.26.0
  • eslint-plugin-jsdoc version: 35.4.1

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

貢獻者指南