mirror of
https://github.com/nodejs/node.git
synced 2025-05-17 22:02:33 +00:00

We are about to upgrade from ESlint 1 to ESLint 2. Remove lint rules that will not exist in ESLint 2. PR-URL: https://github.com/nodejs/node/pull/5214 Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: jbergstroem - Johan Bergström <bugs@bergstroem.nu> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Myles Borins <myles.borins@gmail.com>
32 lines
791 B
JavaScript
32 lines
791 B
JavaScript
/**
|
|
* @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
|
|
};
|