From 52b4a068e5b42d842fbdfb654d5f6666ac153eab Mon Sep 17 00:00:00 2001 From: Frans Date: Thu, 20 Feb 2025 20:09:23 +0200 Subject: [PATCH 1/3] Add prefer_extracted_top_level_constant analyzer comment to javascript resistor color duo (exercism/javascript-analyzer#127) --- .../prefer_extracted_top_level_constant.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md diff --git a/analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md b/analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md new file mode 100644 index 000000000..83d59c238 --- /dev/null +++ b/analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md @@ -0,0 +1,15 @@ +# prefer extracted top level constant + +Consider extracting the constant to the top level scope: + +```javascript +const %{name} = %{value} + +// the rest of your code below it +export const decodedValue = (...) +``` + +Only functions, classes and constants that are `export`ed, are visible and +accessible from the outside. These constants can live in the same +file without being exposed to other code. Also, extracting constants saves memory +by avoiding repeated allocations in functions when those same constants are reused. From eaef42290af876d836f0224fe46893c8d49bbc50 Mon Sep 17 00:00:00 2001 From: Frans Bothma <52746596+Steffe-Dev@users.noreply.github.com> Date: Wed, 5 Mar 2025 21:14:20 +0200 Subject: [PATCH 2/3] Format analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md Co-authored-by: Derk-Jan Karrenbeld --- .../prefer_extracted_top_level_constant.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md b/analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md index 83d59c238..97dec316d 100644 --- a/analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md +++ b/analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md @@ -9,7 +9,6 @@ const %{name} = %{value} export const decodedValue = (...) ``` -Only functions, classes and constants that are `export`ed, are visible and -accessible from the outside. These constants can live in the same -file without being exposed to other code. Also, extracting constants saves memory -by avoiding repeated allocations in functions when those same constants are reused. +Only functions, classes and constants that are `export`ed, are visible and accessible from the outside. +These constants can live in the same file without being exposed to other code. +Also, extracting constants saves memory by avoiding repeated allocations in functions when those same constants are reused. From f3f128c848f9a7804db01ac20cfe84496f29f639 Mon Sep 17 00:00:00 2001 From: Frans Stefanus Bothma Date: Thu, 6 Mar 2025 18:50:02 +0200 Subject: [PATCH 3/3] add exported method to prefer_extracted_top_level_constant in js resistor_color_duo --- .../resistor-color-duo/prefer_extracted_top_level_constant.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md b/analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md index 97dec316d..f1e5e835a 100644 --- a/analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md +++ b/analyzer-comments/javascript/resistor-color-duo/prefer_extracted_top_level_constant.md @@ -6,7 +6,7 @@ Consider extracting the constant to the top level scope: const %{name} = %{value} // the rest of your code below it -export const decodedValue = (...) +export %{method.signature} ``` Only functions, classes and constants that are `export`ed, are visible and accessible from the outside.