Skip to content

Commit

Permalink
fix(log-feature): improve detection of anonymous function assignments…
Browse files Browse the repository at this point in the history
… to variables
  • Loading branch information
Chakroun-Anas committed Dec 28, 2024
1 parent 881b5f6 commit 7a5ac64
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## [2.10.6]

### Fixed

- Improved detection of anonymous functions assigned to variable declarations, especially in cases where type annotations or complex expressions were used.

## [2.10.5]

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions 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": "turbo-console-log",
"displayName": "Turbo Console Log",
"description": "Automating the process of writing meaningful log messages.",
"version": "2.10.5",
"version": "2.10.6",
"publisher": "ChakrounAnas",
"engines": {
"vscode": "^1.50.0"
Expand Down
2 changes: 1 addition & 1 deletion src/line-code-processing/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class JSLineCodeProcessing implements LineCodeProcessing {
/(const|let|var)(\s*)[a-zA-Z0-9]*\s*=(\s*)\(.*\)(\s*){/,
);
const arrowFunctionAssignedToVariableRegex = new RegExp(
/(const|let|var)(\s*)[a-zA-Z0-9]*\s*=.*=>.*/,
/(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*{/,
);
return (
regularNamedFunctionRegex.test(locWithoutFunctionKeyword) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export default (): void => {
];
it('Should return true when LOC contains named function declaration', () => {
namedFunctionsLOCs.forEach((namedFunctionLOC) => {
// console.log(
// '🚀 ~ namedFunctionsLOCs.forEach ~ namedFunctionLOC:',
// namedFunctionLOC,
// );
expect(
helpers.jsLineCodeProcessing.doesContainsNamedFunctionDeclaration(
namedFunctionLOC,
Expand Down

0 comments on commit 7a5ac64

Please sign in to comment.