gajus/eslint-plugin-jsdoc

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

開放

#770 建立於 2021年7月18日

 (10 則留言) (4 個反應) (0 位負責人)JavaScript (176 個分叉)github user discovery
IDE interactionhelp wantedneeds-feedback

倉庫指標

星標
 (1,227 顆星)
PR 合併指標
 (平均合併 2天 8小時) (30 天內合併 10 個 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.

貢獻者指南