UNPKG

eslint-plugin-ava

Version:
107 lines (85 loc) β€’ 10.9 kB
# eslint-plugin-ava [![Coverage Status](https://coveralls.io/repos/github/avajs/eslint-plugin-ava/badge.svg?branch=main)](https://coveralls.io/github/avajs/eslint-plugin-ava?branch=main) > ESLint rules for [AVA](https://avajs.dev) Translations: [FranΓ§ais](https://github.com/avajs/ava-docs/blob/main/fr_FR/related/eslint-plugin-ava/readme.md) This plugin is bundled in [XO](https://github.com/xojs/xo). No need to do anything if you're using it. [**Propose or contribute a new rule ➑**](.github/contributing.md) ## Install ```sh npm install --save-dev eslint eslint-plugin-ava ``` **Requires ESLint `>=10`, [flat config](https://eslint.org/docs/latest/use/configure/configuration-files), and [ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).** ## Usage Use a [preset config](#recommended-config) or configure each rule in `eslint.config.js`. ```js import eslintPluginAva from 'eslint-plugin-ava'; export default [ { plugins: { ava: eslintPluginAva, }, rules: { 'ava/assertion-arguments': 'error', 'ava/no-only-test': 'error', }, }, ]; ``` ## Rules The rules will only activate in test files. <!-- begin auto-generated rules list --> πŸ’Ό [Configurations](https://github.com/avajs/eslint-plugin-ava#recommended-config) enabled in.\ ⚠️ [Configurations](https://github.com/avajs/eslint-plugin-ava#recommended-config) set to warn in.\ 🚫 [Configurations](https://github.com/avajs/eslint-plugin-ava#recommended-config) disabled in.\ βœ… Set in the `recommended` [configuration](https://github.com/avajs/eslint-plugin-ava#recommended-config).\ πŸ”§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\ πŸ’‘ Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).\ ❌ Deprecated. | NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  | Description | πŸ’Ό | ⚠️ | 🚫 | πŸ”§ | πŸ’‘ | ❌ | | :------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------- | :- | :- | :- | :- | :- | :- | | [assertion-arguments](docs/rules/assertion-arguments.md) | Enforce passing correct arguments to assertions. | βœ… | | | πŸ”§ | | | | [failing-test-url](docs/rules/failing-test-url.md) | Require a URL in a comment above `test.failing()`. | | | βœ… | | | | | [hooks-order](docs/rules/hooks-order.md) | Enforce test hook ordering. | βœ… | | | πŸ”§ | | | | [max-asserts](docs/rules/max-asserts.md) | Limit the number of assertions in a test. | | | βœ… | | | | | [no-async-fn-without-await](docs/rules/no-async-fn-without-await.md) | Require async tests to use `await`. | βœ… | | | | πŸ’‘ | | | [no-ava-in-dependencies](docs/rules/no-ava-in-dependencies.md) | Disallow AVA in `dependencies`. | βœ… | | | πŸ”§ | | | | [no-commented-tests](docs/rules/no-commented-tests.md) | Disallow commented-out tests. | | βœ… | | | | | | [no-conditional-assertion](docs/rules/no-conditional-assertion.md) | Disallow assertions inside conditional statements. | βœ… | | | | | | | [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate hook declarations. | βœ… | | | | | | | [no-duplicate-modifiers](docs/rules/no-duplicate-modifiers.md) | Disallow duplicate test modifiers. | | | βœ… | πŸ”§ | | ❌ | | [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical test titles. | βœ… | | | | | | | [no-ignored-test-files](docs/rules/no-ignored-test-files.md) | Disallow tests in ignored files. | βœ… | | | | | | | [no-import-test-files](docs/rules/no-import-test-files.md) | Disallow importing test files. | βœ… | | | | | | | [no-incorrect-deep-equal](docs/rules/no-incorrect-deep-equal.md) | Disallow using `deepEqual` with primitives. | βœ… | | | πŸ”§ | | | | [no-inline-assertions](docs/rules/no-inline-assertions.md) | Disallow inline assertions. | βœ… | | | πŸ”§ | | | | [no-invalid-modifier-chain](docs/rules/no-invalid-modifier-chain.md) | Disallow invalid modifier chains. | βœ… | | | πŸ”§ | πŸ’‘ | | | [no-negated-assertion](docs/rules/no-negated-assertion.md) | Disallow negated assertions. | βœ… | | | πŸ”§ | | | | [no-nested-assertions](docs/rules/no-nested-assertions.md) | Disallow nested assertions. | βœ… | | | | | | | [no-nested-tests](docs/rules/no-nested-tests.md) | Disallow nested tests. | βœ… | | | | | | | [no-only-test](docs/rules/no-only-test.md) | Disallow `test.only()`. | βœ… | | | | πŸ’‘ | | | [no-skip-assert](docs/rules/no-skip-assert.md) | Disallow skipping assertions. | βœ… | | | | πŸ’‘ | | | [no-skip-test](docs/rules/no-skip-test.md) | Disallow skipping tests. | βœ… | | | | πŸ’‘ | | | [no-todo-implementation](docs/rules/no-todo-implementation.md) | Disallow giving `test.todo()` an implementation function. | βœ… | | | | πŸ’‘ | | | [no-todo-test](docs/rules/no-todo-test.md) | Disallow `test.todo()`. | | βœ… | | | πŸ’‘ | | | [no-unknown-modifiers](docs/rules/no-unknown-modifiers.md) | Disallow unknown test modifiers. | | | βœ… | | πŸ’‘ | ❌ | | [no-useless-t-pass](docs/rules/no-useless-t-pass.md) | Disallow useless `t.pass()`. | βœ… | | | | | | | [prefer-async-await](docs/rules/prefer-async-await.md) | Prefer async/await over returning a Promise. | βœ… | | | | | | | [prefer-power-assert](docs/rules/prefer-power-assert.md) | Enforce using only assertions compatible with [power-assert](https://github.com/power-assert-js/power-assert). | | | βœ… | | | | | [prefer-t-regex](docs/rules/prefer-t-regex.md) | Prefer `t.regex()` over `RegExp#test()` and `String#match()`. | βœ… | | | πŸ”§ | | | | [prefer-t-throws](docs/rules/prefer-t-throws.md) | Prefer `t.throws()` or `t.throwsAsync()` over try/catch. | βœ… | | | | | | | [require-assertion](docs/rules/require-assertion.md) | Require that tests contain at least one assertion. | βœ… | | | | | | | [test-title](docs/rules/test-title.md) | Require tests to have a title. | βœ… | | | πŸ”§ | | | | [test-title-format](docs/rules/test-title-format.md) | Require test titles to match a pattern. | | | βœ… | | | | | [use-t](docs/rules/use-t.md) | Require test functions to use `t` as their parameter. | βœ… | | | | | | | [use-t-throws-async-well](docs/rules/use-t-throws-async-well.md) | Require `t.throwsAsync()` and `t.notThrowsAsync()` to be awaited. | βœ… | | | πŸ”§ | | | | [use-t-well](docs/rules/use-t-well.md) | Disallow incorrect use of `t`. | βœ… | | | πŸ”§ | | | | [use-test](docs/rules/use-test.md) | Require AVA to be imported as `test`. | βœ… | | | | | | | [use-true-false](docs/rules/use-true-false.md) | Prefer `t.true()`/`t.false()` over `t.truthy()`/`t.falsy()`. | βœ… | | | πŸ”§ | | | <!-- end auto-generated rules list --> ## Recommended config This plugin exports a [`recommended` config](index.js) that enforces good practices. ```js import eslintPluginAva from 'eslint-plugin-ava'; export default [ ...eslintPluginAva.configs.recommended, ]; ```