Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 = (...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realised, this may NOT be the function declaration the student is using. It could be many forms, including:

export function decodedValue(...)

Ideally, we inject the function signature the student actually used here. Do you think that's something you could add? We do it in another place, where it's using the source code to extract this part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion. I added it, both here and on the analyzer pr. 🙌

```

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.