node/test/parallel/test-eslint-documented-errors.js
Aviv Keller 5a3da7b4e4
tools: enforce errors to not be documented in legacy section
PR-URL: https://github.com/nodejs/node/pull/55218
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2024-10-08 16:59:53 +00:00

34 lines
732 B
JavaScript

'use strict';
const common = require('../common');
if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skip('ESLint tests require crypto and Intl');
}
common.skipIfEslintMissing();
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/documented-errors');
const invalidCode = 'UNDOCUMENTED ERROR CODE';
new RuleTester().run('documented-errors', rule, {
valid: [
`
E('ERR_ASSERTION', 'foo');
`,
],
invalid: [
{
code: `
E('${invalidCode}', 'bar');
`,
errors: [
{
message: `"${invalidCode}" is not documented in doc/api/errors.md`,
line: 2
},
]
},
]
});