• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6
7common.skipIfEslintMissing();
8
9const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
10const rule = require('../../tools/eslint-rules/lowercase-name-for-primitive');
11
12new RuleTester().run('lowercase-name-for-primitive', rule, {
13  valid: [
14    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "a", ["string", "number"])',
15    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "string")',
16    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "number")',
17    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "boolean")',
18    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "null")',
19    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "undefined")',
20  ],
21  invalid: [
22    {
23      code: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'Number')",
24      errors: [{ message: 'primitive should use lowercase: Number' }],
25      output: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'number')",
26    },
27    {
28      code: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'STRING')",
29      errors: [{ message: 'primitive should use lowercase: STRING' }],
30      output: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'string')",
31    },
32    {
33      code: "new e.TypeError('ERR_INVALID_ARG_TYPE', a, ['String','Number'])",
34      errors: [
35        { message: 'primitive should use lowercase: String' },
36        { message: 'primitive should use lowercase: Number' },
37      ],
38      output: "new e.TypeError('ERR_INVALID_ARG_TYPE', a, ['string','number'])",
39    },
40  ]
41});
42