Skip to content

Fix applied incorrectly for require-jsdoc with FunctionExpression: true #403

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

Closed
nemovc opened this issue Oct 17, 2019 · 1 comment
Closed

Comments

@nemovc
Copy link

nemovc commented Oct 17, 2019

When attempting to apply the fix for 'jsdoc/require-jsdoc': ['warn', { require: { FunctionExpression: true } }],, the output is garbled, with the jsdoc /** * */ being inserted in the wrong location. I've provided a simple MRE to demonstrate the issue.

The empty jsdoc comment is inserted exactly prior to the function itself, e.g.,

e = /**
 * 
 */
function () {
}

when it should be placed prior to the naming token e.g.,

/**
 *
 */
e = function () {
}

Additionally, in certain circumstances (functions as properties of an element) the fix is not idempotent, and will keep reapplying (see first example in MRE)

@brettz9 brettz9 added the bug label Oct 18, 2019
@brettz9 brettz9 mentioned this issue Oct 18, 2019
16 tasks
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue May 3, 2020
gajus#403, gajus#502, gajus#522

Properly finds base node for affixing jsdoc block and uses to determine appropriate indent (finds base node in a manner sensitive to context, reusing existing and more accurate detection for this purpose, improving detection for function expressions, including arrow function expressions and method definitions).

As part of `getReducedASTNode` (used also within `getJSDocComment`), need to stop at `VariableDeclaration` or `ExpressionStatement` (where comments shouldl be checked). Needed for proper function expression documentation placement.

Also provides `getJSDocComment` as a named export
brettz9 added a commit to dstaley/eslint-plugin-jsdoc that referenced this issue May 3, 2020
* master:
  fix(require-jsdoc): placement of jsdoc block by fixer; fixes gajus#369, gajus#403, gajus#502, gajus#522
  chore(travis): check Node 14
@brettz9
Copy link
Collaborator

brettz9 commented May 3, 2020

@brettz9 brettz9 closed this as completed May 3, 2020
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