首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ESlint编译es6导入/导出语句失败

ESlint编译es6导入/导出语句失败
EN

Stack Overflow用户
提问于 2016-07-18 05:58:13
回答 1查看 1K关注 0票数 3

我正在尝试使用类将我现有的角应用程序转换为es6。但是,当遇到导入/导出语句时,eslint无法编译js文件。

代码语言:javascript
复制
class HeaderController {

    constructor($rootScope, $scope) {
        this.$rootScope = $rootScope;
        this.$scope = $scope;
    }

    changeNavItem(selectedTab) {
        this.activeNavItem = selectedTab;
    }

    init() {
        this.activeNavItem = 'All';
    } }

HeaderController.$inject = ['$rootScope', '$scope'];

angular.module('app')
    .controller('HeaderController', HeaderController);

export default HeaderController; // fails on this line

ESlint抛出此错误“无法处理源”,因为解析错误“导入”,“导出”可能只出现在“sourceType:模块”

我已经为ESlint添加了必要的配置,但仍然失败。

我在我的eslintrc.json中添加了以下内容

代码语言:javascript
复制
"parserOptions": {
        "ecmaVersion": 6,
        "sourceType": "module",
        "allowImportExportEverywhere": true,
        "ecmaFeatures": {
            "modules": true,
            "arrowFunctions": true,
            "classes": true
        }
    }

请帮助我如何解决这个问题,也是一个完整的例子,设置es6的角度与吞咽将是非常有帮助的。

EN

回答 1

Stack Overflow用户

发布于 2016-07-18 07:20:13

请尝试将配置文件从eslintrc.json重命名为.eslintrc.json

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38429478

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档