mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 07:19:19 +00:00

This adds tests for the custom eslint rules in this repository, using the `RuleTester` test utility bundled with eslint. PR-URL: https://github.com/nodejs/node/pull/16138 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com>
32 lines
659 B
JavaScript
32 lines
659 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const RuleTester = require('../../tools/eslint').RuleTester;
|
|
const rule = require('../../tools/eslint-rules/required-modules');
|
|
|
|
new RuleTester().run('required-modules', rule, {
|
|
valid: [
|
|
{
|
|
code: 'require("common")',
|
|
options: ['common']
|
|
},
|
|
{
|
|
code: 'foo',
|
|
options: []
|
|
},
|
|
],
|
|
invalid: [
|
|
{
|
|
code: 'foo',
|
|
options: ['common'],
|
|
errors: [{ message: 'Mandatory module "common" must be loaded.' }]
|
|
},
|
|
{
|
|
code: 'require("somethingElse")',
|
|
options: ['common'],
|
|
errors: [{ message: 'Mandatory module "common" must be loaded.' }]
|
|
}
|
|
]
|
|
});
|