Skip to content

Commit

Permalink
fix #15 after more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hchiam committed Jul 25, 2019
1 parent c8383f8 commit 2508707
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
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.6.1",
"version": "0.6.2",
"publisher": "hchiam",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function activate(context: vscode.ExtensionContext) {
}

function check_ifIdWithoutNotNull(rangesToDecorate: vscode.DecorationOptions[]) {
let regex = /if ?\(([^=)]*[iI][dD](?!\.)\b) ?[^=<>\r\n]*?\)/g;
let regex = /if ?\(([^=!)]*[iI][dD](?!\.)\b) ?[^=<>\r\n]*?\)/g;
let hoverMessage = 'An ID of 0 would evaluate to false. Consider: ${match[1]} != null';
let popupMessage = 'ID of 0 would evaluate to false. Consider adding "!= null" for if-statements containing IDs: ${errors.join(", ")}';
genericCheck(regex, hoverMessage, popupMessage, rangesToDecorate);
Expand Down Expand Up @@ -110,7 +110,7 @@ export function activate(context: vscode.ExtensionContext) {
}

function check_numberOfId(rangesToDecorate: vscode.DecorationOptions[]) {
let regex = /Number\((.+?I(d|D))\)/g;
let regex = /\WNumber\(([^!]?[^|)]*?I(d|D))\)/g;
let hoverMessage = 'If ${match[1]} is an ID but is empty, then Number(${match[1]}) evaluates to 0 (e.g. Number("") -> 0).';
let popupMessage = 'Number(someId) evaluates to 0 if someId is empty (e.g. "").';
genericCheck(regex, hoverMessage, popupMessage, rangesToDecorate);
Expand Down
9 changes: 8 additions & 1 deletion visually-check-this.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,16 @@ BEGIN // YES

AS--WITH ENCRYPTION
BEGIN
-- comment: sp_password // NO
--comment: sp_password // NO

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

getNumber(something.someId || somethingElse.someOtherId); // NO

if (!equipmentId) {} // NO

Number(someId || -1) // NO
Number(-1 || someId) // NO

0 comments on commit 2508707

Please sign in to comment.