我正在尝试使用类将我现有的角应用程序转换为es6。但是,当遇到导入/导出语句时,eslint无法编译js文件。
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 lineESlint抛出此错误“无法处理源”,因为解析错误“导入”,“导出”可能只出现在“sourceType:模块”
我已经为ESlint添加了必要的配置,但仍然失败。
我在我的eslintrc.json中添加了以下内容
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"allowImportExportEverywhere": true,
"ecmaFeatures": {
"modules": true,
"arrowFunctions": true,
"classes": true
}
}请帮助我如何解决这个问题,也是一个完整的例子,设置es6的角度与吞咽将是非常有帮助的。
发布于 2016-07-18 07:20:13
请尝试将配置文件从eslintrc.json重命名为.eslintrc.json。
https://stackoverflow.com/questions/38429478
复制相似问题