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,
];