'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { ruleTypes, url, eslintProperties } from '@flint/infra/constants/rules-meta';
import { isAwaitExpression, isIdentifier, isChainExpression, isVariableDeclarator, nodeTypes, isNameMatch } from '@flint/infra/analysis';

var __defProp=Object['defineProperty'],__name=(_0x464929,_0x139758)=>__defProp(_0x464929,'name',{'value':_0x139758,'configurable':!![]});const ruleName='must-do-await-data-in-one-line';const ruleId='mustDoAwaitDataInOneLine';const constants={'meta':{'type':ruleTypes['problem'],'docs':{'description':ruleName},'messages':{[ruleId]:ruleName+'\x0a###\x20**Must**\x20add\x20await\x20in\x20one\x20line\x20with\x20data.\x0a\x0a####\x20Wrong\x0a\x0aconst\x20res\x20=\x20await\x20getFoo(foo);\x0aconst\x20baz\x20=\x20res.data;\x0a\x0a####\x20Correct\x0a\x0aconst\x20baz\x20=\x20(await\x20getFoo(foo)).data;\x0a\x0a####\x20Why\x0a\x0aThis\x20improves\x20readability.'},'schema':[]}},createRule=ESLintUtils['RuleCreator'](_0x40a516=>''+url+_0x40a516),mustDoAwaitDataInOneLine=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[],'create'(_0x40730a){return {'VariableDeclaration'(_0x18f527){const _0x5c23ae=_0x18f527['declarations']['at'](0x14*0x7c+-0x1*-0x25b3+-0x6c5*0x7);if(!_0x5c23ae?.['init']||!isAwaitExpression(_0x5c23ae['init'])||!isIdentifier(_0x5c23ae['id']))return;const _0x1f01da=_0x5c23ae['id']['name'],_0x40fc17=_0x40730a['sourceCode']['getScope'](_0x18f527)['variables']['find'](_0x120666=>{return _0x120666['name']===_0x1f01da;});if(!_0x40fc17)return;const _0x4602fc=_0x40fc17['references']['find'](_0x4ad1c=>{const _0xfbe0dd=_0x4ad1c['identifier']['parent'];if(!_0xfbe0dd)return ![];let _0x899265=_0xfbe0dd['parent'];return _0x899265&&isChainExpression(_0x899265)&&(_0x899265=_0x899265['parent']),isDataAccess(_0x1f01da,_0xfbe0dd)&&!!_0x899265&&isVariableDeclarator(_0x899265);});_0x4602fc&&_0x40730a['report']({'node':_0x4602fc['identifier'],'messageId':ruleId});}};}});function isDataAccess(_0x58ac69,_0x5ba1dd){if(!_0x5ba1dd)return ![];if('object'in _0x5ba1dd&&eslintProperties['property']in _0x5ba1dd){const _0x864696=_0x5ba1dd['type'],_0x55a118=_0x864696===nodeTypes['memberExpression']||_0x864696==='TSOptionalMemberExpression';if(_0x55a118)return isIdentifier(_0x5ba1dd['object'])&&isNameMatch(_0x5ba1dd['object'],_0x58ac69)&&isIdentifier(_0x5ba1dd['property'])&&isNameMatch(_0x5ba1dd['property'],eslintProperties['data']);}return ![];}__name(isDataAccess,'isDataAccess');

export { mustDoAwaitDataInOneLine as default, ruleId, ruleName };
