Skip to content

primordials access check can be improved #35449

Closed
@Leko

Description

Problems

Proposal

I created a new draft PR that includes a new custom ESLint rule for that.
#35448

  • It'll report accessing global built-in objects that aren't using primordials such Array or Symbol
  • It'll report static methods such as Array.from or Symbol.for
  • It won't report prototype methods to prevent false-positive reporting. It will need static type information.

Here is the result of make lint-js with new rule on the commit 4d7015f.

If we have a special reason for using the built-in object, we can add an inline comment such as eslint-disable node-core/prefer-primordials.

Pros

  • Improve security
  • Improve performance
  • Reduce reviewing cost
  • No need PRs that replace codes with primordials anymore.

Concerns

I'm not sure whether all codes in lib/ should be replaced with primordials.

What do you think?

Metadata

Assignees

No one assigned

    Labels

    buildIssues and PRs related to build files or the CI.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions