mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 09:02:40 +00:00

Add a custom eslint rule to check for `common.skipIfEslintMissing()` to allow tests to run from source tarballs that do not include eslint. Fix up rule tests that were failing the new check. Refs: https://github.com/nodejs/node/issues/20336 PR-URL: https://github.com/nodejs/node/pull/20372 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
36 lines
753 B
JavaScript
36 lines
753 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
common.skipIfEslintMissing();
|
|
|
|
const RuleTester = require('../../tools/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
|
|
},
|
|
{
|
|
message:
|
|
`doc/api/errors.md does not have an anchor for "${invalidCode}"`,
|
|
line: 2
|
|
}
|
|
]
|
|
}
|
|
]
|
|
});
|