'use strict';
import { isGlobalObject, nodeTypes, getPropertyName, getReference, isInTypePosition } from '@flint/infra/analysis';
import { createEslintRule } from '@flint/infra/create-eslint-rule';
import { flintRuleIdentifiers } from '@flint/infra/constants/shared-string-identifiers';

var __defProp=Object['defineProperty'],__name=(_0x1ebadc,_0x57ea8f)=>__defProp(_0x1ebadc,'name',{'value':_0x57ea8f,'configurable':!![]});const ruleName='must-not-use-fetch';const ruleContent='\x0a###\x20**Must\x20not**\x20use\x20`fetch`.\x0a\x0aInstead,\x20use\x20the\x20API-related\x20functions\x20from\x20the\x20\x22fd-toolbox\x22\x20package:\x0a-\x20base\x20API\x20(\x22@fd-toolbox/api/base-api\x22)\x20for\x20external\x20services;\x0a-\x20API\x20(\x22@fd-toolbox/api/api-client\x22)\x20for\x20the\x20current\x20project\x27s\x20API.\x0a\x0a####\x20Wrong\x0a\x0aconst\x20foo\x20=\x20await\x20fetch(bar);\x0aconst\x20baz\x20=\x20await\x20foo.json();\x0a\x0a####\x20Correct\x0a\x0aimport\x20{\x20apiGet\x20}\x20from\x20\x22@fd-toolbox/api/api-client\x22;\x0a\x0aconst\x20foo\x20=\x20await\x20apiGet<Bar>(baz);\x0a\x0a####\x20Why\x0a\x0aWe\x20use\x20our\x20own\x20wrappers\x20around\x20the\x20`fetch`\x20function.';var mustNotUseFetch = createEslintRule(ruleName,ruleContent,__name(function create(_0x2093c2){return {'Identifier'(_0x3f1d2a){if(_0x3f1d2a['name']!==constants['fetch'])return;const _0x58cb46=getReference(_0x3f1d2a,_0x2093c2['sourceCode']);if(!_0x58cb46?.['isRead']()||_0x58cb46['resolved']||isInTypePosition(_0x3f1d2a))return;_0x2093c2['report']({'node':_0x3f1d2a,'messageId':ruleName});},'MemberExpression'(_0x178cb5){if(!isGlobalObject(_0x178cb5['object'],_0x2093c2['sourceCode'])||getPropertyName(_0x178cb5)!==constants['fetch'])return;_0x2093c2['report']({'node':_0x178cb5['property'],'messageId':ruleName});},'VariableDeclarator'(_0x5237fb){if(!_0x5237fb['init']||!isGlobalObject(_0x5237fb['init'],_0x2093c2['sourceCode'])||_0x5237fb['id']['type']!==nodeTypes['objectPattern'])return;const _0x4856f5=_0x5237fb['id']['properties']['find'](_0x8e2db1=>_0x8e2db1['type']===nodeTypes['property']&&getPropertyName(_0x8e2db1)===constants['fetch']);if(!_0x4856f5)return;_0x2093c2['report']({'node':_0x4856f5['key'],'messageId':ruleName});}};},'create'));const constants={'fetch':flintRuleIdentifiers['fetch']};

export { mustNotUseFetch as default, ruleName };
