UNPKG

765 BJavaScriptView Raw
1'use strict';
2
3const {visitIf} = require('enhance-visitors');
4const createAvaRule = require('../create-ava-rule');
5const util = require('../util');
6
7const create = context => {
8 const ava = createAvaRule();
9
10 return ava.merge({
11 CallExpression: visitIf([
12 ava.isInTestFile,
13 ava.isTestNode,
14 ava.hasNoUtilityModifier,
15 ])(node => {
16 const firstArgumentIsFunction = node.arguments.length === 0 || util.isFunctionExpression(node.arguments[0]);
17
18 if (firstArgumentIsFunction) {
19 context.report({
20 node,
21 message: 'Test should have a title.',
22 });
23 }
24 }),
25 });
26};
27
28module.exports = {
29 create,
30 meta: {
31 type: 'problem',
32 docs: {
33 description: 'Ensure tests have a title.',
34 url: util.getDocsUrl(__filename),
35 },
36 schema: [],
37 },
38};