Skip to content

Commit 7a5ac64

Browse files
committed
fix(log-feature): improve detection of anonymous function assignments to variables
1 parent 881b5f6 commit 7a5ac64

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to the "turbo-console-log" extension will be documented in this file.
44

5+
## [2.10.6]
6+
7+
### Fixed
8+
9+
- Improved detection of anonymous functions assigned to variable declarations, especially in cases where type annotations or complex expressions were used.
10+
511
## [2.10.5]
612

713
### Fixed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "turbo-console-log",
33
"displayName": "Turbo Console Log",
44
"description": "Automating the process of writing meaningful log messages.",
5-
"version": "2.10.5",
5+
"version": "2.10.6",
66
"publisher": "ChakrounAnas",
77
"engines": {
88
"vscode": "^1.50.0"

src/line-code-processing/js/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class JSLineCodeProcessing implements LineCodeProcessing {
6262
/(const|let|var)(\s*)[a-zA-Z0-9]*\s*=(\s*)\(.*\)(\s*){/,
6363
);
6464
const arrowFunctionAssignedToVariableRegex = new RegExp(
65-
/(const|let|var)(\s*)[a-zA-Z0-9]*\s*=.*=>.*/,
65+
/(const|let|var)\s+[a-zA-Z_$][a-zA-Z0-9_$]*\s*=\s*\([^)]*\s*(?::\s*[a-zA-Z_$][a-zA-Z0-9_$<>,\s]*)?\)\s*(?::\s*[a-zA-Z_$][a-zA-Z0-9_$<>,\s]*)?\s*=>\s*{/,
6666
);
6767
return (
6868
regularNamedFunctionRegex.test(locWithoutFunctionKeyword) ||

src/test/unit/js/loc-processing/function/named-function-declaration.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export default (): void => {
3333
];
3434
it('Should return true when LOC contains named function declaration', () => {
3535
namedFunctionsLOCs.forEach((namedFunctionLOC) => {
36+
// console.log(
37+
// '🚀 ~ namedFunctionsLOCs.forEach ~ namedFunctionLOC:',
38+
// namedFunctionLOC,
39+
// );
3640
expect(
3741
helpers.jsLineCodeProcessing.doesContainsNamedFunctionDeclaration(
3842
namedFunctionLOC,

0 commit comments

Comments
 (0)