Skip to content

Commit 52b4a06

Browse files
committed
Add prefer_extracted_top_level_constant analyzer comment to javascript resistor color duo (exercism/javascript-analyzer#127)
1 parent 8b47b7a commit 52b4a06

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# prefer extracted top level constant
2+
3+
Consider extracting the constant to the top level scope:
4+
5+
```javascript
6+
const %{name} = %{value}
7+
8+
// the rest of your code below it
9+
export const decodedValue = (...)
10+
```
11+
12+
Only functions, classes and constants that are `export`ed, are visible and
13+
accessible from the outside. These constants can live in the same
14+
file without being exposed to other code. Also, extracting constants saves memory
15+
by avoiding repeated allocations in functions when those same constants are reused.

0 commit comments

Comments
 (0)