如何将ES6语法添加到Atom编辑器 [英] How to add the es6 syntax to atom editor

查看:265
本文介绍了如何将ES6语法添加到Atom编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当时使用的是崇高的文字,但现在想使用atom.io编辑器.我有以下几行代码:

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 default class RegisterName extends Component {
    constructor(props) {

        // error: Missing semicolon.
        super(props)
        this.state = {
            firstName: '',
            lastName: '',
            displayError: false,
            error: 'Please provide a valid name'

        //error: Missing semicolon.
        }
    }


    // error: Class property must be methods. Expected '(' but saw instead '='....
    next = () => {
        console.log('next')
        console.log(this.state.firstName, this.state.lastName)
    }

    render() {
        return(
            <View style={styles.container}>
                <View>
                    <TouchableOpacity style={styles.logoContainer}>
                        <Icon name="md-analytics" size={60} color="#2ec76e" />

                    // error: Unclosed regular expression
                    </TouchableOpacity>

尽管此代码可以正常工作.我在atom.io编辑器中遇到这些错误.我用以下几行添加了.jshintrc文件:

Although this code is working fine. I'm getting these errors in atom.io editor. I have added the .jshintrc file, with these lines:

{
    "esnext": true
}

语法也设置为:Babel E6 Javascript

Also the grammar is set to: Babel E6 Javascript

但即使这样也无济于事.如何清除这些错误?

But even this is not helping. How do I remove these errors?

推荐答案

在您的根目录中,添加一个新文件:

In your root directory, add a new file:

.jshintrc

添加以下代码并保存:

{
"esversion": 6;
}

这篇关于如何将ES6语法添加到Atom编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