eslint-plugin-vitest

Eslint plugin for vitest

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
eslint-plugin-vitest
74180.0.573 days agoa year agoMinified + gzip package size for eslint-plugin-vitest in KB

Readme

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

To use the all configuration, extend it in your .eslintrc file:
{
  "extends": ["plugin:vitest/all"]
}

Rules


⚠️ 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 asynchrounous 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-equality-matcher | Suggest using the built-in quality matchers | 🌐 | | πŸ’‘ | | prefer-expect-resolves | Suggest using expect().resolves over expect(await ...) syntax | 🌐 | πŸ”§ | | | prefer-lowercase-title | Enforce lowercase titles | 🌐 | πŸ”§ | | | 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-have-length | Suggest using toHaveLength() | 🌐 | πŸ”§ | | | valid-expect | Enforce valid expect() usage | βœ… | | | | valid-title | Enforce valid titles | βœ… | πŸ”§ | |

Credits

Most of the rules in this plugin are essentially ports of Jest plugin rules with minor modifications

Licence

MIT Licence Β© 2022 - present veritem