-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathno-new-wrappers.js
More file actions
60 lines (54 loc) · 1.71 KB
/
no-new-wrappers.js
File metadata and controls
60 lines (54 loc) · 1.71 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* @fileoverview Tests for rule no-new-native-nonconstructor
* @author SukkaW <[email protected]>
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const rule = require("../../../lib/rules/no-new-wrappers.js");
const RuleTester = require("../../rule-tester.js").RuleTester;
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
const ruleTester = new RuleTester();
ruleTester.run("no-new-wrappers", rule, {
valid: [
"const text = String(someValue);",
"const num = Number(someValue);",
"const object = new MyString();"
],
invalid: [
{
code: 'const stringObject = new String("Hello world");',
output: 'const stringObject = String("Hello world");',
errors: 1
},
{
code: "const numberObject = new Number(0x721);",
output: "const numberObject = Number(0x721);",
errors: 1
},
{
code: "const booleanObject = new Boolean(false);",
output: "const booleanObject = Boolean(false);",
errors: 1
},
// no auto fix
{
code: "const stringObject = new String",
output: null,
errors: 1
},
{
code: "const numberObject = new Number",
output: null,
errors: 1
},
{
code: "const booleanObject = new Boolean",
output: null,
errors: 1
}
]
});