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/require-param produces syntactically invalid code #771

Closed
RunDevelopment opened this issue Jul 19, 2021 · 5 comments
Closed

jsdoc/require-param produces syntactically invalid code #771

RunDevelopment opened this issue Jul 19, 2021 · 5 comments

Comments

@RunDevelopment
Copy link

Expected behavior

When given a single-line doc-comment, the rule should add new lines when adding tags.

E.g.

/** Foo. */
function foo(a, b, c) {}

to

/**
 * Foo.
 * @param a
 * @param b
 * @param c
 */
function foo(a, b, c) {}

Actual behavior

* @param a
* @param b
* @param c
/** Foo. */
function foo(a, b, c) {}

Note: This happens with both ESLint and the VSCode ESLint extension.

ESLint Config

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

ESLint sample

/** Foo. */
function foo(a, b, c) {}

Example project.

Environment

  • Node version: v14.15.4
  • ESLint version v7.26.0
  • eslint-plugin-jsdoc version: 35.4.1
@gajus
Copy link
Owner

gajus commented Jul 20, 2021

🎉 This issue has been resolved in version 35.4.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Jul 20, 2021
@brettz9
Copy link
Collaborator

brettz9 commented Jul 20, 2021

I changed the behavior to create a normal multiline comment out of a single line comment per your example when missing tags were present.

However, I did not change handling for:

/** up here
*/

nor:

/**
 * down here */

...which will currently add the tags below and above the text, respectively.

@RunDevelopment
Copy link
Author

...which will currently add the tags below and above the text, respectively.

So the rule still produces syntactically invalid code?

@brettz9
Copy link
Collaborator

brettz9 commented Jul 20, 2021

...which will currently add the tags below and above the text, respectively.

So the rule still produces syntactically invalid code?

No.

It will produce:

/** up here
 * @param a
 * @param b
 * @param c
 */
/**
 * @param a
 * @param b
 * @param c
 * down here */

I don't want to get too far into policing where people want things. The latter is semantically invalid, but I'm not planning on adding time and complexity to address every possible bad case.

The single line comment is a reasonable one to support, and that has been fixed.

@RunDevelopment
Copy link
Author

Thank you for the clarification!

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

No branches or pull requests

3 participants