is-static-require.js 367 B

12345678910111213141516
  1. 'use strict';
  2. const {isStringLiteral} = require('./literal.js');
  3. const isStaticRequire = node => Boolean(
  4. node
  5. && node.type === 'CallExpression'
  6. && node.callee
  7. && node.callee.type === 'Identifier'
  8. && node.callee.name === 'require'
  9. && !node.optional
  10. && node.arguments.length === 1
  11. && isStringLiteral(node.arguments[0]),
  12. );
  13. module.exports = isStaticRequire;