Skip to content

avajs/eslint-plugin-ava

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

393 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

eslint-plugin-ava Coverage Status

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 ➑

Install

npm install --save-dev eslint eslint-plugin-ava

Requires ESLint >=10, flat config, and ESM.

Usage

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

Rules

The rules will only activate in test files.

πŸ’Ό Configurations enabled in.
⚠️ Configurations set to warn 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(). βœ… πŸ”§

Recommended config

This plugin exports a recommended config that enforces good practices.

import eslintPluginAva from 'eslint-plugin-ava';

export default [
	...eslintPluginAva.configs.recommended,
];