'use strict';
import { getFunctionName, nodeTypes, isPropertyNamed, normalizeNodes } from '@flint/infra/analysis';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { commonLowerCaseWords, collectionMethodNames, commandNames, wellKnownProps } from '../../../base-repo/constants/internal-common-strings.js';
import { wellKnownPositions } from '../../../base-repo/constants/tools-constants.js';
import { eslintProperties, eslintSchemaBasicTypes } from '@flint/infra/constants/rules-meta';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0xe60e08,_0x4e8436)=>__defProp(_0xe60e08,'name',{'value':_0x4e8436,'configurable':!![]});const ruleName='must-use-descriptive-names-for-functions-and-parameters';const ruleContent='\x0a###\x20**Must**\x20use\x20descriptive\x20names\x20for\x20functions\x20and\x20parameters.\x0a\x0a####\x20Wrong\x0a\x0afunction\x20calc(a,\x20b)\x20{\x0a\x20\x20\x20\x20...\x0a}\x0a\x0a####\x20Correct\x0a\x0afunction\x20calculateTotalPrice(item,\x20amount)\x20{\x0a\x20\x20\x20\x20...\x0a}\x0a\x0a####\x20Why\x0a\x0aThis\x20makes\x20your\x20code\x20clearer\x20and\x20improves\x20readability.',allowedFunctions={'add':commonLowerCaseWords['add'],'run':commandNames['run'],'url':commonLowerCaseWords['url'],'map':collectionMethodNames['map'],'get':commonLowerCaseWords['get'],'top':wellKnownPositions['top'],'log':commonLowerCaseWords['log']},allowedFunctionNames=new Set(Object['values'](allowedFunctions)),allowedParameterNames=new Set(['_','mr',wellKnownProps['id']]);var mustUseDescriptiveNamesForFunctionsAndParameters = createEslintRule(ruleName,ruleContent,__name(function create(_0x1891b1,_0x4b7863){const _0x21a3b3=firstOrUndefined(_0x4b7863)?.['minFunctionNameLength']??0xb70+-0x1d1f+0x11b3,_0x41dc89=firstOrUndefined(_0x4b7863)?.['minParameterNameLength']??-0xc75+0x1*0xcc8+-0x50;return {'FunctionDeclaration,\x20FunctionExpression'(_0x10a035){const _0x2460d0=getFunctionName(_0x10a035);if(_0x10a035['parent']['type']===nodeTypes['property']&&isPropertyNamed(_0x10a035['parent'],eslintProperties['fix']))return;_0x2460d0&&!allowedFunctionNames['has'](_0x2460d0)&&_0x2460d0['length']<_0x21a3b3&&_0x1891b1['report']({'node':_0x10a035,'messageId':ruleName});if(!_0x10a035['params']['length'])return;for(const _0x30e203 of _0x10a035['params']){const _0x1ae51b=getParameterIdentifiers(_0x30e203);for(const _0x7ce5ba of _0x1ae51b){!allowedParameterNames['has'](_0x7ce5ba['name'])&&_0x7ce5ba['name']['length']<_0x41dc89&&_0x1891b1['report']({'node':_0x7ce5ba,'messageId':ruleName});}}}};},'create'),{'schema':[{'type':'object','properties':{'minFunctionNameLength':{'type':eslintSchemaBasicTypes['integer']},'minParameterNameLength':{'type':eslintSchemaBasicTypes['integer']}},'additionalProperties':![]}],'defaultOptions':[{'minFunctionNameLength':0x4,'minParameterNameLength':0x3}]});function getParameterIdentifiers(_0x4a06f8){switch(_0x4a06f8['type']){case nodeTypes['identifier']:return [_0x4a06f8];case nodeTypes['objectPattern']:return getIdentifiersFromObjectProperties(_0x4a06f8['properties']);case nodeTypes['arrayPattern']:return getIdentifiersFromArrayElements(normalizeNodes(_0x4a06f8['elements']));case nodeTypes['restElement']:return getParameterIdentifiers(_0x4a06f8['argument']);case nodeTypes['assignmentPattern']:return getParameterIdentifiers(_0x4a06f8['left']);default:return [];}}__name(getParameterIdentifiers,'getParameterIdentifiers');function getIdentifiersFromObjectProperties(_0x4fcd94){const _0x50def4=[];for(const _0x201334 of _0x4fcd94){if(_0x201334['type']===nodeTypes['property'])_0x50def4['push'](...getParameterIdentifiers(_0x201334['value']));else _0x201334['type']===nodeTypes['restElement']&&_0x50def4['push'](...getParameterIdentifiers(_0x201334['argument']));}return _0x50def4;}__name(getIdentifiersFromObjectProperties,'getIdentifiersFromObjectProperties');function getIdentifiersFromArrayElements(_0x297d36){const _0x49ff1f=[];for(const _0x5117a4 of _0x297d36){_0x5117a4&&_0x49ff1f['push'](...getParameterIdentifiers(_0x5117a4));}return _0x49ff1f;}__name(getIdentifiersFromArrayElements,'getIdentifiersFromArrayElements');

export { mustUseDescriptiveNamesForFunctionsAndParameters as default, ruleName };
