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

const ruleName='no-then';const constants={'messageIds':{'useAsyncAwait':'useAsyncAwait'},'meta':{'type':ruleTypes['problem'],'docs':{'description':'Enforce\x20async/await\x20instead\x20of\x20.then()'},'messages':{'useAsyncAwait':'no-then\x0a###\x20**Must**\x20use\x20async/await\x20syntax\x20instead\x20of\x20.then().\x0a\x0a####\x20Wrong\x0a\x0afetch(\x27https://api.example.com/data\x27)\x0a\x20\x20\x20\x20.then(response\x20=>\x20response.json())\x0a\x20\x20\x20\x20.then(data\x20=>\x20setData(data))\x0a\x20\x20\x20\x20.catch(error\x20=>\x20setError(error));\x0a\x0a####\x20Correct\x0a\x0aconst\x20response\x20=\x20await\x20fetch(\x27https://api.example.com/data\x27);\x0aif\x20(!response.ok)\x20{\x0a\x20\x20\x20\x20throw\x20new\x20Error(\x27Network\x20response\x20was\x20not\x20ok\x27);\x0a}\x0aconst\x20data\x20=\x20await\x20response.json();\x0asetData(data);\x0a\x0a####\x20Why\x0a\x0aUsing\x20async/await\x20simplifies\x20asynchronous\x20code\x20and\x20makes\x20it\x20more\x20readable\x20and\x20maintainable.\x20This\x20is\x20especially\x20useful\x20when\x20handling\x20complex\x20promise\x20chains,\x20as\x20it\x20improves\x20the\x20code\x20structure\x20by\x20avoiding\x20nesting\x20and\x20enhancing\x20debugging.'},'schema':[]}},createRule=ESLintUtils['RuleCreator'](_0x434472=>''+url+_0x434472),noThen=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[],'create'(_0x34b8e0){return {'CallExpression'(_0x40eda3){_0x40eda3['callee']['type']===nodeTypes['memberExpression']&&_0x40eda3['callee']['property']['type']===nodeTypes['identifier']&&_0x40eda3['callee']['property']['name']==='then'&&_0x34b8e0['report']({'node':_0x40eda3,'messageId':constants['messageIds']['useAsyncAwait']});}};}});

export { noThen as default, ruleName };
