1 | 'use strict';
|
2 |
|
3 | const {visitIf} = require('enhance-visitors');
|
4 | const createAvaRule = require('../create-ava-rule');
|
5 | const util = require('../util');
|
6 |
|
7 | const 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 |
|
28 | module.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 | };
|