Skip to content

JSX comment value is from previous line, not comment #648

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
k2snowman69 opened this issue Jun 26, 2019 · 2 comments · Fixed by #703
Closed

JSX comment value is from previous line, not comment #648

k2snowman69 opened this issue Jun 26, 2019 · 2 comments · Fixed by #703
Labels
bug Something isn't working has pr there is a PR raised to close this package: typescript-estree Issues related to @typescript-eslint/typescript-estree

Comments

@k2snowman69
Copy link

What code were you trying to parse?

return <input 
  // Onclick
  onClick={() =>{}}
  // OnBlur
  onBlur={() =>{}} />;

What did you expect to happen?
When parsing with

  return parser.parse(text, {
    comment: true,
    errorOnUnknownASTType: false,
    jsx: true,
    loc: true,
    range: true,
    tokens: true,
    useJSXTextNode: false,
    // Override logger function with noop,
    // to avoid unsupported version errors being logged
    loggerFn: () => {}
  });

That the comments returned to contain

[
              {
                type: "Line",
                value: " Onclick",
                range: [18, 28],
                loc: {
                  start: { line: 2, column: 2 },
                  end: { line: 2, column: 12 }
                }
              },
              {
                type: "Line",
                value: " OnBlur",
                range: [50, 59],
                loc: {
                  start: { line: 4, column: 2 },
                  end: { line: 4, column: 11 }
                }
              }
            ];

What actually happened?

comments contain:

[
              {
                loc: {
                  end: { column: 15, line: 1 },
                  source: null,
                  start: { column: 0, line: 1 }
                },
                range: [0, 15],
                type: "Line",
                value: "turn <input \r"
              },
              {
                type: "Line",
                value: " Onclick",
                range: [18, 28],
                loc: {
                  start: { line: 2, column: 2 },
                  end: { line: 2, column: 12 }
                }
              }
            ];

Versions

package version
@typescript-eslint/typescript-estree 1.11.0
TypeScript 3.5.2
node 10.15.3
npm 6.5.0
@k2snowman69 k2snowman69 added package: typescript-estree Issues related to @typescript-eslint/typescript-estree triage Waiting for team members to take a look labels Jun 26, 2019
@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for team members to take a look labels Jun 26, 2019
@NickHeiner
Copy link
Contributor

I believe I've observed this same problem. I see it with @typescript-eslint/parser@1.11.0, but not with @typescript-eslint/parser@1.7.0.

Here's a repo that provides a self-contained example: https://github.com/NickHeiner/eslint-test-no-fallthrough/blob/master/index.js. Check out branch https://github.com/NickHeiner/eslint-test-no-fallthrough/blob/tslint-estree-1.7.0/index.js to see it passing with the old version.

@k2snowman69
Copy link
Author

@NickHeiner You should be able to go all the way up to @typescript-eslint/parser@1.10.2 without hitting this issue.

@bradzacher bradzacher added the has pr there is a PR raised to close this label Jul 27, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working has pr there is a PR raised to close this package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants