'use strict';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { isIdentifier, isNameMatch, isMemberExpression, isStaticLiteral } from '@flint/infra/analysis';
import { files } from '../../../base-repo/app-constants/project-paths.js';
import { flintRuleIdentifiers } from '@flint/infra/constants/shared-string-identifiers';
import { firstOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x4dfc2,_0x375dd5)=>__defProp(_0x4dfc2,'name',{'value':_0x375dd5,'configurable':!![]});const ruleName='must-use-env-keys-from-constant';const ruleContent='\x0a###\x20**Must**\x20use\x20env\x20keys\x20from\x20constant.\x0a\x0a####\x20Wrong\x0a\x0aconst\x20ciProjectId\x20=\x20process.env.CI_PROJECT_ID;\x0a\x0aconst\x20dev\x20=\x20getStringEnvSetting(\x22CI_PROJECT_ID\x22);\x0a\x0a####\x20Correct\x0a\x0aconst\x20projectId\x20=\x20process.env[environmentVariables.ciProjectId];\x0a\x0aconst\x20ciProjectId\x20=\x20getStringEnvSetting(environmentVariables.ciProjectId);\x0a\x0a####\x20Why\x0a\x0aEnvironment\x20variable\x20keys\x20must\x20be\x20taken\x20from\x20a\x20constant\x20instead\x20of\x20being\x20written\x20directly.\x20This\x20keeps\x20all\x20environment\x20variable\x20names\x20centralized,\x20prevents\x20duplication\x20and\x20typos,\x20and\x20makes\x20refactoring\x20safer.\x0a';var mustUseEnvKeysFromConstant = createEslintRule(ruleName,ruleContent,__name(function create(_0x3fbc9f){return {'CallExpression'(_0x24cbc5){const _0x120bed=_0x24cbc5['arguments'],_0x35f3b1=/^get(String|RequiredString|Number|Boolean)EnvSetting$/,_0x1126e0=isIdentifier(_0x24cbc5['callee'])&&_0x35f3b1['test'](_0x24cbc5['callee']['name']),_0xf8f796=firstOrUndefined(_0x120bed);_0x1126e0&&_0xf8f796&&isStaticLiteral(_0xf8f796)&&_0x3fbc9f['report']({'node':_0xf8f796,'messageId':ruleName});},'MemberExpression'(_0x33d41e){const _0x3f1ecb=_0x33d41e['parent'],_0x19f9fc=isIdentifier(_0x33d41e['object'])&&isNameMatch(_0x33d41e['object'],flintRuleIdentifiers['process'])&&isIdentifier(_0x33d41e['property'])&&isNameMatch(_0x33d41e['property'],files['env']);if(!_0x19f9fc||!isMemberExpression(_0x3f1ecb))return;const _0x4fbba3=!_0x3f1ecb['computed']||isStaticLiteral(_0x3f1ecb['property']);_0x4fbba3&&_0x3fbc9f['report']({'node':_0x3f1ecb['property'],'messageId':ruleName});}};},'create'));

export { mustUseEnvKeysFromConstant as default, ruleName };
