Skip to content

New Rule: prefer-global/crypto #490

@zanminkian

Description

@zanminkian

Rule details

Just like the existing rule prefer-global/console, add a rule named prefer-global/crypto.

crypto is a global variable since Node 20, but users can still import it by import crypto from 'node:crypto'.

What type of rule is this?

Suggests an alternate way of doing something

Example code

import crypto from 'node:crypto';
import crypto from 'crypto';
const crypto = require('node:crypto');
const crypto = require('crypto');

These 4 lines of code should be reported when enabling prefer-global/crypto.

Participation

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

Additional comments

No response

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