Skip to content

Commit

Permalink
0.6.0 Number(someID)
Browse files Browse the repository at this point in the history
  • Loading branch information
hchiam committed Jul 23, 2019
1 parent 4ddd85e commit 112d5c1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ All notable changes to the "custom-vscode-linter" extension will be documented i
## 0.5.0

- Added more checks ever since 0.1.0, such as reminders for SQL encryption, console.log, and testing in IE.

## 0.6.0

- Added check for `Number(someID)`
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Install it on VS Code: https://marketplace.visualstudio.com/items?itemName=hchia
BEGIN
-- comment: sp_password
```
- `Number(someID)` would evaluate to 0 if someID is empty.

## Future work / Suggestions:

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "custom-vscode-linter",
"displayName": "custom-vscode-linter",
"description": "Custom VSCode Linter!",
"version": "0.5.1",
"version": "0.6.0",
"publisher": "hchiam",
"repository": {
"type": "git",
Expand Down
8 changes: 8 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function activate(context: vscode.ExtensionContext) {
check_rowCountSQL(rangesToDecorate);
check_encryptedSQL(rangesToDecorate);
check_consoleLog(rangesToDecorate);
check_numberOfId(rangesToDecorate);
activeEditor.setDecorations(decorationType, rangesToDecorate);
}

Expand Down Expand Up @@ -108,6 +109,13 @@ export function activate(context: vscode.ExtensionContext) {
genericCheck(regex, hoverMessage, popupMessage, rangesToDecorate);
}

function check_numberOfId(rangesToDecorate: vscode.DecorationOptions[]) {
let regex = /Number\((.+)?I(d|D)\)/g;
let hoverMessage = 'If ${match[1]} is an ID but is empty, then Number(${match[1]}) evaluates to 0.';
let popupMessage = 'Number(${match[1]}) evaluates to 0 if ID is empty.';
genericCheck(regex, hoverMessage, popupMessage, rangesToDecorate);
}

function genericCheck(regex: RegExp = /^$/, hoverMessage: string = '', popupMessage: string = '', rangesToDecorate: vscode.DecorationOptions[] = []) {
if (!activeEditor) {
return;
Expand Down
4 changes: 4 additions & 0 deletions visually-check-this.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ AS--WITH ENCRYPTION
BEGIN
-- comment: sp_password // NO

Number(someOkThing); // NO
Number(someID); // YES
Number(something.someId); // YES
Number(something.someID); // YES

0 comments on commit 112d5c1

Please sign in to comment.