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

Add babylon as default Prettier parser #2220

Merged
merged 6 commits into from
Jan 22, 2019
Merged

Add babylon as default Prettier parser #2220

merged 6 commits into from
Jan 22, 2019

Conversation

chaucerbao
Copy link
Contributor

I'm not sure why the default let l:parser = 'babylon' was removed. babylon is the default parser for prettier.

But since it was removed, this fixer doesn't work for regular Javascript files. This PR will connect javascript file-types to the babylon parser, while keeping the current let l:parser = ''.

@chaucerbao
Copy link
Contributor Author

chaucerbao commented Jan 18, 2019

I see an explanation in this comment, but I believe it's a wrong assumption. If there is no file extension, we need to explicitly set a parser, because prettier has no idea what type of file is being passed in.

So the two solutions are:

  1. Set a default l:parser = 'babylon' to mimic prettier (solution before Javascript prettier filetype detect fix #1769).
  2. Add 'javascript': 'babylon' to the map (this current PR Add babylon as default Prettier parser #2220).

@chaucerbao
Copy link
Contributor Author

Actually, the first is a better solution. There's never a case, when there is no file extension, where you'd want prettier to auto-detect the file type, because it basically cannot. That's why there's a default parser.

I'll change this PR to reflect that.

@chaucerbao chaucerbao changed the title Add babylon parser for javascript filetypes Add babylon as default Prettier parser Jan 20, 2019
w0rp
w0rp previously approved these changes Jan 21, 2019
@w0rp
Copy link
Member

w0rp commented Jan 21, 2019

https://prettier.io/docs/en/options.html#parser It does seem like babylon has been renamed in newer versions.

@w0rp
Copy link
Member

w0rp commented Jan 21, 2019

I wonder if we might have to use the newer name for the parser for newer prettier versions.

@chaucerbao
Copy link
Contributor Author

@w0rp I added a version check to use babel for Prettier v1.16.0+, and added the test.

@w0rp w0rp merged commit f12d312 into dense-analysis:master Jan 22, 2019
@w0rp
Copy link
Member

w0rp commented Jan 22, 2019

Cheers! 🍻

@chaucerbao chaucerbao deleted the feature/add-javascript-to-prettier branch January 22, 2019 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants