ESLint rules for AVA
Translations: FranΓ§ais
This plugin is bundled in XO. No need to do anything if you're using it.
Propose or contribute a new rule β‘
npm install --save-dev eslint eslint-plugin-avaRequires ESLint >=10, flat config, and ESM.
Use a preset config or configure each rule in eslint.config.js.
import eslintPluginAva from 'eslint-plugin-ava';
export default [
{
plugins: {
ava: eslintPluginAva,
},
rules: {
'ava/assertion-arguments': 'error',
'ava/no-only-test': 'error',
},
},
];The rules will only activate in test files.
πΌ Configurations enabled in.
π« Configurations disabled in.
β
Set in the recommended configuration.
π§ Automatically fixable by the --fix CLI option.
π‘ Manually fixable by editor suggestions.
β Deprecated.
| NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β | Description | πΌ | π« | π§ | π‘ | β | |
|---|---|---|---|---|---|---|---|
| assertion-arguments | Enforce passing correct arguments to assertions. | β | π§ | ||||
| failing-test-url | Require a URL in a comment above test.failing(). |
β | |||||
| hooks-order | Enforce test hook ordering. | β | π§ | ||||
| max-asserts | Limit the number of assertions in a test. | β | |||||
| no-async-fn-without-await | Require async tests to use await. |
β | π‘ | ||||
| no-ava-in-dependencies | Disallow AVA in dependencies. |
β | π§ | ||||
| no-commented-tests | Disallow commented-out tests. | β | |||||
| no-conditional-assertion | Disallow assertions inside conditional statements. | β | |||||
| no-duplicate-hooks | Disallow duplicate hook declarations. | β | |||||
| no-duplicate-modifiers | Disallow duplicate test modifiers. | β | π§ | β | |||
| no-identical-title | Disallow identical test titles. | β | |||||
| no-ignored-test-files | Disallow tests in ignored files. | β | |||||
| no-import-test-files | Disallow importing test files. | β | |||||
| no-incorrect-deep-equal | Disallow using deepEqual with primitives. |
β | π§ | ||||
| no-inline-assertions | Disallow inline assertions. | β | π§ | ||||
| no-invalid-modifier-chain | Disallow invalid modifier chains. | β | π§ | π‘ | |||
| no-negated-assertion | Disallow negated assertions. | β | π§ | ||||
| no-nested-assertions | Disallow nested assertions. | β | |||||
| no-nested-tests | Disallow nested tests. | β | |||||
| no-only-test | Disallow test.only(). |
β | π‘ | ||||
| no-skip-assert | Disallow skipping assertions. | β | π‘ | ||||
| no-skip-test | Disallow skipping tests. | β | π‘ | ||||
| no-todo-implementation | Disallow giving test.todo() an implementation function. |
β | π‘ | ||||
| no-todo-test | Disallow test.todo(). |
β | π‘ | ||||
| no-unknown-modifiers | Disallow unknown test modifiers. | β | π‘ | β | |||
| no-useless-t-pass | Disallow useless t.pass(). |
β | |||||
| prefer-async-await | Prefer async/await over returning a Promise. | β | |||||
| prefer-power-assert | Enforce using only assertions compatible with power-assert. | β | |||||
| prefer-t-regex | Prefer t.regex() over RegExp#test() and String#match(). |
β | π§ | ||||
| prefer-t-throws | Prefer t.throws() or t.throwsAsync() over try/catch. |
β | |||||
| require-assertion | Require that tests contain at least one assertion. | β | |||||
| test-title | Require tests to have a title. | β | π§ | ||||
| test-title-format | Require test titles to match a pattern. | β | |||||
| use-t | Require test functions to use t as their parameter. |
β | |||||
| use-t-throws-async-well | Require t.throwsAsync() and t.notThrowsAsync() to be awaited. |
β | π§ | ||||
| use-t-well | Disallow incorrect use of t. |
β | π§ | ||||
| use-test | Require AVA to be imported as test. |
β | |||||
| use-true-false | Prefer t.true()/t.false() over t.truthy()/t.falsy(). |
β | π§ |
This plugin exports a recommended config that enforces good practices.
import eslintPluginAva from 'eslint-plugin-ava';
export default [
...eslintPluginAva.configs.recommended,
];