| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4b9817b commit c9cee63
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,45 +7,33 @@ common.skipIfEslintMissing(); | |||
| 7 | 7 | const RuleTester = require('../../tools/node_modules/eslint').RuleTester; | |
| 8 | 8 | const rule = require('../../tools/eslint-rules/lowercase-name-for-primitive'); | |
| 9 | 9 | ||
| 10 | - const valid = [ | ||
| 11 | - 'string', | ||
| 12 | - 'number', | ||
| 13 | - 'boolean', | ||
| 14 | - 'null', | ||
| 15 | - 'undefined' | ||
| 16 | - ]; | ||
| 17 | - | ||
| 18 | 10 | new RuleTester().run('lowercase-name-for-primitive', rule, { | |
| 19 | 11 | valid: [ | |
| 20 | 12 | '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")', | ||
| 24 | 18 | ], | |
| 25 | 19 | invalid: [ | |
| 26 | 20 | { | |
| 27 | - code: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' + | ||
| 28 | - '\'Number\')', | ||
| 21 | + code: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'Number')", | ||
| 29 | 22 | 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')", | ||
| 32 | 24 | }, | |
| 33 | 25 | { | |
| 34 | - code: 'new errors.TypeError(\'ERR_INVALID_ARG_TYPE\', \'a\', ' + | ||
| 35 | - '\'STRING\')', | ||
| 26 | + code: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'STRING')", | ||
| 36 | 27 | 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')", | ||
| 39 | 29 | }, | |
| 40 | 30 | { | |
| 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'])", | ||
| 43 | 32 | errors: [ | |
| 44 | 33 | { message: 'primitive should use lowercase: String' }, | |
| 45 | - { message: 'primitive should use lowercase: Number' } | ||
| 34 | + { message: 'primitive should use lowercase: Number' }, | ||
| 46 | 35 | ], | |
| 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 | + }, | ||
| 50 | 38 | ] | |
| 51 | 39 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,9 +12,7 @@ | |||
| 12 | 12 | const astSelector = 'NewExpression[callee.property.name="TypeError"]' + | |
| 13 | 13 | '[arguments.0.value="ERR_INVALID_ARG_TYPE"]'; | |
| 14 | 14 | ||
| 15 | - const primitives = [ | ||
| 16 | - 'number', 'string', 'boolean', 'null', 'undefined' | ||
| 17 | - ]; | ||
| 15 | + const primitives = [ 'number', 'string', 'boolean', 'null', 'undefined' ]; | ||
| 18 | 16 | ||
| 19 | 17 | module.exports = function(context) { | |
| 20 | 18 | function checkNamesArgument(node) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments