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

Allow implicit 'this' with destructured param #1190

Closed
scronay opened this issue Jan 24, 2024 · 1 comment · Fixed by #1191
Closed

Allow implicit 'this' with destructured param #1190

scronay opened this issue Jan 24, 2024 · 1 comment · Fixed by #1191

Comments

@scronay
Copy link

scronay commented Jan 24, 2024

Expected behavior

No warning should be triggered when this param is accompanied by a destructured parameter.

Actual behavior

A warning is triggered, implying that the @param for the destructured root is being referenced as a match for this

image

Note: this warning does not trigger when the parameter following this is not destructured, or when @param is explicitly provided for this, as in the following cases:

/**
 * Returns the sum of two numbers
 * @param {number} a First value
 * @param {number} b Second value
 * @returns {number} Sum of a and b
 */
function sum(this: unknown, a: number, b: number) {
	return a + b;
}
/**
 * Returns the sum of two numbers
 * @param this 'this'
 * @param options Object to destructure
 * @param options.a First value
 * @param options.b Second value
 * @returns Sum of a and b
 */
function sumDestructure(this: T, { a, b }: { a: number, b: number }) {
	return a + b;
}

ESLint Config

module.exports = {
	env: {
		node: true
	},
	extends: [
		'eslint:recommended',
		'plugin:@typescript-eslint/recommended',
		'plugin:jsdoc/recommended'
	],
	parser: '@typescript-eslint/parser',
	plugins: [
		'@typescript-eslint',
		'jsdoc'
	],
	rules: {
		'jsdoc/require-param-type': 0,
		'jsdoc/require-returns-type': 0
	}
}

ESLint sample

image

/**
 * Returns the sum of two numbers
 * @param options Object to destructure
 * @param options.a First value
 * @param options.b Second value
 * @returns Sum of a and b
 */
function sumDestructure(this: unknown, { a, b }: { a: number, b: number }) {
	return a + b;
}

Environment

  • Node version: v18.16.0
  • ESLint version 8.46.0
  • eslint-plugin-jsdoc version: 48.0.2
Copy link

🎉 This issue has been resolved in version 48.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant