'use strict';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { isMemberExpression, isGlobalObjectConstructor, isIdentifier, getPropertyName } from '@flint/infra/analysis';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';
import { jsBasicTypes } from '../../../base-repo/constants/basic-types.js';
import { collectionMethodNames } from '../../../base-repo/constants/internal-common-strings.js';
import { flintRuleIdentifiers } from '@flint/infra/constants/shared-string-identifiers';

var __defProp=Object['defineProperty'],__name=(_0x478bae,_0x31c9cc)=>__defProp(_0x478bae,'name',{'value':_0x31c9cc,'configurable':!![]});const ruleName='must-not-use-object-constructor-methods';const ruleContent='\x0a###\x20**Must\x20not**\x20use\x20Object.keys()\x20or\x20Object.values()\x20on\x20objects.\x0a\x0a####\x20Wrong\x0a\x0aconst\x20allowedHttpMethods\x20=\x20Object.values(httpMethods);\x0aconst\x20allowedHttpMethodNames\x20=\x20Object.keys(httpMethods);\x0a\x0a####\x20Correct\x0a\x0aconst\x20allowedHttpMethods\x20=\x20[\x0a\x20\x20\x20\x20httpMethods.get,\x0a\x20\x20\x20\x20httpMethods.post,\x0a\x20\x20\x20\x20httpMethods.put,\x0a\x20\x20\x20\x20httpMethods.delete,\x0a\x20\x20\x20\x20httpMethods.patch,\x0a\x20\x20\x20\x20httpMethods.options,\x0a\x20\x20\x20\x20httpMethods.connect,\x0a\x20\x20\x20\x20httpMethods.method,\x0a\x20\x20\x20\x20httpMethods.trace,\x0a];\x0a\x0aconst\x20allowedHttpMethodNames\x20=\x20[\x0a\x20\x20\x20\x20\x22get\x22,\x0a\x20\x20\x20\x20\x22post\x22,\x0a\x20\x20\x20\x20\x22put\x22,\x0a\x20\x20\x20\x20\x22delete\x22,\x0a\x20\x20\x20\x20\x22patch\x22,\x0a\x20\x20\x20\x20\x22options\x22,\x0a\x20\x20\x20\x20\x22connect\x22,\x0a\x20\x20\x20\x20\x22method\x22,\x0a\x20\x20\x20\x20\x22trace\x22,\x0a];\x0a\x0a####\x20Why\x0a\x0aPrefer\x20explicit\x20property\x20access\x20or\x20explicit\x20key\x20lists\x20so\x20the\x20resulting\x20list\x20changes\x20only\x20when\x20intentionally\x20updated,\x20instead\x20of\x20silently\x20including\x20every\x20current\x20and\x20future\x20object\x20property.';var mustNotUseObjectConstructorMethods = createEslintRule(ruleName,ruleContent,__name(function create(_0x958bb7,_0xca12c3){const _0x40b18c=firstOrUndefined(_0xca12c3)?.['forbiddenMethods']??[];return {'CallExpression'(_0x14384d){const _0x4baf8e=_0x14384d['callee'];isMemberExpression(_0x4baf8e)&&isGlobalObjectConstructor(_0x4baf8e['object'],_0x958bb7['sourceCode'])&&isForbiddenMethod(_0x4baf8e,_0x40b18c)&&_0x958bb7['report']({'node':_0x14384d,'messageId':ruleName});}};},'create'),{'schema':[{'type':jsBasicTypes['object'],'properties':{'forbiddenMethods':{'type':jsBasicTypes['array'],'items':{'type':jsBasicTypes['string']}}}}],'defaultOptions':[{'forbiddenMethods':[collectionMethodNames['values'],flintRuleIdentifiers['keys']]}]});function isForbiddenMethod(_0x2c7079,_0x475363){if(!isIdentifier(_0x2c7079['property']))return ![];const _0x312886=getPropertyName(_0x2c7079);return Boolean(_0x312886&&_0x475363['includes'](_0x312886));}__name(isForbiddenMethod,'isForbiddenMethod');

export { mustNotUseObjectConstructorMethods as default, ruleName };
