close

valid-title

Added in v0.8.0

Configuration

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

export default defineConfig([
  rstestPlugin.configs.recommended,
  {
    rules: {
      'rstest/valid-title': 'error',
    },
  },
]);

Rule Details

Validates Rstest describe, test, and it titles. Clear, consistently formatted titles make test output easier to scan and project conventions easier to enforce.

The rule rejects empty titles, titles that are not strings, titles with leading or trailing whitespace, and titles that repeat the registration name as their first word, such as test('test creates a user'). The disallowedWords, mustMatch, and mustNotMatch options add project-specific title conventions on top of that.

In array-based .each and .for titles the rule also checks format specifiers, accepting %s, %d, %i, %f, %j, %o, %O, %c, %#, %$, and %%.

Incorrect

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

Correct

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

Options

{
  "rstest/valid-title": [
    "error",
    {
      "disallowedWords": ["should"],
      "mustMatch": "^[a-z]"
    }
  ]
}
OptionTypeDefaultDescription
ignoreSpacesbooleanfalseAllow leading and trailing whitespace.
ignoreTypeOfDescribeNamebooleanfalseAllow non-string describe titles.
ignoreTypeOfTestNamebooleanfalseAllow non-string test and it titles.
disallowedWordsstring[][]Words that titles must not contain.
mustMatchmatchernonePattern a title must match.
mustNotMatchmatchernonePattern a title must not match.

A matcher is a pattern string, [pattern, message], or an object with separate describe, test, and it matchers.

Autofix

Removes literal surrounding whitespace and duplicate test, it, or describe prefixes from titles.