This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Added es6.erb fileType for source.js.rails #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
Sprockets 4 beta (finally) adds functionality for compiling ES6 as part of the asset pipeline. Hurray! They've decided that the filename must end in
.es6
, which when combined with.erb
like.js.erb
ends up with files likebestfileever.es6.erb
. Unfortunately, this package doesn't recognize that. This very tiny PR adds.es6.erb
to the fileType list so that it selects the file syntax correctly (currently it's guessing HTML).Here's where Sprockets describes this setup: https://github.com/rails/sprockets/blob/master/UPGRADING.md#es6-support
Benefits
People who are trying to use modern JavaScript in their Rails files won't have to suffer with HTML syntax or have to manually choose the file type over and over.
Possible Drawbacks
Sprockets might choose to use some other sane file extension (like
.js.erb
?!) but we're stuck with it for now. If that happens, this package would still be covering the existing cases.Applicable Issues
There was surprisingly no tests for fileType selection for any of the grammars, and I'm unsure how to add them. It worked on my machine® though.