function modifyConfigsFromComments(filename,ast,config,reportingConfig,messages){var commentConfig={exported:{},astGlobals:{},rules:{},env:{}};var commentRules={};ast.comments.forEach(function(comment){var value=comment.value.trim();var match=/^(eslint(-\w+){0,3}|exported|globals?)(\s|$)/.exec(value);if(match){value=value.substring(match.index+match[1].length);if(comment.type==="Block"){switch(match[1]){case"exported":(0,_assign4.default)(commentConfig.exported,parseBooleanConfig(value,comment));break;case"globals":case"global":(0,_assign4.default)(commentConfig.astGlobals,parseBooleanConfig(value,comment));break;case"eslint-env":(0,_assign4.default)(commentConfig.env,parseListConfig(value));break;case"eslint-disable":disableReporting(reportingConfig,comment.loc.start,(0,_keys4.default)(parseListConfig(value)));break;case"eslint-enable":enableReporting(reportingConfig,comment.loc.start,(0,_keys4.default)(parseListConfig(value)));break;case"eslint":{var items=parseJsonConfig(value,comment.loc,messages);(0,_keys4.default)(items).forEach(function(name){var ruleValue=items[name];validator.validateRuleOptions(name,ruleValue,filename+" line "+comment.loc.start.line);commentRules[name]=ruleValue;});break;}// no default
}}else{// comment.type === "Line"
if(match[1]==="eslint-disable-line"){disableReporting(reportingConfig,{line:comment.loc.start.line,column:0},(0,_keys4.default)(parseListConfig(value)));enableReporting(reportingConfig,comment.loc.end,(0,_keys4.default)(parseListConfig(value)));}else if(match[1]==="eslint-disable-next-line"){disableReporting(reportingConfig,comment.loc.start,(0,_keys4.default)(parseListConfig(value)));enableReporting(reportingConfig,{line:comment.loc.start.line+2},(0,_keys4.default)(parseListConfig(value)));}}}});// apply environment configs
(0,_keys4.default)(commentConfig.env).forEach(function(name){var env=Environments.get(name);if(env){commentConfig=ConfigOps.merge(commentConfig,env);}});(0,_assign4.default)(commentConfig.rules,commentRules);return ConfigOps.merge(config,commentConfig);}
Parses comments in file to extract file-specific config of rules, globals
and environments and merges them with global config; also code blocks
where reporting is disabled or enabled and merges them with reporting config.
@param {string} filename The file being checked.
@param {ASTNode} ast The top node of the AST.
@param {Object} config The existing configuration data.
@param {Object[]} reportingConfig The existing reporting configuration data.
@param {Object[]} messages The messages queue.
@returns {Object} Modified config object