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

Breaking: switch 'jsx' option by filename (fixes #517) #543

Merged
merged 5 commits into from
Nov 9, 2018
Merged

Conversation

mysticatea
Copy link
Member

@mysticatea mysticatea commented Nov 8, 2018

This PR makes the parser setting jsx option by filename automatically.

  • *.ts ... it sets jsx: false.
  • *.tsx ... it sets jsx: true.
  • Otherwise (E.g., *.js, not provided, etc...) ... respects the given jsx option.

(Edited at 2018-11-08 20:52Z)

Fixes #517.

@mysticatea mysticatea added enhancement breaking This change is backwards-incompatible labels Nov 8, 2018
Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I have a few questions/concerns.

Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to let this block the PR, but my two cents would be that this option has outgrown its boolean type.

It would be far clearer to have an enum of possible strings:

jsx: 'disabled' | 'enabled' | 'auto'

Or something like that, where 'auto' or 'infer' or similar is the option that looks at your file extension. You could also provide fallback of false being the same as 'disabled' and true being the same as 'enabled' so as not to break anyone.

@mysticatea
Copy link
Member Author

@JamesHenry Thank you for the review.

The intention of this PR's spec is:

  • It's always "auto" essentially because we cannot configure it on tsc -- we cannot use JSX syntax on *.ts files and cannot disable JSX syntax on *.tsx files on tsc. So the jsx option on TypeScript files doesn't make sense.
  • But people may use this parser on other files such as *.js. Or if people use stdin, the filename is unknown. This jsx option is provided for such a case.
    E.g., curl a_url | eslint --stdin --perser-options jsx:true

@JamesHenry
Copy link
Member

Ah I see, I get it now, thanks!

@kaicataldo kaicataldo merged commit 2d22321 into master Nov 9, 2018
@kaicataldo
Copy link
Member

Thanks for contributing!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking This change is backwards-incompatible enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants