• Stars
    star
    112
  • Rank 311,092 (Top 7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 3 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

eslint plugin for vitest.

eslint-plugin-vitest

npm ci

Eslint plugin for vitest

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-vitest:

npm install eslint-plugin-vitest --save-dev

Usage

Add vitest to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["vitest"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "vitest/max-nested-describe": [
      "error",
      {
        "max": 3
      }
    ]
  }
}

Recommended

To use the recommended configuration, extend it in your .eslintrc file:

{
  "extends": ["plugin:vitest/recommended"]
}

All recommend rules will be set to error by default. You can however disable some rules by setting turning them off in your .eslintrc file or by setting them to warn in your .eslintrc.

all

To use the all configuration, extend it in your .eslintrc file:

{
  "extends": ["plugin:vitest/all"]
}

Rules

๐Ÿ’ผ Configurations enabled in.
โš ๏ธ Configurations set to warn in.
๐ŸŒ Set in the all configuration.
โœ… Set in the recommended configuration.
๐Ÿ”ง Automatically fixable by the --fix CLI option.
๐Ÿ’ก Manually fixable by editor suggestions.

Nameย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  Description ๐Ÿ’ผ โš ๏ธ ๐Ÿ”ง ๐Ÿ’ก
consistent-test-filename forbidden .spec test file pattern ๐ŸŒ
consistent-test-it Prefer test or it but not both ๐ŸŒ ๐Ÿ”ง
expect-expect Enforce having expectation in test body โœ…
max-expects Enforce a maximum number of expect per test ๐ŸŒ
max-nested-describe Nested describe block should be less than set max value or default value ๐ŸŒ
no-alias-methods Disallow alias methods ๐ŸŒ ๐Ÿ”ง
no-commented-out-tests Disallow commented out tests โœ…
no-conditional-expect Disallow conditional expects ๐ŸŒ
no-conditional-in-test Disallow conditional tests ๐ŸŒ
no-conditional-tests Disallow conditional tests ๐ŸŒ
no-disabled-tests Disallow disabled tests ๐ŸŒ
no-done-callback Disallow using a callback in asynchronous tests and hooks ๐ŸŒ ๐Ÿ’ก
no-duplicate-hooks Disallow duplicate hooks and teardown hooks ๐ŸŒ
no-focused-tests Disallow focused tests ๐ŸŒ ๐Ÿ”ง
no-hooks Disallow setup and teardown hooks ๐ŸŒ
no-identical-title Disallow identical titles โœ… ๐Ÿ”ง
no-interpolation-in-snapshots Disallow string interpolation in snapshots ๐ŸŒ ๐Ÿ”ง
no-large-snapshots Disallow large snapshots ๐ŸŒ
no-mocks-import Disallow importing from mocks directory ๐ŸŒ
no-restricted-matchers Disallow the use of certain matchers ๐ŸŒ
no-restricted-vi-methods Disallow specific vi. methods ๐ŸŒ
no-standalone-expect Disallow using expect outside of it or test blocks ๐ŸŒ
no-test-prefixes Disallow using test as a prefix ๐ŸŒ ๐Ÿ”ง
no-test-return-statement Disallow return statements in tests ๐ŸŒ
prefer-called-with Suggest using toBeCalledWith() or toHaveBeenCalledWith() ๐ŸŒ ๐Ÿ”ง
prefer-comparison-matcher Suggest using the built-in comparison matchers ๐ŸŒ ๐Ÿ”ง
prefer-each Prefer each rather than manual loops ๐ŸŒ
prefer-equality-matcher Suggest using the built-in quality matchers ๐ŸŒ ๐Ÿ’ก
prefer-expect-resolves Suggest using expect().resolves over expect(await ...) syntax ๐ŸŒ ๐Ÿ”ง
prefer-hooks-in-order Prefer having hooks in consistent order ๐ŸŒ
prefer-hooks-on-top Suggest having hooks before any test cases ๐ŸŒ
prefer-lowercase-title Enforce lowercase titles ๐ŸŒ ๐Ÿ”ง
prefer-mock-promise-shorthand Prefer mock resolved/rejected shorthands for promises ๐ŸŒ ๐Ÿ”ง
prefer-snapshot-hint Prefer including a hint with external snapshots ๐ŸŒ
prefer-spy-on Suggest using vi.spyOn ๐ŸŒ ๐Ÿ”ง
prefer-strict-equal Prefer strict equal over equal ๐ŸŒ ๐Ÿ’ก
prefer-to-be Suggest using toBe() โœ… ๐Ÿ”ง
prefer-to-be-falsy Suggest using toBeFalsy() ๐ŸŒ ๐Ÿ”ง
prefer-to-be-object Prefer toBeObject() ๐ŸŒ ๐Ÿ”ง
prefer-to-be-truthy Suggest using toBeTruthy ๐ŸŒ ๐Ÿ”ง
prefer-to-contain Prefer using toContain() ๐ŸŒ ๐Ÿ”ง
prefer-to-have-length Suggest using toHaveLength() ๐ŸŒ ๐Ÿ”ง
prefer-todo Suggest using test.todo ๐ŸŒ ๐Ÿ”ง
require-hook Require setup and teardown to be within a hook ๐ŸŒ
require-to-throw-message Require toThrow() to be called with an error message ๐ŸŒ
require-top-level-describe Enforce that all tests are in a top-level describe ๐ŸŒ
valid-describe-callback Enforce valid describe callback โœ…
valid-expect Enforce valid expect() usage โœ…
valid-title Enforce valid titles โœ… ๐Ÿ”ง

