mirror of https://github.com/lukechilds/node.git
Browse Source
Replace custom lint rule for `assert.fail()` function signature errors with a restricted-syntax rule. PR-URL: https://github.com/nodejs/node/pull/12287 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com>v6
2 changed files with 3 additions and 31 deletions
@ -1,30 +0,0 @@ |
|||||
/** |
|
||||
* @fileoverview Prohibit use of a single argument only in `assert.fail()`. It |
|
||||
* is almost always an error. |
|
||||
* @author Rich Trott |
|
||||
*/ |
|
||||
'use strict'; |
|
||||
|
|
||||
//------------------------------------------------------------------------------
|
|
||||
// Rule Definition
|
|
||||
//------------------------------------------------------------------------------
|
|
||||
|
|
||||
const msg = 'assert.fail() message should be third argument'; |
|
||||
|
|
||||
function isAssert(node) { |
|
||||
return node.callee.object && node.callee.object.name === 'assert'; |
|
||||
} |
|
||||
|
|
||||
function isFail(node) { |
|
||||
return node.callee.property && node.callee.property.name === 'fail'; |
|
||||
} |
|
||||
|
|
||||
module.exports = function(context) { |
|
||||
return { |
|
||||
'CallExpression': function(node) { |
|
||||
if (isAssert(node) && isFail(node) && node.arguments.length === 1) { |
|
||||
context.report(node, msg); |
|
||||
} |
|
||||
} |
|
||||
}; |
|
||||
}; |
|
Loading…
Reference in new issue