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

lib: simplify primordial safe generation #52479

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

RedYetiDev
Copy link
Member

Simplify primordial generation using of ObjectEntries

Caution

For security reasons regarding prototype pollution, using of is generally considered bad practice, but at this point in time, the user does not have access to the prototype of ObjectEntries (object).

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Apr 11, 2024
RedYetiDev and others added 2 commits April 11, 2024 14:46
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
@RedYetiDev
Copy link
Member Author

RedYetiDev commented Apr 11, 2024

The following lint errors were triggered:

Error: 420:23 error Missing trailing comma comma-dangle

I can resolve this at a later point in time, as more edits to the file will probably be made


Error: 423:12 error Use object destructuring instead of array destructuring node-core/no-array-destructuring

This array destructure occurs before the user is able to override it, but I can change it if needed


Error: 423:39 error 'ObjectEntries' is not defined no-undef

Defined here


Error: 440:9 error 'SafePromise' is not defined no-undef

Defined here


Error: 455:13 error 'SafePromise' is not defined no-undef

Defined here


Error: 469:5 error 'SafePromise' is not defined no-undef

Defined here


Error: 532:5 error 'SafePromise' is not defined no-undef

Defined here


Error: 565:5 error 'SafePromise' is not defined no-undef

Defined here


Error: 578:5 error 'SafePromise' is not defined no-undef

Defined here


@aduh95 aduh95 added dont-land-on-v18.x PRs that should not land on the v18.x-staging branch and should not be released in v18.x. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v21.x PRs that should not land on the v21.x-staging branch and should not be released in v21.x. labels Apr 11, 2024
@RedYetiDev
Copy link
Member Author

@aduh95, do you know the eslint comments to avoid some of these errors?

@aduh95
Copy link
Contributor

aduh95 commented Apr 12, 2024

@aduh95, do you know the eslint comments to avoid some of these errors?

You don't need ESLint commands, you need to refactor the code so it's valid JavaScript (when it comes to SafePromise not being defined, you need to define e.g. const SafePromise = primordials.SafePromise), or adapted to the style of the codebase (so adding the trailing comma, and refactor to use object destructuring instead of array destructuring). All the errors reported by ESLint are valid AFAICT.

You can use make lint-js-fix to apply ESLint autofixes, if that was what you were asking.

Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not blocking, but I don't find this code more readable nor does the duplication bother me that much.

@RedYetiDev
Copy link
Member Author

I'm not blocking, but I don't find this code more readable nor does the duplication bother me that much.

In my latest change, the code now matches the format for several other generations within the file

Comment on lines +420 to +422
const {
SafePromise,
} = primordials;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that SafePromise used to not be on the primordials object, it was only used locally on that file; it probably makes sense to keep it that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dont-land-on-v18.x PRs that should not land on the v18.x-staging branch and should not be released in v18.x. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v21.x PRs that should not land on the v21.x-staging branch and should not be released in v21.x. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants