For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/eslint/no-prototype-builtins.md.
close

no-prototype-builtins

Added in v0.5.0

Configuration

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

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

Rule Details

This rule disallows calling Object.prototype methods directly on object instances. In particular, it flags calls to hasOwnProperty, isPrototypeOf, and propertyIsEnumerable invoked as members of a target object. Such calls can break on objects created with Object.create(null) (which do not inherit from Object.prototype) or on objects that define shadowing properties with the same names.

Examples of incorrect code for this rule:

var hasBarProperty = foo.hasOwnProperty('bar');
var isPrototypeOfBar = foo.isPrototypeOf(bar);
var barIsEnumerable = foo.propertyIsEnumerable('bar');

Examples of correct code for this rule:

var hasBarProperty = Object.prototype.hasOwnProperty.call(foo, 'bar');
var isPrototypeOfBar = Object.prototype.isPrototypeOf.call(foo, bar);
var barIsEnumerable = {}.propertyIsEnumerable.call(foo, 'bar');

Options

This rule has no options.

Original Documentation