Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsdoc/check-template-names reports used template as unused #1286

Closed
ehoogeveen-medweb opened this issue Jul 30, 2024 · 3 comments · Fixed by #1287 · May be fixed by AKJUS/node#19
Closed

jsdoc/check-template-names reports used template as unused #1286

ehoogeveen-medweb opened this issue Jul 30, 2024 · 3 comments · Fixed by #1287 · May be fixed by AKJUS/node#19

Comments

@ehoogeveen-medweb
Copy link

ehoogeveen-medweb commented Jul 30, 2024

Expected behavior

No warnings. Template T is in use and the function type checks with // @ts-check. I would expect both @params and maybe the @returns to separately be enough to mark the template as used.

The @type inside the function also references it, but that probably shouldn't be considered as the template should already be part of the function signature.

Actual behavior

Starting from eslint-plugin-jsdoc version 48.10.0, jsdoc/check-template-names reports that @template T not in use.

ESLint Config

{
	"root": true,
	"parserOptions": {
		"ecmaVersion": "latest",
		"sourceType": "module"
	},
	"plugins": ["jsdoc"],
	"settings": {
		"jsdoc": {
			"mode": "typescript"
		}
	},
	"env": { "es2024": true },
	"rules": {
		"jsdoc/check-template-names": "warn"
	}
}

ESLint sample

/**
 * Uses the provided callback to group the given array into the keys of a map.
 * Based on the array grouping proposal: https://github.com/tc39/proposal-array-grouping/
 *
 * @template T
 * @param {T[]} array
 * @param {(value: T, index: number) => string} callbackFn
 * @returns {Map<string, T[]>}
 */
export function mapGroupBy(array, callbackFn) {
	/** @type {Map<string, T[]>} */
	const map = new Map();
	for (const [index, element] of array.entries()) {
		const key = callbackFn(element, index);
		const arr = map.get(key);
		if (arr) {
			arr.push(element);
		} else {
			map.set(key, [element]);
		}
	}
	return map;
}

Environment

  • Node version: v20.16.0
  • ESLint version v8.57.0
  • eslint-plugin-jsdoc version: 48.10.1
Copy link

🎉 This issue has been resolved in version 48.10.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@brettz9
Copy link
Collaborator

brettz9 commented Jul 30, 2024

Thanks for the report!

@ehoogeveen-medweb
Copy link
Author

Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment