Some bugs are hard to notice during code reviews, or can be easily forgotten despite attempts at sharing knowledge across the team. Some of those bugs are also easy for a code linter to flag.
This linter flags common bugs I've encountered, so you can fix them before code review, and without having to remember to check for them.
Install it on VS Code: https://marketplace.visualstudio.com/items?itemName=hchiam.custom-vscode-linter
if (request.clientID)
-> should beif (request.clientID != null)
if (a = 1)
-> should beif (a == 1)
$http.get
-> should be$http.post
for a GET to work in IE (the request object can be an empty JSON).SCOPE_IDENTITY()
@@ROWCOUNT
console.log
AS BEGIN
-> should be:AS--WITH ENCRYPTION BEGIN -- comment: sp_password
Number(someID)
would evaluate to 0 if someID is empty (e.g. Number('') -> 0).
https://github.com/hchiam/custom-vscode-linter/issues
I suggest you start reading at function updateDecorations()
in src/extension.ts
- (do the usual steps to download from GitHub and navigate to folder)
npm install
(just once inside the folder)npm run watch
(every time you want to test it)- open folder in VS Code and hit F5 or go to Debug and click on the green triangle play button
- in user settings, you can customize the decoration color.
"workbench.colorCustomizations": {
"myextension.decorationType": "#ff00ff"
}
The key file to edit is extension.ts
(in the src
folder).
npm install -g yo generator-code
npm install -g vsce
yo code
_-----_ ╭──────────────────────────╮
| | │ Welcome to the Visual │
|--(o)--| │ Studio Code Extension │
`---------´ │ generator! │
( _´U`_ ) ╰──────────────────────────╯
/___A___\ /
| ~ |
__'.___.'__
´ ` |° ´ Y `
? What type of extension do you want to create? New Extension (TypeScript)
? What's the name of your extension? custom-vscode-linter
? What's the identifier of your extension? custom-vscode-linter
? What's the description of your extension? Custom VSCode Linter!
? Enable JavaScript type checking in 'jsconfig.json'? No
? Initialize a git repository? No
? Which package manager to use? npm
edit extension.ts edit README.md edit package.json (add publisher and repository)
vsce package
(in VS Code:) Ctrl+Shift+P VSIX
(get token as per steps in references)
edit package.json (update version) edit package-lock.json (update version)
vsce publish -p <token>
vsce publish
If you keep trying to use the VSIX in VS Code and it doesn't update, check if the extension is disabled.
https://itnext.io/creating-and-publishing-vs-code-extensions-912b5b8b529