简体   繁体   English

为什么 prettier.semi 不在我的 JavaScript 文件中添加任何分号?

[英]why prettier.semi not adding any semicolons on my JavaScript files?

This one of my files that prettier didn't add any semicolons but format it well,这是我的一个更漂亮的文件,没有添加任何分号,但格式很好,

function usercreate(name,score){
        this.name = name 
        this.score = score
        }
        usercreate.prototype.increment=function(){
            this.score++
            console.log(this.score)
        }
        usercreate.prototype.login=function(){
            console.log("loged in")
        }
    const user1=new usercreate("zahal",100)
    user1.increment()
    user1.login()
    const user2=new usercreate("sam",01)
    user2.increment()
    user2.login()

and this is my v-code setting.json这是我的 v 代码设置。json

{
    "workbench.colorTheme": "Visual Studio Light",
    "security.workspace.trust.untrustedFiles": "open",
    "prettier.semi": true
}

and I don't use Eslint而且我不使用 Eslint

How I've sorted it after having super huge frustrations with Prettier stopping working in VSCode.在对 Prettier 停止在 VSCode 中工作感到非常沮丧之后,我是如何对它进行排序的。

  1. Select VS Code -> View -> Command Palette , and type: Format Document With Select VS Code -> View -> Command Palette ,然后输入: Format Document With
  2. Then Configure Default Formatter ... and then choose Prettier - Code formatter .然后Configure Default Formatter ... 然后选择Prettier - Code formatter

This sorted the problem for me magically.这神奇地为我解决了问题。

Depending on your case this might help you...根据您的情况,这可能会帮助您......

go to setting and type word semi it will show this if it's not checked then checked it and try again go 设置并键入 word semi 如果未选中,它将显示此内容,然后选中并重试在此处输入图像描述

enter image description here在此处输入图像描述

Write these words in the setting search bar and make sure to change the default option to the insert option I hope this helps you.在设置搜索栏中写下这些词,并确保将默认选项更改为插入选项我希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM