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.
25 lines
679 B
25 lines
679 B
/**
|
|
* @fileoverview Require at least two arguments when calling setTimeout() or
|
|
* setInterval().
|
|
* @author Rich Trott
|
|
*/
|
|
'use strict';
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
|
|
function isTimer(name) {
|
|
return ['setTimeout', 'setInterval'].includes(name);
|
|
}
|
|
|
|
module.exports = function(context) {
|
|
return {
|
|
'CallExpression': function(node) {
|
|
const name = node.callee.name;
|
|
if (isTimer(name) && node.arguments.length < 2) {
|
|
context.report(node, `${name} must have at least 2 arguments`);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|