-
-
Couldn't load subscription status.
- Fork 74
Breaking: Infer parsing as JSX from file extension (fixes #399) #436
Conversation
|
The reasons not to distinguish I can understand having a lint rule that requires the |
|
@shawnrice It's actually not quite the same thing. In TypeScript, |
|
I think that this point breaking changes are pretty expected here as things are still moving pretty fast. I at least am totally ok with this. |
|
Very cool, thanks for exploring this @kaicataldo! @azz I think prettier will only benefit from this, right? We could potentially get rid the of the heuristics in https://github.com/prettier/prettier/blob/master/src/language-js/parser-typescript.js Prettier is the only known programmatic consumer at this point. |
|
Currently it is possible to use Prettier without passing a file path: So we'd have to keep the try tsx then ts behaviour at least in that case, but it would be a welcome improvement. |
|
How are we feeling about this? |
|
Other than updating it to be a breaking change I think it is good to go! |
|
Sorry I lost track of this. Besides for updating the commit message/PR title, what else needs to be done to update it to a breaking change? Also, it looks like snapshot tests are failing. My naive guess is that it has something to do with filename extensions of fixture files, but I'll take a look and see what's going on. |
|
If the snapshots fail it's still a breaking change (see my comment above) |
|
@azz Mind clarifying what you mean? I thought we decided this was a breaking change. |
|
@kaicataldo Since this was first created I added a lot more sophisticated integration testing: https://github.com/eslint/typescript-eslint-parser#integration-tests Please could you add some for this? You can ping me in ESLint chat if anything is unclear |
|
@kaicataldo If you are interested in reopening this against the new project, please feel free, otherwise I will happily reimplement this myself of there. Thanks again! |
fixes #399
This is a WIP implementation of inferring whether the parser should parse in JSX mode or not based on the file extension of the file being parsed. Wanted to have a place to start a discussion, and then when we decide how we want to proceed finish this up.
This is a breaking change for users who are running ESLint on files (and therefore have a filepath). However, I can't think of a reason why you'd ever want the behavior to be different.
That being said, I believe that we do need to keep the behavior to set it manually for when a filepath is not provided, since we don't know whether it should be parsed in JSX mode or not. Example:
A few questions I have:
{ isParseForESLint: true }, or would this be a welcome change for others in the community as well?parserOptions.ecmaFeatures.jsxdefined in their configuration. How does the team feel about this?