Fixing Atom’s Default File Grammar for Babel

Photo by Luca Bravo on Unsplash

If you’re like me you like to use language-babel for working with your javascript files. It works really well with react, ES6, Styled Components and everything you need.

Recently Atom released an update which changes the parser that is used for detecting what type of file uses what grammar. This has the result that even with language-babel installed, it will still default to using the old javascript grammar which i find lacking.

A quick google will reveal that it can be fixed by disabling the new feature however this is a sub-optimal approach

Instead, I recommend you add this to your config.cson file (access this by searching for Application: Open Your Config`

(Make sure you add to customFileTypes if it already exists)

core:
customFileTypes:
"source.js.jsx": [
"js"
]

Save the file and restart atom for good measure.

If that doesn’t work you can disable the new parsing feature by looking towards the bottom of settings > core and uncheck Use Tree Sitter Parsers

When you create a new *.js file it should now automatically set the language to Babel.