mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
791 B
32 lines
791 B
9 years ago
|
/**
|
||
|
* @fileoverview Require `throw new Error()` rather than `throw Error()`
|
||
|
* @author Rich Trott
|
||
|
*/
|
||
|
'use strict';
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
// Rule Definition
|
||
|
//------------------------------------------------------------------------------
|
||
|
|
||
|
module.exports = function(context) {
|
||
|
|
||
|
var errorList = context.options.length !== 0 ? context.options : ['Error'];
|
||
|
|
||
|
return {
|
||
|
'ThrowStatement': function(node) {
|
||
|
if (node.argument.type === 'CallExpression' &&
|
||
|
errorList.indexOf(node.argument.callee.name) !== -1) {
|
||
|
context.report(node, 'Use new keyword when throwing.');
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
};
|
||
|
|
||
|
module.exports.schema = {
|
||
|
'type': 'array',
|
||
|
'additionalItems': {
|
||
|
'type': 'string'
|
||
|
},
|
||
|
'uniqueItems': true
|
||
|
};
|