About VSCode formatting JS automatically adding or removing semicolons

About VSCode formatting JS automatically adding or removing semicolons

introduction

It is okay to add or not add a semicolon at the end of a js code sentence. Generally, when developing a team, a unified standard is required, either adding a semicolon or not. However, sometimes we can remember to add a semicolon, and sometimes we can't remember to add it. This will cause some of our codes to have semicolons and some not, which will be messy. To solve this problem, we can use a formatter to help us automatically add or remove semicolons at the end of sentences.

The specific operation method is to type some js code first, and then use it to see the effect. If you have downloaded a lot of plug-ins and have a bunch of js formatters, then you need to configure the default formatter.

Please add a description of the image

Select Configure Default Formatter

Please add a description of the image

Select the js formatter that comes with VSCode

Please add a description of the image

Open Settings

Please add a description of the image

Open the settings json file

Please add a description of the image

Add a javascript.format.semicolons property

This attribute has three values.

The first type ignore

"javascript.format.semicolons": "ignore",

This is the default value of this property. When formatting, do not delete or add semicolons. It does not matter what happens. It is the same as when there is no configuration. I will not demonstrate it.

The second insert

"javascript.format.semicolons": "insert",

When formatting, add a semicolon at the end of the sentence, the effect is as follows:

Please add a description of the image

The third type remove

"javascript.format.semicolons": "remove",

When formatting, no semicolon is added at the end of the sentence, and the effect is as follows:

Please add a description of the image

If you need other code formatting related configurations, you can send me a private message in the comment area. I may write a few more articles about formatting configuration in the future.

This is the end of this article about how to automatically add or remove semicolons in VSCode formatted JS. For more information about VSCode formatted JS, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of using code to format configuration using the Prettier plugin in vscode
  • Implementation of VSCode formatting indented code
  • VScode formatting ESlint method (the most complete and best method)
  • Vue-cli Eslint code automatic formatting method in vscode
  • Solve the problem that vscode will automatically add semicolons and double quotes when formatting vue

<<:  Docker executes a command in a container outside the container

>>:  Using HTML web page examples to explain the meaning of the head area code

Recommend

Ten useful and simple MySQL functions

function 0. Display current time Command: select ...

WeChat applet to obtain mobile phone number step record

Preface Recently, I encountered such a problem wh...

Automatic backup of MySQL database using shell script

Automatic backup of MySQL database using shell sc...

Example of using Docker to build an ELK log system

The following installations all use the ~/ direct...

An article teaches you JS function inheritance

Table of contents 1. Introduction: 2. Prototype c...

Summary of important components of MySQL InnoDB

Innodb includes the following components 1. innod...

A detailed introduction to HTML page loading and parsing process

The order in which the browser loads and renders H...

JavaScript implements fireworks effects with sound effects

It took me half an hour to write the code, and th...

mysql 8.0.19 win10 quick installation tutorial

This tutorial shares the installation tutorial of...

Detailed explanation of the getBoundingClientRect() method in js

1. getBoundingClientRect() Analysis The getBoundi...

Example code of html formatting json

Without further ado, I will post the code for you...

Idea configures tomcat to start a web project graphic tutorial

Configure tomcat 1. Click run configuration 2. Se...

Common symbols in Unicode

Unicode is a character encoding scheme developed ...

Detailed explanation of MySQL syntax, special symbols and regular expressions

Mysql commonly used display commands 1. Display t...

Tutorial on installing MySQL 5.7.18 decompressed version on Windows

1. Installation process MySQL version: 5.7.18 1. ...