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 applied incorrectly for require-jsdoc with MethodDefinition: true #522

Closed
ege24 opened this issue Apr 29, 2020 · 2 comments
Closed

Fix applied incorrectly for require-jsdoc with MethodDefinition: true #522

ege24 opened this issue Apr 29, 2020 · 2 comments

Comments

@ege24
Copy link

ege24 commented Apr 29, 2020

Example code

/**
 *
 */
export class Class {
    test = 1;

    foo() {
        this.test = 2;
    }
}

fix result:

/**
 *
 */
export class Class {
    test = 1;

    foo/**
 *
 */
() {
        this.test = 2;
    }
}

Very similar to #403 but for Method Definitions

@brettz9
Copy link
Collaborator

brettz9 commented Apr 29, 2020

Yeah, no doubt this is due to the same core issue, so closing as a dupe of #403. I am too preoccupied with other work to examine this, but someone with a little time should be able to figure this out by looking at https://github.com/syavorsky/comment-parser and our use of it, particularly its stringify methods.

(For someone ambitious, it would be nice to address #483 in the same go, as the parsing of comment-parser may also need to be enhanced to preserve more whitespace info--which would then need to be properly stringified.)

@brettz9 brettz9 closed this as completed Apr 29, 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants