Skip to content

New Rule: prefer-process-get-builtin-module #475

@fisker

Description

@fisker

Rule details

Prefer use process.getBuiltinModule() to get modules instead of await import() and require()

What type of rule is this?

Suggests an alternate way of doing something

Example code

// ❌
const fs = await import('node:fs')

// ✅
const fs = process.getBuiltinModule('node:fs')
// ❌
function foo() {
  const fs = require('node:fs')
}

// ✅
function foo() {
  const fs = process.getBuiltinModule('node:fs')
}

Participation

  • I am willing to submit a pull request to implement this rule.

Additional comments

I don't use require() now, the import() case is only I need.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions