Skip to content

Feature: Add a 'stylistic' preset #867

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Overview

There are a lot of rules mentioned in https://github.com/vitest-dev/eslint-plugin-vitest?tab=readme-ov-file#rules that are very good, but don't impact logic of tests - just stylistic consistency. Some are kind of up to personal preference / subjective, but others I think are pretty universal / objective in what most Vitest projects use if they have enforced stylistic opinions:

  • consistent-vitest-vi
  • hoisted-apis-on-top
  • no-test-prefixes
  • padding-around-all & co.
  • prefer-called-times
  • prefer-called-with
  • prefer-comparison-matcher
  • prefer-describe-function-title
  • prefer-each
  • prefer-equality-matcher
  • prefer-expect-assertions
  • prefer-expect-resolves
  • prefer-expect-type-of
  • prefer-hooks-in-order
  • prefer-hooks-on-top
  • prefer-importing-vitest-globals
  • prefer-mock-promise-shorthand
  • prefer-mock-return-shorthand
  • prefer-spy-on
  • prefer-strict-boolean-matchers
  • prefer-to-be
  • prefer-to-be-object
  • prefer-to-contain
  • prefer-to-have-been-called-times
  • prefer-to-have-length
  • prefer-todo
  • prefer-vi-mocked

Additional Information

Splitting out "logical" (recommended) and "stylistic" rules has some prior art: e.g. https://typescript-eslint.io/users/configs.

I don't consider myself particularly expert on Vitest best practices. Seeking feedback: is that list of most-projects-do-it-this-way rules accurate at all?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions