| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,16 +10,11 @@ | |||
| 10 | 10 | const msg = 'Use of the Buffer() constructor has been deprecated. ' + | |
| 11 | 11 | 'Please use either Buffer.alloc(), Buffer.allocUnsafe(), ' + | |
| 12 | 12 | 'or Buffer.from()'; | |
| 13 | - | ||
| 14 | - function test(context, node) { | ||
| 15 | - if (node.callee.name === 'Buffer') { | ||
| 16 | - context.report(node, msg); | ||
| 17 | - } | ||
| 18 | - } | ||
| 13 | + const astSelector = 'NewExpression[callee.name="Buffer"],' + | ||
| 14 | + 'CallExpression[callee.name="Buffer"]'; | ||
| 19 | 15 | ||
| 20 | 16 | module.exports = function(context) { | |
| 21 | 17 | return { | |
| 22 | - 'NewExpression': (node) => test(context, node), | ||
| 23 | - 'CallExpression': (node) => test(context, node) | ||
| 18 | + [astSelector]: (node) => context.report(node, msg) | ||
| 24 | 19 | }; | |
| 25 | 20 | }; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments