close

no-obj-calls

Configuration

PresetConfigured Value
✅ js.configs.recommended"error"
rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-obj-calls': 'error',
    },
  },
]);

Rule Details

Disallows calling global objects (Math, JSON, Reflect, Atomics, Intl) as functions or constructors. These are namespace objects that provide properties and methods but are not themselves callable. Attempting to call them will throw a TypeError at runtime.

Examples of incorrect code for this rule:

var x = Math();
var y = JSON();
var z = Reflect();
var a = new Math();
var b = new JSON();

Examples of correct code for this rule:

var x = Math.random();
var y = JSON.parse('{}');
var z = Reflect.get(obj, 'key');
var a = new Intl.Segmenter();
var b = Math.PI;

Original Documentation