Skip to content

globalObjectCalls

Reports calling global objects like Math, JSON, or Reflect as functions.

✅ This rule is included in the ts untyped preset.

The global objects Math, JSON, Reflect, and Atomics are not constructors or functions. They are built-in objects that provide utility methods and properties as namespaces. Attempting to call them as functions or instantiate them with new will result in a TypeError at runtime.

const result = Math();
const data = JSON();
const reflected = Reflect();
const instance = new Atomics();

This rule is not configurable.

If your codebase redefines these objects, you likely will not want to enable this rule. Otherwise this rule should generally always be enabled, as calling these global objects as functions will always result in a runtime error.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.