htmx icon indicating copy to clipboard operation
htmx copied to clipboard

Get rid of latest usages of substr

Open scrhartley opened this issue 1 year ago • 2 comments

Description

Follow up to #2951. Replace more usages of deprecated String.prototype.substr.

Should I just keep making these, or perhaps we could make this a lint check or something?

Testing

Trivial change

Checklist

  • [x] I have read the contribution guidelines
  • [x] I have targeted this PR against the correct branch (master for website changes, dev for source changes)
  • [x] This is either a bugfix, a documentation update, or a new feature that has been explicitly approved via an issue
  • [x] I ran the test suite locally (npm run test) and verified that it succeeded

scrhartley avatar Dec 13 '24 00:12 scrhartley

Added commit to also update affected test file

scrhartley avatar Dec 13 '24 15:12 scrhartley

Once this is merged I'll create another PR to add an eslint rule to enforce it in the future:

      "no-restricted-properties": ["error", {
        "property": "substr",
        "message": "Use .slice or .substring instead of .substr"
      }],

Corresponding eslint docs: https://eslint.org/docs/latest/rules/no-restricted-properties

scrhartley avatar Dec 13 '24 15:12 scrhartley