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

var __defProp=Object['defineProperty'],__name=(_0xca4238,_0x112b7b)=>__defProp(_0xca4238,'name',{'value':_0x112b7b,'configurable':!![]});const ruleName='no-redundant-type-alias';const constants={'meta':{'type':ruleTypes['problem'],'docs':{'description':'Disallow\x20redundant\x20type\x20aliases\x20for\x20non-enum-like\x20objects'},'messages':{'noRedundantTypeAlias':'no-redundant-type-alias\x0a###\x20**Must\x20not**\x20define\x20redundant\x20type\x20aliases\x20for\x20non-enum\x20objects.\x0a\x0a####\x20Wrong\x0a\x0aexport\x20const\x20foo\x20=\x20{\x0a\x20\x20\x20\x20bar:\x20\x22Bar\x22,\x0a};\x0a\x0a**export\x20type\x20Foo\x20=\x20(typeof\x20foo)[keyof\x20typeof\x20foo];**\x0a\x0a####\x20Correct\x0a\x0aexport\x20const\x20foo\x20=\x20{\x0a\x20\x20\x20\x20bar:\x20\x22Bar\x22,\x0a};\x0a\x0a####\x20Why\x0a\x0aDefining\x20type\x20aliases\x20for\x20non-enum\x20objects\x20is\x20unnecessary\x20and\x20can\x20lead\x20to\x20code\x20clutter.\x20Such\x20aliases\x20add\x20little\x20value,\x20as\x20their\x20primary\x20purpose\x20is\x20already\x20achieved\x20by\x20the\x20original\x20object’s\x20inferred\x20type.'},'schema':[]}},createRule=ESLintUtils['RuleCreator'](_0x51aa54=>''+url+_0x51aa54),noRedundantTypeAlias=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[],'create'(_0x5d753b){const _0x4347f8=new Set();return {'VariableDeclarator'(_0xef3079){_0xef3079['id']['type']===nodeTypes['identifier']&&isNumericEnumLike(_0xef3079)&&_0x4347f8['add'](_0xef3079['id']['name']);},'TSTypeAliasDeclaration'(_0x2f8cfc){isRedundantTypeAlias(_0x2f8cfc['typeAnnotation'],_0x4347f8)&&_0x5d753b['report']({'node':_0x2f8cfc,'messageId':'noRedundantTypeAlias'});}};}});function getIdentifierName(_0x137b92){if(_0x137b92&&_0x137b92['type']===nodeTypes['TSTypeQuery']&&_0x137b92['exprName']['type']===nodeTypes['identifier'])return _0x137b92['exprName']['name'];return void(0x876+-0x115*-0x6+-0xef4);}__name(getIdentifierName,'getIdentifierName');function isRedundantTypeAlias(_0x581161,_0x2243c5){const _0x2d9ca6=getEnumConstantNameFromAnnotation(_0x581161);if(!_0x2d9ca6||_0x581161['type']!==nodeTypes['TSIndexedAccessType']||_0x581161['indexType']['type']!==nodeTypes['TSTypeOperator'])return ![];const _0x40b2a6=getIdentifierName(_0x581161['indexType']['typeAnnotation']);if(_0x2d9ca6===_0x40b2a6)return !_0x2243c5['has'](_0x2d9ca6);return ![];}__name(isRedundantTypeAlias,'isRedundantTypeAlias');

export { noRedundantTypeAlias as default, ruleName };
