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

Fix apply require-jsdoc for ArrowFunctionExpression #502

Closed
winor30 opened this issue Mar 16, 2020 · 2 comments
Closed

Fix apply require-jsdoc for ArrowFunctionExpression #502

winor30 opened this issue Mar 16, 2020 · 2 comments

Comments

@winor30
Copy link

winor30 commented Mar 16, 2020

It seemed that auto fixing by require-jsdoc is incorrect.
This bug add jsdoc comment to incorrect position in arrow function case.
If you would like to check, running the command in bellow with the repository is reproduction the bug.

$ cat index.js
const hello = name => {
  document.body.textContent = "Hello, " + name + "!";
};

hello("World");

$ npx eslint --fix index.js

$ cat index.js
const hello = /**
 *
 */
name => {
  document.body.textContent = "Hello, " + name + "!";
};

hello("World");
@brettz9
Copy link
Collaborator

brettz9 commented Mar 17, 2020

Seems essentially the same as #403, so closing. Feel free to subscribe there, or if you think the issue is different (beyond being about arrow vs. non-arrow expressions), feel free to comment further here.

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

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

2 participants