Skip to content
This repository was archived by the owner on Jan 14, 2019. It is now read-only.

Change the way to retrieve comments. #32

Closed
g-plane opened this issue Nov 10, 2018 · 5 comments
Closed

Change the way to retrieve comments. #32

g-plane opened this issue Nov 10, 2018 · 5 comments

Comments

@g-plane
Copy link
Contributor

g-plane commented Nov 10, 2018

Currently, this parser uses the scanner of TypeScript to retrieve comments. And there is an issue:

For example, we have code like this (please ignore the syntax highlight from GitHub):

let jsx = <div>//not a comment</div>

As we can see above, the text in the div tag is JSXText, however, the typescript-estree regards it as comment and adds it to the comments property. Note that this only affected on the comments property if the comments option is on, while the AST and the tokens property work fine.

@shmidt-i
Copy link

Thats kinda critical, because you can have <div>http://notacomment.com</div> which will be treated as a comment

@kaicataldo
Copy link
Collaborator

I've run into this as well. I'd love to look at this at some point, but need to get to the rest of my OSS backlog first! Does anyone who might be more familiar with TS's internals have an idea of how this could be achieved a different way?

@armano2
Copy link
Contributor

armano2 commented Dec 20, 2018

@kaicataldo @shmidt-i @g-plane issue is due to https://github.com/JamesHenry/typescript-estree/blob/master/src/parser.ts#L134

what you want is

jsx: extra.jsx ? ts.JsxEmit.ReactNative : undefined

but right now there is:

jsx: extra.jsx ? ts.JsxEmit.Preserve : undefined

you should be able to specify one of 3 values there: "preserve", "react", "react-native", but this will not be aligned with eslint :(

@JamesHenry
Copy link
Owner

We can switch this parser to optionally accept all the values

@armano2
Copy link
Contributor

armano2 commented Jan 4, 2019

@JamesHenry this got fixed in #82

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants