'use strict';
import { jsBasicTypes } from '../../../base-repo/constants/basic-types.js';
import { nodeTypes, isStringType, isNumberType, isVariableDeclaration, getVariableName } from '@flint/infra/analysis';
import { variableDeclarationKinds } from '@flint/infra/analysis/module-analysis';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { eslintProperties } from '@flint/infra/constants/rules-meta';

var __defProp=Object['defineProperty'],__name=(_0x2c1973,_0x5694d9)=>__defProp(_0x2c1973,'name',{'value':_0x5694d9,'configurable':!![]});const ruleName='must-not-use-anonymous-objects-only-with-explicit-typization';const ruleContent='\x0a###\x20**Must\x20not**\x20use\x20anonymous\x20object\x20only\x20with\x20explicit\x20typization.\x0a\x0a####\x20Wrong\x0a\x0aconst\x20foo\x20=\x20{\x20bar:\x203\x20};\x0a\x0a####\x20Correct\x0a\x0ainterface\x20Foo\x20{\x0a\x20\x20\x20\x20bar:\x20number;\x0a}\x0aconst\x20foo:\x20Foo\x20=\x20{\x20bar:\x203\x20};\x0a\x0a####\x20Why\x0a\x0aHelps\x20with\x20typization,\x20prevents\x20bugs.';var mustNotUseAnonymousObjectsOnlyWithExplicitTypization = createEslintRule(ruleName,ruleContent,__name(function create(_0x1095a8){return {'VariableDeclarator'(_0x2f0c68){const _0x101356=_0x2f0c68['init'];if(!_0x101356)return;if(_0x101356['type']===nodeTypes['objectExpression']){if(isEnumLikeObject(_0x101356['properties'],_0x2f0c68))return;reportAnonymousObject(_0x101356,_0x1095a8);}}};},'create'));function isPrimitive(_0x4b8354){let _0x2413e9=![];return _0x4b8354['type']===nodeTypes['literal']&&(_0x2413e9=isStringType(_0x4b8354['value'])||isNumberType(_0x4b8354['value'])||typeof _0x4b8354['value']===jsBasicTypes['boolean']),_0x4b8354['type']===nodeTypes['unaryExpression']&&(_0x2413e9=_0x4b8354['operator']==='-'&&_0x4b8354['argument']['type']===nodeTypes['literal']&&isNumberType(_0x4b8354['argument']['value'])),_0x2413e9;}__name(isPrimitive,'isPrimitive');function hasOnlyStaticProperties(_0x4908c5){let _0x629e91=!![];for(let _0x5aa9be of _0x4908c5){_0x5aa9be['type']!==nodeTypes['property']&&(_0x629e91=![]),'computed'in _0x5aa9be&&(_0x5aa9be['computed']||_0x5aa9be['kind']!==eslintProperties['init'])&&(_0x629e91=![]),eslintProperties['value']in _0x5aa9be&&!isPrimitive(_0x5aa9be['value'])&&(_0x629e91=![]);}return _0x629e91;}__name(hasOnlyStaticProperties,'hasOnlyStaticProperties');function isEnumLikeObject(_0x51e2bb,_0x505c2c){let _0x32714f=!![];const _0x2b2695=_0x505c2c['parent'],_0x5f2510=isVariableDeclaration(_0x2b2695)&&_0x2b2695['kind']===variableDeclarationKinds['const'];return (!_0x5f2510||!hasOnlyStaticProperties(_0x51e2bb))&&(_0x32714f=![]),_0x32714f;}__name(isEnumLikeObject,'isEnumLikeObject');function reportAnonymousObject(_0x5b5275,_0x4d4580){const _0x273e55=_0x5b5275['parent'];if(_0x273e55?.['type']===nodeTypes['variableDeclarator']&&_0x273e55['id']['type']===nodeTypes['objectPattern'])return;const _0x17c016=_0x273e55?.['type']===nodeTypes['variableDeclarator']&&_0x273e55['id']['type']===nodeTypes['identifier']&&!_0x273e55['id']['typeAnnotation'];if(_0x17c016){const _0x3253bf=getVariableName(_0x5b5275),_0x263dbe=_0x3253bf?'\x27'+_0x3253bf+'\x27':'';_0x4d4580['report']({'node':_0x5b5275,'messageId':ruleName,'data':{'variableNameText':_0x263dbe}});}}__name(reportAnonymousObject,'reportAnonymousObject');

export { mustNotUseAnonymousObjectsOnlyWithExplicitTypization as default, ruleName };
