'use strict';
import { ESLintUtils } from '@typescript-eslint/utils';
import { nodeTypes } from '@flint/infra/analysis';
import { ruleTypes, url } from '@flint/infra/constants/rules-meta';

var __defProp=Object['defineProperty'],__name=(_0x5bd75c,_0x4645b1)=>__defProp(_0x5bd75c,'name',{'value':_0x4645b1,'configurable':!![]});const ruleName='no-new-date';const constants={'messageId':'noNewDate','dateIdentifier':Date['name'],'meta':{'type':ruleTypes['problem'],'docs':{'description':'Disallow\x20the\x20use\x20of\x20new\x20Date();\x20use\x20team\x27s\x20date\x20utilities\x20instead'},'messages':{'noNewDate':'no-new-date\x0a###\x20**Must**\x20use\x20our\x20date\x20functions\x20instead\x20of\x20new\x20Date().\x0a\x0a####\x20Wrong\x0a\x0aif\x20(new\x20Date(foo)\x20>\x20new\x20Date())\x20{\x20…\x20}\x0aconst\x20timestamp\x20=\x20Date.now();\x0aconst\x20parsed\x20=\x20Date.parse(dateString);\x0a\x0a####\x20Correct\x0a\x0aconst\x20now\x20=\x20getNow();\x0aconst\x20fooDate\x20=\x20unixTimestampToDate(foo);\x0a\x0aif\x20(fooDate\x20>\x20now)\x20{\x20…\x20}\x0a\x0a####\x20Why\x0a\x0aNot\x20using\x20new\x20Date()\x20or\x20Date.*\x20methods\x20simplifies\x20the\x20code\x20and\x20makes\x20it\x20easier\x20to\x20manage.\x20By\x20using\x20already\x20written\x20functions,\x20you\x20keep\x20all\x20the\x20date\x20logic\x20in\x20one\x20place.\x20This\x20makes\x20the\x20code\x20cleaner,\x20more\x20consistent,\x20and\x20easier\x20to\x20test.'},'schema':[]}},createRule=ESLintUtils['RuleCreator'](_0x254dc8=>''+url+_0x254dc8),noNewDate=createRule({'name':ruleName,'meta':constants['meta'],'defaultOptions':[],'create'(_0x5b59d5){return {'NewExpression'(_0x179b6b){isDateIdentifier(_0x179b6b['callee'])&&_0x5b59d5['report']({'node':_0x179b6b,'messageId':constants['messageId']});},'CallExpression'(_0x1b8e9e){if(isDateIdentifier(_0x1b8e9e['callee'])){_0x5b59d5['report']({'node':_0x1b8e9e,'messageId':constants['messageId']});return;}if(_0x1b8e9e['callee']['type']===nodeTypes['memberExpression']){const _0x46db6b=_0x1b8e9e['callee'];isDateIdentifier(_0x46db6b['object'])&&_0x5b59d5['report']({'node':_0x1b8e9e,'messageId':constants['messageId']});}}};}});function isDateIdentifier(_0x31c683){return _0x31c683!==void(0x1*0x11dd+-0x191d+0x740)&&_0x31c683['type']===nodeTypes['identifier']&&_0x31c683['name']===constants['dateIdentifier'];}__name(isDateIdentifier,'isDateIdentifier');

export { noNewDate as default, ruleName };
