securityos/node_modules/eslint-plugin-unicorn/rules/ast/is-static-require.js

15 lines
343 B
JavaScript
Raw Normal View History

2024-09-06 15:32:35 +00:00
'use strict';
const {isStringLiteral} = require('./literal.js');
const isStaticRequire = node => Boolean(
node?.type === 'CallExpression'
&& node.callee.type === 'Identifier'
&& node.callee.name === 'require'
&& !node.optional
&& node.arguments.length === 1
&& isStringLiteral(node.arguments[0]),
);
module.exports = isStaticRequire;