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
|
'use strict';
require('../common');
const RuleTester = require('../../tools/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/lowercase-name-for-primitive');
const valid = [
'string',
'number',
'boolean',
'null',
'undefined'
];
new RuleTester().run('lowercase-name-for-primitive', rule, {
valid: [
'new errors.TypeError("ERR_INVALID_ARG_TYPE", "a", ["string", "number"])',
...valid.map((name) =>
`new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "${name}")`
)
],
invalid: [
{
code: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +
'\'Number\')',
errors: [{ message: 'primitive should use lowercase: Number' }],
output: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +
'\'number\')'
},
{
code: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +
'\'STRING\')',
errors: [{ message: 'primitive should use lowercase: STRING' }],
output: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +
'\'string\')'
},
{
code: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +
'[\'String\', \'Number\']) ',
errors: [
{ message: 'primitive should use lowercase: String' },
{ message: 'primitive should use lowercase: Number' }
],
output: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +
'[\'string\', \'number\']) '
}
]
});
|