代码格式化程序删除所需的换行符

时间:2017-11-29 14:16:43

标签: vue.js visual-studio-code eslint prettier

我在vue.js项目中使用visual studio代码。

我安装了Eslint,vutur和更漂亮的代码格式化程序。

我的问题:

1    import Aside from './Aside.vue'
2    import Breadcrumb from './Breadcrumb.vue'
3    import Callout from './Callout.vue'
4    import Footer from './Footer.vue'
5    import Header from './Header.vue'
6    import Sidebar from './Sidebar.vue'
7    import Switch from './Switch.vue'
8    
9    export { Aside, Breadcrumb, Callout, Footer, Header, Sidebar, Switch }
10

CTR + S 保存文件给我这个:

1    import Aside from './Aside.vue'
2    import Breadcrumb from './Breadcrumb.vue'
3    import Callout from './Callout.vue'
4    import Footer from './Footer.vue'
5    import Header from './Header.vue'
6    import Sidebar from './Sidebar.vue'
7    import Switch from './Switch.vue'
8    
9    export { Aside, Breadcrumb, Callout, Footer, Header, Sidebar, Switch }

导致eslint说:

  

文件末尾但未找到新行

这只发生在.js文件中。

我的设置:

{
    "window.zoomLevel": 0,
    "javascript.format.enable": false,
    "javascript.validate.enable": false,
    "prettier.eslintIntegration": true,
    "editor.formatOnSave": true,
    "prettier.singleQuote": true,
    "prettier.trailingComma": "none",
    "prettier.semi": false,
    "prettier.useTabs": false,
    "prettier.bracketSpacing": true,
    "prettier.jsxBracketSameLine": true
}

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

根据此处所述的同一问题https://github.com/vuejs/vue-cli/issues/11 您必须将vue-loader版本更新为class Girl: gender = "female" def __init__(self, name:str): self.name = name self.name.capitalize() # <- Pycharm shows me capitalize() as a method of name:str def capitalize_name(self): """ :cvar name:str # <- :type name:str # <--- These don't :cvar self.name:str # <--- help either :type self.name:str # <- """ self.name = self.name..... # <- Pycharm does not know the type of self.name alice = Girl(name="Alice") alice.capitalize_name()

或者在导致错误的行上面使用它

vue-loader@8.0.2.