Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.23 KB

use-test.md

File metadata and controls

38 lines (27 loc) · 1.23 KB

Ensure that AVA is imported with test as the variable name (ava/use-test)

💼 This rule is enabled in the ✅ recommended config.

Translations: Français

The convention is to import AVA and assign it to a variable named test. Most rules in eslint-plugin-ava are based on that assumption. In a TypeScript file (.ts or .tsx) AVA can be assigned to a variable named anyTest in order to define the types of t.context (see Typing t.context). Type-only imports (import type ... from 'ava') are not linted.

Fail

var ava = require('ava');
let ava = require('ava');
const ava = require('ava');
import ava from 'ava';

Pass

var test = require('ava');
let test = require('ava');
const test = require('ava');
import test from 'ava';

var test = require('foo');
const test = require('foo');
import anyTest from 'ava';
import type {TestInterface} from 'ava';

const test = anyTest as TestInterface<{foo: string}>;