Reports extending the prototype of native JavaScript objects.
✅ This rule is included in the ts javascript presets.
Extending native JavaScript prototypes like Array.prototype or Object.prototype affects all instances of that type across the entire codebase.
This can cause conflicts with other libraries that expect standard prototype behavior.
Future ECMAScript versions may add methods with the same name, causing unexpected behavior when those methods are overwritten.
@param ― start The index to the beginning of the specified portion of stringObj.
@param ― end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end.
If this value is not specified, the substring continues to the end of stringObj.
slice(1);
};
var Object:ObjectConstructor
Provides functionality common to all JavaScript objects.
Adds a property to an object, or modifies attributes of an existing property.
@param ― o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object.
@param ― p The property name.
@param ― attributes Descriptor for the property. It can be for a data property or an accessor property.
defineProperty(
var Array:ArrayConstructor
Array.
ArrayConstructor.prototype: any[]
prototype, "custom", {
PropertyDescriptor.value?: any
value: function() {},
});
var Object:ObjectConstructor
Provides functionality common to all JavaScript objects.
Adds one or more properties to an object, and/or modifies attributes of existing properties.
@param ― o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object.
@param ― properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property.
defineProperties(
var Object:ObjectConstructor
Provides functionality common to all JavaScript objects.
Object.
ObjectConstructor.prototype: Object
A reference to the prototype for a class of objects.
@param ― start The index to the beginning of the specified portion of stringObj.
@param ― end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end.
If this value is not specified, the substring continues to the end of stringObj.
If you are developing a polyfill library that intentionally adds missing standard methods to native prototypes, you may need to disable this rule.
Some frameworks also extend native prototypes as part of their core design, though this is increasingly rare in modern JavaScript development.