forked from mysticatea/eslint-plugin-node
-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
no-new-require.js
36 lines (34 loc) · 978 Bytes
/
no-new-require.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* @author Wil Moore III
* See LICENSE file in root directory for full license.
*/
"use strict"
const RuleTester = require("#test-helpers").RuleTester
const rule = require("../../../lib/rules/no-new-require")
new RuleTester().run("no-new-require", rule, {
valid: [
"var appHeader = require('app-header')",
"var AppHeader = new (require('app-header'))",
"var AppHeader = new (require('headers').appHeader)",
],
invalid: [
{
code: "var appHeader = new require('app-header')",
errors: [
{
messageId: "noNewRequire",
type: "NewExpression",
},
],
},
{
code: "var appHeader = new require('headers').appHeader",
errors: [
{
messageId: "noNewRequire",
type: "NewExpression",
},
],
},
],
})