0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/deps/node-inspect/tools/eslint-rules/require-buffer.js

20 lines
485 B
JavaScript
Raw Normal View History

'use strict';
module.exports = function(context) {
function flagIt(reference) {
const msg = 'Use const Buffer = require(\'buffer\').Buffer; ' +
'at the beginning of this file';
context.report(reference.identifier, msg);
}
return {
'Program:exit': function() {
const globalScope = context.getScope();
const variable = globalScope.set.get('Buffer');
if (variable) {
variable.references.forEach(flagIt);
}
}
};
};