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

leadingComments of anonymous class export are broken. #158

Closed
h13i32maru opened this issue Jul 5, 2015 · 6 comments
Closed

leadingComments of anonymous class export are broken. #158

h13i32maru opened this issue Jul 5, 2015 · 6 comments

Comments

@h13i32maru
Copy link

Hi! I use Espree in ESDoc.

A leadingComments position are unexpected, when I parse following code with Espree.

/**
 * this is anonymous class.
 */
export default class {
  /**
   * this is method1.
   */
  method1(){
  }
}

2015-07-05 12 06 17

(full JSON https://gist.github.com/h13i32maru/f22536ca8c224e08cc9e)

Espree option:

  {
      comments: true,
      attachComment: true,
      loc: true,
      ecmaFeatures: {
        arrowFunctions: true,
        blockBindings: true,
        destructuring: true,
        regexYFlag: true,
        regexUFlag: true,
        templateStrings: true,
        binaryLiterals: true,
        octalLiterals: true,
        unicodeCodePointEscapes: true,
        defaultParams: true,
        restParams: true,
        forOf: true,
        objectLiteralComputedProperties: true,
        objectLiteralShorthandMethods: true,
        objectLiteralShorthandProperties: true,
        objectLiteralDuplicateProperties: true,
        generators: true,
        spread: true,
        classes: true,
        modules: true,
        jsx: true,
        globalReturn: true
      }
  };

Thank you.

@nzakas
Copy link
Member

nzakas commented Jul 6, 2015

Can you explain what's wrong? I can't tell from your screenshot.

@nzakas nzakas added the question label Jul 6, 2015
@h13i32maru
Copy link
Author

Sorry, I explain it.

this is anonymous class. is commented on export default class, but the comment is inserted into leadingComments of method1().

49c8d898-230e-11e5-8bff-99a130e48cb3

Is this would be the correct behavior?
I expect that the comment is inserted into leadingComments of ExportDefaultDeclaration.

@nzakas
Copy link
Member

nzakas commented Jul 8, 2015

Thanks for explaining. Yeah, that looks like a bug to me.

@mysticatea
Copy link
Member

I will try to fix this.

mysticatea added a commit to mysticatea/espree that referenced this issue Jul 10, 2015
@nzakas
Copy link
Member

nzakas commented Jul 10, 2015

Thanks @mysticatea

@nzakas nzakas closed this as completed in d535900 Jul 10, 2015
nzakas added a commit that referenced this issue Jul 10, 2015
…onymouse-class

Fix: Leading comments for anonymous classes (fixes: #158)
@h13i32maru
Copy link
Author

@mysticatea Thank you ✨

arv added a commit to arv/babel that referenced this issue Mar 6, 2019
The fix for eslint/js#158 has an error; If
`lastChild === node` it ended up removing comments.
arv added a commit to arv/babel that referenced this issue Mar 6, 2019
The fix for eslint/js#158 has an error; If
`lastChild === node` it ended up removing comments.
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