◐ Shell
clean mode source ↗

test,tools: refactor custom ESLint for readability · nodejs/node@c9cee63

@@ -7,45 +7,33 @@ common.skipIfEslintMissing();

77

const RuleTester = require('../../tools/node_modules/eslint').RuleTester;

88

const rule = require('../../tools/eslint-rules/lowercase-name-for-primitive');

9910-

const valid = [

11-

'string',

12-

'number',

13-

'boolean',

14-

'null',

15-

'undefined'

16-

];

17-1810

new RuleTester().run('lowercase-name-for-primitive', rule, {

1911

valid: [

2012

'new errors.TypeError("ERR_INVALID_ARG_TYPE", "a", ["string", "number"])',

21-

...valid.map((name) =>

22-

`new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "${name}")`

23-

)

13+

'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "string")',

14+

'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "number")',

15+

'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "boolean")',

16+

'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "null")',

17+

'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "undefined")',

2418

],

2519

invalid: [

2620

{

27-

code: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +

28-

'\'Number\')',

21+

code: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'Number')",

2922

errors: [{ message: 'primitive should use lowercase: Number' }],

30-

output: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +

31-

'\'number\')'

23+

output: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'number')",

3224

},

3325

{

34-

code: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +

35-

'\'STRING\')',

26+

code: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'STRING')",

3627

errors: [{ message: 'primitive should use lowercase: STRING' }],

37-

output: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +

38-

'\'string\')'

28+

output: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'string')",

3929

},

4030

{

41-

code: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +

42-

'[\'String\', \'Number\']) ',

31+

code: "new e.TypeError('ERR_INVALID_ARG_TYPE', a, ['String','Number'])",

4332

errors: [

4433

{ message: 'primitive should use lowercase: String' },

45-

{ message: 'primitive should use lowercase: Number' }

34+

{ message: 'primitive should use lowercase: Number' },

4635

],

47-

output: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' +

48-

'[\'string\', \'number\']) '

49-

}

36+

output: "new e.TypeError('ERR_INVALID_ARG_TYPE', a, ['string','number'])",

37+

},

5038

]

5139

});