close

prefer-global/process

Unreleased

Configuration

rslint.config.ts
import { defineConfig, nodePlugin } from '@rslint/core';

export default defineConfig([
  nodePlugin.configs.recommended,
  {
    rules: {
      'node/prefer-global/process': 'error',
    },
  },
]);

Enforce consistent use of the global process variable or the process module.

Options

This rule accepts one string option:

  • "always" (default): use the global process variable.
  • "never": import or require the process module.

The rule recognizes both process and node:process module names, including ESM imports and re-exports, require(), and process.getBuiltinModule(). Global references respect local bindings and configured globals. Enable Node.js globals in the configuration:

import { globals } from '@rslint/core';

export default [
  {
    plugins: ['node'],
    languageOptions: { globals: globals.node },
    rules: {
      'node/prefer-global/process': ['error', 'always'],
    },
  },
];

always

Incorrect:

const process = require('process');
import proc from 'node:process';

Correct:

process.exit(0);

never

Incorrect:

process.exit(0);

Correct:

const process = require('process');
process.exit(0);

This rule does not provide automatic fixes or suggestions.

References