Credits

  • eslint-plugin-jest Most of the rules in this plugin are essentially ports of Jest plugin rules with minor modifications

Licence

MIT Licence ยฉ 2022 - present veritem

More Repositories

1

upro

web UI starter for performant apps
TypeScript
42
star
2

valdie

Ts/Js schema validator for Node and Browser
TypeScript
18
star
3

next2ts

CLI tool to help you migrate your Next-js project to typescript in seconds
JavaScript
16
star
4

springboot-template

unopinionated springboot project template that everybody agrees on.
Java
13
star
5

eslint-config-veritem

eslint setup
JavaScript
9
star
6

useform

Tiny hook that make react forms easy
TypeScript
7
star
7

lyrica

iOS - Lyrics search engine
Swift
6
star
8

piste

[Experimental] A better projects management tool that everyone deserves
Svelte
6
star
9

Differ

BirthDay Reminder Slack Bot
Go
4
star
10

dcl

Directory cleaner
Rust
4
star
11

xdeno

Finite State Machine Library for Deno
TypeScript
4
star
12

veritem.me

Personal website
Svelte
4
star
13

hn

Yet another hacker news client
Vue
3
star
14

supamenu

TypeScript
3
star
15

fitty

(WIP) Cross-platform File system utility for golang
Go
3
star
16

covid19tracker

Dashboard to tracker updates about COVID-19
JavaScript
3
star
17

raxi

Automated Typescript libraries development workflow
TypeScript
3
star
18

mongodb-exporter

Svelte
3
star
19

dots

dot files โš’๏ธ
Vim Script
3
star
20

minimalized

Tiny overlay component for React and Next.js apps
TypeScript
3
star
21

homebrew-gcm

Homebrew formula for gcm
Ruby
2
star
22

node-testing

production nodejs testing example
TypeScript
2
star
23

codekin.tech

My Code Garden on the internet, moved to https://veritem.me/
TypeScript
2
star
24

api

API for my personal website
Go
2
star
25

gcm

conventional commits utility cli
Rust
2
star
26

bpurse

TypeScript
2
star
27

ts-lib-template

my ultimate typescript library authoring template
TypeScript
1
star
28

dns-server

(WIP) DNS protocol implementation in RUST
Rust
1
star
29

svere

(WIP) The Modern c/c++ builder and runner
Rust
1
star
30

fally

TypeScript
1
star
31

ndi

cross-platform easiest nerd fonts installation script
Rust
1
star
32

veritem

Profile
1
star
33

tech-assess

TypeScript
1
star
34

standalone-pub-server

A standalone pub server
Dart
1
star
35

spauno

TypeScript
1
star
36

gts

CLI to help you stay organized with your github
Rust
1
star