Skip to content Skip to sidebar Skip to footer

How To Add The Es6 Syntax To Atom Editor

I was using sublime text, but now would like to use the atom.io editor. I have these lines of code: // error: Missing semicolon. import React, { Component } from 'react' export de

Solution 1:

In your root directory, add a new file:

.jshintrc

Add the following code and save:

{"esversion":6}

You can find the settings in using ctrl+, to open the settings and go to packages => linter-jshint (or something like that) and find the pointer to the .jshintrc file. If the file in your project structure differs, you can change that here.

Solution 2:

  1. Run npm install language-babel in the terminal.
  2. Restart Atom (if it's running)
  3. Choose babel from the list of Editor Grammars (bottom-left side of the editor on the bar you should see the current syntax grammar being used, click on it and change it to babel)

Solution 3:

Here's how you can install ESLint with Atom and configure it to have ES6 syntax:

  1. Install Atom Linter if you haven't already.
  2. Install linter-eslint.
  3. In your project directory, install eslint locally: npm install eslint
  4. Again in your project directory, create an eslint config file (name it .eslintrc)

Here's an example .eslintrc from the eslint website—see below if you want to use the Airbnb styleguide:

{"parserOptions":{"ecmaVersion":6,"sourceType":"module","ecmaFeatures":{"jsx":true}},"rules":{"semi":2}}

Alternatively, you could use the Airbnb ES6 styleguide.

  1. Install it via npm: npm install eslint-config-airbnb.
  2. Put this in your .eslintrc
{
  "extends": "airbnb"
}

Post a Comment for "How To Add The Es6 Syntax To Atom Editor"