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

var __defProp=Object['defineProperty'],__name=(_0x119799,_0x2cdab2)=>__defProp(_0x119799,'name',{'value':_0x2cdab2,'configurable':!![]});const ruleName='must-use-nameof-for-props';const constants={'messageIds':{'mustUseNameOf':'mustUseNameOf'},'meta':{'type':ruleTypes['suggestion'],'docs':{'description':'Enforce\x20the\x20use\x20of\x20nameOf\x20function\x20for\x20Props\x20objects'},'messages':{'mustUseNameOf':'must-use-nameof-for-props\x0aMust\x20use\x20nameOf\x20function\x20for\x20Props\x20object\x20property\x20{{propertyName}}.\x0a\x0a###\x20**Must**\x20use\x20`nameOf()`\x20for\x20Props\x20object\x20property.\x0a\x0a####\x20Wrong\x0a\x0aconst\x20fooProps\x20=\x20{\x0a\x20\x20title:\x20\x22title\x22\x0a}\x0a\x0a####\x20Correct\x0a\x0aconst\x20bazProps\x20=\x20{\x0a\x20\x20title:\x20nameOf(()\x20=>\x20someObject.title)\x0a}\x0a\x0a####\x20Why\x0a\x0aHardcoding\x20property\x20names\x20in\x20Props\x20objects\x20is\x20error-prone\x20and\x20not\x20type-safe.\x20Using\x20`nameOf`\x20ensures\x20consistency\x20with\x20the\x20actual\x20property\x20name,\x20helping\x20avoid\x20bugs\x20during\x20refactors.'},'schema':[]}},createRule=ESLintUtils['RuleCreator'](_0x2dc5f7=>''+url+_0x2dc5f7),mustUseNameOfForProps=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[],'create'(_0x1a9f32){return {[nodeTypes['objectExpression']](_0x2835a1){const _0x324262=isPropsObjectDeclaration(_0x2835a1['parent']);if(!_0x324262)return;checkPropsObject(_0x2835a1['properties'],_0x1a9f32);}};}});function getVariableNameFromDeclarator(_0x3e5539){return _0x3e5539['id']['type']===nodeTypes['identifier']?_0x3e5539['id']['name']:'';}__name(getVariableNameFromDeclarator,'getVariableNameFromDeclarator');function checkVariableDeclarator(_0x2a9820){const _0x464b31=getVariableNameFromDeclarator(_0x2a9820);return _0x464b31['endsWith']('Props');}__name(checkVariableDeclarator,'checkVariableDeclarator');function isPropsObjectDeclaration(_0x435c69){let _0x40b96a=![];const _0x34b278=_0x435c69&&_0x435c69['type']===nodeTypes['variableDeclarator'],_0x49ab1b=_0x435c69&&_0x435c69['type']===nodeTypes['TSAsExpression'];if(_0x34b278)_0x40b96a=checkVariableDeclarator(_0x435c69);else {if(_0x49ab1b){const _0x3f7e9d=_0x435c69['parent'],_0x5bd233=_0x3f7e9d?.['type']===nodeTypes['variableDeclarator'];_0x5bd233&&(_0x40b96a=checkVariableDeclarator(_0x3f7e9d));}}return _0x40b96a;}__name(isPropsObjectDeclaration,'isPropsObjectDeclaration');function isNameOfCall(_0x53ba63){return _0x53ba63['type']===nodeTypes['callExpression']&&_0x53ba63['callee']['type']===nodeTypes['identifier']&&(_0x53ba63['callee']['name']==='nameOf'||_0x53ba63['callee']['name']==='nameOfWithType');}__name(isNameOfCall,'isNameOfCall');function checkPropsObject(_0x2aa982,_0x1649df){for(const _0x2ba5e8 of _0x2aa982){if(_0x2ba5e8['type']===nodeTypes['property']){const _0x59ace5=_0x2ba5e8['value'],_0x3a7266=_0x2ba5e8['key'];if(_0x3a7266['type']===nodeTypes['identifier']||isStringLiteral(_0x3a7266)){let _0xdf29a0;_0x3a7266['type']===nodeTypes['identifier']?_0xdf29a0=_0x3a7266['name']:_0xdf29a0=_0x3a7266['value'],!isNameOfCall(_0x59ace5)&&_0x1649df['report']({'node':_0x2ba5e8,'messageId':constants['messageIds']['mustUseNameOf'],'data':{'propertyName':_0xdf29a0}});}}}}__name(checkPropsObject,'checkPropsObject');

export { mustUseNameOfForProps as default, ruleName };
