Here’s a quick recipe to get linting and autocomplete with support for ES6 and JSX.
Tested in OS-X only, assumes you have the following installed already:
- Package Control
The Babel Sublime Text package adds Syntax settings with good highlighting for ES6 and JSX. It’s a must-have!
Eslint is the modern linter of choice, but have a look at all these rules and decide if you really want to spend your time configuring them.
Make your choice and install it in your project (
--save-dev) or globally (
npm install --save-dev semistandard
Then install the matching SublimeLinter-contrib-standard or SublimeLinter-contrib-semistandard package via Package Control.
In your project you should now see warnings about unused vars, indentation and newlines. If not, check the console ( ctrl+` ) and make sure the linter installed correctly!
Start by installing the tern_for_sublime package via Package Control.
After installation, Sublime should prompt you to install the tern node package as well.
If tern has issues launching npm or node on OS-X, it probably has not inherited your path properly. There are two options to fix this:
- Start Sublime from the terminal using
- Install the FixMacPath package.
In the root of your project create a .tern-project file with the following contents:
You should a list of es6 array functions after typing
You front-end packager (browserify or webpack) should already be using Babel to transpile ES6 for current browser support.
The same transpilation will be necessary to run your jasmine tests. Install jasmine-es6 to automate this for you:
npm install jasmine-es6
In the project’s package.json, add a
"test": "jasmine" line under scripts.
Finally, add a build system to Sublime with the following content.
You should now be able to run your tests with with
super+b and navigate to errors with