Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ESLint freezes context, so can't monkey patch directly
proxyContext = Object.create(context);
proxyContext.report = function report(...args) {
const node = args.length === 1 ? args[0].node : args[0];
if (isDestructuredVarWithRestProperty(node)) {
// ignore reports for nodes passing the test
return;
}
context.report(...args);
};
}
// create the core rule with the patched context
return noUnusedVars.create(proxyContext);
},
};
lintRules['Program:exit'] = node => {
noUnused(mockContext)['Program:exit'](node);
collectedReport.forEach(
(item, index) => {
var declaration = item.node;
var name = declaration.name;
var namespacedVar = STUB_RE.test(name);
var namespacedFn = false;
if (namespacedVar) {
var parentType = declaration.parent.type;
if (parentType === 'FunctionDeclaration' ||
(parentType === 'VariableDeclarator' && declaration.parent.init && declaration.parent.init.type === 'FunctionExpression')
) {
create(context) {
const rules = baseRule.create(context);
/**
* Mark heritage clause as used
* @param node The node currently being traversed
*/
function markHeritageAsUsed(node: TSESTree.Expression): void {
switch (node.type) {
case AST_NODE_TYPES.Identifier:
context.markVariableAsUsed(node.name);
break;
case AST_NODE_TYPES.MemberExpression:
markHeritageAsUsed(node.object);
break;
case AST_NODE_TYPES.CallExpression:
markHeritageAsUsed(node.callee);
break;