'use strict';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { packagesPath, folders } from '../../../base-repo/app-constants/project-paths.js';
import { createNodeVisitor, nodeTypes } from '@flint/infra/analysis';

const ruleName='must-not-define-functions-in-constants-files';const ruleContent='\x0a###\x20**Must\x20not**\x20define\x20functions\x20in\x20constants\x20files.\x0a\x0a####\x20Wrong\x0a\x0a//\x20constants.ts\x0aexport\x20function\x20foo()\x20{\x0a\x20\x20\x20\x20return\x20\x22bar\x22;\x0a}\x0a\x0a####\x20Correct\x0a\x0a//\x20foo.ts\x0aexport\x20function\x20foo()\x20{\x0a\x20\x20\x20\x20return\x20\x22bar\x22;\x0a}\x0a\x0a####\x20Why\x0a\x0aConstants\x20files\x20should\x20only\x20contain\x20static\x20data\x20definitions.\x20Functions\x20belong\x20in\x20files\x20relevant\x20to\x20its\x20area.',ignoredFolders=[''+packagesPath['packagesFlint']+folders['rules']],regexes={'isInConstantsFolder':new RegExp('/(?:[^/]+-)?'+folders['constants']+'/'),'isConstantsFile':new RegExp(folders['constants']+'\x5c.(ts|js)$')};var mustNotDefineFunctionsInConstantsFiles = createEslintRule(ruleName,ruleContent,_0x33cdfb=>{const _0x40b1dd=_0x33cdfb['filename']['replaceAll']('\x5c','/');if((regexes['isInConstantsFolder']['test'](_0x40b1dd)||regexes['isConstantsFile']['test'](_0x40b1dd))&&!ignoredFolders['some'](_0x45aa9e=>_0x40b1dd['includes'](_0x45aa9e)))return {'FunctionDeclaration'(_0x390a4e){_0x33cdfb['report']({'node':_0x390a4e,'messageId':ruleName});},...createNodeVisitor(_0x584872=>{_0x584872['parent']['type']===nodeTypes['variableDeclarator']&&_0x33cdfb['report']({'node':_0x584872,'messageId':ruleName});},[nodeTypes['functionExpression'],nodeTypes['arrowFunctionExpression']])};return {};});

export { mustNotDefineFunctionsInConstantsFiles as default, ruleName };
