Unnecessary semicolon using Sublime Text 3 autocomplete for JavaScript if-statement

I use sublime text 3 autocomplete for JavaScript.

In the case of if-statement, he added a semicolon at the end.

if (true) {}; 

Using JSHint, this gives me an error for most of the written code.

I would like to ask how to configure this autocomplete as my preference?

+5
source share
2 answers

Open the Sublime Text Folder by choosing PreferencesBrowse Packages .

Then find the folder named JavaScript

Then open if.sublime-snippet and remove the half-hour so that your snippet now looks like this:

 <snippet> <content><![CDATA[if (${1:true}) {${0:$TM_SELECTED_TEXT}}]]></content> <tabTrigger>if</tabTrigger> <scope>source.js</scope> <description>if</description> </snippet> 
+6
source

Since @wesbos answer didn't help, here is what I found out.

Sublime 3 does not retrieve packages. You will find your packages (on linux) in /opt/sublime_text/Packages/ for the default packages or ~/.config/sublime-text-3/Installed Packages for the packages you installed in the zip archive with the extension .sublime-package .

To change the contents of a package, install the package resource viewer and run the command : Open resource to go to the file you want to change ( if.sublime-snippet , I would also change for-()-{}.sublime-snippet , so as it has the same weird semicolon there) and edit it.

After saving the file, it will save it to ~/.config/sublime-text-3/Packages/JavaScript/if.sublime-snippet . This file then overwrites the default file in the original zip package.

As I understand it, it is important to know that the files that you overwrite in this way will not be updated when the packages are updated, since they overwrite everything that is in the updated package!

0
source

Source: https://habr.com/ru/post/1207189/


All Articles