Skip to content

Warn against bad JS functions #2669

@chenglou

Description

@chenglou

Inspired by #2666

JavaScript array's sorting is confusing since it compares using the stringified value. We can put a warning on that external (Js.Array.sortInPlace) to discourage its usage. I'm wondering which other Js helpers we should discourage, aka what JS functions should we discourage even if we're writing in pure JS?

  • sort
  • isNaN (use Number.isNaN instead)
  • parseInt (we can warn and ask folks to use the version with the radix instead)
  • ?

Basically, we can piggy back on ocaml's warning system as a linter. It's interesting that writing in BS (+ Reason) might allow you to write better JS here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleOld issues that went stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions