'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { nodeTypes } from '@flint/infra/analysis';
import { eslintFixTypeNames } from '../../../base-repo/constants/internal-common-strings.js';
import { ruleTypes, url } from '@flint/infra/constants/rules-meta';

var __defProp=Object['defineProperty'],__name=(_0x5b9b63,_0x25b8b8)=>__defProp(_0x5b9b63,'name',{'value':_0x25b8b8,'configurable':!![]});const ruleName='must-use-create-error';const constants={'messageIds':{'mustUseCreateError':'mustUseCreateError'},'meta':{'type':ruleTypes['suggestion'],'docs':{'description':'Must\x20use\x20createError\x20instead\x20of\x20new\x20Error'},'messages':{'mustUseCreateError':'must-use-create-error\x0a###\x20**Must**\x20use\x20\x27createError\x27\x20instead\x20of\x20\x27new\x20Error\x27.\x0a\x0a####\x20Wrong\x0a\x0athrow\x20new\x20Error(errors.fooError);\x0a\x0a####\x20Correct\x0a\x0athrow\x20createError(errors.fooError);\x0a\x0a####\x20Why\x0a\x0aTo\x20ensure\x20saas-kit\x20is\x20properly\x20handling\x20every\x20occurring\x20error.'},'schema':[],'fixable':eslintFixTypeNames['code']},'target':{'constructorName':Error['name']},'callText':__name(_0x344bb5=>'createError('+_0x344bb5+')','callText')},createRule=ESLintUtils['RuleCreator'](_0x60da1c=>''+url+_0x60da1c),mustUseCreateError=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[],'create'(_0x3b3b40){return {'NewExpression'(_0x684395){_0x684395['callee']['type']===nodeTypes['identifier']&&_0x684395['callee']['name']===constants['target']['constructorName']&&_0x684395['parent']?.['type']===nodeTypes['throwStatement']&&_0x3b3b40['report']({'node':_0x684395,'messageId':constants['messageIds']['mustUseCreateError'],'fix'(_0x1d09cb){const _0x2415eb=_0x3b3b40['sourceCode'],_0x447bd4=_0x684395['arguments']['map'](_0x3d5b17=>_0x2415eb['getText'](_0x3d5b17)),_0x158ad1=_0x447bd4['join'](',\x20');return _0x1d09cb['replaceText'](_0x684395,constants['callText'](_0x158ad1));}});}};}});

export { mustUseCreateError as default, ruleName };
