oxc-project/oxc · error · OxcDiagnostic
`{obj_name}` is not a function and cannot be called
Error message
`{obj_name}` is not a function and cannot be called What it means
Lint diagnostic from eslint/no-obj-calls (check_callee): the callee of a call expression resolves to a known non-callable global object such as Math, JSON, or Reflect. Calling it throws 'TypeError: X is not a function' at runtime; the diagnostic's help states exactly that.
Source
Thrown at crates/oxc_linter/src/rules/eslint/no_obj_calls.rs:16
use oxc_allocator::ArenaBox;
use oxc_ast::{
AstKind,
ast::{Expression, IdentifierReference, MemberExpression, match_member_expression},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::AstNode;
use oxc_span::Span;
use crate::{context::LintContext, rule::Rule};
const GLOBAL_THIS: &str = "globalThis";
fn no_obj_calls_diagnostic(obj_name: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("`{obj_name}` is not a function and cannot be called"))
.with_help("This call will throw a TypeError at runtime.")
.with_label(span)
}
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct NoObjCalls;
declare_oxc_lint!(
/// ### What it does
///
/// Disallow calling some global objects as functions.
///
/// This rule can be disabled for TypeScript code, as the TypeScript compiler
/// enforces this check.
///
/// ### Why is this bad?
///
/// Some global objects are not intended to be called as functions.View on GitHub (pinned to e1e7af627c)
Solutions
- Use the intended method on the object, e.g. Math.max(...), JSON.parse(...)
- Fix the typo if a function was intended (e.g. JSON vs JSONp)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/eslint/no_obj_calls.rs:16 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/19b09a2574bec5ab.
Report an issue: GitHub.