close

no-import-node-test

Added in v0.8.1

Configuration

PresetConfigured Value
✅ rstestPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, rstestPlugin } from '@rslint/core';

export default defineConfig([
  rstestPlugin.configs.recommended,
  {
    rules: {
      'rstest/no-import-node-test': 'error',
    },
  },
]);

Rule Details

Disallows importing Node's test runner in an Rstest test file. Editor auto-import can otherwise select node:test instead of Rstest.

The rule reports static imports, require(), and TypeScript import = require forms for node:test and paths beneath it.

Incorrect

import { test } from 'node:test';

test('creates a user', () => {});

Correct

import { test } from '@rstest/core';

test('creates a user', () => {});

Autofix

Changes an exact named import from node:test to an Rstest module when it imports only test, it, or describe.

The test API is reachable as both @rstest/core and rstack/test, and the fix writes whichever of the two the file already uses — in another import, a require, or a /// <reference types="..." /> directive — so that the rewritten import resolves in the project it was written for. A file that names both, or names neither, gets @rstest/core.