Back to all reviewers

Function invocation syntax

oven-sh/bun
Based on 2 comments
JavaScript

Use the appropriate invocation syntax for functions based on their intended usage. Regular functions should be called directly without the `new` keyword, while constructor functions (typically capitalized) should be instantiated with `new`.

Code Style JavaScript

Reviewer Prompt

Use the appropriate invocation syntax for functions based on their intended usage. Regular functions should be called directly without the new keyword, while constructor functions (typically capitalized) should be instantiated with new.

Incorrect:

// Using constructor syntax with a regular function
const context2 = new vm.createContext(context);

Correct:

// Calling a regular function properly
const context2 = vm.createContext(context);

// Using constructor syntax with an actual constructor
const myDate = new Date();

This distinction is important for code correctness and readability. Using new with a non-constructor function can lead to unexpected behavior, while omitting new when required can cause the function to execute in the global context instead of creating a new object instance.

2
Comments Analyzed
JavaScript
Primary Language
Code Style
Category

Source Discussions