function collectUnusedVariables(scope,unusedVars){var variables=scope.variables;var childScopes=scope.childScopes;var i=void 0,l=void 0;if(scope.type!=="TDZ"&&(scope.type!=="global"||config.vars==="all")){for(i=0,l=variables.length;i<l;++i){var variable=variables[i];// skip a variable of class itself name in the class scope
if(scope.type==="class"&&scope.block.id===variable.identifiers[0]){continue;}// skip function expression names and variables marked with markVariableAsUsed()
if(scope.functionExpressionScope||variable.eslintUsed){continue;}// skip implicit "arguments" variable
if(scope.type==="function"&&variable.name==="arguments"&&variable.identifiers.length===0){continue;}// explicit global variables don't have definitions.
var def=variable.defs[0];if(def){var type=def.type;// skip catch variables
if(type==="CatchClause"){if(config.caughtErrors==="none"){continue;}// skip ignored parameters
if(config.caughtErrorsIgnorePattern&&config.caughtErrorsIgnorePattern.test(def.name.name)){continue;}}if(type==="Parameter"){// skip any setter argument
if((def.node.parent.type==="Property"||def.node.parent.type==="MethodDefinition")&&def.node.parent.kind==="set"){continue;}// if "args" option is "none", skip any parameter
if(config.args==="none"){continue;}// skip ignored parameters
if(config.argsIgnorePattern&&config.argsIgnorePattern.test(def.name.name)){continue;}// if "args" option is "after-used", skip all but the last parameter
if(config.args==="after-used"&&!isLastInNonIgnoredParameters(variable)){continue;}}else{// skip ignored variables
if(config.varsIgnorePattern&&config.varsIgnorePattern.test(def.name.name)){continue;}}}if(!isUsedVariable(variable)&&!isExported(variable)&&!hasRestSpreadSibling(variable)){unusedVars.push(variable);}}}for(i=0,l=childScopes.length;i<l;++i){collectUnusedVariables(childScopes[i],unusedVars);}return unusedVars;}
Gets an array of variables without read references.
@param {Scope} scope - an escope Scope object.
@param {Variable[]} unusedVars - an array that saving result.
@returns {Variable[]} unused variables of the scope and descendant scopes.
@private