Skip to content

Monkey patching detection #476

@fraxken

Description

@fraxken

Implement a new warning (and probe) monkey-patch when native JavaScript prototype are overrided.

Array.prototype.map = function() {};

My idea is to iterate step by step to implement the new probe:

  • Detect AssignExpression of prototypes and usage of Object.defineProperty
  • Use VariableTracer to detect re-assignment
  • Resolve evaluation (eval)

We can take inspiration from the no-extend-native rule of ESLint: https://eslint.org/docs/latest/rules/no-extend-native

Code itself can be an inspiration too: https://github.com/dustinspecker/eslint-plugin-no-use-extend-native/blob/main/src/no-use-extend-native.js


List of JavaScript types are available here: https://github.com/sindresorhus/js-types/blob/main/js-types.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions