summaryrefslogtreecommitdiff
path: root/deps/node/deps/node-inspect/tools/eslint-rules/require-buffer.js
blob: c9818cb758f7bdcb2643c9746b2b3ace64bff650 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'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);
      }
    }
  };
};