mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
tools: add eslint rule for documented errors
PR-URL: https://github.com/nodejs/node/pull/16450 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
This commit is contained in:
parent
fb477f3fa5
commit
76b8803630
3 changed files with 81 additions and 0 deletions
34
test/parallel/test-eslint-documented-errors.js
Normal file
34
test/parallel/test-eslint-documented-errors.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
'use strict';
|
||||
|
||||
require('../common');
|
||||
|
||||
const RuleTester = require('../../tools/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
|
||||
},
|
||||
{
|
||||
message:
|
||||
`doc/api/errors.md does not have an anchor for "${invalidCode}"`,
|
||||
line: 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue