• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6common.skipIfEslintMissing();
7
8const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
9const rule = require('../../tools/eslint-rules/documented-errors');
10
11const invalidCode = 'UNDOCUMENTED ERROR CODE';
12
13new RuleTester().run('documented-errors', rule, {
14  valid: [
15    `
16      E('ERR_ASSERTION', 'foo');
17    `,
18  ],
19  invalid: [
20    {
21      code: `
22        E('${invalidCode}', 'bar');
23      `,
24      errors: [
25        {
26          message: `"${invalidCode}" is not documented in doc/api/errors.md`,
27          line: 2
28        },
29        {
30          message:
31            `doc/api/errors.md does not have an anchor for "${invalidCode}"`,
32          line: 2
33        },
34      ]
35    },
36  ]
37});
38