How can code with multiple empty line using Prettier (Vs Code)? - visual-studio-code

Before saving:
Before
After saving:
After
I couldn't find anything on Prettier settings.

Related

Where is the Terminal's formatting defined in VS Code?

I cannot locate the settings or other configurations that define the colors and other formatting shown in VS Code's Terminal output. I'd like to mimic or use these settings elsewhere, such as in word processing software, HTML/CSS, or simply a Language Mode when copying & pasting the output into a new VS Code file.
Where is this formatting defined? Also, how can I keep this formatting intact when using the text elsewhere?

How to disable VS Code prettier from deleting extra parenthesis

I'm using prettier in VS Code for typescript. It always remove extra parenthesis, for example
(new Controller()).setData(data).run();
will always be format into
new Controller().setData(data).run();
Which rules handle this deletion? I did see a similar rule in eslint: no-extra-parens. However, I am not using this rule in my eslint file.

Prettier Code Formatter for VS code fails with 'No loader specified for extension ".cjs"'

In VS Code, When I select Format Document With... then choose Prettier - Code Formatter, I get the following error:
Command 'Format Document' resulted in an error (No loader specified for extension ".cjs", so searchPlaces item ".prettierrc.cjs" is invalid)
From what I can gather this has something to do with underlying TypeScript in VS Code not having a loader available for .cjs files and Prettier searching for prettierrc.cjs but I can't quite see how that all fits together, or how to work around it.
Has anyone else encountered, found a work around or solved this or a similar issue in VS Code?
I tried disabling the Prettier VS Code extension and enabling it again and that fixed the issue for me.
Credits #NikolajDamLarsen

Autocomplete for the require statement in VS Code

I can't find anything straight and to the point on why VS Code's intellisense doesn't show a suggestion for the require() statement. E.g. const EventEmitter = require('events'); Why is it that require() doesn't appear in intellisense? I've looked at the settings.json file and tried a number of VS Code extensions, but can't get this to work. What am I leaving out?

Prevent Intellisense from inserting semicolons in VS Code

We don't use semicolons in TypeScript. Each time Intellisense in VS code (v1.18.1) inserts a line, it terminates it with ;. Example would be an import statement.
Is it possible to configure VS Code not to append semicolons? Very inefficient right now to have to delete them manually.
TSLint semicolon rule (has autofix)
TSLint extension for vscode
tslint.json rules section:
"semicolon": [true, "never"]
settings.json Ctrl+,
"tslint.autoFixOnSave": ["semicolon"]
There is an open issue about it https://github.com/Microsoft/TypeScript/issues/19882
If you're using Prettier add to settings.json
"prettier.semi": false
And then in tslint.json
"semicolon": [true, "never"],
TypeScript 3.6 is now able to detect whether your file uses semicolons or not, which can be leveraged in VS Code for quick fixes, refactorings, transformations (e.g. auto import) and other features. It is called Semicolon-Aware Code Edits.
Editors like Visual Studio and Visual Studio Code can automatically apply quick fixes, refactorings, and other transformations like automatically importing values from other modules. These transformations are powered by TypeScript, and older versions of TypeScript unconditionally added semicolons to the end of every statement; unfortunately, this disagreed with many users’ style guidelines, and many users were displeased with the editor inserting semicolons.
TypeScript is now smart enough to detect whether your file uses semicolons when applying these sorts of edits. If your file generally lacks semicolons, TypeScript won’t add one.