[英]ESlint fails on compiling es6 import/export statements
我正在嘗試使用類將現有的angular應用程序轉換為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 line
ESlint拋出此錯誤“ 由於解析錯誤“導入”而無法處理源,並且“導出”可能僅與“ sourceType:模塊”一起出現 ”
我已經為ESlint添加了必要的配置,但是仍然失敗。
我在eslintrc.json中添加了以下內容
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"allowImportExportEverywhere": true,
"ecmaFeatures": {
"modules": true,
"arrowFunctions": true,
"classes": true
}
}
請幫助我如何解決此問題,另外一個完整的示例是用gulp設置es6,這將非常有幫助。
請嘗試將配置文件從eslintrc.json
重命名為.eslintrc.json
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.