sb-edit icon indicating copy to clipboard operation
sb-edit copied to clipboard

Prevent naming collisions between custom blocks and scratch-js built-in methods

Open PullJosh opened this issue 5 years ago • 2 comments
trafficstars

Example of issue is here: https://scratch.mit.edu/users/PullJosh/#comments-65746024

User has a custom block called mouse. this.mouse is colliding with the built-in this.mouse. sb-edit should have a blacklist of custom block names that are not allowed.

PullJosh avatar Dec 20 '19 18:12 PullJosh

Current list of blacklisted names:

  • stage
  • direction
  • x
  • y
  • penDown
  • penColor
  • vars
  • costumeNumber
  • costume
  • mouse
  • timer
  • triggers
  • costumes
  • size
  • visible
  • penSize
  • askAndWait
  • answer
  • parent
  • clones
  • andClones
  • effects
  • rotationStyle
  • Plus "private" stuff internal to scratch-js which is prefixed by an underscore. Not concerned about collisions because sb-edit already standardizes to camelCase, so underscores will be removed.

This will need to be kept in sync with scratch-js. Is there an easy way to enforce that? (Forgetting to add a new blacklisted keyword is the kind of bug that could go under the radar for a long time.)

PullJosh avatar Dec 20 '19 19:12 PullJosh

Fixed in 68e306789d68aee6c9cbf547f117ea1cafc62d56

I think I'm going to leave this open for now as a constant reminder to keep the blacklist updated.

PullJosh avatar Dec 20 '19 19:12 PullJosh

Vetoing your decision from 3+ years ago, I think we've mostly succeeded at failing to introduce more bugs this way without needing to refer back to this issue :P

towerofnix avatar Mar 10 '23 17:03 towerofnix