Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer.slice is deprecated #40

Open
jimmywarting opened this issue Aug 7, 2022 · 2 comments
Open

Buffer.slice is deprecated #40

jimmywarting opened this issue Aug 7, 2022 · 2 comments

Comments

@jimmywarting
Copy link

It was bad that they overrided it in the first place...
https://nodejs.org/dist/latest-v18.x/docs/api/buffer.html#bufslicestart-end

Buffer don't even have a slice method that did the correct thing. slice is only an alias for subarray. and subarray is what ppl should have been using instead.

@aladdin-add
Copy link

PRs are welcome! 👍

@scagood
Copy link

scagood commented Feb 23, 2024

I have been thinking about this one while updating the es-syntax.

I think we should look to move definePrototypeMethodHandler from eslint-plugin-es-x into @eslint-community/eslint-utils

I think its the best solution to adding prototype deprecation warnings. The one change I would make would be to make the callback required. 🤔

I was looking for a similar thing here too -- #180 (comment)

Something like:

import { definePrototypeMethodHandler } from "@eslint-community/eslint-utils"

definePrototypeMethodHandler(
  context,
  { Buffer: ["slice"] },
  ({ node }) => context.report({
    node: node,
    messageId: "buffer#slice-deprecated"
  }),
)

What do you think @aladdin-add?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants