jshint.js 345 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375
  1. define(function(require, exports, module) {
  2. module.exports = (function outer (modules, cache, entry) {
  3. var previousRequire = typeof require == "function" && require;
  4. function newRequire(name, jumped){
  5. if(!cache[name]) {
  6. if(!modules[name]) {
  7. var currentRequire = typeof require == "function" && require;
  8. if (!jumped && currentRequire) return currentRequire(name, true);
  9. if (previousRequire) return previousRequire(name, true);
  10. var err = new Error('Cannot find module \'' + name + '\'');
  11. err.code = 'MODULE_NOT_FOUND';
  12. throw err;
  13. }
  14. var m = cache[name] = {exports:{}};
  15. modules[name][0].call(m.exports, function(x){
  16. var id = modules[name][1][x];
  17. return newRequire(id ? id : x);
  18. },m,m.exports,outer,modules,cache,entry);
  19. }
  20. return cache[name].exports;
  21. }
  22. for(var i=0;i<entry.length;i++) newRequire(entry[i]);
  23. return newRequire(entry[0]);
  24. })
  25. ({"/node_modules/browserify/node_modules/events/events.js":[function(_dereq_,module,exports){
  26. // Copyright Joyent, Inc. and other Node contributors.
  27. //
  28. // Permission is hereby granted, free of charge, to any person obtaining a
  29. // copy of this software and associated documentation files (the
  30. // "Software"), to deal in the Software without restriction, including
  31. // without limitation the rights to use, copy, modify, merge, publish,
  32. // distribute, sublicense, and/or sell copies of the Software, and to permit
  33. // persons to whom the Software is furnished to do so, subject to the
  34. // following conditions:
  35. //
  36. // The above copyright notice and this permission notice shall be included
  37. // in all copies or substantial portions of the Software.
  38. //
  39. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  40. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  41. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  42. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  43. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  44. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  45. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  46. function EventEmitter() {
  47. this._events = this._events || {};
  48. this._maxListeners = this._maxListeners || undefined;
  49. }
  50. module.exports = EventEmitter;
  51. // Backwards-compat with node 0.10.x
  52. EventEmitter.EventEmitter = EventEmitter;
  53. EventEmitter.prototype._events = undefined;
  54. EventEmitter.prototype._maxListeners = undefined;
  55. // By default EventEmitters will print a warning if more than 10 listeners are
  56. // added to it. This is a useful default which helps finding memory leaks.
  57. EventEmitter.defaultMaxListeners = 10;
  58. // Obviously not all Emitters should be limited to 10. This function allows
  59. // that to be increased. Set to zero for unlimited.
  60. EventEmitter.prototype.setMaxListeners = function(n) {
  61. if (!isNumber(n) || n < 0 || isNaN(n))
  62. throw TypeError('n must be a positive number');
  63. this._maxListeners = n;
  64. return this;
  65. };
  66. EventEmitter.prototype.emit = function(type) {
  67. var er, handler, len, args, i, listeners;
  68. if (!this._events)
  69. this._events = {};
  70. // If there is no 'error' event listener then throw.
  71. if (type === 'error') {
  72. if (!this._events.error ||
  73. (isObject(this._events.error) && !this._events.error.length)) {
  74. er = arguments[1];
  75. if (er instanceof Error) {
  76. throw er; // Unhandled 'error' event
  77. }
  78. throw TypeError('Uncaught, unspecified "error" event.');
  79. }
  80. }
  81. handler = this._events[type];
  82. if (isUndefined(handler))
  83. return false;
  84. if (isFunction(handler)) {
  85. switch (arguments.length) {
  86. // fast cases
  87. case 1:
  88. handler.call(this);
  89. break;
  90. case 2:
  91. handler.call(this, arguments[1]);
  92. break;
  93. case 3:
  94. handler.call(this, arguments[1], arguments[2]);
  95. break;
  96. // slower
  97. default:
  98. len = arguments.length;
  99. args = new Array(len - 1);
  100. for (i = 1; i < len; i++)
  101. args[i - 1] = arguments[i];
  102. handler.apply(this, args);
  103. }
  104. } else if (isObject(handler)) {
  105. len = arguments.length;
  106. args = new Array(len - 1);
  107. for (i = 1; i < len; i++)
  108. args[i - 1] = arguments[i];
  109. listeners = handler.slice();
  110. len = listeners.length;
  111. for (i = 0; i < len; i++)
  112. listeners[i].apply(this, args);
  113. }
  114. return true;
  115. };
  116. EventEmitter.prototype.addListener = function(type, listener) {
  117. var m;
  118. if (!isFunction(listener))
  119. throw TypeError('listener must be a function');
  120. if (!this._events)
  121. this._events = {};
  122. // To avoid recursion in the case that type === "newListener"! Before
  123. // adding it to the listeners, first emit "newListener".
  124. if (this._events.newListener)
  125. this.emit('newListener', type,
  126. isFunction(listener.listener) ?
  127. listener.listener : listener);
  128. if (!this._events[type])
  129. // Optimize the case of one listener. Don't need the extra array object.
  130. this._events[type] = listener;
  131. else if (isObject(this._events[type]))
  132. // If we've already got an array, just append.
  133. this._events[type].push(listener);
  134. else
  135. // Adding the second element, need to change to array.
  136. this._events[type] = [this._events[type], listener];
  137. // Check for listener leak
  138. if (isObject(this._events[type]) && !this._events[type].warned) {
  139. var m;
  140. if (!isUndefined(this._maxListeners)) {
  141. m = this._maxListeners;
  142. } else {
  143. m = EventEmitter.defaultMaxListeners;
  144. }
  145. if (m && m > 0 && this._events[type].length > m) {
  146. this._events[type].warned = true;
  147. console.error('(node) warning: possible EventEmitter memory ' +
  148. 'leak detected. %d listeners added. ' +
  149. 'Use emitter.setMaxListeners() to increase limit.',
  150. this._events[type].length);
  151. if (typeof console.trace === 'function') {
  152. // not supported in IE 10
  153. console.trace();
  154. }
  155. }
  156. }
  157. return this;
  158. };
  159. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  160. EventEmitter.prototype.once = function(type, listener) {
  161. if (!isFunction(listener))
  162. throw TypeError('listener must be a function');
  163. var fired = false;
  164. function g() {
  165. this.removeListener(type, g);
  166. if (!fired) {
  167. fired = true;
  168. listener.apply(this, arguments);
  169. }
  170. }
  171. g.listener = listener;
  172. this.on(type, g);
  173. return this;
  174. };
  175. // emits a 'removeListener' event iff the listener was removed
  176. EventEmitter.prototype.removeListener = function(type, listener) {
  177. var list, position, length, i;
  178. if (!isFunction(listener))
  179. throw TypeError('listener must be a function');
  180. if (!this._events || !this._events[type])
  181. return this;
  182. list = this._events[type];
  183. length = list.length;
  184. position = -1;
  185. if (list === listener ||
  186. (isFunction(list.listener) && list.listener === listener)) {
  187. delete this._events[type];
  188. if (this._events.removeListener)
  189. this.emit('removeListener', type, listener);
  190. } else if (isObject(list)) {
  191. for (i = length; i-- > 0;) {
  192. if (list[i] === listener ||
  193. (list[i].listener && list[i].listener === listener)) {
  194. position = i;
  195. break;
  196. }
  197. }
  198. if (position < 0)
  199. return this;
  200. if (list.length === 1) {
  201. list.length = 0;
  202. delete this._events[type];
  203. } else {
  204. list.splice(position, 1);
  205. }
  206. if (this._events.removeListener)
  207. this.emit('removeListener', type, listener);
  208. }
  209. return this;
  210. };
  211. EventEmitter.prototype.removeAllListeners = function(type) {
  212. var key, listeners;
  213. if (!this._events)
  214. return this;
  215. // not listening for removeListener, no need to emit
  216. if (!this._events.removeListener) {
  217. if (arguments.length === 0)
  218. this._events = {};
  219. else if (this._events[type])
  220. delete this._events[type];
  221. return this;
  222. }
  223. // emit removeListener for all listeners on all events
  224. if (arguments.length === 0) {
  225. for (key in this._events) {
  226. if (key === 'removeListener') continue;
  227. this.removeAllListeners(key);
  228. }
  229. this.removeAllListeners('removeListener');
  230. this._events = {};
  231. return this;
  232. }
  233. listeners = this._events[type];
  234. if (isFunction(listeners)) {
  235. this.removeListener(type, listeners);
  236. } else {
  237. // LIFO order
  238. while (listeners.length)
  239. this.removeListener(type, listeners[listeners.length - 1]);
  240. }
  241. delete this._events[type];
  242. return this;
  243. };
  244. EventEmitter.prototype.listeners = function(type) {
  245. var ret;
  246. if (!this._events || !this._events[type])
  247. ret = [];
  248. else if (isFunction(this._events[type]))
  249. ret = [this._events[type]];
  250. else
  251. ret = this._events[type].slice();
  252. return ret;
  253. };
  254. EventEmitter.listenerCount = function(emitter, type) {
  255. var ret;
  256. if (!emitter._events || !emitter._events[type])
  257. ret = 0;
  258. else if (isFunction(emitter._events[type]))
  259. ret = 1;
  260. else
  261. ret = emitter._events[type].length;
  262. return ret;
  263. };
  264. function isFunction(arg) {
  265. return typeof arg === 'function';
  266. }
  267. function isNumber(arg) {
  268. return typeof arg === 'number';
  269. }
  270. function isObject(arg) {
  271. return typeof arg === 'object' && arg !== null;
  272. }
  273. function isUndefined(arg) {
  274. return arg === void 0;
  275. }
  276. },{}],"/node_modules/jshint/data/ascii-identifier-data.js":[function(_dereq_,module,exports){
  277. var identifierStartTable = [];
  278. for (var i = 0; i < 128; i++) {
  279. identifierStartTable[i] =
  280. i === 36 || // $
  281. i >= 65 && i <= 90 || // A-Z
  282. i === 95 || // _
  283. i >= 97 && i <= 122; // a-z
  284. }
  285. var identifierPartTable = [];
  286. for (var i = 0; i < 128; i++) {
  287. identifierPartTable[i] =
  288. identifierStartTable[i] || // $, _, A-Z, a-z
  289. i >= 48 && i <= 57; // 0-9
  290. }
  291. module.exports = {
  292. asciiIdentifierStartTable: identifierStartTable,
  293. asciiIdentifierPartTable: identifierPartTable
  294. };
  295. },{}],"/node_modules/jshint/lodash.js":[function(_dereq_,module,exports){
  296. (function (global){
  297. ;(function() {
  298. var undefined;
  299. var VERSION = '3.7.0';
  300. var FUNC_ERROR_TEXT = 'Expected a function';
  301. var argsTag = '[object Arguments]',
  302. arrayTag = '[object Array]',
  303. boolTag = '[object Boolean]',
  304. dateTag = '[object Date]',
  305. errorTag = '[object Error]',
  306. funcTag = '[object Function]',
  307. mapTag = '[object Map]',
  308. numberTag = '[object Number]',
  309. objectTag = '[object Object]',
  310. regexpTag = '[object RegExp]',
  311. setTag = '[object Set]',
  312. stringTag = '[object String]',
  313. weakMapTag = '[object WeakMap]';
  314. var arrayBufferTag = '[object ArrayBuffer]',
  315. float32Tag = '[object Float32Array]',
  316. float64Tag = '[object Float64Array]',
  317. int8Tag = '[object Int8Array]',
  318. int16Tag = '[object Int16Array]',
  319. int32Tag = '[object Int32Array]',
  320. uint8Tag = '[object Uint8Array]',
  321. uint8ClampedTag = '[object Uint8ClampedArray]',
  322. uint16Tag = '[object Uint16Array]',
  323. uint32Tag = '[object Uint32Array]';
  324. var reIsDeepProp = /\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/,
  325. reIsPlainProp = /^\w*$/,
  326. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
  327. var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
  328. reHasRegExpChars = RegExp(reRegExpChars.source);
  329. var reEscapeChar = /\\(\\)?/g;
  330. var reFlags = /\w*$/;
  331. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  332. var typedArrayTags = {};
  333. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  334. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  335. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  336. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  337. typedArrayTags[uint32Tag] = true;
  338. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  339. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  340. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  341. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  342. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  343. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  344. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  345. var cloneableTags = {};
  346. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  347. cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =
  348. cloneableTags[dateTag] = cloneableTags[float32Tag] =
  349. cloneableTags[float64Tag] = cloneableTags[int8Tag] =
  350. cloneableTags[int16Tag] = cloneableTags[int32Tag] =
  351. cloneableTags[numberTag] = cloneableTags[objectTag] =
  352. cloneableTags[regexpTag] = cloneableTags[stringTag] =
  353. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  354. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  355. cloneableTags[errorTag] = cloneableTags[funcTag] =
  356. cloneableTags[mapTag] = cloneableTags[setTag] =
  357. cloneableTags[weakMapTag] = false;
  358. var objectTypes = {
  359. 'function': true,
  360. 'object': true
  361. };
  362. var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
  363. var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
  364. var freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;
  365. var freeSelf = objectTypes[typeof self] && self && self.Object && self;
  366. var freeWindow = objectTypes[typeof window] && window && window.Object && window;
  367. var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
  368. var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;
  369. function baseFindIndex(array, predicate, fromRight) {
  370. var length = array.length,
  371. index = fromRight ? length : -1;
  372. while ((fromRight ? index-- : ++index < length)) {
  373. if (predicate(array[index], index, array)) {
  374. return index;
  375. }
  376. }
  377. return -1;
  378. }
  379. function baseIndexOf(array, value, fromIndex) {
  380. if (value !== value) {
  381. return indexOfNaN(array, fromIndex);
  382. }
  383. var index = fromIndex - 1,
  384. length = array.length;
  385. while (++index < length) {
  386. if (array[index] === value) {
  387. return index;
  388. }
  389. }
  390. return -1;
  391. }
  392. function baseIsFunction(value) {
  393. return typeof value == 'function' || false;
  394. }
  395. function baseToString(value) {
  396. if (typeof value == 'string') {
  397. return value;
  398. }
  399. return value == null ? '' : (value + '');
  400. }
  401. function indexOfNaN(array, fromIndex, fromRight) {
  402. var length = array.length,
  403. index = fromIndex + (fromRight ? 0 : -1);
  404. while ((fromRight ? index-- : ++index < length)) {
  405. var other = array[index];
  406. if (other !== other) {
  407. return index;
  408. }
  409. }
  410. return -1;
  411. }
  412. function isObjectLike(value) {
  413. return !!value && typeof value == 'object';
  414. }
  415. var arrayProto = Array.prototype,
  416. objectProto = Object.prototype;
  417. var fnToString = Function.prototype.toString;
  418. var hasOwnProperty = objectProto.hasOwnProperty;
  419. var objToString = objectProto.toString;
  420. var reIsNative = RegExp('^' +
  421. escapeRegExp(objToString)
  422. .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  423. );
  424. var ArrayBuffer = isNative(ArrayBuffer = root.ArrayBuffer) && ArrayBuffer,
  425. bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice,
  426. floor = Math.floor,
  427. getOwnPropertySymbols = isNative(getOwnPropertySymbols = Object.getOwnPropertySymbols) && getOwnPropertySymbols,
  428. getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
  429. push = arrayProto.push,
  430. preventExtensions = isNative(Object.preventExtensions = Object.preventExtensions) && preventExtensions,
  431. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  432. Uint8Array = isNative(Uint8Array = root.Uint8Array) && Uint8Array;
  433. var Float64Array = (function() {
  434. try {
  435. var func = isNative(func = root.Float64Array) && func,
  436. result = new func(new ArrayBuffer(10), 0, 1) && func;
  437. } catch(e) {}
  438. return result;
  439. }());
  440. var nativeAssign = (function() {
  441. var object = { '1': 0 },
  442. func = preventExtensions && isNative(func = Object.assign) && func;
  443. try { func(preventExtensions(object), 'xo'); } catch(e) {}
  444. return !object[1] && func;
  445. }());
  446. var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray,
  447. nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys,
  448. nativeMax = Math.max,
  449. nativeMin = Math.min;
  450. var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;
  451. var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1,
  452. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  453. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  454. var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0;
  455. var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
  456. function lodash() {
  457. }
  458. var support = lodash.support = {};
  459. (function(x) {
  460. var Ctor = function() { this.x = x; },
  461. object = { '0': x, 'length': x },
  462. props = [];
  463. Ctor.prototype = { 'valueOf': x, 'y': x };
  464. for (var key in new Ctor) { props.push(key); }
  465. support.funcDecomp = /\bthis\b/.test(function() { return this; });
  466. support.funcNames = typeof Function.name == 'string';
  467. try {
  468. support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
  469. } catch(e) {
  470. support.nonEnumArgs = true;
  471. }
  472. }(1, 0));
  473. function arrayCopy(source, array) {
  474. var index = -1,
  475. length = source.length;
  476. array || (array = Array(length));
  477. while (++index < length) {
  478. array[index] = source[index];
  479. }
  480. return array;
  481. }
  482. function arrayEach(array, iteratee) {
  483. var index = -1,
  484. length = array.length;
  485. while (++index < length) {
  486. if (iteratee(array[index], index, array) === false) {
  487. break;
  488. }
  489. }
  490. return array;
  491. }
  492. function arrayFilter(array, predicate) {
  493. var index = -1,
  494. length = array.length,
  495. resIndex = -1,
  496. result = [];
  497. while (++index < length) {
  498. var value = array[index];
  499. if (predicate(value, index, array)) {
  500. result[++resIndex] = value;
  501. }
  502. }
  503. return result;
  504. }
  505. function arrayMap(array, iteratee) {
  506. var index = -1,
  507. length = array.length,
  508. result = Array(length);
  509. while (++index < length) {
  510. result[index] = iteratee(array[index], index, array);
  511. }
  512. return result;
  513. }
  514. function arrayMax(array) {
  515. var index = -1,
  516. length = array.length,
  517. result = NEGATIVE_INFINITY;
  518. while (++index < length) {
  519. var value = array[index];
  520. if (value > result) {
  521. result = value;
  522. }
  523. }
  524. return result;
  525. }
  526. function arraySome(array, predicate) {
  527. var index = -1,
  528. length = array.length;
  529. while (++index < length) {
  530. if (predicate(array[index], index, array)) {
  531. return true;
  532. }
  533. }
  534. return false;
  535. }
  536. function assignWith(object, source, customizer) {
  537. var props = keys(source);
  538. push.apply(props, getSymbols(source));
  539. var index = -1,
  540. length = props.length;
  541. while (++index < length) {
  542. var key = props[index],
  543. value = object[key],
  544. result = customizer(value, source[key], key, object, source);
  545. if ((result === result ? (result !== value) : (value === value)) ||
  546. (value === undefined && !(key in object))) {
  547. object[key] = result;
  548. }
  549. }
  550. return object;
  551. }
  552. var baseAssign = nativeAssign || function(object, source) {
  553. return source == null
  554. ? object
  555. : baseCopy(source, getSymbols(source), baseCopy(source, keys(source), object));
  556. };
  557. function baseCopy(source, props, object) {
  558. object || (object = {});
  559. var index = -1,
  560. length = props.length;
  561. while (++index < length) {
  562. var key = props[index];
  563. object[key] = source[key];
  564. }
  565. return object;
  566. }
  567. function baseCallback(func, thisArg, argCount) {
  568. var type = typeof func;
  569. if (type == 'function') {
  570. return thisArg === undefined
  571. ? func
  572. : bindCallback(func, thisArg, argCount);
  573. }
  574. if (func == null) {
  575. return identity;
  576. }
  577. if (type == 'object') {
  578. return baseMatches(func);
  579. }
  580. return thisArg === undefined
  581. ? property(func)
  582. : baseMatchesProperty(func, thisArg);
  583. }
  584. function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {
  585. var result;
  586. if (customizer) {
  587. result = object ? customizer(value, key, object) : customizer(value);
  588. }
  589. if (result !== undefined) {
  590. return result;
  591. }
  592. if (!isObject(value)) {
  593. return value;
  594. }
  595. var isArr = isArray(value);
  596. if (isArr) {
  597. result = initCloneArray(value);
  598. if (!isDeep) {
  599. return arrayCopy(value, result);
  600. }
  601. } else {
  602. var tag = objToString.call(value),
  603. isFunc = tag == funcTag;
  604. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  605. result = initCloneObject(isFunc ? {} : value);
  606. if (!isDeep) {
  607. return baseAssign(result, value);
  608. }
  609. } else {
  610. return cloneableTags[tag]
  611. ? initCloneByTag(value, tag, isDeep)
  612. : (object ? value : {});
  613. }
  614. }
  615. stackA || (stackA = []);
  616. stackB || (stackB = []);
  617. var length = stackA.length;
  618. while (length--) {
  619. if (stackA[length] == value) {
  620. return stackB[length];
  621. }
  622. }
  623. stackA.push(value);
  624. stackB.push(result);
  625. (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {
  626. result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);
  627. });
  628. return result;
  629. }
  630. var baseEach = createBaseEach(baseForOwn);
  631. function baseFilter(collection, predicate) {
  632. var result = [];
  633. baseEach(collection, function(value, index, collection) {
  634. if (predicate(value, index, collection)) {
  635. result.push(value);
  636. }
  637. });
  638. return result;
  639. }
  640. var baseFor = createBaseFor();
  641. function baseForIn(object, iteratee) {
  642. return baseFor(object, iteratee, keysIn);
  643. }
  644. function baseForOwn(object, iteratee) {
  645. return baseFor(object, iteratee, keys);
  646. }
  647. function baseGet(object, path, pathKey) {
  648. if (object == null) {
  649. return;
  650. }
  651. if (pathKey !== undefined && pathKey in toObject(object)) {
  652. path = [pathKey];
  653. }
  654. var index = -1,
  655. length = path.length;
  656. while (object != null && ++index < length) {
  657. var result = object = object[path[index]];
  658. }
  659. return result;
  660. }
  661. function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
  662. if (value === other) {
  663. return value !== 0 || (1 / value == 1 / other);
  664. }
  665. var valType = typeof value,
  666. othType = typeof other;
  667. if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') ||
  668. value == null || other == null) {
  669. return value !== value && other !== other;
  670. }
  671. return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
  672. }
  673. function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  674. var objIsArr = isArray(object),
  675. othIsArr = isArray(other),
  676. objTag = arrayTag,
  677. othTag = arrayTag;
  678. if (!objIsArr) {
  679. objTag = objToString.call(object);
  680. if (objTag == argsTag) {
  681. objTag = objectTag;
  682. } else if (objTag != objectTag) {
  683. objIsArr = isTypedArray(object);
  684. }
  685. }
  686. if (!othIsArr) {
  687. othTag = objToString.call(other);
  688. if (othTag == argsTag) {
  689. othTag = objectTag;
  690. } else if (othTag != objectTag) {
  691. othIsArr = isTypedArray(other);
  692. }
  693. }
  694. var objIsObj = objTag == objectTag,
  695. othIsObj = othTag == objectTag,
  696. isSameTag = objTag == othTag;
  697. if (isSameTag && !(objIsArr || objIsObj)) {
  698. return equalByTag(object, other, objTag);
  699. }
  700. if (!isLoose) {
  701. var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  702. othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  703. if (valWrapped || othWrapped) {
  704. return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
  705. }
  706. }
  707. if (!isSameTag) {
  708. return false;
  709. }
  710. stackA || (stackA = []);
  711. stackB || (stackB = []);
  712. var length = stackA.length;
  713. while (length--) {
  714. if (stackA[length] == object) {
  715. return stackB[length] == other;
  716. }
  717. }
  718. stackA.push(object);
  719. stackB.push(other);
  720. var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
  721. stackA.pop();
  722. stackB.pop();
  723. return result;
  724. }
  725. function baseIsMatch(object, props, values, strictCompareFlags, customizer) {
  726. var index = -1,
  727. length = props.length,
  728. noCustomizer = !customizer;
  729. while (++index < length) {
  730. if ((noCustomizer && strictCompareFlags[index])
  731. ? values[index] !== object[props[index]]
  732. : !(props[index] in object)
  733. ) {
  734. return false;
  735. }
  736. }
  737. index = -1;
  738. while (++index < length) {
  739. var key = props[index],
  740. objValue = object[key],
  741. srcValue = values[index];
  742. if (noCustomizer && strictCompareFlags[index]) {
  743. var result = objValue !== undefined || (key in object);
  744. } else {
  745. result = customizer ? customizer(objValue, srcValue, key) : undefined;
  746. if (result === undefined) {
  747. result = baseIsEqual(srcValue, objValue, customizer, true);
  748. }
  749. }
  750. if (!result) {
  751. return false;
  752. }
  753. }
  754. return true;
  755. }
  756. function baseMatches(source) {
  757. var props = keys(source),
  758. length = props.length;
  759. if (!length) {
  760. return constant(true);
  761. }
  762. if (length == 1) {
  763. var key = props[0],
  764. value = source[key];
  765. if (isStrictComparable(value)) {
  766. return function(object) {
  767. if (object == null) {
  768. return false;
  769. }
  770. return object[key] === value && (value !== undefined || (key in toObject(object)));
  771. };
  772. }
  773. }
  774. var values = Array(length),
  775. strictCompareFlags = Array(length);
  776. while (length--) {
  777. value = source[props[length]];
  778. values[length] = value;
  779. strictCompareFlags[length] = isStrictComparable(value);
  780. }
  781. return function(object) {
  782. return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags);
  783. };
  784. }
  785. function baseMatchesProperty(path, value) {
  786. var isArr = isArray(path),
  787. isCommon = isKey(path) && isStrictComparable(value),
  788. pathKey = (path + '');
  789. path = toPath(path);
  790. return function(object) {
  791. if (object == null) {
  792. return false;
  793. }
  794. var key = pathKey;
  795. object = toObject(object);
  796. if ((isArr || !isCommon) && !(key in object)) {
  797. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  798. if (object == null) {
  799. return false;
  800. }
  801. key = last(path);
  802. object = toObject(object);
  803. }
  804. return object[key] === value
  805. ? (value !== undefined || (key in object))
  806. : baseIsEqual(value, object[key], null, true);
  807. };
  808. }
  809. function baseMerge(object, source, customizer, stackA, stackB) {
  810. if (!isObject(object)) {
  811. return object;
  812. }
  813. var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
  814. if (!isSrcArr) {
  815. var props = keys(source);
  816. push.apply(props, getSymbols(source));
  817. }
  818. arrayEach(props || source, function(srcValue, key) {
  819. if (props) {
  820. key = srcValue;
  821. srcValue = source[key];
  822. }
  823. if (isObjectLike(srcValue)) {
  824. stackA || (stackA = []);
  825. stackB || (stackB = []);
  826. baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
  827. }
  828. else {
  829. var value = object[key],
  830. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  831. isCommon = result === undefined;
  832. if (isCommon) {
  833. result = srcValue;
  834. }
  835. if ((isSrcArr || result !== undefined) &&
  836. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  837. object[key] = result;
  838. }
  839. }
  840. });
  841. return object;
  842. }
  843. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  844. var length = stackA.length,
  845. srcValue = source[key];
  846. while (length--) {
  847. if (stackA[length] == srcValue) {
  848. object[key] = stackB[length];
  849. return;
  850. }
  851. }
  852. var value = object[key],
  853. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  854. isCommon = result === undefined;
  855. if (isCommon) {
  856. result = srcValue;
  857. if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) {
  858. result = isArray(value)
  859. ? value
  860. : (getLength(value) ? arrayCopy(value) : []);
  861. }
  862. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  863. result = isArguments(value)
  864. ? toPlainObject(value)
  865. : (isPlainObject(value) ? value : {});
  866. }
  867. else {
  868. isCommon = false;
  869. }
  870. }
  871. stackA.push(srcValue);
  872. stackB.push(result);
  873. if (isCommon) {
  874. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
  875. } else if (result === result ? (result !== value) : (value === value)) {
  876. object[key] = result;
  877. }
  878. }
  879. function baseProperty(key) {
  880. return function(object) {
  881. return object == null ? undefined : object[key];
  882. };
  883. }
  884. function basePropertyDeep(path) {
  885. var pathKey = (path + '');
  886. path = toPath(path);
  887. return function(object) {
  888. return baseGet(object, path, pathKey);
  889. };
  890. }
  891. function baseSlice(array, start, end) {
  892. var index = -1,
  893. length = array.length;
  894. start = start == null ? 0 : (+start || 0);
  895. if (start < 0) {
  896. start = -start > length ? 0 : (length + start);
  897. }
  898. end = (end === undefined || end > length) ? length : (+end || 0);
  899. if (end < 0) {
  900. end += length;
  901. }
  902. length = start > end ? 0 : ((end - start) >>> 0);
  903. start >>>= 0;
  904. var result = Array(length);
  905. while (++index < length) {
  906. result[index] = array[index + start];
  907. }
  908. return result;
  909. }
  910. function baseSome(collection, predicate) {
  911. var result;
  912. baseEach(collection, function(value, index, collection) {
  913. result = predicate(value, index, collection);
  914. return !result;
  915. });
  916. return !!result;
  917. }
  918. function baseValues(object, props) {
  919. var index = -1,
  920. length = props.length,
  921. result = Array(length);
  922. while (++index < length) {
  923. result[index] = object[props[index]];
  924. }
  925. return result;
  926. }
  927. function binaryIndex(array, value, retHighest) {
  928. var low = 0,
  929. high = array ? array.length : low;
  930. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  931. while (low < high) {
  932. var mid = (low + high) >>> 1,
  933. computed = array[mid];
  934. if (retHighest ? (computed <= value) : (computed < value)) {
  935. low = mid + 1;
  936. } else {
  937. high = mid;
  938. }
  939. }
  940. return high;
  941. }
  942. return binaryIndexBy(array, value, identity, retHighest);
  943. }
  944. function binaryIndexBy(array, value, iteratee, retHighest) {
  945. value = iteratee(value);
  946. var low = 0,
  947. high = array ? array.length : 0,
  948. valIsNaN = value !== value,
  949. valIsUndef = value === undefined;
  950. while (low < high) {
  951. var mid = floor((low + high) / 2),
  952. computed = iteratee(array[mid]),
  953. isReflexive = computed === computed;
  954. if (valIsNaN) {
  955. var setLow = isReflexive || retHighest;
  956. } else if (valIsUndef) {
  957. setLow = isReflexive && (retHighest || computed !== undefined);
  958. } else {
  959. setLow = retHighest ? (computed <= value) : (computed < value);
  960. }
  961. if (setLow) {
  962. low = mid + 1;
  963. } else {
  964. high = mid;
  965. }
  966. }
  967. return nativeMin(high, MAX_ARRAY_INDEX);
  968. }
  969. function bindCallback(func, thisArg, argCount) {
  970. if (typeof func != 'function') {
  971. return identity;
  972. }
  973. if (thisArg === undefined) {
  974. return func;
  975. }
  976. switch (argCount) {
  977. case 1: return function(value) {
  978. return func.call(thisArg, value);
  979. };
  980. case 3: return function(value, index, collection) {
  981. return func.call(thisArg, value, index, collection);
  982. };
  983. case 4: return function(accumulator, value, index, collection) {
  984. return func.call(thisArg, accumulator, value, index, collection);
  985. };
  986. case 5: return function(value, other, key, object, source) {
  987. return func.call(thisArg, value, other, key, object, source);
  988. };
  989. }
  990. return function() {
  991. return func.apply(thisArg, arguments);
  992. };
  993. }
  994. function bufferClone(buffer) {
  995. return bufferSlice.call(buffer, 0);
  996. }
  997. if (!bufferSlice) {
  998. bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) {
  999. var byteLength = buffer.byteLength,
  1000. floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0,
  1001. offset = floatLength * FLOAT64_BYTES_PER_ELEMENT,
  1002. result = new ArrayBuffer(byteLength);
  1003. if (floatLength) {
  1004. var view = new Float64Array(result, 0, floatLength);
  1005. view.set(new Float64Array(buffer, 0, floatLength));
  1006. }
  1007. if (byteLength != offset) {
  1008. view = new Uint8Array(result, offset);
  1009. view.set(new Uint8Array(buffer, offset));
  1010. }
  1011. return result;
  1012. };
  1013. }
  1014. function createAssigner(assigner) {
  1015. return restParam(function(object, sources) {
  1016. var index = -1,
  1017. length = object == null ? 0 : sources.length,
  1018. customizer = length > 2 && sources[length - 2],
  1019. guard = length > 2 && sources[2],
  1020. thisArg = length > 1 && sources[length - 1];
  1021. if (typeof customizer == 'function') {
  1022. customizer = bindCallback(customizer, thisArg, 5);
  1023. length -= 2;
  1024. } else {
  1025. customizer = typeof thisArg == 'function' ? thisArg : null;
  1026. length -= (customizer ? 1 : 0);
  1027. }
  1028. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  1029. customizer = length < 3 ? null : customizer;
  1030. length = 1;
  1031. }
  1032. while (++index < length) {
  1033. var source = sources[index];
  1034. if (source) {
  1035. assigner(object, source, customizer);
  1036. }
  1037. }
  1038. return object;
  1039. });
  1040. }
  1041. function createBaseEach(eachFunc, fromRight) {
  1042. return function(collection, iteratee) {
  1043. var length = collection ? getLength(collection) : 0;
  1044. if (!isLength(length)) {
  1045. return eachFunc(collection, iteratee);
  1046. }
  1047. var index = fromRight ? length : -1,
  1048. iterable = toObject(collection);
  1049. while ((fromRight ? index-- : ++index < length)) {
  1050. if (iteratee(iterable[index], index, iterable) === false) {
  1051. break;
  1052. }
  1053. }
  1054. return collection;
  1055. };
  1056. }
  1057. function createBaseFor(fromRight) {
  1058. return function(object, iteratee, keysFunc) {
  1059. var iterable = toObject(object),
  1060. props = keysFunc(object),
  1061. length = props.length,
  1062. index = fromRight ? length : -1;
  1063. while ((fromRight ? index-- : ++index < length)) {
  1064. var key = props[index];
  1065. if (iteratee(iterable[key], key, iterable) === false) {
  1066. break;
  1067. }
  1068. }
  1069. return object;
  1070. };
  1071. }
  1072. function createFindIndex(fromRight) {
  1073. return function(array, predicate, thisArg) {
  1074. if (!(array && array.length)) {
  1075. return -1;
  1076. }
  1077. predicate = getCallback(predicate, thisArg, 3);
  1078. return baseFindIndex(array, predicate, fromRight);
  1079. };
  1080. }
  1081. function createForEach(arrayFunc, eachFunc) {
  1082. return function(collection, iteratee, thisArg) {
  1083. return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
  1084. ? arrayFunc(collection, iteratee)
  1085. : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
  1086. };
  1087. }
  1088. function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
  1089. var index = -1,
  1090. arrLength = array.length,
  1091. othLength = other.length,
  1092. result = true;
  1093. if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
  1094. return false;
  1095. }
  1096. while (result && ++index < arrLength) {
  1097. var arrValue = array[index],
  1098. othValue = other[index];
  1099. result = undefined;
  1100. if (customizer) {
  1101. result = isLoose
  1102. ? customizer(othValue, arrValue, index)
  1103. : customizer(arrValue, othValue, index);
  1104. }
  1105. if (result === undefined) {
  1106. if (isLoose) {
  1107. var othIndex = othLength;
  1108. while (othIndex--) {
  1109. othValue = other[othIndex];
  1110. result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  1111. if (result) {
  1112. break;
  1113. }
  1114. }
  1115. } else {
  1116. result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  1117. }
  1118. }
  1119. }
  1120. return !!result;
  1121. }
  1122. function equalByTag(object, other, tag) {
  1123. switch (tag) {
  1124. case boolTag:
  1125. case dateTag:
  1126. return +object == +other;
  1127. case errorTag:
  1128. return object.name == other.name && object.message == other.message;
  1129. case numberTag:
  1130. return (object != +object)
  1131. ? other != +other
  1132. : (object == 0 ? ((1 / object) == (1 / other)) : object == +other);
  1133. case regexpTag:
  1134. case stringTag:
  1135. return object == (other + '');
  1136. }
  1137. return false;
  1138. }
  1139. function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  1140. var objProps = keys(object),
  1141. objLength = objProps.length,
  1142. othProps = keys(other),
  1143. othLength = othProps.length;
  1144. if (objLength != othLength && !isLoose) {
  1145. return false;
  1146. }
  1147. var skipCtor = isLoose,
  1148. index = -1;
  1149. while (++index < objLength) {
  1150. var key = objProps[index],
  1151. result = isLoose ? key in other : hasOwnProperty.call(other, key);
  1152. if (result) {
  1153. var objValue = object[key],
  1154. othValue = other[key];
  1155. result = undefined;
  1156. if (customizer) {
  1157. result = isLoose
  1158. ? customizer(othValue, objValue, key)
  1159. : customizer(objValue, othValue, key);
  1160. }
  1161. if (result === undefined) {
  1162. result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB);
  1163. }
  1164. }
  1165. if (!result) {
  1166. return false;
  1167. }
  1168. skipCtor || (skipCtor = key == 'constructor');
  1169. }
  1170. if (!skipCtor) {
  1171. var objCtor = object.constructor,
  1172. othCtor = other.constructor;
  1173. if (objCtor != othCtor &&
  1174. ('constructor' in object && 'constructor' in other) &&
  1175. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  1176. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  1177. return false;
  1178. }
  1179. }
  1180. return true;
  1181. }
  1182. function getCallback(func, thisArg, argCount) {
  1183. var result = lodash.callback || callback;
  1184. result = result === callback ? baseCallback : result;
  1185. return argCount ? result(func, thisArg, argCount) : result;
  1186. }
  1187. function getIndexOf(collection, target, fromIndex) {
  1188. var result = lodash.indexOf || indexOf;
  1189. result = result === indexOf ? baseIndexOf : result;
  1190. return collection ? result(collection, target, fromIndex) : result;
  1191. }
  1192. var getLength = baseProperty('length');
  1193. var getSymbols = !getOwnPropertySymbols ? constant([]) : function(object) {
  1194. return getOwnPropertySymbols(toObject(object));
  1195. };
  1196. function initCloneArray(array) {
  1197. var length = array.length,
  1198. result = new array.constructor(length);
  1199. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  1200. result.index = array.index;
  1201. result.input = array.input;
  1202. }
  1203. return result;
  1204. }
  1205. function initCloneObject(object) {
  1206. var Ctor = object.constructor;
  1207. if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {
  1208. Ctor = Object;
  1209. }
  1210. return new Ctor;
  1211. }
  1212. function initCloneByTag(object, tag, isDeep) {
  1213. var Ctor = object.constructor;
  1214. switch (tag) {
  1215. case arrayBufferTag:
  1216. return bufferClone(object);
  1217. case boolTag:
  1218. case dateTag:
  1219. return new Ctor(+object);
  1220. case float32Tag: case float64Tag:
  1221. case int8Tag: case int16Tag: case int32Tag:
  1222. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  1223. var buffer = object.buffer;
  1224. return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);
  1225. case numberTag:
  1226. case stringTag:
  1227. return new Ctor(object);
  1228. case regexpTag:
  1229. var result = new Ctor(object.source, reFlags.exec(object));
  1230. result.lastIndex = object.lastIndex;
  1231. }
  1232. return result;
  1233. }
  1234. function isIndex(value, length) {
  1235. value = +value;
  1236. length = length == null ? MAX_SAFE_INTEGER : length;
  1237. return value > -1 && value % 1 == 0 && value < length;
  1238. }
  1239. function isIterateeCall(value, index, object) {
  1240. if (!isObject(object)) {
  1241. return false;
  1242. }
  1243. var type = typeof index;
  1244. if (type == 'number') {
  1245. var length = getLength(object),
  1246. prereq = isLength(length) && isIndex(index, length);
  1247. } else {
  1248. prereq = type == 'string' && index in object;
  1249. }
  1250. if (prereq) {
  1251. var other = object[index];
  1252. return value === value ? (value === other) : (other !== other);
  1253. }
  1254. return false;
  1255. }
  1256. function isKey(value, object) {
  1257. var type = typeof value;
  1258. if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
  1259. return true;
  1260. }
  1261. if (isArray(value)) {
  1262. return false;
  1263. }
  1264. var result = !reIsDeepProp.test(value);
  1265. return result || (object != null && value in toObject(object));
  1266. }
  1267. function isLength(value) {
  1268. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  1269. }
  1270. function isStrictComparable(value) {
  1271. return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value));
  1272. }
  1273. function shimIsPlainObject(value) {
  1274. var Ctor,
  1275. support = lodash.support;
  1276. if (!(isObjectLike(value) && objToString.call(value) == objectTag) ||
  1277. (!hasOwnProperty.call(value, 'constructor') &&
  1278. (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  1279. return false;
  1280. }
  1281. var result;
  1282. baseForIn(value, function(subValue, key) {
  1283. result = key;
  1284. });
  1285. return result === undefined || hasOwnProperty.call(value, result);
  1286. }
  1287. function shimKeys(object) {
  1288. var props = keysIn(object),
  1289. propsLength = props.length,
  1290. length = propsLength && object.length,
  1291. support = lodash.support;
  1292. var allowIndexes = length && isLength(length) &&
  1293. (isArray(object) || (support.nonEnumArgs && isArguments(object)));
  1294. var index = -1,
  1295. result = [];
  1296. while (++index < propsLength) {
  1297. var key = props[index];
  1298. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  1299. result.push(key);
  1300. }
  1301. }
  1302. return result;
  1303. }
  1304. function toObject(value) {
  1305. return isObject(value) ? value : Object(value);
  1306. }
  1307. function toPath(value) {
  1308. if (isArray(value)) {
  1309. return value;
  1310. }
  1311. var result = [];
  1312. baseToString(value).replace(rePropName, function(match, number, quote, string) {
  1313. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  1314. });
  1315. return result;
  1316. }
  1317. var findLastIndex = createFindIndex(true);
  1318. function indexOf(array, value, fromIndex) {
  1319. var length = array ? array.length : 0;
  1320. if (!length) {
  1321. return -1;
  1322. }
  1323. if (typeof fromIndex == 'number') {
  1324. fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
  1325. } else if (fromIndex) {
  1326. var index = binaryIndex(array, value),
  1327. other = array[index];
  1328. if (value === value ? (value === other) : (other !== other)) {
  1329. return index;
  1330. }
  1331. return -1;
  1332. }
  1333. return baseIndexOf(array, value, fromIndex || 0);
  1334. }
  1335. function last(array) {
  1336. var length = array ? array.length : 0;
  1337. return length ? array[length - 1] : undefined;
  1338. }
  1339. function slice(array, start, end) {
  1340. var length = array ? array.length : 0;
  1341. if (!length) {
  1342. return [];
  1343. }
  1344. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  1345. start = 0;
  1346. end = length;
  1347. }
  1348. return baseSlice(array, start, end);
  1349. }
  1350. function unzip(array) {
  1351. var index = -1,
  1352. length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0,
  1353. result = Array(length);
  1354. while (++index < length) {
  1355. result[index] = arrayMap(array, baseProperty(index));
  1356. }
  1357. return result;
  1358. }
  1359. var zip = restParam(unzip);
  1360. var forEach = createForEach(arrayEach, baseEach);
  1361. function includes(collection, target, fromIndex, guard) {
  1362. var length = collection ? getLength(collection) : 0;
  1363. if (!isLength(length)) {
  1364. collection = values(collection);
  1365. length = collection.length;
  1366. }
  1367. if (!length) {
  1368. return false;
  1369. }
  1370. if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
  1371. fromIndex = 0;
  1372. } else {
  1373. fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
  1374. }
  1375. return (typeof collection == 'string' || !isArray(collection) && isString(collection))
  1376. ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
  1377. : (getIndexOf(collection, target, fromIndex) > -1);
  1378. }
  1379. function reject(collection, predicate, thisArg) {
  1380. var func = isArray(collection) ? arrayFilter : baseFilter;
  1381. predicate = getCallback(predicate, thisArg, 3);
  1382. return func(collection, function(value, index, collection) {
  1383. return !predicate(value, index, collection);
  1384. });
  1385. }
  1386. function some(collection, predicate, thisArg) {
  1387. var func = isArray(collection) ? arraySome : baseSome;
  1388. if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
  1389. predicate = null;
  1390. }
  1391. if (typeof predicate != 'function' || thisArg !== undefined) {
  1392. predicate = getCallback(predicate, thisArg, 3);
  1393. }
  1394. return func(collection, predicate);
  1395. }
  1396. function restParam(func, start) {
  1397. if (typeof func != 'function') {
  1398. throw new TypeError(FUNC_ERROR_TEXT);
  1399. }
  1400. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  1401. return function() {
  1402. var args = arguments,
  1403. index = -1,
  1404. length = nativeMax(args.length - start, 0),
  1405. rest = Array(length);
  1406. while (++index < length) {
  1407. rest[index] = args[start + index];
  1408. }
  1409. switch (start) {
  1410. case 0: return func.call(this, rest);
  1411. case 1: return func.call(this, args[0], rest);
  1412. case 2: return func.call(this, args[0], args[1], rest);
  1413. }
  1414. var otherArgs = Array(start + 1);
  1415. index = -1;
  1416. while (++index < start) {
  1417. otherArgs[index] = args[index];
  1418. }
  1419. otherArgs[start] = rest;
  1420. return func.apply(this, otherArgs);
  1421. };
  1422. }
  1423. function clone(value, isDeep, customizer, thisArg) {
  1424. if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {
  1425. isDeep = false;
  1426. }
  1427. else if (typeof isDeep == 'function') {
  1428. thisArg = customizer;
  1429. customizer = isDeep;
  1430. isDeep = false;
  1431. }
  1432. customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1);
  1433. return baseClone(value, isDeep, customizer);
  1434. }
  1435. function isArguments(value) {
  1436. var length = isObjectLike(value) ? value.length : undefined;
  1437. return isLength(length) && objToString.call(value) == argsTag;
  1438. }
  1439. var isArray = nativeIsArray || function(value) {
  1440. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  1441. };
  1442. function isEmpty(value) {
  1443. if (value == null) {
  1444. return true;
  1445. }
  1446. var length = getLength(value);
  1447. if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) ||
  1448. (isObjectLike(value) && isFunction(value.splice)))) {
  1449. return !length;
  1450. }
  1451. return !keys(value).length;
  1452. }
  1453. var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
  1454. return objToString.call(value) == funcTag;
  1455. };
  1456. function isObject(value) {
  1457. var type = typeof value;
  1458. return type == 'function' || (!!value && type == 'object');
  1459. }
  1460. function isNative(value) {
  1461. if (value == null) {
  1462. return false;
  1463. }
  1464. if (objToString.call(value) == funcTag) {
  1465. return reIsNative.test(fnToString.call(value));
  1466. }
  1467. return isObjectLike(value) && reIsHostCtor.test(value);
  1468. }
  1469. function isNumber(value) {
  1470. return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
  1471. }
  1472. var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
  1473. if (!(value && objToString.call(value) == objectTag)) {
  1474. return false;
  1475. }
  1476. var valueOf = value.valueOf,
  1477. objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
  1478. return objProto
  1479. ? (value == objProto || getPrototypeOf(value) == objProto)
  1480. : shimIsPlainObject(value);
  1481. };
  1482. function isString(value) {
  1483. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
  1484. }
  1485. function isTypedArray(value) {
  1486. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
  1487. }
  1488. function toPlainObject(value) {
  1489. return baseCopy(value, keysIn(value));
  1490. }
  1491. var assign = createAssigner(function(object, source, customizer) {
  1492. return customizer
  1493. ? assignWith(object, source, customizer)
  1494. : baseAssign(object, source);
  1495. });
  1496. function has(object, path) {
  1497. if (object == null) {
  1498. return false;
  1499. }
  1500. var result = hasOwnProperty.call(object, path);
  1501. if (!result && !isKey(path)) {
  1502. path = toPath(path);
  1503. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  1504. path = last(path);
  1505. result = object != null && hasOwnProperty.call(object, path);
  1506. }
  1507. return result;
  1508. }
  1509. var keys = !nativeKeys ? shimKeys : function(object) {
  1510. if (object) {
  1511. var Ctor = object.constructor,
  1512. length = object.length;
  1513. }
  1514. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  1515. (typeof object != 'function' && isLength(length))) {
  1516. return shimKeys(object);
  1517. }
  1518. return isObject(object) ? nativeKeys(object) : [];
  1519. };
  1520. function keysIn(object) {
  1521. if (object == null) {
  1522. return [];
  1523. }
  1524. if (!isObject(object)) {
  1525. object = Object(object);
  1526. }
  1527. var length = object.length;
  1528. length = (length && isLength(length) &&
  1529. (isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0;
  1530. var Ctor = object.constructor,
  1531. index = -1,
  1532. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  1533. result = Array(length),
  1534. skipIndexes = length > 0;
  1535. while (++index < length) {
  1536. result[index] = (index + '');
  1537. }
  1538. for (var key in object) {
  1539. if (!(skipIndexes && isIndex(key, length)) &&
  1540. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  1541. result.push(key);
  1542. }
  1543. }
  1544. return result;
  1545. }
  1546. var merge = createAssigner(baseMerge);
  1547. function values(object) {
  1548. return baseValues(object, keys(object));
  1549. }
  1550. function escapeRegExp(string) {
  1551. string = baseToString(string);
  1552. return (string && reHasRegExpChars.test(string))
  1553. ? string.replace(reRegExpChars, '\\$&')
  1554. : string;
  1555. }
  1556. function callback(func, thisArg, guard) {
  1557. if (guard && isIterateeCall(func, thisArg, guard)) {
  1558. thisArg = null;
  1559. }
  1560. return baseCallback(func, thisArg);
  1561. }
  1562. function constant(value) {
  1563. return function() {
  1564. return value;
  1565. };
  1566. }
  1567. function identity(value) {
  1568. return value;
  1569. }
  1570. function property(path) {
  1571. return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
  1572. }
  1573. // Add functions that return wrapped values when chaining.
  1574. lodash.assign = assign;
  1575. lodash.callback = callback;
  1576. lodash.constant = constant;
  1577. lodash.forEach = forEach;
  1578. lodash.keys = keys;
  1579. lodash.keysIn = keysIn;
  1580. lodash.merge = merge;
  1581. lodash.property = property;
  1582. lodash.reject = reject;
  1583. lodash.restParam = restParam;
  1584. lodash.slice = slice;
  1585. lodash.toPlainObject = toPlainObject;
  1586. lodash.unzip = unzip;
  1587. lodash.values = values;
  1588. lodash.zip = zip;
  1589. lodash.each = forEach;
  1590. lodash.extend = assign;
  1591. lodash.iteratee = callback;
  1592. // Add functions that return unwrapped values when chaining.
  1593. lodash.clone = clone;
  1594. lodash.escapeRegExp = escapeRegExp;
  1595. lodash.findLastIndex = findLastIndex;
  1596. lodash.has = has;
  1597. lodash.identity = identity;
  1598. lodash.includes = includes;
  1599. lodash.indexOf = indexOf;
  1600. lodash.isArguments = isArguments;
  1601. lodash.isArray = isArray;
  1602. lodash.isEmpty = isEmpty;
  1603. lodash.isFunction = isFunction;
  1604. lodash.isNative = isNative;
  1605. lodash.isNumber = isNumber;
  1606. lodash.isObject = isObject;
  1607. lodash.isPlainObject = isPlainObject;
  1608. lodash.isString = isString;
  1609. lodash.isTypedArray = isTypedArray;
  1610. lodash.last = last;
  1611. lodash.some = some;
  1612. lodash.any = some;
  1613. lodash.contains = includes;
  1614. lodash.include = includes;
  1615. lodash.VERSION = VERSION;
  1616. // Some AMD build optimizers like r.js check for condition patterns like the following:
  1617. if (freeExports && freeModule) {
  1618. if (moduleExports) {
  1619. (freeModule.exports = lodash)._ = lodash;
  1620. }
  1621. else {
  1622. freeExports._ = lodash;
  1623. }
  1624. }
  1625. else {
  1626. root._ = lodash;
  1627. }
  1628. }.call(this));
  1629. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  1630. },{}],"/node_modules/jshint/src/jshint.js":[function(_dereq_,module,exports){
  1631. /*!
  1632. * JSHint, by JSHint Community.
  1633. *
  1634. * This file (and this file only) is licensed under the same slightly modified
  1635. * MIT license that JSLint is. It stops evil-doers everywhere:
  1636. *
  1637. * Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
  1638. *
  1639. * Permission is hereby granted, free of charge, to any person obtaining
  1640. * a copy of this software and associated documentation files (the "Software"),
  1641. * to deal in the Software without restriction, including without limitation
  1642. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  1643. * and/or sell copies of the Software, and to permit persons to whom
  1644. * the Software is furnished to do so, subject to the following conditions:
  1645. *
  1646. * The above copyright notice and this permission notice shall be included
  1647. * in all copies or substantial portions of the Software.
  1648. *
  1649. * The Software shall be used for Good, not Evil.
  1650. *
  1651. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1652. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1653. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1654. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1655. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  1656. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  1657. * DEALINGS IN THE SOFTWARE.
  1658. *
  1659. */
  1660. /*jshint quotmark:double */
  1661. /*global console:true */
  1662. /*exported console */
  1663. var _ = _dereq_("../lodash");
  1664. var events = _dereq_("events");
  1665. var vars = _dereq_("./vars.js");
  1666. var messages = _dereq_("./messages.js");
  1667. var Lexer = _dereq_("./lex.js").Lexer;
  1668. var reg = _dereq_("./reg.js");
  1669. var state = _dereq_("./state.js").state;
  1670. var style = _dereq_("./style.js");
  1671. var options = _dereq_("./options.js");
  1672. var scopeManager = _dereq_("./scope-manager.js");
  1673. // We build the application inside a function so that we produce only a singleton
  1674. // variable. That function will be invoked immediately, and its return value is
  1675. // the JSHINT function itself.
  1676. var JSHINT = (function() {
  1677. "use strict";
  1678. var api, // Extension API
  1679. // These are operators that should not be used with the ! operator.
  1680. bang = {
  1681. "<" : true,
  1682. "<=" : true,
  1683. "==" : true,
  1684. "===": true,
  1685. "!==": true,
  1686. "!=" : true,
  1687. ">" : true,
  1688. ">=" : true,
  1689. "+" : true,
  1690. "-" : true,
  1691. "*" : true,
  1692. "/" : true,
  1693. "%" : true
  1694. },
  1695. declared, // Globals that were declared using /*global ... */ syntax.
  1696. functionicity = [
  1697. "closure", "exception", "global", "label",
  1698. "outer", "unused", "var"
  1699. ],
  1700. functions, // All of the functions
  1701. inblock,
  1702. indent,
  1703. lookahead,
  1704. lex,
  1705. member,
  1706. membersOnly,
  1707. predefined, // Global variables defined by option
  1708. stack,
  1709. urls,
  1710. extraModules = [],
  1711. emitter = new events.EventEmitter();
  1712. function checkOption(name, t) {
  1713. name = name.trim();
  1714. if (/^[+-]W\d{3}$/g.test(name)) {
  1715. return true;
  1716. }
  1717. if (options.validNames.indexOf(name) === -1) {
  1718. if (t.type !== "jslint" && !_.has(options.removed, name)) {
  1719. error("E001", t, name);
  1720. return false;
  1721. }
  1722. }
  1723. return true;
  1724. }
  1725. function isString(obj) {
  1726. return Object.prototype.toString.call(obj) === "[object String]";
  1727. }
  1728. function isIdentifier(tkn, value) {
  1729. if (!tkn)
  1730. return false;
  1731. if (!tkn.identifier || tkn.value !== value)
  1732. return false;
  1733. return true;
  1734. }
  1735. function isReserved(token) {
  1736. if (!token.reserved) {
  1737. return false;
  1738. }
  1739. var meta = token.meta;
  1740. if (meta && meta.isFutureReservedWord && state.inES5()) {
  1741. // ES3 FutureReservedWord in an ES5 environment.
  1742. if (!meta.es5) {
  1743. return false;
  1744. }
  1745. // Some ES5 FutureReservedWord identifiers are active only
  1746. // within a strict mode environment.
  1747. if (meta.strictOnly) {
  1748. if (!state.option.strict && !state.isStrict()) {
  1749. return false;
  1750. }
  1751. }
  1752. if (token.isProperty) {
  1753. return false;
  1754. }
  1755. }
  1756. return true;
  1757. }
  1758. function supplant(str, data) {
  1759. return str.replace(/\{([^{}]*)\}/g, function(a, b) {
  1760. var r = data[b];
  1761. return typeof r === "string" || typeof r === "number" ? r : a;
  1762. });
  1763. }
  1764. function combine(dest, src) {
  1765. Object.keys(src).forEach(function(name) {
  1766. if (_.has(JSHINT.blacklist, name)) return;
  1767. dest[name] = src[name];
  1768. });
  1769. }
  1770. function processenforceall() {
  1771. if (state.option.enforceall) {
  1772. for (var enforceopt in options.bool.enforcing) {
  1773. if (state.option[enforceopt] === undefined &&
  1774. !options.noenforceall[enforceopt]) {
  1775. state.option[enforceopt] = true;
  1776. }
  1777. }
  1778. for (var relaxopt in options.bool.relaxing) {
  1779. if (state.option[relaxopt] === undefined) {
  1780. state.option[relaxopt] = false;
  1781. }
  1782. }
  1783. }
  1784. }
  1785. function assume() {
  1786. processenforceall();
  1787. /**
  1788. * TODO: Remove in JSHint 3
  1789. */
  1790. if (!state.option.esversion && !state.option.moz) {
  1791. if (state.option.es3) {
  1792. state.option.esversion = 3;
  1793. } else if (state.option.esnext) {
  1794. state.option.esversion = 6;
  1795. } else {
  1796. state.option.esversion = 5;
  1797. }
  1798. }
  1799. if (state.inES5()) {
  1800. combine(predefined, vars.ecmaIdentifiers[5]);
  1801. }
  1802. if (state.inES6()) {
  1803. combine(predefined, vars.ecmaIdentifiers[6]);
  1804. }
  1805. if (state.option.module) {
  1806. if (state.option.strict === true) {
  1807. state.option.strict = "global";
  1808. }
  1809. /**
  1810. * TODO: Extend this restriction to *all* ES6-specific options.
  1811. */
  1812. if (!state.inES6()) {
  1813. warning("W134", state.tokens.next, "module", 6);
  1814. }
  1815. }
  1816. if (state.option.couch) {
  1817. combine(predefined, vars.couch);
  1818. }
  1819. if (state.option.qunit) {
  1820. combine(predefined, vars.qunit);
  1821. }
  1822. if (state.option.rhino) {
  1823. combine(predefined, vars.rhino);
  1824. }
  1825. if (state.option.shelljs) {
  1826. combine(predefined, vars.shelljs);
  1827. combine(predefined, vars.node);
  1828. }
  1829. if (state.option.typed) {
  1830. combine(predefined, vars.typed);
  1831. }
  1832. if (state.option.phantom) {
  1833. combine(predefined, vars.phantom);
  1834. if (state.option.strict === true) {
  1835. state.option.strict = "global";
  1836. }
  1837. }
  1838. if (state.option.prototypejs) {
  1839. combine(predefined, vars.prototypejs);
  1840. }
  1841. if (state.option.node) {
  1842. combine(predefined, vars.node);
  1843. combine(predefined, vars.typed);
  1844. if (state.option.strict === true) {
  1845. state.option.strict = "global";
  1846. }
  1847. }
  1848. if (state.option.devel) {
  1849. combine(predefined, vars.devel);
  1850. }
  1851. if (state.option.dojo) {
  1852. combine(predefined, vars.dojo);
  1853. }
  1854. if (state.option.browser) {
  1855. combine(predefined, vars.browser);
  1856. combine(predefined, vars.typed);
  1857. }
  1858. if (state.option.browserify) {
  1859. combine(predefined, vars.browser);
  1860. combine(predefined, vars.typed);
  1861. combine(predefined, vars.browserify);
  1862. if (state.option.strict === true) {
  1863. state.option.strict = "global";
  1864. }
  1865. }
  1866. if (state.option.nonstandard) {
  1867. combine(predefined, vars.nonstandard);
  1868. }
  1869. if (state.option.jasmine) {
  1870. combine(predefined, vars.jasmine);
  1871. }
  1872. if (state.option.jquery) {
  1873. combine(predefined, vars.jquery);
  1874. }
  1875. if (state.option.mootools) {
  1876. combine(predefined, vars.mootools);
  1877. }
  1878. if (state.option.worker) {
  1879. combine(predefined, vars.worker);
  1880. }
  1881. if (state.option.wsh) {
  1882. combine(predefined, vars.wsh);
  1883. }
  1884. if (state.option.globalstrict && state.option.strict !== false) {
  1885. state.option.strict = "global";
  1886. }
  1887. if (state.option.yui) {
  1888. combine(predefined, vars.yui);
  1889. }
  1890. if (state.option.mocha) {
  1891. combine(predefined, vars.mocha);
  1892. }
  1893. }
  1894. // Produce an error warning.
  1895. function quit(code, line, chr) {
  1896. var percentage = Math.floor((line / state.lines.length) * 100);
  1897. var message = messages.errors[code].desc;
  1898. throw {
  1899. name: "JSHintError",
  1900. line: line,
  1901. character: chr,
  1902. message: message + " (" + percentage + "% scanned).",
  1903. raw: message,
  1904. code: code
  1905. };
  1906. }
  1907. function removeIgnoredMessages() {
  1908. var ignored = state.ignoredLines;
  1909. if (_.isEmpty(ignored)) return;
  1910. JSHINT.errors = _.reject(JSHINT.errors, function(err) { return ignored[err.line] });
  1911. }
  1912. function warning(code, t, a, b, c, d) {
  1913. var ch, l, w, msg;
  1914. if (/^W\d{3}$/.test(code)) {
  1915. if (state.ignored[code])
  1916. return;
  1917. msg = messages.warnings[code];
  1918. } else if (/E\d{3}/.test(code)) {
  1919. msg = messages.errors[code];
  1920. } else if (/I\d{3}/.test(code)) {
  1921. msg = messages.info[code];
  1922. }
  1923. t = t || state.tokens.next || {};
  1924. if (t.id === "(end)") { // `~
  1925. t = state.tokens.curr;
  1926. }
  1927. l = t.line || 0;
  1928. ch = t.from || 0;
  1929. w = {
  1930. id: "(error)",
  1931. raw: msg.desc,
  1932. code: msg.code,
  1933. evidence: state.lines[l - 1] || "",
  1934. line: l,
  1935. character: ch,
  1936. scope: JSHINT.scope,
  1937. a: a,
  1938. b: b,
  1939. c: c,
  1940. d: d
  1941. };
  1942. w.reason = supplant(msg.desc, w);
  1943. JSHINT.errors.push(w);
  1944. removeIgnoredMessages();
  1945. if (JSHINT.errors.length >= state.option.maxerr)
  1946. quit("E043", l, ch);
  1947. return w;
  1948. }
  1949. function warningAt(m, l, ch, a, b, c, d) {
  1950. return warning(m, {
  1951. line: l,
  1952. from: ch
  1953. }, a, b, c, d);
  1954. }
  1955. function error(m, t, a, b, c, d) {
  1956. warning(m, t, a, b, c, d);
  1957. }
  1958. function errorAt(m, l, ch, a, b, c, d) {
  1959. return error(m, {
  1960. line: l,
  1961. from: ch
  1962. }, a, b, c, d);
  1963. }
  1964. // Tracking of "internal" scripts, like eval containing a static string
  1965. function addInternalSrc(elem, src) {
  1966. var i;
  1967. i = {
  1968. id: "(internal)",
  1969. elem: elem,
  1970. value: src
  1971. };
  1972. JSHINT.internals.push(i);
  1973. return i;
  1974. }
  1975. function doOption() {
  1976. var nt = state.tokens.next;
  1977. var body = nt.body.match(/(-\s+)?[^\s,:]+(?:\s*:\s*(-\s+)?[^\s,]+)?/g) || [];
  1978. var predef = {};
  1979. if (nt.type === "globals") {
  1980. body.forEach(function(g, idx) {
  1981. g = g.split(":");
  1982. var key = (g[0] || "").trim();
  1983. var val = (g[1] || "").trim();
  1984. if (key === "-" || !key.length) {
  1985. // Ignore trailing comma
  1986. if (idx > 0 && idx === body.length - 1) {
  1987. return;
  1988. }
  1989. error("E002", nt);
  1990. return;
  1991. }
  1992. if (key.charAt(0) === "-") {
  1993. key = key.slice(1);
  1994. val = false;
  1995. JSHINT.blacklist[key] = key;
  1996. delete predefined[key];
  1997. } else {
  1998. predef[key] = (val === "true");
  1999. }
  2000. });
  2001. combine(predefined, predef);
  2002. for (var key in predef) {
  2003. if (_.has(predef, key)) {
  2004. declared[key] = nt;
  2005. }
  2006. }
  2007. }
  2008. if (nt.type === "exported") {
  2009. body.forEach(function(e, idx) {
  2010. if (!e.length) {
  2011. // Ignore trailing comma
  2012. if (idx > 0 && idx === body.length - 1) {
  2013. return;
  2014. }
  2015. error("E002", nt);
  2016. return;
  2017. }
  2018. state.funct["(scope)"].addExported(e);
  2019. });
  2020. }
  2021. if (nt.type === "members") {
  2022. membersOnly = membersOnly || {};
  2023. body.forEach(function(m) {
  2024. var ch1 = m.charAt(0);
  2025. var ch2 = m.charAt(m.length - 1);
  2026. if (ch1 === ch2 && (ch1 === "\"" || ch1 === "'")) {
  2027. m = m
  2028. .substr(1, m.length - 2)
  2029. .replace("\\\"", "\"");
  2030. }
  2031. membersOnly[m] = false;
  2032. });
  2033. }
  2034. var numvals = [
  2035. "maxstatements",
  2036. "maxparams",
  2037. "maxdepth",
  2038. "maxcomplexity",
  2039. "maxerr",
  2040. "maxlen",
  2041. "indent"
  2042. ];
  2043. if (nt.type === "jshint" || nt.type === "jslint") {
  2044. body.forEach(function(g) {
  2045. g = g.split(":");
  2046. var key = (g[0] || "").trim();
  2047. var val = (g[1] || "").trim();
  2048. if (!checkOption(key, nt)) {
  2049. return;
  2050. }
  2051. if (numvals.indexOf(key) >= 0) {
  2052. // GH988 - numeric options can be disabled by setting them to `false`
  2053. if (val !== "false") {
  2054. val = +val;
  2055. if (typeof val !== "number" || !isFinite(val) || val <= 0 || Math.floor(val) !== val) {
  2056. error("E032", nt, g[1].trim());
  2057. return;
  2058. }
  2059. state.option[key] = val;
  2060. } else {
  2061. state.option[key] = key === "indent" ? 4 : false;
  2062. }
  2063. return;
  2064. }
  2065. if (key === "validthis") {
  2066. // `validthis` is valid only within a function scope.
  2067. if (state.funct["(global)"])
  2068. return void error("E009");
  2069. if (val !== "true" && val !== "false")
  2070. return void error("E002", nt);
  2071. state.option.validthis = (val === "true");
  2072. return;
  2073. }
  2074. if (key === "quotmark") {
  2075. switch (val) {
  2076. case "true":
  2077. case "false":
  2078. state.option.quotmark = (val === "true");
  2079. break;
  2080. case "double":
  2081. case "single":
  2082. state.option.quotmark = val;
  2083. break;
  2084. default:
  2085. error("E002", nt);
  2086. }
  2087. return;
  2088. }
  2089. if (key === "shadow") {
  2090. switch (val) {
  2091. case "true":
  2092. state.option.shadow = true;
  2093. break;
  2094. case "outer":
  2095. state.option.shadow = "outer";
  2096. break;
  2097. case "false":
  2098. case "inner":
  2099. state.option.shadow = "inner";
  2100. break;
  2101. default:
  2102. error("E002", nt);
  2103. }
  2104. return;
  2105. }
  2106. if (key === "unused") {
  2107. switch (val) {
  2108. case "true":
  2109. state.option.unused = true;
  2110. break;
  2111. case "false":
  2112. state.option.unused = false;
  2113. break;
  2114. case "vars":
  2115. case "strict":
  2116. state.option.unused = val;
  2117. break;
  2118. default:
  2119. error("E002", nt);
  2120. }
  2121. return;
  2122. }
  2123. if (key === "latedef") {
  2124. switch (val) {
  2125. case "true":
  2126. state.option.latedef = true;
  2127. break;
  2128. case "false":
  2129. state.option.latedef = false;
  2130. break;
  2131. case "nofunc":
  2132. state.option.latedef = "nofunc";
  2133. break;
  2134. default:
  2135. error("E002", nt);
  2136. }
  2137. return;
  2138. }
  2139. if (key === "ignore") {
  2140. switch (val) {
  2141. case "line":
  2142. state.ignoredLines[nt.line] = true;
  2143. removeIgnoredMessages();
  2144. break;
  2145. default:
  2146. error("E002", nt);
  2147. }
  2148. return;
  2149. }
  2150. if (key === "strict") {
  2151. switch (val) {
  2152. case "true":
  2153. state.option.strict = true;
  2154. break;
  2155. case "false":
  2156. state.option.strict = false;
  2157. break;
  2158. case "func":
  2159. case "global":
  2160. case "implied":
  2161. state.option.strict = val;
  2162. break;
  2163. default:
  2164. error("E002", nt);
  2165. }
  2166. return;
  2167. }
  2168. if (key === "module") {
  2169. /**
  2170. * TODO: Extend this restriction to *all* "environmental" options.
  2171. */
  2172. if (!hasParsedCode(state.funct)) {
  2173. error("E055", state.tokens.next, "module");
  2174. }
  2175. }
  2176. /**
  2177. * TODO: Remove in JSHint 3
  2178. */
  2179. var esversions = {
  2180. es3 : 3,
  2181. es5 : 5,
  2182. esnext: 6
  2183. };
  2184. if (_.has(esversions, key)) {
  2185. switch (val) {
  2186. case "true":
  2187. state.option.moz = false;
  2188. state.option.esversion = esversions[key];
  2189. break;
  2190. case "false":
  2191. if (!state.option.moz) {
  2192. state.option.esversion = 5;
  2193. }
  2194. break;
  2195. default:
  2196. error("E002", nt);
  2197. }
  2198. return;
  2199. }
  2200. if (key === "esversion") {
  2201. switch (val) {
  2202. case "5":
  2203. if (state.inES5(true)) {
  2204. warning("I003");
  2205. }
  2206. /* falls through */
  2207. case "3":
  2208. case "6":
  2209. state.option.moz = false;
  2210. state.option.esversion = +val;
  2211. break;
  2212. case "2015":
  2213. state.option.moz = false;
  2214. state.option.esversion = 6;
  2215. break;
  2216. default:
  2217. error("E002", nt);
  2218. }
  2219. if (!hasParsedCode(state.funct)) {
  2220. error("E055", state.tokens.next, "esversion");
  2221. }
  2222. return;
  2223. }
  2224. var match = /^([+-])(W\d{3})$/g.exec(key);
  2225. if (match) {
  2226. // ignore for -W..., unignore for +W...
  2227. state.ignored[match[2]] = (match[1] === "-");
  2228. return;
  2229. }
  2230. var tn;
  2231. if (val === "true" || val === "false") {
  2232. if (nt.type === "jslint") {
  2233. tn = options.renamed[key] || key;
  2234. state.option[tn] = (val === "true");
  2235. if (options.inverted[tn] !== undefined) {
  2236. state.option[tn] = !state.option[tn];
  2237. }
  2238. } else {
  2239. state.option[key] = (val === "true");
  2240. }
  2241. if (key === "newcap") {
  2242. state.option["(explicitNewcap)"] = true;
  2243. }
  2244. return;
  2245. }
  2246. error("E002", nt);
  2247. });
  2248. assume();
  2249. }
  2250. }
  2251. // We need a peek function. If it has an argument, it peeks that much farther
  2252. // ahead. It is used to distinguish
  2253. // for ( var i in ...
  2254. // from
  2255. // for ( var i = ...
  2256. function peek(p) {
  2257. var i = p || 0, j = lookahead.length, t;
  2258. if (i < j) {
  2259. return lookahead[i];
  2260. }
  2261. while (j <= i) {
  2262. t = lookahead[j];
  2263. if (!t) {
  2264. t = lookahead[j] = lex.token();
  2265. }
  2266. j += 1;
  2267. }
  2268. // Peeking past the end of the program should produce the "(end)" token.
  2269. if (!t && state.tokens.next.id === "(end)") {
  2270. return state.tokens.next;
  2271. }
  2272. return t;
  2273. }
  2274. function peekIgnoreEOL() {
  2275. var i = 0;
  2276. var t;
  2277. do {
  2278. t = peek(i++);
  2279. } while (t.id === "(endline)");
  2280. return t;
  2281. }
  2282. // Produce the next token. It looks for programming errors.
  2283. function advance(id, t) {
  2284. switch (state.tokens.curr.id) {
  2285. case "(number)":
  2286. if (state.tokens.next.id === ".") {
  2287. warning("W005", state.tokens.curr);
  2288. }
  2289. break;
  2290. case "-":
  2291. if (state.tokens.next.id === "-" || state.tokens.next.id === "--") {
  2292. warning("W006");
  2293. }
  2294. break;
  2295. case "+":
  2296. if (state.tokens.next.id === "+" || state.tokens.next.id === "++") {
  2297. warning("W007");
  2298. }
  2299. break;
  2300. }
  2301. if (id && state.tokens.next.id !== id) {
  2302. if (t) {
  2303. if (state.tokens.next.id === "(end)") {
  2304. error("E019", t, t.id);
  2305. } else {
  2306. error("E020", state.tokens.next, id, t.id, t.line, state.tokens.next.value);
  2307. }
  2308. } else if (state.tokens.next.type !== "(identifier)" || state.tokens.next.value !== id) {
  2309. warning("W116", state.tokens.next, id, state.tokens.next.value);
  2310. }
  2311. }
  2312. state.tokens.prev = state.tokens.curr;
  2313. state.tokens.curr = state.tokens.next;
  2314. for (;;) {
  2315. state.tokens.next = lookahead.shift() || lex.token();
  2316. if (!state.tokens.next) { // No more tokens left, give up
  2317. quit("E041", state.tokens.curr.line);
  2318. }
  2319. if (state.tokens.next.id === "(end)" || state.tokens.next.id === "(error)") {
  2320. return;
  2321. }
  2322. if (state.tokens.next.check) {
  2323. state.tokens.next.check();
  2324. }
  2325. if (state.tokens.next.isSpecial) {
  2326. if (state.tokens.next.type === "falls through") {
  2327. state.tokens.curr.caseFallsThrough = true;
  2328. } else {
  2329. doOption();
  2330. }
  2331. } else {
  2332. if (state.tokens.next.id !== "(endline)") {
  2333. break;
  2334. }
  2335. }
  2336. }
  2337. }
  2338. function isInfix(token) {
  2339. return token.infix || (!token.identifier && !token.template && !!token.led);
  2340. }
  2341. function isEndOfExpr() {
  2342. var curr = state.tokens.curr;
  2343. var next = state.tokens.next;
  2344. if (next.id === ";" || next.id === "}" || next.id === ":") {
  2345. return true;
  2346. }
  2347. if (isInfix(next) === isInfix(curr) || (curr.id === "yield" && state.inMoz())) {
  2348. return curr.line !== startLine(next);
  2349. }
  2350. return false;
  2351. }
  2352. function isBeginOfExpr(prev) {
  2353. return !prev.left && prev.arity !== "unary";
  2354. }
  2355. // This is the heart of JSHINT, the Pratt parser. In addition to parsing, it
  2356. // is looking for ad hoc lint patterns. We add .fud to Pratt's model, which is
  2357. // like .nud except that it is only used on the first token of a statement.
  2358. // Having .fud makes it much easier to define statement-oriented languages like
  2359. // JavaScript. I retained Pratt's nomenclature.
  2360. // .nud Null denotation
  2361. // .fud First null denotation
  2362. // .led Left denotation
  2363. // lbp Left binding power
  2364. // rbp Right binding power
  2365. // They are elements of the parsing method called Top Down Operator Precedence.
  2366. function expression(rbp, initial) {
  2367. var left, isArray = false, isObject = false, isLetExpr = false;
  2368. state.nameStack.push();
  2369. // if current expression is a let expression
  2370. if (!initial && state.tokens.next.value === "let" && peek(0).value === "(") {
  2371. if (!state.inMoz()) {
  2372. warning("W118", state.tokens.next, "let expressions");
  2373. }
  2374. isLetExpr = true;
  2375. // create a new block scope we use only for the current expression
  2376. state.funct["(scope)"].stack();
  2377. advance("let");
  2378. advance("(");
  2379. state.tokens.prev.fud();
  2380. advance(")");
  2381. }
  2382. if (state.tokens.next.id === "(end)")
  2383. error("E006", state.tokens.curr);
  2384. var isDangerous =
  2385. state.option.asi &&
  2386. state.tokens.prev.line !== startLine(state.tokens.curr) &&
  2387. _.contains(["]", ")"], state.tokens.prev.id) &&
  2388. _.contains(["[", "("], state.tokens.curr.id);
  2389. if (isDangerous)
  2390. warning("W014", state.tokens.curr, state.tokens.curr.id);
  2391. advance();
  2392. if (initial) {
  2393. state.funct["(verb)"] = state.tokens.curr.value;
  2394. state.tokens.curr.beginsStmt = true;
  2395. }
  2396. if (initial === true && state.tokens.curr.fud) {
  2397. left = state.tokens.curr.fud();
  2398. } else {
  2399. if (state.tokens.curr.nud) {
  2400. left = state.tokens.curr.nud();
  2401. } else {
  2402. error("E030", state.tokens.curr, state.tokens.curr.id);
  2403. }
  2404. // TODO: use pratt mechanics rather than special casing template tokens
  2405. while ((rbp < state.tokens.next.lbp || state.tokens.next.type === "(template)") &&
  2406. !isEndOfExpr()) {
  2407. isArray = state.tokens.curr.value === "Array";
  2408. isObject = state.tokens.curr.value === "Object";
  2409. // #527, new Foo.Array(), Foo.Array(), new Foo.Object(), Foo.Object()
  2410. // Line breaks in IfStatement heads exist to satisfy the checkJSHint
  2411. // "Line too long." error.
  2412. if (left && (left.value || (left.first && left.first.value))) {
  2413. // If the left.value is not "new", or the left.first.value is a "."
  2414. // then safely assume that this is not "new Array()" and possibly
  2415. // not "new Object()"...
  2416. if (left.value !== "new" ||
  2417. (left.first && left.first.value && left.first.value === ".")) {
  2418. isArray = false;
  2419. // ...In the case of Object, if the left.value and state.tokens.curr.value
  2420. // are not equal, then safely assume that this not "new Object()"
  2421. if (left.value !== state.tokens.curr.value) {
  2422. isObject = false;
  2423. }
  2424. }
  2425. }
  2426. advance();
  2427. if (isArray && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
  2428. warning("W009", state.tokens.curr);
  2429. }
  2430. if (isObject && state.tokens.curr.id === "(" && state.tokens.next.id === ")") {
  2431. warning("W010", state.tokens.curr);
  2432. }
  2433. if (left && state.tokens.curr.led) {
  2434. left = state.tokens.curr.led(left);
  2435. } else {
  2436. error("E033", state.tokens.curr, state.tokens.curr.id);
  2437. }
  2438. }
  2439. }
  2440. if (isLetExpr) {
  2441. state.funct["(scope)"].unstack();
  2442. }
  2443. state.nameStack.pop();
  2444. return left;
  2445. }
  2446. // Functions for conformance of style.
  2447. function startLine(token) {
  2448. return token.startLine || token.line;
  2449. }
  2450. function nobreaknonadjacent(left, right) {
  2451. left = left || state.tokens.curr;
  2452. right = right || state.tokens.next;
  2453. if (!state.option.laxbreak && left.line !== startLine(right)) {
  2454. warning("W014", right, right.value);
  2455. }
  2456. }
  2457. function nolinebreak(t) {
  2458. t = t || state.tokens.curr;
  2459. if (t.line !== startLine(state.tokens.next)) {
  2460. warning("E022", t, t.value);
  2461. }
  2462. }
  2463. function nobreakcomma(left, right) {
  2464. if (left.line !== startLine(right)) {
  2465. if (!state.option.laxcomma) {
  2466. if (comma.first) {
  2467. warning("I001");
  2468. comma.first = false;
  2469. }
  2470. warning("W014", left, right.value);
  2471. }
  2472. }
  2473. }
  2474. function comma(opts) {
  2475. opts = opts || {};
  2476. if (!opts.peek) {
  2477. nobreakcomma(state.tokens.curr, state.tokens.next);
  2478. advance(",");
  2479. } else {
  2480. nobreakcomma(state.tokens.prev, state.tokens.curr);
  2481. }
  2482. if (state.tokens.next.identifier && !(opts.property && state.inES5())) {
  2483. // Keywords that cannot follow a comma operator.
  2484. switch (state.tokens.next.value) {
  2485. case "break":
  2486. case "case":
  2487. case "catch":
  2488. case "continue":
  2489. case "default":
  2490. case "do":
  2491. case "else":
  2492. case "finally":
  2493. case "for":
  2494. case "if":
  2495. case "in":
  2496. case "instanceof":
  2497. case "return":
  2498. case "switch":
  2499. case "throw":
  2500. case "try":
  2501. case "var":
  2502. case "let":
  2503. case "while":
  2504. case "with":
  2505. error("E024", state.tokens.next, state.tokens.next.value);
  2506. return false;
  2507. }
  2508. }
  2509. if (state.tokens.next.type === "(punctuator)") {
  2510. switch (state.tokens.next.value) {
  2511. case "}":
  2512. case "]":
  2513. case ",":
  2514. if (opts.allowTrailing) {
  2515. return true;
  2516. }
  2517. /* falls through */
  2518. case ")":
  2519. error("E024", state.tokens.next, state.tokens.next.value);
  2520. return false;
  2521. }
  2522. }
  2523. return true;
  2524. }
  2525. // Functional constructors for making the symbols that will be inherited by
  2526. // tokens.
  2527. function symbol(s, p) {
  2528. var x = state.syntax[s];
  2529. if (!x || typeof x !== "object") {
  2530. state.syntax[s] = x = {
  2531. id: s,
  2532. lbp: p,
  2533. value: s
  2534. };
  2535. }
  2536. return x;
  2537. }
  2538. function delim(s) {
  2539. var x = symbol(s, 0);
  2540. x.delim = true;
  2541. return x;
  2542. }
  2543. function stmt(s, f) {
  2544. var x = delim(s);
  2545. x.identifier = x.reserved = true;
  2546. x.fud = f;
  2547. return x;
  2548. }
  2549. function blockstmt(s, f) {
  2550. var x = stmt(s, f);
  2551. x.block = true;
  2552. return x;
  2553. }
  2554. function reserveName(x) {
  2555. var c = x.id.charAt(0);
  2556. if ((c >= "a" && c <= "z") || (c >= "A" && c <= "Z")) {
  2557. x.identifier = x.reserved = true;
  2558. }
  2559. return x;
  2560. }
  2561. function prefix(s, f) {
  2562. var x = symbol(s, 150);
  2563. reserveName(x);
  2564. x.nud = (typeof f === "function") ? f : function() {
  2565. this.arity = "unary";
  2566. this.right = expression(150);
  2567. if (this.id === "++" || this.id === "--") {
  2568. if (state.option.plusplus) {
  2569. warning("W016", this, this.id);
  2570. } else if (this.right && (!this.right.identifier || isReserved(this.right)) &&
  2571. this.right.id !== "." && this.right.id !== "[") {
  2572. warning("W017", this);
  2573. }
  2574. if (this.right && this.right.isMetaProperty) {
  2575. error("E031", this);
  2576. // detect increment/decrement of a const
  2577. // in the case of a.b, right will be the "." punctuator
  2578. } else if (this.right && this.right.identifier) {
  2579. state.funct["(scope)"].block.modify(this.right.value, this);
  2580. }
  2581. }
  2582. return this;
  2583. };
  2584. return x;
  2585. }
  2586. function type(s, f) {
  2587. var x = delim(s);
  2588. x.type = s;
  2589. x.nud = f;
  2590. return x;
  2591. }
  2592. function reserve(name, func) {
  2593. var x = type(name, func);
  2594. x.identifier = true;
  2595. x.reserved = true;
  2596. return x;
  2597. }
  2598. function FutureReservedWord(name, meta) {
  2599. var x = type(name, (meta && meta.nud) || function() {
  2600. return this;
  2601. });
  2602. meta = meta || {};
  2603. meta.isFutureReservedWord = true;
  2604. x.value = name;
  2605. x.identifier = true;
  2606. x.reserved = true;
  2607. x.meta = meta;
  2608. return x;
  2609. }
  2610. function reservevar(s, v) {
  2611. return reserve(s, function() {
  2612. if (typeof v === "function") {
  2613. v(this);
  2614. }
  2615. return this;
  2616. });
  2617. }
  2618. function infix(s, f, p, w) {
  2619. var x = symbol(s, p);
  2620. reserveName(x);
  2621. x.infix = true;
  2622. x.led = function(left) {
  2623. if (!w) {
  2624. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  2625. }
  2626. if ((s === "in" || s === "instanceof") && left.id === "!") {
  2627. warning("W018", left, "!");
  2628. }
  2629. if (typeof f === "function") {
  2630. return f(left, this);
  2631. } else {
  2632. this.left = left;
  2633. this.right = expression(p);
  2634. return this;
  2635. }
  2636. };
  2637. return x;
  2638. }
  2639. function application(s) {
  2640. var x = symbol(s, 42);
  2641. x.led = function(left) {
  2642. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  2643. this.left = left;
  2644. this.right = doFunction({ type: "arrow", loneArg: left });
  2645. return this;
  2646. };
  2647. return x;
  2648. }
  2649. function relation(s, f) {
  2650. var x = symbol(s, 100);
  2651. x.led = function(left) {
  2652. nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
  2653. this.left = left;
  2654. var right = this.right = expression(100);
  2655. if (isIdentifier(left, "NaN") || isIdentifier(right, "NaN")) {
  2656. warning("W019", this);
  2657. } else if (f) {
  2658. f.apply(this, [left, right]);
  2659. }
  2660. if (!left || !right) {
  2661. quit("E041", state.tokens.curr.line);
  2662. }
  2663. if (left.id === "!") {
  2664. warning("W018", left, "!");
  2665. }
  2666. if (right.id === "!") {
  2667. warning("W018", right, "!");
  2668. }
  2669. return this;
  2670. };
  2671. return x;
  2672. }
  2673. function isPoorRelation(node) {
  2674. return node &&
  2675. ((node.type === "(number)" && +node.value === 0) ||
  2676. (node.type === "(string)" && node.value === "") ||
  2677. (node.type === "null" && !state.option.eqnull) ||
  2678. node.type === "true" ||
  2679. node.type === "false" ||
  2680. node.type === "undefined");
  2681. }
  2682. var typeofValues = {};
  2683. typeofValues.legacy = [
  2684. // E4X extended the `typeof` operator to return "xml" for the XML and
  2685. // XMLList types it introduced.
  2686. // Ref: 11.3.2 The typeof Operator
  2687. // http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-357.pdf
  2688. "xml",
  2689. // IE<9 reports "unknown" when the `typeof` operator is applied to an
  2690. // object existing across a COM+ bridge. In lieu of official documentation
  2691. // (which does not exist), see:
  2692. // http://robertnyman.com/2005/12/21/what-is-typeof-unknown/
  2693. "unknown"
  2694. ];
  2695. typeofValues.es3 = [
  2696. "undefined", "boolean", "number", "string", "function", "object",
  2697. ];
  2698. typeofValues.es3 = typeofValues.es3.concat(typeofValues.legacy);
  2699. typeofValues.es6 = typeofValues.es3.concat("symbol");
  2700. // Checks whether the 'typeof' operator is used with the correct
  2701. // value. For docs on 'typeof' see:
  2702. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof
  2703. function isTypoTypeof(left, right, state) {
  2704. var values;
  2705. if (state.option.notypeof)
  2706. return false;
  2707. if (!left || !right)
  2708. return false;
  2709. values = state.inES6() ? typeofValues.es6 : typeofValues.es3;
  2710. if (right.type === "(identifier)" && right.value === "typeof" && left.type === "(string)")
  2711. return !_.contains(values, left.value);
  2712. return false;
  2713. }
  2714. function isGlobalEval(left, state) {
  2715. var isGlobal = false;
  2716. // permit methods to refer to an "eval" key in their own context
  2717. if (left.type === "this" && state.funct["(context)"] === null) {
  2718. isGlobal = true;
  2719. }
  2720. // permit use of "eval" members of objects
  2721. else if (left.type === "(identifier)") {
  2722. if (state.option.node && left.value === "global") {
  2723. isGlobal = true;
  2724. }
  2725. else if (state.option.browser && (left.value === "window" || left.value === "document")) {
  2726. isGlobal = true;
  2727. }
  2728. }
  2729. return isGlobal;
  2730. }
  2731. function findNativePrototype(left) {
  2732. var natives = [
  2733. "Array", "ArrayBuffer", "Boolean", "Collator", "DataView", "Date",
  2734. "DateTimeFormat", "Error", "EvalError", "Float32Array", "Float64Array",
  2735. "Function", "Infinity", "Intl", "Int16Array", "Int32Array", "Int8Array",
  2736. "Iterator", "Number", "NumberFormat", "Object", "RangeError",
  2737. "ReferenceError", "RegExp", "StopIteration", "String", "SyntaxError",
  2738. "TypeError", "Uint16Array", "Uint32Array", "Uint8Array", "Uint8ClampedArray",
  2739. "URIError"
  2740. ];
  2741. function walkPrototype(obj) {
  2742. if (typeof obj !== "object") return;
  2743. return obj.right === "prototype" ? obj : walkPrototype(obj.left);
  2744. }
  2745. function walkNative(obj) {
  2746. while (!obj.identifier && typeof obj.left === "object")
  2747. obj = obj.left;
  2748. if (obj.identifier && natives.indexOf(obj.value) >= 0)
  2749. return obj.value;
  2750. }
  2751. var prototype = walkPrototype(left);
  2752. if (prototype) return walkNative(prototype);
  2753. }
  2754. /**
  2755. * Checks the left hand side of an assignment for issues, returns if ok
  2756. * @param {token} left - the left hand side of the assignment
  2757. * @param {token=} assignToken - the token for the assignment, used for reporting
  2758. * @param {object=} options - optional object
  2759. * @param {boolean} options.allowDestructuring - whether to allow destructuting binding
  2760. * @returns {boolean} Whether the left hand side is OK
  2761. */
  2762. function checkLeftSideAssign(left, assignToken, options) {
  2763. var allowDestructuring = options && options.allowDestructuring;
  2764. assignToken = assignToken || left;
  2765. if (state.option.freeze) {
  2766. var nativeObject = findNativePrototype(left);
  2767. if (nativeObject)
  2768. warning("W121", left, nativeObject);
  2769. }
  2770. if (left.identifier && !left.isMetaProperty) {
  2771. // reassign also calls modify
  2772. // but we are specific in order to catch function re-assignment
  2773. // and globals re-assignment
  2774. state.funct["(scope)"].block.reassign(left.value, left);
  2775. }
  2776. if (left.id === ".") {
  2777. if (!left.left || left.left.value === "arguments" && !state.isStrict()) {
  2778. warning("E031", assignToken);
  2779. }
  2780. state.nameStack.set(state.tokens.prev);
  2781. return true;
  2782. } else if (left.id === "{" || left.id === "[") {
  2783. if (allowDestructuring && state.tokens.curr.left.destructAssign) {
  2784. state.tokens.curr.left.destructAssign.forEach(function(t) {
  2785. if (t.id) {
  2786. state.funct["(scope)"].block.modify(t.id, t.token);
  2787. }
  2788. });
  2789. } else {
  2790. if (left.id === "{" || !left.left) {
  2791. warning("E031", assignToken);
  2792. } else if (left.left.value === "arguments" && !state.isStrict()) {
  2793. warning("E031", assignToken);
  2794. }
  2795. }
  2796. if (left.id === "[") {
  2797. state.nameStack.set(left.right);
  2798. }
  2799. return true;
  2800. } else if (left.isMetaProperty) {
  2801. error("E031", assignToken);
  2802. return true;
  2803. } else if (left.identifier && !isReserved(left)) {
  2804. if (state.funct["(scope)"].labeltype(left.value) === "exception") {
  2805. warning("W022", left);
  2806. }
  2807. state.nameStack.set(left);
  2808. return true;
  2809. }
  2810. if (left === state.syntax["function"]) {
  2811. warning("W023", state.tokens.curr);
  2812. }
  2813. return false;
  2814. }
  2815. function assignop(s, f, p) {
  2816. var x = infix(s, typeof f === "function" ? f : function(left, that) {
  2817. that.left = left;
  2818. if (left && checkLeftSideAssign(left, that, { allowDestructuring: true })) {
  2819. that.right = expression(10);
  2820. return that;
  2821. }
  2822. error("E031", that);
  2823. }, p);
  2824. x.exps = true;
  2825. x.assign = true;
  2826. return x;
  2827. }
  2828. function bitwise(s, f, p) {
  2829. var x = symbol(s, p);
  2830. reserveName(x);
  2831. x.led = (typeof f === "function") ? f : function(left) {
  2832. if (state.option.bitwise) {
  2833. warning("W016", this, this.id);
  2834. }
  2835. this.left = left;
  2836. this.right = expression(p);
  2837. return this;
  2838. };
  2839. return x;
  2840. }
  2841. function bitwiseassignop(s) {
  2842. return assignop(s, function(left, that) {
  2843. if (state.option.bitwise) {
  2844. warning("W016", that, that.id);
  2845. }
  2846. if (left && checkLeftSideAssign(left, that)) {
  2847. that.right = expression(10);
  2848. return that;
  2849. }
  2850. error("E031", that);
  2851. }, 20);
  2852. }
  2853. function suffix(s) {
  2854. var x = symbol(s, 150);
  2855. x.led = function(left) {
  2856. // this = suffix e.g. "++" punctuator
  2857. // left = symbol operated e.g. "a" identifier or "a.b" punctuator
  2858. if (state.option.plusplus) {
  2859. warning("W016", this, this.id);
  2860. } else if ((!left.identifier || isReserved(left)) && left.id !== "." && left.id !== "[") {
  2861. warning("W017", this);
  2862. }
  2863. if (left.isMetaProperty) {
  2864. error("E031", this);
  2865. // detect increment/decrement of a const
  2866. // in the case of a.b, left will be the "." punctuator
  2867. } else if (left && left.identifier) {
  2868. state.funct["(scope)"].block.modify(left.value, left);
  2869. }
  2870. this.left = left;
  2871. return this;
  2872. };
  2873. return x;
  2874. }
  2875. // fnparam means that this identifier is being defined as a function
  2876. // argument (see identifier())
  2877. // prop means that this identifier is that of an object property
  2878. function optionalidentifier(fnparam, prop, preserve) {
  2879. if (!state.tokens.next.identifier) {
  2880. return;
  2881. }
  2882. if (!preserve) {
  2883. advance();
  2884. }
  2885. var curr = state.tokens.curr;
  2886. var val = state.tokens.curr.value;
  2887. if (!isReserved(curr)) {
  2888. return val;
  2889. }
  2890. if (prop) {
  2891. if (state.inES5()) {
  2892. return val;
  2893. }
  2894. }
  2895. if (fnparam && val === "undefined") {
  2896. return val;
  2897. }
  2898. warning("W024", state.tokens.curr, state.tokens.curr.id);
  2899. return val;
  2900. }
  2901. // fnparam means that this identifier is being defined as a function
  2902. // argument
  2903. // prop means that this identifier is that of an object property
  2904. function identifier(fnparam, prop) {
  2905. var i = optionalidentifier(fnparam, prop, false);
  2906. if (i) {
  2907. return i;
  2908. }
  2909. // parameter destructuring with rest operator
  2910. if (state.tokens.next.value === "...") {
  2911. if (!state.inES6(true)) {
  2912. warning("W119", state.tokens.next, "spread/rest operator", "6");
  2913. }
  2914. advance();
  2915. if (checkPunctuator(state.tokens.next, "...")) {
  2916. warning("E024", state.tokens.next, "...");
  2917. while (checkPunctuator(state.tokens.next, "...")) {
  2918. advance();
  2919. }
  2920. }
  2921. if (!state.tokens.next.identifier) {
  2922. warning("E024", state.tokens.curr, "...");
  2923. return;
  2924. }
  2925. return identifier(fnparam, prop);
  2926. } else {
  2927. error("E030", state.tokens.next, state.tokens.next.value);
  2928. // The token should be consumed after a warning is issued so the parser
  2929. // can continue as though an identifier were found. The semicolon token
  2930. // should not be consumed in this way so that the parser interprets it as
  2931. // a statement delimeter;
  2932. if (state.tokens.next.id !== ";") {
  2933. advance();
  2934. }
  2935. }
  2936. }
  2937. function reachable(controlToken) {
  2938. var i = 0, t;
  2939. if (state.tokens.next.id !== ";" || controlToken.inBracelessBlock) {
  2940. return;
  2941. }
  2942. for (;;) {
  2943. do {
  2944. t = peek(i);
  2945. i += 1;
  2946. } while (t.id !== "(end)" && t.id === "(comment)");
  2947. if (t.reach) {
  2948. return;
  2949. }
  2950. if (t.id !== "(endline)") {
  2951. if (t.id === "function") {
  2952. if (state.option.latedef === true) {
  2953. warning("W026", t);
  2954. }
  2955. break;
  2956. }
  2957. warning("W027", t, t.value, controlToken.value);
  2958. break;
  2959. }
  2960. }
  2961. }
  2962. function parseFinalSemicolon() {
  2963. if (state.tokens.next.id !== ";") {
  2964. // don't complain about unclosed templates / strings
  2965. if (state.tokens.next.isUnclosed) return advance();
  2966. var sameLine = startLine(state.tokens.next) === state.tokens.curr.line &&
  2967. state.tokens.next.id !== "(end)";
  2968. var blockEnd = checkPunctuator(state.tokens.next, "}");
  2969. if (sameLine && !blockEnd) {
  2970. errorAt("E058", state.tokens.curr.line, state.tokens.curr.character);
  2971. } else if (!state.option.asi) {
  2972. // If this is the last statement in a block that ends on
  2973. // the same line *and* option lastsemic is on, ignore the warning.
  2974. // Otherwise, complain about missing semicolon.
  2975. if ((blockEnd && !state.option.lastsemic) || !sameLine) {
  2976. warningAt("W033", state.tokens.curr.line, state.tokens.curr.character);
  2977. }
  2978. }
  2979. } else {
  2980. advance(";");
  2981. }
  2982. }
  2983. function statement() {
  2984. var i = indent, r, t = state.tokens.next, hasOwnScope = false;
  2985. if (t.id === ";") {
  2986. advance(";");
  2987. return;
  2988. }
  2989. // Is this a labelled statement?
  2990. var res = isReserved(t);
  2991. // We're being more tolerant here: if someone uses
  2992. // a FutureReservedWord as a label, we warn but proceed
  2993. // anyway.
  2994. if (res && t.meta && t.meta.isFutureReservedWord && peek().id === ":") {
  2995. warning("W024", t, t.id);
  2996. res = false;
  2997. }
  2998. if (t.identifier && !res && peek().id === ":") {
  2999. advance();
  3000. advance(":");
  3001. hasOwnScope = true;
  3002. state.funct["(scope)"].stack();
  3003. state.funct["(scope)"].block.addBreakLabel(t.value, { token: state.tokens.curr });
  3004. if (!state.tokens.next.labelled && state.tokens.next.value !== "{") {
  3005. warning("W028", state.tokens.next, t.value, state.tokens.next.value);
  3006. }
  3007. state.tokens.next.label = t.value;
  3008. t = state.tokens.next;
  3009. }
  3010. // Is it a lonely block?
  3011. if (t.id === "{") {
  3012. // Is it a switch case block?
  3013. //
  3014. // switch (foo) {
  3015. // case bar: { <= here.
  3016. // ...
  3017. // }
  3018. // }
  3019. var iscase = (state.funct["(verb)"] === "case" && state.tokens.curr.value === ":");
  3020. block(true, true, false, false, iscase);
  3021. return;
  3022. }
  3023. // Parse the statement.
  3024. r = expression(0, true);
  3025. if (r && !(r.identifier && r.value === "function") &&
  3026. !(r.type === "(punctuator)" && r.left &&
  3027. r.left.identifier && r.left.value === "function")) {
  3028. if (!state.isStrict() &&
  3029. state.option.strict === "global") {
  3030. warning("E007");
  3031. }
  3032. }
  3033. // Look for the final semicolon.
  3034. if (!t.block) {
  3035. if (!state.option.expr && (!r || !r.exps)) {
  3036. warning("W030", state.tokens.curr);
  3037. } else if (state.option.nonew && r && r.left && r.id === "(" && r.left.id === "new") {
  3038. warning("W031", t);
  3039. }
  3040. parseFinalSemicolon();
  3041. }
  3042. // Restore the indentation.
  3043. indent = i;
  3044. if (hasOwnScope) {
  3045. state.funct["(scope)"].unstack();
  3046. }
  3047. return r;
  3048. }
  3049. function statements() {
  3050. var a = [], p;
  3051. while (!state.tokens.next.reach && state.tokens.next.id !== "(end)") {
  3052. if (state.tokens.next.id === ";") {
  3053. p = peek();
  3054. if (!p || (p.id !== "(" && p.id !== "[")) {
  3055. warning("W032");
  3056. }
  3057. advance(";");
  3058. } else {
  3059. a.push(statement());
  3060. }
  3061. }
  3062. return a;
  3063. }
  3064. /*
  3065. * read all directives
  3066. * recognizes a simple form of asi, but always
  3067. * warns, if it is used
  3068. */
  3069. function directives() {
  3070. var i, p, pn;
  3071. while (state.tokens.next.id === "(string)") {
  3072. p = peek(0);
  3073. if (p.id === "(endline)") {
  3074. i = 1;
  3075. do {
  3076. pn = peek(i++);
  3077. } while (pn.id === "(endline)");
  3078. if (pn.id === ";") {
  3079. p = pn;
  3080. } else if (pn.value === "[" || pn.value === ".") {
  3081. // string -> [ | . is a valid production
  3082. break;
  3083. } else if (!state.option.asi || pn.value === "(") {
  3084. // string -> ( is not a valid production
  3085. warning("W033", state.tokens.next);
  3086. }
  3087. } else if (p.id === "." || p.id === "[") {
  3088. break;
  3089. } else if (p.id !== ";") {
  3090. warning("W033", p);
  3091. }
  3092. advance();
  3093. var directive = state.tokens.curr.value;
  3094. if (state.directive[directive] ||
  3095. (directive === "use strict" && state.option.strict === "implied")) {
  3096. warning("W034", state.tokens.curr, directive);
  3097. }
  3098. // there's no directive negation, so always set to true
  3099. state.directive[directive] = true;
  3100. if (p.id === ";") {
  3101. advance(";");
  3102. }
  3103. }
  3104. if (state.isStrict()) {
  3105. if (!state.option["(explicitNewcap)"]) {
  3106. state.option.newcap = true;
  3107. }
  3108. state.option.undef = true;
  3109. }
  3110. }
  3111. /*
  3112. * Parses a single block. A block is a sequence of statements wrapped in
  3113. * braces.
  3114. *
  3115. * ordinary - true for everything but function bodies and try blocks.
  3116. * stmt - true if block can be a single statement (e.g. in if/for/while).
  3117. * isfunc - true if block is a function body
  3118. * isfatarrow - true if its a body of a fat arrow function
  3119. * iscase - true if block is a switch case block
  3120. */
  3121. function block(ordinary, stmt, isfunc, isfatarrow, iscase) {
  3122. var a,
  3123. b = inblock,
  3124. old_indent = indent,
  3125. m,
  3126. t,
  3127. line,
  3128. d;
  3129. inblock = ordinary;
  3130. t = state.tokens.next;
  3131. var metrics = state.funct["(metrics)"];
  3132. metrics.nestedBlockDepth += 1;
  3133. metrics.verifyMaxNestedBlockDepthPerFunction();
  3134. if (state.tokens.next.id === "{") {
  3135. advance("{");
  3136. // create a new block scope
  3137. state.funct["(scope)"].stack();
  3138. line = state.tokens.curr.line;
  3139. if (state.tokens.next.id !== "}") {
  3140. indent += state.option.indent;
  3141. while (!ordinary && state.tokens.next.from > indent) {
  3142. indent += state.option.indent;
  3143. }
  3144. if (isfunc) {
  3145. m = {};
  3146. for (d in state.directive) {
  3147. if (_.has(state.directive, d)) {
  3148. m[d] = state.directive[d];
  3149. }
  3150. }
  3151. directives();
  3152. if (state.option.strict && state.funct["(context)"]["(global)"]) {
  3153. if (!m["use strict"] && !state.isStrict()) {
  3154. warning("E007");
  3155. }
  3156. }
  3157. }
  3158. a = statements();
  3159. metrics.statementCount += a.length;
  3160. indent -= state.option.indent;
  3161. }
  3162. advance("}", t);
  3163. if (isfunc) {
  3164. state.funct["(scope)"].validateParams();
  3165. if (m) {
  3166. state.directive = m;
  3167. }
  3168. }
  3169. state.funct["(scope)"].unstack();
  3170. indent = old_indent;
  3171. } else if (!ordinary) {
  3172. if (isfunc) {
  3173. state.funct["(scope)"].stack();
  3174. m = {};
  3175. if (stmt && !isfatarrow && !state.inMoz()) {
  3176. error("W118", state.tokens.curr, "function closure expressions");
  3177. }
  3178. if (!stmt) {
  3179. for (d in state.directive) {
  3180. if (_.has(state.directive, d)) {
  3181. m[d] = state.directive[d];
  3182. }
  3183. }
  3184. }
  3185. expression(10);
  3186. if (state.option.strict && state.funct["(context)"]["(global)"]) {
  3187. if (!m["use strict"] && !state.isStrict()) {
  3188. warning("E007");
  3189. }
  3190. }
  3191. state.funct["(scope)"].unstack();
  3192. } else {
  3193. error("E021", state.tokens.next, "{", state.tokens.next.value);
  3194. }
  3195. } else {
  3196. // check to avoid let declaration not within a block
  3197. // though is fine inside for loop initializer section
  3198. state.funct["(noblockscopedvar)"] = state.tokens.next.id !== "for";
  3199. state.funct["(scope)"].stack();
  3200. if (!stmt || state.option.curly) {
  3201. warning("W116", state.tokens.next, "{", state.tokens.next.value);
  3202. }
  3203. state.tokens.next.inBracelessBlock = true;
  3204. indent += state.option.indent;
  3205. // test indentation only if statement is in new line
  3206. a = [statement()];
  3207. indent -= state.option.indent;
  3208. state.funct["(scope)"].unstack();
  3209. delete state.funct["(noblockscopedvar)"];
  3210. }
  3211. // Don't clear and let it propagate out if it is "break", "return" or similar in switch case
  3212. switch (state.funct["(verb)"]) {
  3213. case "break":
  3214. case "continue":
  3215. case "return":
  3216. case "throw":
  3217. if (iscase) {
  3218. break;
  3219. }
  3220. /* falls through */
  3221. default:
  3222. state.funct["(verb)"] = null;
  3223. }
  3224. inblock = b;
  3225. if (ordinary && state.option.noempty && (!a || a.length === 0)) {
  3226. warning("W035", state.tokens.prev);
  3227. }
  3228. metrics.nestedBlockDepth -= 1;
  3229. return a;
  3230. }
  3231. function countMember(m) {
  3232. if (membersOnly && typeof membersOnly[m] !== "boolean") {
  3233. warning("W036", state.tokens.curr, m);
  3234. }
  3235. if (typeof member[m] === "number") {
  3236. member[m] += 1;
  3237. } else {
  3238. member[m] = 1;
  3239. }
  3240. }
  3241. // Build the syntax table by declaring the syntactic elements of the language.
  3242. type("(number)", function() {
  3243. return this;
  3244. });
  3245. type("(string)", function() {
  3246. return this;
  3247. });
  3248. state.syntax["(identifier)"] = {
  3249. type: "(identifier)",
  3250. lbp: 0,
  3251. identifier: true,
  3252. nud: function() {
  3253. var v = this.value;
  3254. // If this identifier is the lone parameter to a shorthand "fat arrow"
  3255. // function definition, i.e.
  3256. //
  3257. // x => x;
  3258. //
  3259. // ...it should not be considered as a variable in the current scope. It
  3260. // will be added to the scope of the new function when the next token is
  3261. // parsed, so it can be safely ignored for now.
  3262. if (state.tokens.next.id === "=>") {
  3263. return this;
  3264. }
  3265. if (!state.funct["(comparray)"].check(v)) {
  3266. state.funct["(scope)"].block.use(v, state.tokens.curr);
  3267. }
  3268. return this;
  3269. },
  3270. led: function() {
  3271. error("E033", state.tokens.next, state.tokens.next.value);
  3272. }
  3273. };
  3274. var baseTemplateSyntax = {
  3275. lbp: 0,
  3276. identifier: false,
  3277. template: true,
  3278. };
  3279. state.syntax["(template)"] = _.extend({
  3280. type: "(template)",
  3281. nud: doTemplateLiteral,
  3282. led: doTemplateLiteral,
  3283. noSubst: false
  3284. }, baseTemplateSyntax);
  3285. state.syntax["(template middle)"] = _.extend({
  3286. type: "(template middle)",
  3287. middle: true,
  3288. noSubst: false
  3289. }, baseTemplateSyntax);
  3290. state.syntax["(template tail)"] = _.extend({
  3291. type: "(template tail)",
  3292. tail: true,
  3293. noSubst: false
  3294. }, baseTemplateSyntax);
  3295. state.syntax["(no subst template)"] = _.extend({
  3296. type: "(template)",
  3297. nud: doTemplateLiteral,
  3298. led: doTemplateLiteral,
  3299. noSubst: true,
  3300. tail: true // mark as tail, since it's always the last component
  3301. }, baseTemplateSyntax);
  3302. type("(regexp)", function() {
  3303. return this;
  3304. });
  3305. // ECMAScript parser
  3306. delim("(endline)");
  3307. delim("(begin)");
  3308. delim("(end)").reach = true;
  3309. delim("(error)").reach = true;
  3310. delim("}").reach = true;
  3311. delim(")");
  3312. delim("]");
  3313. delim("\"").reach = true;
  3314. delim("'").reach = true;
  3315. delim(";");
  3316. delim(":").reach = true;
  3317. delim("#");
  3318. reserve("else");
  3319. reserve("case").reach = true;
  3320. reserve("catch");
  3321. reserve("default").reach = true;
  3322. reserve("finally");
  3323. reservevar("arguments", function(x) {
  3324. if (state.isStrict() && state.funct["(global)"]) {
  3325. warning("E008", x);
  3326. }
  3327. });
  3328. reservevar("eval");
  3329. reservevar("false");
  3330. reservevar("Infinity");
  3331. reservevar("null");
  3332. reservevar("this", function(x) {
  3333. if (state.isStrict() && !isMethod() &&
  3334. !state.option.validthis && ((state.funct["(statement)"] &&
  3335. state.funct["(name)"].charAt(0) > "Z") || state.funct["(global)"])) {
  3336. warning("W040", x);
  3337. }
  3338. });
  3339. reservevar("true");
  3340. reservevar("undefined");
  3341. assignop("=", "assign", 20);
  3342. assignop("+=", "assignadd", 20);
  3343. assignop("-=", "assignsub", 20);
  3344. assignop("*=", "assignmult", 20);
  3345. assignop("/=", "assigndiv", 20).nud = function() {
  3346. error("E014");
  3347. };
  3348. assignop("%=", "assignmod", 20);
  3349. bitwiseassignop("&=");
  3350. bitwiseassignop("|=");
  3351. bitwiseassignop("^=");
  3352. bitwiseassignop("<<=");
  3353. bitwiseassignop(">>=");
  3354. bitwiseassignop(">>>=");
  3355. infix(",", function(left, that) {
  3356. var expr;
  3357. that.exprs = [left];
  3358. if (state.option.nocomma) {
  3359. warning("W127");
  3360. }
  3361. if (!comma({ peek: true })) {
  3362. return that;
  3363. }
  3364. while (true) {
  3365. if (!(expr = expression(10))) {
  3366. break;
  3367. }
  3368. that.exprs.push(expr);
  3369. if (state.tokens.next.value !== "," || !comma()) {
  3370. break;
  3371. }
  3372. }
  3373. return that;
  3374. }, 10, true);
  3375. infix("?", function(left, that) {
  3376. increaseComplexityCount();
  3377. that.left = left;
  3378. that.right = expression(10);
  3379. advance(":");
  3380. that["else"] = expression(10);
  3381. return that;
  3382. }, 30);
  3383. var orPrecendence = 40;
  3384. infix("||", function(left, that) {
  3385. increaseComplexityCount();
  3386. that.left = left;
  3387. that.right = expression(orPrecendence);
  3388. return that;
  3389. }, orPrecendence);
  3390. infix("&&", "and", 50);
  3391. bitwise("|", "bitor", 70);
  3392. bitwise("^", "bitxor", 80);
  3393. bitwise("&", "bitand", 90);
  3394. relation("==", function(left, right) {
  3395. var eqnull = state.option.eqnull &&
  3396. ((left && left.value) === "null" || (right && right.value) === "null");
  3397. switch (true) {
  3398. case !eqnull && state.option.eqeqeq:
  3399. this.from = this.character;
  3400. warning("W116", this, "===", "==");
  3401. break;
  3402. case isPoorRelation(left):
  3403. warning("W041", this, "===", left.value);
  3404. break;
  3405. case isPoorRelation(right):
  3406. warning("W041", this, "===", right.value);
  3407. break;
  3408. case isTypoTypeof(right, left, state):
  3409. warning("W122", this, right.value);
  3410. break;
  3411. case isTypoTypeof(left, right, state):
  3412. warning("W122", this, left.value);
  3413. break;
  3414. }
  3415. return this;
  3416. });
  3417. relation("===", function(left, right) {
  3418. if (isTypoTypeof(right, left, state)) {
  3419. warning("W122", this, right.value);
  3420. } else if (isTypoTypeof(left, right, state)) {
  3421. warning("W122", this, left.value);
  3422. }
  3423. return this;
  3424. });
  3425. relation("!=", function(left, right) {
  3426. var eqnull = state.option.eqnull &&
  3427. ((left && left.value) === "null" || (right && right.value) === "null");
  3428. if (!eqnull && state.option.eqeqeq) {
  3429. this.from = this.character;
  3430. warning("W116", this, "!==", "!=");
  3431. } else if (isPoorRelation(left)) {
  3432. warning("W041", this, "!==", left.value);
  3433. } else if (isPoorRelation(right)) {
  3434. warning("W041", this, "!==", right.value);
  3435. } else if (isTypoTypeof(right, left, state)) {
  3436. warning("W122", this, right.value);
  3437. } else if (isTypoTypeof(left, right, state)) {
  3438. warning("W122", this, left.value);
  3439. }
  3440. return this;
  3441. });
  3442. relation("!==", function(left, right) {
  3443. if (isTypoTypeof(right, left, state)) {
  3444. warning("W122", this, right.value);
  3445. } else if (isTypoTypeof(left, right, state)) {
  3446. warning("W122", this, left.value);
  3447. }
  3448. return this;
  3449. });
  3450. relation("<");
  3451. relation(">");
  3452. relation("<=");
  3453. relation(">=");
  3454. bitwise("<<", "shiftleft", 120);
  3455. bitwise(">>", "shiftright", 120);
  3456. bitwise(">>>", "shiftrightunsigned", 120);
  3457. infix("in", "in", 120);
  3458. infix("instanceof", "instanceof", 120);
  3459. infix("+", function(left, that) {
  3460. var right;
  3461. that.left = left;
  3462. that.right = right = expression(130);
  3463. if (left && right && left.id === "(string)" && right.id === "(string)") {
  3464. left.value += right.value;
  3465. left.character = right.character;
  3466. if (!state.option.scripturl && reg.javascriptURL.test(left.value)) {
  3467. warning("W050", left);
  3468. }
  3469. return left;
  3470. }
  3471. return that;
  3472. }, 130);
  3473. prefix("+", "num");
  3474. prefix("+++", function() {
  3475. warning("W007");
  3476. this.arity = "unary";
  3477. this.right = expression(150);
  3478. return this;
  3479. });
  3480. infix("+++", function(left) {
  3481. warning("W007");
  3482. this.left = left;
  3483. this.right = expression(130);
  3484. return this;
  3485. }, 130);
  3486. infix("-", "sub", 130);
  3487. prefix("-", "neg");
  3488. prefix("---", function() {
  3489. warning("W006");
  3490. this.arity = "unary";
  3491. this.right = expression(150);
  3492. return this;
  3493. });
  3494. infix("---", function(left) {
  3495. warning("W006");
  3496. this.left = left;
  3497. this.right = expression(130);
  3498. return this;
  3499. }, 130);
  3500. infix("*", "mult", 140);
  3501. infix("/", "div", 140);
  3502. infix("%", "mod", 140);
  3503. suffix("++");
  3504. prefix("++", "preinc");
  3505. state.syntax["++"].exps = true;
  3506. suffix("--");
  3507. prefix("--", "predec");
  3508. state.syntax["--"].exps = true;
  3509. prefix("delete", function() {
  3510. var p = expression(10);
  3511. if (!p) {
  3512. return this;
  3513. }
  3514. if (p.id !== "." && p.id !== "[") {
  3515. warning("W051");
  3516. }
  3517. this.first = p;
  3518. // The `delete` operator accepts unresolvable references when not in strict
  3519. // mode, so the operand may be undefined.
  3520. if (p.identifier && !state.isStrict()) {
  3521. p.forgiveUndef = true;
  3522. }
  3523. return this;
  3524. }).exps = true;
  3525. prefix("~", function() {
  3526. if (state.option.bitwise) {
  3527. warning("W016", this, "~");
  3528. }
  3529. this.arity = "unary";
  3530. this.right = expression(150);
  3531. return this;
  3532. });
  3533. prefix("...", function() {
  3534. if (!state.inES6(true)) {
  3535. warning("W119", this, "spread/rest operator", "6");
  3536. }
  3537. // TODO: Allow all AssignmentExpression
  3538. // once parsing permits.
  3539. //
  3540. // How to handle eg. number, boolean when the built-in
  3541. // prototype of may have an @@iterator definition?
  3542. //
  3543. // Number.prototype[Symbol.iterator] = function * () {
  3544. // yield this.valueOf();
  3545. // };
  3546. //
  3547. // var a = [ ...1 ];
  3548. // console.log(a); // [1];
  3549. //
  3550. // for (let n of [...10]) {
  3551. // console.log(n);
  3552. // }
  3553. // // 10
  3554. //
  3555. //
  3556. // Boolean.prototype[Symbol.iterator] = function * () {
  3557. // yield this.valueOf();
  3558. // };
  3559. //
  3560. // var a = [ ...true ];
  3561. // console.log(a); // [true];
  3562. //
  3563. // for (let n of [...false]) {
  3564. // console.log(n);
  3565. // }
  3566. // // false
  3567. //
  3568. if (!state.tokens.next.identifier &&
  3569. state.tokens.next.type !== "(string)" &&
  3570. !checkPunctuators(state.tokens.next, ["[", "("])) {
  3571. error("E030", state.tokens.next, state.tokens.next.value);
  3572. }
  3573. expression(150);
  3574. return this;
  3575. });
  3576. prefix("!", function() {
  3577. this.arity = "unary";
  3578. this.right = expression(150);
  3579. if (!this.right) { // '!' followed by nothing? Give up.
  3580. quit("E041", this.line || 0);
  3581. }
  3582. if (bang[this.right.id] === true) {
  3583. warning("W018", this, "!");
  3584. }
  3585. return this;
  3586. });
  3587. prefix("typeof", (function() {
  3588. var p = expression(150);
  3589. this.first = this.right = p;
  3590. if (!p) { // 'typeof' followed by nothing? Give up.
  3591. quit("E041", this.line || 0, this.character || 0);
  3592. }
  3593. // The `typeof` operator accepts unresolvable references, so the operand
  3594. // may be undefined.
  3595. if (p.identifier) {
  3596. p.forgiveUndef = true;
  3597. }
  3598. return this;
  3599. }));
  3600. prefix("new", function() {
  3601. var mp = metaProperty("target", function() {
  3602. if (!state.inES6(true)) {
  3603. warning("W119", state.tokens.prev, "new.target", "6");
  3604. }
  3605. var inFunction, c = state.funct;
  3606. while (c) {
  3607. inFunction = !c["(global)"];
  3608. if (!c["(arrow)"]) { break; }
  3609. c = c["(context)"];
  3610. }
  3611. if (!inFunction) {
  3612. warning("W136", state.tokens.prev, "new.target");
  3613. }
  3614. });
  3615. if (mp) { return mp; }
  3616. var c = expression(155), i;
  3617. if (c && c.id !== "function") {
  3618. if (c.identifier) {
  3619. c["new"] = true;
  3620. switch (c.value) {
  3621. case "Number":
  3622. case "String":
  3623. case "Boolean":
  3624. case "Math":
  3625. case "JSON":
  3626. warning("W053", state.tokens.prev, c.value);
  3627. break;
  3628. case "Symbol":
  3629. if (state.inES6()) {
  3630. warning("W053", state.tokens.prev, c.value);
  3631. }
  3632. break;
  3633. case "Function":
  3634. if (!state.option.evil) {
  3635. warning("W054");
  3636. }
  3637. break;
  3638. case "Date":
  3639. case "RegExp":
  3640. case "this":
  3641. break;
  3642. default:
  3643. if (c.id !== "function") {
  3644. i = c.value.substr(0, 1);
  3645. if (state.option.newcap && (i < "A" || i > "Z") &&
  3646. !state.funct["(scope)"].isPredefined(c.value)) {
  3647. warning("W055", state.tokens.curr);
  3648. }
  3649. }
  3650. }
  3651. } else {
  3652. if (c.id !== "." && c.id !== "[" && c.id !== "(") {
  3653. warning("W056", state.tokens.curr);
  3654. }
  3655. }
  3656. } else {
  3657. if (!state.option.supernew)
  3658. warning("W057", this);
  3659. }
  3660. if (state.tokens.next.id !== "(" && !state.option.supernew) {
  3661. warning("W058", state.tokens.curr, state.tokens.curr.value);
  3662. }
  3663. this.first = this.right = c;
  3664. return this;
  3665. });
  3666. state.syntax["new"].exps = true;
  3667. prefix("void").exps = true;
  3668. infix(".", function(left, that) {
  3669. var m = identifier(false, true);
  3670. if (typeof m === "string") {
  3671. countMember(m);
  3672. }
  3673. that.left = left;
  3674. that.right = m;
  3675. if (m && m === "hasOwnProperty" && state.tokens.next.value === "=") {
  3676. warning("W001");
  3677. }
  3678. if (left && left.value === "arguments" && (m === "callee" || m === "caller")) {
  3679. if (state.option.noarg)
  3680. warning("W059", left, m);
  3681. else if (state.isStrict())
  3682. error("E008");
  3683. } else if (!state.option.evil && left && left.value === "document" &&
  3684. (m === "write" || m === "writeln")) {
  3685. warning("W060", left);
  3686. }
  3687. if (!state.option.evil && (m === "eval" || m === "execScript")) {
  3688. if (isGlobalEval(left, state)) {
  3689. warning("W061");
  3690. }
  3691. }
  3692. return that;
  3693. }, 160, true);
  3694. infix("(", function(left, that) {
  3695. if (state.option.immed && left && !left.immed && left.id === "function") {
  3696. warning("W062");
  3697. }
  3698. var n = 0;
  3699. var p = [];
  3700. if (left) {
  3701. if (left.type === "(identifier)") {
  3702. if (left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)) {
  3703. if ("Array Number String Boolean Date Object Error Symbol".indexOf(left.value) === -1) {
  3704. if (left.value === "Math") {
  3705. warning("W063", left);
  3706. } else if (state.option.newcap) {
  3707. warning("W064", left);
  3708. }
  3709. }
  3710. }
  3711. }
  3712. }
  3713. if (state.tokens.next.id !== ")") {
  3714. for (;;) {
  3715. p[p.length] = expression(10);
  3716. n += 1;
  3717. if (state.tokens.next.id !== ",") {
  3718. break;
  3719. }
  3720. comma();
  3721. }
  3722. }
  3723. advance(")");
  3724. if (typeof left === "object") {
  3725. if (!state.inES5() && left.value === "parseInt" && n === 1) {
  3726. warning("W065", state.tokens.curr);
  3727. }
  3728. if (!state.option.evil) {
  3729. if (left.value === "eval" || left.value === "Function" ||
  3730. left.value === "execScript") {
  3731. warning("W061", left);
  3732. if (p[0] && [0].id === "(string)") {
  3733. addInternalSrc(left, p[0].value);
  3734. }
  3735. } else if (p[0] && p[0].id === "(string)" &&
  3736. (left.value === "setTimeout" ||
  3737. left.value === "setInterval")) {
  3738. warning("W066", left);
  3739. addInternalSrc(left, p[0].value);
  3740. // window.setTimeout/setInterval
  3741. } else if (p[0] && p[0].id === "(string)" &&
  3742. left.value === "." &&
  3743. left.left.value === "window" &&
  3744. (left.right === "setTimeout" ||
  3745. left.right === "setInterval")) {
  3746. warning("W066", left);
  3747. addInternalSrc(left, p[0].value);
  3748. }
  3749. }
  3750. if (!left.identifier && left.id !== "." && left.id !== "[" && left.id !== "=>" &&
  3751. left.id !== "(" && left.id !== "&&" && left.id !== "||" && left.id !== "?" &&
  3752. !(state.inES6() && left["(name)"])) {
  3753. warning("W067", that);
  3754. }
  3755. }
  3756. that.left = left;
  3757. return that;
  3758. }, 155, true).exps = true;
  3759. prefix("(", function() {
  3760. var pn = state.tokens.next, pn1, i = -1;
  3761. var ret, triggerFnExpr, first, last;
  3762. var parens = 1;
  3763. var opening = state.tokens.curr;
  3764. var preceeding = state.tokens.prev;
  3765. var isNecessary = !state.option.singleGroups;
  3766. do {
  3767. if (pn.value === "(") {
  3768. parens += 1;
  3769. } else if (pn.value === ")") {
  3770. parens -= 1;
  3771. }
  3772. i += 1;
  3773. pn1 = pn;
  3774. pn = peek(i);
  3775. } while (!(parens === 0 && pn1.value === ")") && pn.value !== ";" && pn.type !== "(end)");
  3776. if (state.tokens.next.id === "function") {
  3777. triggerFnExpr = state.tokens.next.immed = true;
  3778. }
  3779. // If the balanced grouping operator is followed by a "fat arrow", the
  3780. // current token marks the beginning of a "fat arrow" function and parsing
  3781. // should proceed accordingly.
  3782. if (pn.value === "=>") {
  3783. return doFunction({ type: "arrow", parsedOpening: true });
  3784. }
  3785. var exprs = [];
  3786. if (state.tokens.next.id !== ")") {
  3787. for (;;) {
  3788. exprs.push(expression(10));
  3789. if (state.tokens.next.id !== ",") {
  3790. break;
  3791. }
  3792. if (state.option.nocomma) {
  3793. warning("W127");
  3794. }
  3795. comma();
  3796. }
  3797. }
  3798. advance(")", this);
  3799. if (state.option.immed && exprs[0] && exprs[0].id === "function") {
  3800. if (state.tokens.next.id !== "(" &&
  3801. state.tokens.next.id !== "." && state.tokens.next.id !== "[") {
  3802. warning("W068", this);
  3803. }
  3804. }
  3805. if (!exprs.length) {
  3806. return;
  3807. }
  3808. if (exprs.length > 1) {
  3809. ret = Object.create(state.syntax[","]);
  3810. ret.exprs = exprs;
  3811. first = exprs[0];
  3812. last = exprs[exprs.length - 1];
  3813. if (!isNecessary) {
  3814. isNecessary = preceeding.assign || preceeding.delim;
  3815. }
  3816. } else {
  3817. ret = first = last = exprs[0];
  3818. if (!isNecessary) {
  3819. isNecessary =
  3820. // Used to distinguish from an ExpressionStatement which may not
  3821. // begin with the `{` and `function` tokens
  3822. (opening.beginsStmt && (ret.id === "{" || triggerFnExpr || isFunctor(ret))) ||
  3823. // Used to signal that a function expression is being supplied to
  3824. // some other operator.
  3825. (triggerFnExpr &&
  3826. // For parenthesis wrapping a function expression to be considered
  3827. // necessary, the grouping operator should be the left-hand-side of
  3828. // some other operator--either within the parenthesis or directly
  3829. // following them.
  3830. (!isEndOfExpr() || state.tokens.prev.id !== "}")) ||
  3831. // Used to demarcate an arrow function as the left-hand side of some
  3832. // operator.
  3833. (isFunctor(ret) && !isEndOfExpr()) ||
  3834. // Used as the return value of a single-statement arrow function
  3835. (ret.id === "{" && preceeding.id === "=>") ||
  3836. // Used to delineate an integer number literal from a dereferencing
  3837. // punctuator (otherwise interpreted as a decimal point)
  3838. (ret.type === "(number)" &&
  3839. checkPunctuator(pn, ".") && /^\d+$/.test(ret.value));
  3840. }
  3841. }
  3842. if (ret) {
  3843. // The operator may be necessary to override the default binding power of
  3844. // neighboring operators (whenever there is an operator in use within the
  3845. // first expression *or* the current group contains multiple expressions)
  3846. if (!isNecessary && (first.left || first.right || ret.exprs)) {
  3847. isNecessary =
  3848. (!isBeginOfExpr(preceeding) && first.lbp <= preceeding.lbp) ||
  3849. (!isEndOfExpr() && last.lbp < state.tokens.next.lbp);
  3850. }
  3851. if (!isNecessary) {
  3852. warning("W126", opening);
  3853. }
  3854. ret.paren = true;
  3855. }
  3856. return ret;
  3857. });
  3858. application("=>");
  3859. infix("[", function(left, that) {
  3860. var e = expression(10), s;
  3861. if (e && e.type === "(string)") {
  3862. if (!state.option.evil && (e.value === "eval" || e.value === "execScript")) {
  3863. if (isGlobalEval(left, state)) {
  3864. warning("W061");
  3865. }
  3866. }
  3867. countMember(e.value);
  3868. if (!state.option.sub && reg.identifier.test(e.value)) {
  3869. s = state.syntax[e.value];
  3870. if (!s || !isReserved(s)) {
  3871. warning("W069", state.tokens.prev, e.value);
  3872. }
  3873. }
  3874. }
  3875. advance("]", that);
  3876. if (e && e.value === "hasOwnProperty" && state.tokens.next.value === "=") {
  3877. warning("W001");
  3878. }
  3879. that.left = left;
  3880. that.right = e;
  3881. return that;
  3882. }, 160, true);
  3883. function comprehensiveArrayExpression() {
  3884. var res = {};
  3885. res.exps = true;
  3886. state.funct["(comparray)"].stack();
  3887. // Handle reversed for expressions, used in spidermonkey
  3888. var reversed = false;
  3889. if (state.tokens.next.value !== "for") {
  3890. reversed = true;
  3891. if (!state.inMoz()) {
  3892. warning("W116", state.tokens.next, "for", state.tokens.next.value);
  3893. }
  3894. state.funct["(comparray)"].setState("use");
  3895. res.right = expression(10);
  3896. }
  3897. advance("for");
  3898. if (state.tokens.next.value === "each") {
  3899. advance("each");
  3900. if (!state.inMoz()) {
  3901. warning("W118", state.tokens.curr, "for each");
  3902. }
  3903. }
  3904. advance("(");
  3905. state.funct["(comparray)"].setState("define");
  3906. res.left = expression(130);
  3907. if (_.contains(["in", "of"], state.tokens.next.value)) {
  3908. advance();
  3909. } else {
  3910. error("E045", state.tokens.curr);
  3911. }
  3912. state.funct["(comparray)"].setState("generate");
  3913. expression(10);
  3914. advance(")");
  3915. if (state.tokens.next.value === "if") {
  3916. advance("if");
  3917. advance("(");
  3918. state.funct["(comparray)"].setState("filter");
  3919. res.filter = expression(10);
  3920. advance(")");
  3921. }
  3922. if (!reversed) {
  3923. state.funct["(comparray)"].setState("use");
  3924. res.right = expression(10);
  3925. }
  3926. advance("]");
  3927. state.funct["(comparray)"].unstack();
  3928. return res;
  3929. }
  3930. prefix("[", function() {
  3931. var blocktype = lookupBlockType();
  3932. if (blocktype.isCompArray) {
  3933. if (!state.option.esnext && !state.inMoz()) {
  3934. warning("W118", state.tokens.curr, "array comprehension");
  3935. }
  3936. return comprehensiveArrayExpression();
  3937. } else if (blocktype.isDestAssign) {
  3938. this.destructAssign = destructuringPattern({ openingParsed: true, assignment: true });
  3939. return this;
  3940. }
  3941. var b = state.tokens.curr.line !== startLine(state.tokens.next);
  3942. this.first = [];
  3943. if (b) {
  3944. indent += state.option.indent;
  3945. if (state.tokens.next.from === indent + state.option.indent) {
  3946. indent += state.option.indent;
  3947. }
  3948. }
  3949. while (state.tokens.next.id !== "(end)") {
  3950. while (state.tokens.next.id === ",") {
  3951. if (!state.option.elision) {
  3952. if (!state.inES5()) {
  3953. // Maintain compat with old options --- ES5 mode without
  3954. // elision=true will warn once per comma
  3955. warning("W070");
  3956. } else {
  3957. warning("W128");
  3958. do {
  3959. advance(",");
  3960. } while (state.tokens.next.id === ",");
  3961. continue;
  3962. }
  3963. }
  3964. advance(",");
  3965. }
  3966. if (state.tokens.next.id === "]") {
  3967. break;
  3968. }
  3969. this.first.push(expression(10));
  3970. if (state.tokens.next.id === ",") {
  3971. comma({ allowTrailing: true });
  3972. if (state.tokens.next.id === "]" && !state.inES5()) {
  3973. warning("W070", state.tokens.curr);
  3974. break;
  3975. }
  3976. } else {
  3977. break;
  3978. }
  3979. }
  3980. if (b) {
  3981. indent -= state.option.indent;
  3982. }
  3983. advance("]", this);
  3984. return this;
  3985. });
  3986. function isMethod() {
  3987. return state.funct["(statement)"] && state.funct["(statement)"].type === "class" ||
  3988. state.funct["(context)"] && state.funct["(context)"]["(verb)"] === "class";
  3989. }
  3990. function isPropertyName(token) {
  3991. return token.identifier || token.id === "(string)" || token.id === "(number)";
  3992. }
  3993. function propertyName(preserveOrToken) {
  3994. var id;
  3995. var preserve = true;
  3996. if (typeof preserveOrToken === "object") {
  3997. id = preserveOrToken;
  3998. } else {
  3999. preserve = preserveOrToken;
  4000. id = optionalidentifier(false, true, preserve);
  4001. }
  4002. if (!id) {
  4003. if (state.tokens.next.id === "(string)") {
  4004. id = state.tokens.next.value;
  4005. if (!preserve) {
  4006. advance();
  4007. }
  4008. } else if (state.tokens.next.id === "(number)") {
  4009. id = state.tokens.next.value.toString();
  4010. if (!preserve) {
  4011. advance();
  4012. }
  4013. }
  4014. } else if (typeof id === "object") {
  4015. if (id.id === "(string)" || id.id === "(identifier)") id = id.value;
  4016. else if (id.id === "(number)") id = id.value.toString();
  4017. }
  4018. if (id === "hasOwnProperty") {
  4019. warning("W001");
  4020. }
  4021. return id;
  4022. }
  4023. /**
  4024. * @param {Object} [options]
  4025. * @param {token} [options.loneArg] The argument to the function in cases
  4026. * where it was defined using the
  4027. * single-argument shorthand.
  4028. * @param {bool} [options.parsedOpening] Whether the opening parenthesis has
  4029. * already been parsed.
  4030. * @returns {{ arity: number, params: Array.<string>}}
  4031. */
  4032. function functionparams(options) {
  4033. var next;
  4034. var paramsIds = [];
  4035. var ident;
  4036. var tokens = [];
  4037. var t;
  4038. var pastDefault = false;
  4039. var pastRest = false;
  4040. var arity = 0;
  4041. var loneArg = options && options.loneArg;
  4042. if (loneArg && loneArg.identifier === true) {
  4043. state.funct["(scope)"].addParam(loneArg.value, loneArg);
  4044. return { arity: 1, params: [ loneArg.value ] };
  4045. }
  4046. next = state.tokens.next;
  4047. if (!options || !options.parsedOpening) {
  4048. advance("(");
  4049. }
  4050. if (state.tokens.next.id === ")") {
  4051. advance(")");
  4052. return;
  4053. }
  4054. function addParam(addParamArgs) {
  4055. state.funct["(scope)"].addParam.apply(state.funct["(scope)"], addParamArgs);
  4056. }
  4057. for (;;) {
  4058. arity++;
  4059. // are added to the param scope
  4060. var currentParams = [];
  4061. if (_.contains(["{", "["], state.tokens.next.id)) {
  4062. tokens = destructuringPattern();
  4063. for (t in tokens) {
  4064. t = tokens[t];
  4065. if (t.id) {
  4066. paramsIds.push(t.id);
  4067. currentParams.push([t.id, t.token]);
  4068. }
  4069. }
  4070. } else {
  4071. if (checkPunctuator(state.tokens.next, "...")) pastRest = true;
  4072. ident = identifier(true);
  4073. if (ident) {
  4074. paramsIds.push(ident);
  4075. currentParams.push([ident, state.tokens.curr]);
  4076. } else {
  4077. // Skip invalid parameter.
  4078. while (!checkPunctuators(state.tokens.next, [",", ")"])) advance();
  4079. }
  4080. }
  4081. // It is valid to have a regular argument after a default argument
  4082. // since undefined can be used for missing parameters. Still warn as it is
  4083. // a possible code smell.
  4084. if (pastDefault) {
  4085. if (state.tokens.next.id !== "=") {
  4086. error("W138", state.tokens.current);
  4087. }
  4088. }
  4089. if (state.tokens.next.id === "=") {
  4090. if (!state.inES6()) {
  4091. warning("W119", state.tokens.next, "default parameters", "6");
  4092. }
  4093. advance("=");
  4094. pastDefault = true;
  4095. expression(10);
  4096. }
  4097. // now we have evaluated the default expression, add the variable to the param scope
  4098. currentParams.forEach(addParam);
  4099. if (state.tokens.next.id === ",") {
  4100. if (pastRest) {
  4101. warning("W131", state.tokens.next);
  4102. }
  4103. comma();
  4104. } else {
  4105. advance(")", next);
  4106. return { arity: arity, params: paramsIds };
  4107. }
  4108. }
  4109. }
  4110. function functor(name, token, overwrites) {
  4111. var funct = {
  4112. "(name)" : name,
  4113. "(breakage)" : 0,
  4114. "(loopage)" : 0,
  4115. "(tokens)" : {},
  4116. "(properties)": {},
  4117. "(catch)" : false,
  4118. "(global)" : false,
  4119. "(line)" : null,
  4120. "(character)" : null,
  4121. "(metrics)" : null,
  4122. "(statement)" : null,
  4123. "(context)" : null,
  4124. "(scope)" : null,
  4125. "(comparray)" : null,
  4126. "(generator)" : null,
  4127. "(arrow)" : null,
  4128. "(params)" : null
  4129. };
  4130. if (token) {
  4131. _.extend(funct, {
  4132. "(line)" : token.line,
  4133. "(character)": token.character,
  4134. "(metrics)" : createMetrics(token)
  4135. });
  4136. }
  4137. _.extend(funct, overwrites);
  4138. if (funct["(context)"]) {
  4139. funct["(scope)"] = funct["(context)"]["(scope)"];
  4140. funct["(comparray)"] = funct["(context)"]["(comparray)"];
  4141. }
  4142. return funct;
  4143. }
  4144. function isFunctor(token) {
  4145. return "(scope)" in token;
  4146. }
  4147. /**
  4148. * Determine if the parser has begun parsing executable code.
  4149. *
  4150. * @param {Token} funct - The current "functor" token
  4151. *
  4152. * @returns {boolean}
  4153. */
  4154. function hasParsedCode(funct) {
  4155. return funct["(global)"] && !funct["(verb)"];
  4156. }
  4157. function doTemplateLiteral(left) {
  4158. // ASSERT: this.type === "(template)"
  4159. // jshint validthis: true
  4160. var ctx = this.context;
  4161. var noSubst = this.noSubst;
  4162. var depth = this.depth;
  4163. if (!noSubst) {
  4164. while (!end()) {
  4165. if (!state.tokens.next.template || state.tokens.next.depth > depth) {
  4166. expression(0); // should probably have different rbp?
  4167. } else {
  4168. // skip template start / middle
  4169. advance();
  4170. }
  4171. }
  4172. }
  4173. return {
  4174. id: "(template)",
  4175. type: "(template)",
  4176. tag: left
  4177. };
  4178. function end() {
  4179. if (state.tokens.curr.template && state.tokens.curr.tail &&
  4180. state.tokens.curr.context === ctx) return true;
  4181. var complete = (state.tokens.next.template && state.tokens.next.tail &&
  4182. state.tokens.next.context === ctx);
  4183. if (complete) advance();
  4184. return complete || state.tokens.next.isUnclosed;
  4185. }
  4186. }
  4187. /**
  4188. * @param {Object} [options]
  4189. * @param {token} [options.name] The identifier belonging to the function (if
  4190. * any)
  4191. * @param {boolean} [options.statement] The statement that triggered creation
  4192. * of the current function.
  4193. * @param {string} [options.type] If specified, either "generator" or "arrow"
  4194. * @param {token} [options.loneArg] The argument to the function in cases
  4195. * where it was defined using the
  4196. * single-argument shorthand
  4197. * @param {bool} [options.parsedOpening] Whether the opening parenthesis has
  4198. * already been parsed
  4199. * @param {token} [options.classExprBinding] Define a function with this
  4200. * identifier in the new function's
  4201. * scope, mimicking the bahavior of
  4202. * class expression names within
  4203. * the body of member functions.
  4204. */
  4205. function doFunction(options) {
  4206. var f, token, name, statement, classExprBinding, isGenerator, isArrow, ignoreLoopFunc;
  4207. var oldOption = state.option;
  4208. var oldIgnored = state.ignored;
  4209. if (options) {
  4210. name = options.name;
  4211. statement = options.statement;
  4212. classExprBinding = options.classExprBinding;
  4213. isGenerator = options.type === "generator";
  4214. isArrow = options.type === "arrow";
  4215. ignoreLoopFunc = options.ignoreLoopFunc;
  4216. }
  4217. state.option = Object.create(state.option);
  4218. state.ignored = Object.create(state.ignored);
  4219. state.funct = functor(name || state.nameStack.infer(), state.tokens.next, {
  4220. "(statement)": statement,
  4221. "(context)": state.funct,
  4222. "(arrow)": isArrow,
  4223. "(generator)": isGenerator
  4224. });
  4225. f = state.funct;
  4226. token = state.tokens.curr;
  4227. token.funct = state.funct;
  4228. functions.push(state.funct);
  4229. // So that the function is available to itself and referencing itself is not
  4230. // seen as a closure, add the function name to a new scope, but do not
  4231. // test for unused (unused: false)
  4232. // it is a new block scope so that params can override it, it can be block scoped
  4233. // but declarations inside the function don't cause already declared error
  4234. state.funct["(scope)"].stack("functionouter");
  4235. var internallyAccessibleName = name || classExprBinding;
  4236. if (internallyAccessibleName) {
  4237. state.funct["(scope)"].block.add(internallyAccessibleName,
  4238. classExprBinding ? "class" : "function", state.tokens.curr, false);
  4239. }
  4240. // create the param scope (params added in functionparams)
  4241. state.funct["(scope)"].stack("functionparams");
  4242. var paramsInfo = functionparams(options);
  4243. if (paramsInfo) {
  4244. state.funct["(params)"] = paramsInfo.params;
  4245. state.funct["(metrics)"].arity = paramsInfo.arity;
  4246. state.funct["(metrics)"].verifyMaxParametersPerFunction();
  4247. } else {
  4248. state.funct["(metrics)"].arity = 0;
  4249. }
  4250. if (isArrow) {
  4251. if (!state.inES6(true)) {
  4252. warning("W119", state.tokens.curr, "arrow function syntax (=>)", "6");
  4253. }
  4254. if (!options.loneArg) {
  4255. advance("=>");
  4256. }
  4257. }
  4258. block(false, true, true, isArrow);
  4259. if (!state.option.noyield && isGenerator &&
  4260. state.funct["(generator)"] !== "yielded") {
  4261. warning("W124", state.tokens.curr);
  4262. }
  4263. state.funct["(metrics)"].verifyMaxStatementsPerFunction();
  4264. state.funct["(metrics)"].verifyMaxComplexityPerFunction();
  4265. state.funct["(unusedOption)"] = state.option.unused;
  4266. state.option = oldOption;
  4267. state.ignored = oldIgnored;
  4268. state.funct["(last)"] = state.tokens.curr.line;
  4269. state.funct["(lastcharacter)"] = state.tokens.curr.character;
  4270. // unstack the params scope
  4271. state.funct["(scope)"].unstack(); // also does usage and label checks
  4272. // unstack the function outer stack
  4273. state.funct["(scope)"].unstack();
  4274. state.funct = state.funct["(context)"];
  4275. if (!ignoreLoopFunc && !state.option.loopfunc && state.funct["(loopage)"]) {
  4276. // If the function we just parsed accesses any non-local variables
  4277. // trigger a warning. Otherwise, the function is safe even within
  4278. // a loop.
  4279. if (f["(isCapturing)"]) {
  4280. warning("W083", token);
  4281. }
  4282. }
  4283. return f;
  4284. }
  4285. function createMetrics(functionStartToken) {
  4286. return {
  4287. statementCount: 0,
  4288. nestedBlockDepth: -1,
  4289. ComplexityCount: 1,
  4290. arity: 0,
  4291. verifyMaxStatementsPerFunction: function() {
  4292. if (state.option.maxstatements &&
  4293. this.statementCount > state.option.maxstatements) {
  4294. warning("W071", functionStartToken, this.statementCount);
  4295. }
  4296. },
  4297. verifyMaxParametersPerFunction: function() {
  4298. if (_.isNumber(state.option.maxparams) &&
  4299. this.arity > state.option.maxparams) {
  4300. warning("W072", functionStartToken, this.arity);
  4301. }
  4302. },
  4303. verifyMaxNestedBlockDepthPerFunction: function() {
  4304. if (state.option.maxdepth &&
  4305. this.nestedBlockDepth > 0 &&
  4306. this.nestedBlockDepth === state.option.maxdepth + 1) {
  4307. warning("W073", null, this.nestedBlockDepth);
  4308. }
  4309. },
  4310. verifyMaxComplexityPerFunction: function() {
  4311. var max = state.option.maxcomplexity;
  4312. var cc = this.ComplexityCount;
  4313. if (max && cc > max) {
  4314. warning("W074", functionStartToken, cc);
  4315. }
  4316. }
  4317. };
  4318. }
  4319. function increaseComplexityCount() {
  4320. state.funct["(metrics)"].ComplexityCount += 1;
  4321. }
  4322. // Parse assignments that were found instead of conditionals.
  4323. // For example: if (a = 1) { ... }
  4324. function checkCondAssignment(expr) {
  4325. var id, paren;
  4326. if (expr) {
  4327. id = expr.id;
  4328. paren = expr.paren;
  4329. if (id === "," && (expr = expr.exprs[expr.exprs.length - 1])) {
  4330. id = expr.id;
  4331. paren = paren || expr.paren;
  4332. }
  4333. }
  4334. switch (id) {
  4335. case "=":
  4336. case "+=":
  4337. case "-=":
  4338. case "*=":
  4339. case "%=":
  4340. case "&=":
  4341. case "|=":
  4342. case "^=":
  4343. case "/=":
  4344. if (!paren && !state.option.boss) {
  4345. warning("W084");
  4346. }
  4347. }
  4348. }
  4349. /**
  4350. * @param {object} props Collection of property descriptors for a given
  4351. * object.
  4352. */
  4353. function checkProperties(props) {
  4354. // Check for lonely setters if in the ES5 mode.
  4355. if (state.inES5()) {
  4356. for (var name in props) {
  4357. if (props[name] && props[name].setterToken && !props[name].getterToken) {
  4358. warning("W078", props[name].setterToken);
  4359. }
  4360. }
  4361. }
  4362. }
  4363. function metaProperty(name, c) {
  4364. if (checkPunctuator(state.tokens.next, ".")) {
  4365. var left = state.tokens.curr.id;
  4366. advance(".");
  4367. var id = identifier();
  4368. state.tokens.curr.isMetaProperty = true;
  4369. if (name !== id) {
  4370. error("E057", state.tokens.prev, left, id);
  4371. } else {
  4372. c();
  4373. }
  4374. return state.tokens.curr;
  4375. }
  4376. }
  4377. (function(x) {
  4378. x.nud = function() {
  4379. var b, f, i, p, t, isGeneratorMethod = false, nextVal;
  4380. var props = Object.create(null); // All properties, including accessors
  4381. b = state.tokens.curr.line !== startLine(state.tokens.next);
  4382. if (b) {
  4383. indent += state.option.indent;
  4384. if (state.tokens.next.from === indent + state.option.indent) {
  4385. indent += state.option.indent;
  4386. }
  4387. }
  4388. var blocktype = lookupBlockType();
  4389. if (blocktype.isDestAssign) {
  4390. this.destructAssign = destructuringPattern({ openingParsed: true, assignment: true });
  4391. return this;
  4392. }
  4393. for (;;) {
  4394. if (state.tokens.next.id === "}") {
  4395. break;
  4396. }
  4397. nextVal = state.tokens.next.value;
  4398. if (state.tokens.next.identifier &&
  4399. (peekIgnoreEOL().id === "," || peekIgnoreEOL().id === "}")) {
  4400. if (!state.inES6()) {
  4401. warning("W104", state.tokens.next, "object short notation", "6");
  4402. }
  4403. i = propertyName(true);
  4404. saveProperty(props, i, state.tokens.next);
  4405. expression(10);
  4406. } else if (peek().id !== ":" && (nextVal === "get" || nextVal === "set")) {
  4407. advance(nextVal);
  4408. if (!state.inES5()) {
  4409. error("E034");
  4410. }
  4411. i = propertyName();
  4412. // ES6 allows for get() {...} and set() {...} method
  4413. // definition shorthand syntax, so we don't produce an error
  4414. // if linting ECMAScript 6 code.
  4415. if (!i && !state.inES6()) {
  4416. error("E035");
  4417. }
  4418. // We don't want to save this getter unless it's an actual getter
  4419. // and not an ES6 concise method
  4420. if (i) {
  4421. saveAccessor(nextVal, props, i, state.tokens.curr);
  4422. }
  4423. t = state.tokens.next;
  4424. f = doFunction();
  4425. p = f["(params)"];
  4426. // Don't warn about getter/setter pairs if this is an ES6 concise method
  4427. if (nextVal === "get" && i && p) {
  4428. warning("W076", t, p[0], i);
  4429. } else if (nextVal === "set" && i && (!p || p.length !== 1)) {
  4430. warning("W077", t, i);
  4431. }
  4432. } else {
  4433. if (state.tokens.next.value === "*" && state.tokens.next.type === "(punctuator)") {
  4434. if (!state.inES6()) {
  4435. warning("W104", state.tokens.next, "generator functions", "6");
  4436. }
  4437. advance("*");
  4438. isGeneratorMethod = true;
  4439. } else {
  4440. isGeneratorMethod = false;
  4441. }
  4442. if (state.tokens.next.id === "[") {
  4443. i = computedPropertyName();
  4444. state.nameStack.set(i);
  4445. } else {
  4446. state.nameStack.set(state.tokens.next);
  4447. i = propertyName();
  4448. saveProperty(props, i, state.tokens.next);
  4449. if (typeof i !== "string") {
  4450. break;
  4451. }
  4452. }
  4453. if (state.tokens.next.value === "(") {
  4454. if (!state.inES6()) {
  4455. warning("W104", state.tokens.curr, "concise methods", "6");
  4456. }
  4457. doFunction({ type: isGeneratorMethod ? "generator" : null });
  4458. } else {
  4459. advance(":");
  4460. expression(10);
  4461. }
  4462. }
  4463. countMember(i);
  4464. if (state.tokens.next.id === ",") {
  4465. comma({ allowTrailing: true, property: true });
  4466. if (state.tokens.next.id === ",") {
  4467. warning("W070", state.tokens.curr);
  4468. } else if (state.tokens.next.id === "}" && !state.inES5()) {
  4469. warning("W070", state.tokens.curr);
  4470. }
  4471. } else {
  4472. break;
  4473. }
  4474. }
  4475. if (b) {
  4476. indent -= state.option.indent;
  4477. }
  4478. advance("}", this);
  4479. checkProperties(props);
  4480. return this;
  4481. };
  4482. x.fud = function() {
  4483. error("E036", state.tokens.curr);
  4484. };
  4485. }(delim("{")));
  4486. function destructuringPattern(options) {
  4487. var isAssignment = options && options.assignment;
  4488. if (!state.inES6()) {
  4489. warning("W104", state.tokens.curr,
  4490. isAssignment ? "destructuring assignment" : "destructuring binding", "6");
  4491. }
  4492. return destructuringPatternRecursive(options);
  4493. }
  4494. function destructuringPatternRecursive(options) {
  4495. var ids;
  4496. var identifiers = [];
  4497. var openingParsed = options && options.openingParsed;
  4498. var isAssignment = options && options.assignment;
  4499. var recursiveOptions = isAssignment ? { assignment: isAssignment } : null;
  4500. var firstToken = openingParsed ? state.tokens.curr : state.tokens.next;
  4501. var nextInnerDE = function() {
  4502. var ident;
  4503. if (checkPunctuators(state.tokens.next, ["[", "{"])) {
  4504. ids = destructuringPatternRecursive(recursiveOptions);
  4505. for (var id in ids) {
  4506. id = ids[id];
  4507. identifiers.push({ id: id.id, token: id.token });
  4508. }
  4509. } else if (checkPunctuator(state.tokens.next, ",")) {
  4510. identifiers.push({ id: null, token: state.tokens.curr });
  4511. } else if (checkPunctuator(state.tokens.next, "(")) {
  4512. advance("(");
  4513. nextInnerDE();
  4514. advance(")");
  4515. } else {
  4516. var is_rest = checkPunctuator(state.tokens.next, "...");
  4517. if (isAssignment) {
  4518. var identifierToken = is_rest ? peek(0) : state.tokens.next;
  4519. if (!identifierToken.identifier) {
  4520. warning("E030", identifierToken, identifierToken.value);
  4521. }
  4522. var assignTarget = expression(155);
  4523. if (assignTarget) {
  4524. checkLeftSideAssign(assignTarget);
  4525. // if the target was a simple identifier, add it to the list to return
  4526. if (assignTarget.identifier) {
  4527. ident = assignTarget.value;
  4528. }
  4529. }
  4530. } else {
  4531. ident = identifier();
  4532. }
  4533. if (ident) {
  4534. identifiers.push({ id: ident, token: state.tokens.curr });
  4535. }
  4536. return is_rest;
  4537. }
  4538. return false;
  4539. };
  4540. var assignmentProperty = function() {
  4541. var id;
  4542. if (checkPunctuator(state.tokens.next, "[")) {
  4543. advance("[");
  4544. expression(10);
  4545. advance("]");
  4546. advance(":");
  4547. nextInnerDE();
  4548. } else if (state.tokens.next.id === "(string)" ||
  4549. state.tokens.next.id === "(number)") {
  4550. advance();
  4551. advance(":");
  4552. nextInnerDE();
  4553. } else {
  4554. // this id will either be the property name or the property name and the assigning identifier
  4555. id = identifier();
  4556. if (checkPunctuator(state.tokens.next, ":")) {
  4557. advance(":");
  4558. nextInnerDE();
  4559. } else if (id) {
  4560. // in this case we are assigning (not declaring), so check assignment
  4561. if (isAssignment) {
  4562. checkLeftSideAssign(state.tokens.curr);
  4563. }
  4564. identifiers.push({ id: id, token: state.tokens.curr });
  4565. }
  4566. }
  4567. };
  4568. if (checkPunctuator(firstToken, "[")) {
  4569. if (!openingParsed) {
  4570. advance("[");
  4571. }
  4572. if (checkPunctuator(state.tokens.next, "]")) {
  4573. warning("W137", state.tokens.curr);
  4574. }
  4575. var element_after_rest = false;
  4576. while (!checkPunctuator(state.tokens.next, "]")) {
  4577. if (nextInnerDE() && !element_after_rest &&
  4578. checkPunctuator(state.tokens.next, ",")) {
  4579. warning("W130", state.tokens.next);
  4580. element_after_rest = true;
  4581. }
  4582. if (checkPunctuator(state.tokens.next, "=")) {
  4583. if (checkPunctuator(state.tokens.prev, "...")) {
  4584. advance("]");
  4585. } else {
  4586. advance("=");
  4587. }
  4588. if (state.tokens.next.id === "undefined") {
  4589. warning("W080", state.tokens.prev, state.tokens.prev.value);
  4590. }
  4591. expression(10);
  4592. }
  4593. if (!checkPunctuator(state.tokens.next, "]")) {
  4594. advance(",");
  4595. }
  4596. }
  4597. advance("]");
  4598. } else if (checkPunctuator(firstToken, "{")) {
  4599. if (!openingParsed) {
  4600. advance("{");
  4601. }
  4602. if (checkPunctuator(state.tokens.next, "}")) {
  4603. warning("W137", state.tokens.curr);
  4604. }
  4605. while (!checkPunctuator(state.tokens.next, "}")) {
  4606. assignmentProperty();
  4607. if (checkPunctuator(state.tokens.next, "=")) {
  4608. advance("=");
  4609. if (state.tokens.next.id === "undefined") {
  4610. warning("W080", state.tokens.prev, state.tokens.prev.value);
  4611. }
  4612. expression(10);
  4613. }
  4614. if (!checkPunctuator(state.tokens.next, "}")) {
  4615. advance(",");
  4616. if (checkPunctuator(state.tokens.next, "}")) {
  4617. // Trailing comma
  4618. // ObjectBindingPattern: { BindingPropertyList , }
  4619. break;
  4620. }
  4621. }
  4622. }
  4623. advance("}");
  4624. }
  4625. return identifiers;
  4626. }
  4627. function destructuringPatternMatch(tokens, value) {
  4628. var first = value.first;
  4629. if (!first)
  4630. return;
  4631. _.zip(tokens, Array.isArray(first) ? first : [ first ]).forEach(function(val) {
  4632. var token = val[0];
  4633. var value = val[1];
  4634. if (token && value)
  4635. token.first = value;
  4636. else if (token && token.first && !value)
  4637. warning("W080", token.first, token.first.value);
  4638. });
  4639. }
  4640. function blockVariableStatement(type, statement, context) {
  4641. // used for both let and const statements
  4642. var prefix = context && context.prefix;
  4643. var inexport = context && context.inexport;
  4644. var isLet = type === "let";
  4645. var isConst = type === "const";
  4646. var tokens, lone, value, letblock;
  4647. if (!state.inES6()) {
  4648. warning("W104", state.tokens.curr, type, "6");
  4649. }
  4650. if (isLet && state.tokens.next.value === "(") {
  4651. if (!state.inMoz()) {
  4652. warning("W118", state.tokens.next, "let block");
  4653. }
  4654. advance("(");
  4655. state.funct["(scope)"].stack();
  4656. letblock = true;
  4657. } else if (state.funct["(noblockscopedvar)"]) {
  4658. error("E048", state.tokens.curr, isConst ? "Const" : "Let");
  4659. }
  4660. statement.first = [];
  4661. for (;;) {
  4662. var names = [];
  4663. if (_.contains(["{", "["], state.tokens.next.value)) {
  4664. tokens = destructuringPattern();
  4665. lone = false;
  4666. } else {
  4667. tokens = [ { id: identifier(), token: state.tokens.curr } ];
  4668. lone = true;
  4669. }
  4670. if (!prefix && isConst && state.tokens.next.id !== "=") {
  4671. warning("E012", state.tokens.curr, state.tokens.curr.value);
  4672. }
  4673. for (var t in tokens) {
  4674. if (tokens.hasOwnProperty(t)) {
  4675. t = tokens[t];
  4676. if (state.funct["(scope)"].block.isGlobal()) {
  4677. if (predefined[t.id] === false) {
  4678. warning("W079", t.token, t.id);
  4679. }
  4680. }
  4681. if (t.id && !state.funct["(noblockscopedvar)"]) {
  4682. state.funct["(scope)"].addlabel(t.id, {
  4683. type: type,
  4684. token: t.token });
  4685. names.push(t.token);
  4686. if (lone && inexport) {
  4687. state.funct["(scope)"].setExported(t.token.value, t.token);
  4688. }
  4689. }
  4690. }
  4691. }
  4692. if (state.tokens.next.id === "=") {
  4693. advance("=");
  4694. if (!prefix && state.tokens.next.id === "undefined") {
  4695. warning("W080", state.tokens.prev, state.tokens.prev.value);
  4696. }
  4697. if (!prefix && peek(0).id === "=" && state.tokens.next.identifier) {
  4698. warning("W120", state.tokens.next, state.tokens.next.value);
  4699. }
  4700. // don't accept `in` in expression if prefix is used for ForIn/Of loop.
  4701. value = expression(prefix ? 120 : 10);
  4702. if (lone) {
  4703. tokens[0].first = value;
  4704. } else {
  4705. destructuringPatternMatch(names, value);
  4706. }
  4707. }
  4708. statement.first = statement.first.concat(names);
  4709. if (state.tokens.next.id !== ",") {
  4710. break;
  4711. }
  4712. comma();
  4713. }
  4714. if (letblock) {
  4715. advance(")");
  4716. block(true, true);
  4717. statement.block = true;
  4718. state.funct["(scope)"].unstack();
  4719. }
  4720. return statement;
  4721. }
  4722. var conststatement = stmt("const", function(context) {
  4723. return blockVariableStatement("const", this, context);
  4724. });
  4725. conststatement.exps = true;
  4726. var letstatement = stmt("let", function(context) {
  4727. return blockVariableStatement("let", this, context);
  4728. });
  4729. letstatement.exps = true;
  4730. var varstatement = stmt("var", function(context) {
  4731. var prefix = context && context.prefix;
  4732. var inexport = context && context.inexport;
  4733. var tokens, lone, value;
  4734. // If the `implied` option is set, bindings are set differently.
  4735. var implied = context && context.implied;
  4736. var report = !(context && context.ignore);
  4737. this.first = [];
  4738. for (;;) {
  4739. var names = [];
  4740. if (_.contains(["{", "["], state.tokens.next.value)) {
  4741. tokens = destructuringPattern();
  4742. lone = false;
  4743. } else {
  4744. tokens = [ { id: identifier(), token: state.tokens.curr } ];
  4745. lone = true;
  4746. }
  4747. if (!(prefix && implied) && report && state.option.varstmt) {
  4748. warning("W132", this);
  4749. }
  4750. this.first = this.first.concat(names);
  4751. for (var t in tokens) {
  4752. if (tokens.hasOwnProperty(t)) {
  4753. t = tokens[t];
  4754. if (!implied && state.funct["(global)"]) {
  4755. if (predefined[t.id] === false) {
  4756. warning("W079", t.token, t.id);
  4757. } else if (state.option.futurehostile === false) {
  4758. if ((!state.inES5() && vars.ecmaIdentifiers[5][t.id] === false) ||
  4759. (!state.inES6() && vars.ecmaIdentifiers[6][t.id] === false)) {
  4760. warning("W129", t.token, t.id);
  4761. }
  4762. }
  4763. }
  4764. if (t.id) {
  4765. if (implied === "for") {
  4766. if (!state.funct["(scope)"].has(t.id)) {
  4767. if (report) warning("W088", t.token, t.id);
  4768. }
  4769. state.funct["(scope)"].block.use(t.id, t.token);
  4770. } else {
  4771. state.funct["(scope)"].addlabel(t.id, {
  4772. type: "var",
  4773. token: t.token });
  4774. if (lone && inexport) {
  4775. state.funct["(scope)"].setExported(t.id, t.token);
  4776. }
  4777. }
  4778. names.push(t.token);
  4779. }
  4780. }
  4781. }
  4782. if (state.tokens.next.id === "=") {
  4783. state.nameStack.set(state.tokens.curr);
  4784. advance("=");
  4785. if (!prefix && report && !state.funct["(loopage)"] &&
  4786. state.tokens.next.id === "undefined") {
  4787. warning("W080", state.tokens.prev, state.tokens.prev.value);
  4788. }
  4789. if (peek(0).id === "=" && state.tokens.next.identifier) {
  4790. if (!prefix && report &&
  4791. !state.funct["(params)"] ||
  4792. state.funct["(params)"].indexOf(state.tokens.next.value) === -1) {
  4793. warning("W120", state.tokens.next, state.tokens.next.value);
  4794. }
  4795. }
  4796. // don't accept `in` in expression if prefix is used for ForIn/Of loop.
  4797. value = expression(prefix ? 120 : 10);
  4798. if (lone) {
  4799. tokens[0].first = value;
  4800. } else {
  4801. destructuringPatternMatch(names, value);
  4802. }
  4803. }
  4804. if (state.tokens.next.id !== ",") {
  4805. break;
  4806. }
  4807. comma();
  4808. }
  4809. return this;
  4810. });
  4811. varstatement.exps = true;
  4812. blockstmt("class", function() {
  4813. return classdef.call(this, true);
  4814. });
  4815. function classdef(isStatement) {
  4816. /*jshint validthis:true */
  4817. if (!state.inES6()) {
  4818. warning("W104", state.tokens.curr, "class", "6");
  4819. }
  4820. if (isStatement) {
  4821. // BindingIdentifier
  4822. this.name = identifier();
  4823. state.funct["(scope)"].addlabel(this.name, {
  4824. type: "class",
  4825. token: state.tokens.curr });
  4826. } else if (state.tokens.next.identifier && state.tokens.next.value !== "extends") {
  4827. // BindingIdentifier(opt)
  4828. this.name = identifier();
  4829. this.namedExpr = true;
  4830. } else {
  4831. this.name = state.nameStack.infer();
  4832. }
  4833. classtail(this);
  4834. return this;
  4835. }
  4836. function classtail(c) {
  4837. var wasInClassBody = state.inClassBody;
  4838. // ClassHeritage(opt)
  4839. if (state.tokens.next.value === "extends") {
  4840. advance("extends");
  4841. c.heritage = expression(10);
  4842. }
  4843. state.inClassBody = true;
  4844. advance("{");
  4845. // ClassBody(opt)
  4846. c.body = classbody(c);
  4847. advance("}");
  4848. state.inClassBody = wasInClassBody;
  4849. }
  4850. function classbody(c) {
  4851. var name;
  4852. var isStatic;
  4853. var isGenerator;
  4854. var getset;
  4855. var props = Object.create(null);
  4856. var staticProps = Object.create(null);
  4857. var computed;
  4858. for (var i = 0; state.tokens.next.id !== "}"; ++i) {
  4859. name = state.tokens.next;
  4860. isStatic = false;
  4861. isGenerator = false;
  4862. getset = null;
  4863. // The ES6 grammar for ClassElement includes the `;` token, but it is
  4864. // defined only as a placeholder to facilitate future language
  4865. // extensions. In ES6 code, it serves no purpose.
  4866. if (name.id === ";") {
  4867. warning("W032");
  4868. advance(";");
  4869. continue;
  4870. }
  4871. if (name.id === "*") {
  4872. isGenerator = true;
  4873. advance("*");
  4874. name = state.tokens.next;
  4875. }
  4876. if (name.id === "[") {
  4877. name = computedPropertyName();
  4878. computed = true;
  4879. } else if (isPropertyName(name)) {
  4880. // Non-Computed PropertyName
  4881. advance();
  4882. computed = false;
  4883. if (name.identifier && name.value === "static") {
  4884. if (checkPunctuator(state.tokens.next, "*")) {
  4885. isGenerator = true;
  4886. advance("*");
  4887. }
  4888. if (isPropertyName(state.tokens.next) || state.tokens.next.id === "[") {
  4889. computed = state.tokens.next.id === "[";
  4890. isStatic = true;
  4891. name = state.tokens.next;
  4892. if (state.tokens.next.id === "[") {
  4893. name = computedPropertyName();
  4894. } else advance();
  4895. }
  4896. }
  4897. if (name.identifier && (name.value === "get" || name.value === "set")) {
  4898. if (isPropertyName(state.tokens.next) || state.tokens.next.id === "[") {
  4899. computed = state.tokens.next.id === "[";
  4900. getset = name;
  4901. name = state.tokens.next;
  4902. if (state.tokens.next.id === "[") {
  4903. name = computedPropertyName();
  4904. } else advance();
  4905. }
  4906. }
  4907. } else {
  4908. warning("W052", state.tokens.next, state.tokens.next.value || state.tokens.next.type);
  4909. advance();
  4910. continue;
  4911. }
  4912. if (!checkPunctuator(state.tokens.next, "(")) {
  4913. // error --- class properties must be methods
  4914. error("E054", state.tokens.next, state.tokens.next.value);
  4915. while (state.tokens.next.id !== "}" &&
  4916. !checkPunctuator(state.tokens.next, "(")) {
  4917. advance();
  4918. }
  4919. if (state.tokens.next.value !== "(") {
  4920. doFunction({ statement: c });
  4921. }
  4922. }
  4923. if (!computed) {
  4924. // We don't know how to determine if we have duplicate computed property names :(
  4925. if (getset) {
  4926. saveAccessor(
  4927. getset.value, isStatic ? staticProps : props, name.value, name, true, isStatic);
  4928. } else {
  4929. if (name.value === "constructor") {
  4930. state.nameStack.set(c);
  4931. } else {
  4932. state.nameStack.set(name);
  4933. }
  4934. saveProperty(isStatic ? staticProps : props, name.value, name, true, isStatic);
  4935. }
  4936. }
  4937. if (getset && name.value === "constructor") {
  4938. var propDesc = getset.value === "get" ? "class getter method" : "class setter method";
  4939. error("E049", name, propDesc, "constructor");
  4940. } else if (name.value === "prototype") {
  4941. error("E049", name, "class method", "prototype");
  4942. }
  4943. propertyName(name);
  4944. doFunction({
  4945. statement: c,
  4946. type: isGenerator ? "generator" : null,
  4947. classExprBinding: c.namedExpr ? c.name : null
  4948. });
  4949. }
  4950. checkProperties(props);
  4951. }
  4952. blockstmt("function", function(context) {
  4953. var inexport = context && context.inexport;
  4954. var generator = false;
  4955. if (state.tokens.next.value === "*") {
  4956. advance("*");
  4957. if (state.inES6({ strict: true })) {
  4958. generator = true;
  4959. } else {
  4960. warning("W119", state.tokens.curr, "function*", "6");
  4961. }
  4962. }
  4963. if (inblock) {
  4964. warning("W082", state.tokens.curr);
  4965. }
  4966. var i = optionalidentifier();
  4967. state.funct["(scope)"].addlabel(i, {
  4968. type: "function",
  4969. token: state.tokens.curr });
  4970. if (i === undefined) {
  4971. warning("W025");
  4972. } else if (inexport) {
  4973. state.funct["(scope)"].setExported(i, state.tokens.prev);
  4974. }
  4975. doFunction({
  4976. name: i,
  4977. statement: this,
  4978. type: generator ? "generator" : null,
  4979. ignoreLoopFunc: inblock // a declaration may already have warned
  4980. });
  4981. if (state.tokens.next.id === "(" && state.tokens.next.line === state.tokens.curr.line) {
  4982. error("E039");
  4983. }
  4984. return this;
  4985. });
  4986. prefix("function", function() {
  4987. var generator = false;
  4988. if (state.tokens.next.value === "*") {
  4989. if (!state.inES6()) {
  4990. warning("W119", state.tokens.curr, "function*", "6");
  4991. }
  4992. advance("*");
  4993. generator = true;
  4994. }
  4995. var i = optionalidentifier();
  4996. doFunction({ name: i, type: generator ? "generator" : null });
  4997. return this;
  4998. });
  4999. blockstmt("if", function() {
  5000. var t = state.tokens.next;
  5001. increaseComplexityCount();
  5002. state.condition = true;
  5003. advance("(");
  5004. var expr = expression(0);
  5005. checkCondAssignment(expr);
  5006. // When the if is within a for-in loop, check if the condition
  5007. // starts with a negation operator
  5008. var forinifcheck = null;
  5009. if (state.option.forin && state.forinifcheckneeded) {
  5010. state.forinifcheckneeded = false; // We only need to analyze the first if inside the loop
  5011. forinifcheck = state.forinifchecks[state.forinifchecks.length - 1];
  5012. if (expr.type === "(punctuator)" && expr.value === "!") {
  5013. forinifcheck.type = "(negative)";
  5014. } else {
  5015. forinifcheck.type = "(positive)";
  5016. }
  5017. }
  5018. advance(")", t);
  5019. state.condition = false;
  5020. var s = block(true, true);
  5021. // When the if is within a for-in loop and the condition has a negative form,
  5022. // check if the body contains nothing but a continue statement
  5023. if (forinifcheck && forinifcheck.type === "(negative)") {
  5024. if (s && s[0] && s[0].type === "(identifier)" && s[0].value === "continue") {
  5025. forinifcheck.type = "(negative-with-continue)";
  5026. }
  5027. }
  5028. if (state.tokens.next.id === "else") {
  5029. advance("else");
  5030. if (state.tokens.next.id === "if" || state.tokens.next.id === "switch") {
  5031. statement();
  5032. } else {
  5033. block(true, true);
  5034. }
  5035. }
  5036. return this;
  5037. });
  5038. blockstmt("try", function() {
  5039. var b;
  5040. function doCatch() {
  5041. advance("catch");
  5042. advance("(");
  5043. state.funct["(scope)"].stack("catchparams");
  5044. if (checkPunctuators(state.tokens.next, ["[", "{"])) {
  5045. var tokens = destructuringPattern();
  5046. _.each(tokens, function(token) {
  5047. if (token.id) {
  5048. state.funct["(scope)"].addParam(token.id, token, "exception");
  5049. }
  5050. });
  5051. } else if (state.tokens.next.type !== "(identifier)") {
  5052. warning("E030", state.tokens.next, state.tokens.next.value);
  5053. } else {
  5054. // only advance if we have an identifier so we can continue parsing in the most common error - that no param is given.
  5055. state.funct["(scope)"].addParam(identifier(), state.tokens.curr, "exception");
  5056. }
  5057. if (state.tokens.next.value === "if") {
  5058. if (!state.inMoz()) {
  5059. warning("W118", state.tokens.curr, "catch filter");
  5060. }
  5061. advance("if");
  5062. expression(0);
  5063. }
  5064. advance(")");
  5065. block(false);
  5066. state.funct["(scope)"].unstack();
  5067. }
  5068. block(true);
  5069. while (state.tokens.next.id === "catch") {
  5070. increaseComplexityCount();
  5071. if (b && (!state.inMoz())) {
  5072. warning("W118", state.tokens.next, "multiple catch blocks");
  5073. }
  5074. doCatch();
  5075. b = true;
  5076. }
  5077. if (state.tokens.next.id === "finally") {
  5078. advance("finally");
  5079. block(true);
  5080. return;
  5081. }
  5082. if (!b) {
  5083. error("E021", state.tokens.next, "catch", state.tokens.next.value);
  5084. }
  5085. return this;
  5086. });
  5087. blockstmt("while", function() {
  5088. var t = state.tokens.next;
  5089. state.funct["(breakage)"] += 1;
  5090. state.funct["(loopage)"] += 1;
  5091. increaseComplexityCount();
  5092. advance("(");
  5093. checkCondAssignment(expression(0));
  5094. advance(")", t);
  5095. block(true, true);
  5096. state.funct["(breakage)"] -= 1;
  5097. state.funct["(loopage)"] -= 1;
  5098. return this;
  5099. }).labelled = true;
  5100. blockstmt("with", function() {
  5101. var t = state.tokens.next;
  5102. if (state.isStrict()) {
  5103. error("E010", state.tokens.curr);
  5104. } else if (!state.option.withstmt) {
  5105. warning("W085", state.tokens.curr);
  5106. }
  5107. advance("(");
  5108. expression(0);
  5109. advance(")", t);
  5110. block(true, true);
  5111. return this;
  5112. });
  5113. blockstmt("switch", function() {
  5114. var t = state.tokens.next;
  5115. var g = false;
  5116. var noindent = false;
  5117. state.funct["(breakage)"] += 1;
  5118. advance("(");
  5119. checkCondAssignment(expression(0));
  5120. advance(")", t);
  5121. t = state.tokens.next;
  5122. advance("{");
  5123. if (state.tokens.next.from === indent)
  5124. noindent = true;
  5125. if (!noindent)
  5126. indent += state.option.indent;
  5127. this.cases = [];
  5128. for (;;) {
  5129. switch (state.tokens.next.id) {
  5130. case "case":
  5131. switch (state.funct["(verb)"]) {
  5132. case "yield":
  5133. case "break":
  5134. case "case":
  5135. case "continue":
  5136. case "return":
  5137. case "switch":
  5138. case "throw":
  5139. break;
  5140. default:
  5141. // You can tell JSHint that you don't use break intentionally by
  5142. // adding a comment /* falls through */ on a line just before
  5143. // the next `case`.
  5144. if (!state.tokens.curr.caseFallsThrough) {
  5145. warning("W086", state.tokens.curr, "case");
  5146. }
  5147. }
  5148. advance("case");
  5149. this.cases.push(expression(0));
  5150. increaseComplexityCount();
  5151. g = true;
  5152. advance(":");
  5153. state.funct["(verb)"] = "case";
  5154. break;
  5155. case "default":
  5156. switch (state.funct["(verb)"]) {
  5157. case "yield":
  5158. case "break":
  5159. case "continue":
  5160. case "return":
  5161. case "throw":
  5162. break;
  5163. default:
  5164. // Do not display a warning if 'default' is the first statement or if
  5165. // there is a special /* falls through */ comment.
  5166. if (this.cases.length) {
  5167. if (!state.tokens.curr.caseFallsThrough) {
  5168. warning("W086", state.tokens.curr, "default");
  5169. }
  5170. }
  5171. }
  5172. advance("default");
  5173. g = true;
  5174. advance(":");
  5175. break;
  5176. case "}":
  5177. if (!noindent)
  5178. indent -= state.option.indent;
  5179. advance("}", t);
  5180. state.funct["(breakage)"] -= 1;
  5181. state.funct["(verb)"] = undefined;
  5182. return;
  5183. case "(end)":
  5184. error("E023", state.tokens.next, "}");
  5185. return;
  5186. default:
  5187. indent += state.option.indent;
  5188. if (g) {
  5189. switch (state.tokens.curr.id) {
  5190. case ",":
  5191. error("E040");
  5192. return;
  5193. case ":":
  5194. g = false;
  5195. statements();
  5196. break;
  5197. default:
  5198. error("E025", state.tokens.curr);
  5199. return;
  5200. }
  5201. } else {
  5202. if (state.tokens.curr.id === ":") {
  5203. advance(":");
  5204. error("E024", state.tokens.curr, ":");
  5205. statements();
  5206. } else {
  5207. error("E021", state.tokens.next, "case", state.tokens.next.value);
  5208. return;
  5209. }
  5210. }
  5211. indent -= state.option.indent;
  5212. }
  5213. }
  5214. return this;
  5215. }).labelled = true;
  5216. stmt("debugger", function() {
  5217. if (!state.option.debug) {
  5218. warning("W087", this);
  5219. }
  5220. return this;
  5221. }).exps = true;
  5222. (function() {
  5223. var x = stmt("do", function() {
  5224. state.funct["(breakage)"] += 1;
  5225. state.funct["(loopage)"] += 1;
  5226. increaseComplexityCount();
  5227. this.first = block(true, true);
  5228. advance("while");
  5229. var t = state.tokens.next;
  5230. advance("(");
  5231. checkCondAssignment(expression(0));
  5232. advance(")", t);
  5233. state.funct["(breakage)"] -= 1;
  5234. state.funct["(loopage)"] -= 1;
  5235. return this;
  5236. });
  5237. x.labelled = true;
  5238. x.exps = true;
  5239. }());
  5240. blockstmt("for", function() {
  5241. var s, t = state.tokens.next;
  5242. var letscope = false;
  5243. var foreachtok = null;
  5244. if (t.value === "each") {
  5245. foreachtok = t;
  5246. advance("each");
  5247. if (!state.inMoz()) {
  5248. warning("W118", state.tokens.curr, "for each");
  5249. }
  5250. }
  5251. increaseComplexityCount();
  5252. advance("(");
  5253. // what kind of for(…) statement it is? for(…of…)? for(…in…)? for(…;…;…)?
  5254. var nextop; // contains the token of the "in" or "of" operator
  5255. var i = 0;
  5256. var inof = ["in", "of"];
  5257. var level = 0; // BindingPattern "level" --- level 0 === no BindingPattern
  5258. var comma; // First comma punctuator at level 0
  5259. var initializer; // First initializer at level 0
  5260. // If initial token is a BindingPattern, count it as such.
  5261. if (checkPunctuators(state.tokens.next, ["{", "["])) ++level;
  5262. do {
  5263. nextop = peek(i);
  5264. ++i;
  5265. if (checkPunctuators(nextop, ["{", "["])) ++level;
  5266. else if (checkPunctuators(nextop, ["}", "]"])) --level;
  5267. if (level < 0) break;
  5268. if (level === 0) {
  5269. if (!comma && checkPunctuator(nextop, ",")) comma = nextop;
  5270. else if (!initializer && checkPunctuator(nextop, "=")) initializer = nextop;
  5271. }
  5272. } while (level > 0 || !_.contains(inof, nextop.value) && nextop.value !== ";" &&
  5273. nextop.type !== "(end)"); // Is this a JSCS bug? This looks really weird.
  5274. // if we're in a for (… in|of …) statement
  5275. if (_.contains(inof, nextop.value)) {
  5276. if (!state.inES6() && nextop.value === "of") {
  5277. warning("W104", nextop, "for of", "6");
  5278. }
  5279. var ok = !(initializer || comma);
  5280. if (initializer) {
  5281. error("W133", comma, nextop.value, "initializer is forbidden");
  5282. }
  5283. if (comma) {
  5284. error("W133", comma, nextop.value, "more than one ForBinding");
  5285. }
  5286. if (state.tokens.next.id === "var") {
  5287. advance("var");
  5288. state.tokens.curr.fud({ prefix: true });
  5289. } else if (state.tokens.next.id === "let" || state.tokens.next.id === "const") {
  5290. advance(state.tokens.next.id);
  5291. // create a new block scope
  5292. letscope = true;
  5293. state.funct["(scope)"].stack();
  5294. state.tokens.curr.fud({ prefix: true });
  5295. } else {
  5296. // Parse as a var statement, with implied bindings. Ignore errors if an error
  5297. // was already reported
  5298. Object.create(varstatement).fud({ prefix: true, implied: "for", ignore: !ok });
  5299. }
  5300. advance(nextop.value);
  5301. expression(20);
  5302. advance(")", t);
  5303. if (nextop.value === "in" && state.option.forin) {
  5304. state.forinifcheckneeded = true;
  5305. if (state.forinifchecks === undefined) {
  5306. state.forinifchecks = [];
  5307. }
  5308. // Push a new for-in-if check onto the stack. The type will be modified
  5309. // when the loop's body is parsed and a suitable if statement exists.
  5310. state.forinifchecks.push({
  5311. type: "(none)"
  5312. });
  5313. }
  5314. state.funct["(breakage)"] += 1;
  5315. state.funct["(loopage)"] += 1;
  5316. s = block(true, true);
  5317. if (nextop.value === "in" && state.option.forin) {
  5318. if (state.forinifchecks && state.forinifchecks.length > 0) {
  5319. var check = state.forinifchecks.pop();
  5320. if (// No if statement or not the first statement in loop body
  5321. s && s.length > 0 && (typeof s[0] !== "object" || s[0].value !== "if") ||
  5322. // Positive if statement is not the only one in loop body
  5323. check.type === "(positive)" && s.length > 1 ||
  5324. // Negative if statement but no continue
  5325. check.type === "(negative)") {
  5326. warning("W089", this);
  5327. }
  5328. }
  5329. // Reset the flag in case no if statement was contained in the loop body
  5330. state.forinifcheckneeded = false;
  5331. }
  5332. state.funct["(breakage)"] -= 1;
  5333. state.funct["(loopage)"] -= 1;
  5334. } else {
  5335. if (foreachtok) {
  5336. error("E045", foreachtok);
  5337. }
  5338. if (state.tokens.next.id !== ";") {
  5339. if (state.tokens.next.id === "var") {
  5340. advance("var");
  5341. state.tokens.curr.fud();
  5342. } else if (state.tokens.next.id === "let") {
  5343. advance("let");
  5344. // create a new block scope
  5345. letscope = true;
  5346. state.funct["(scope)"].stack();
  5347. state.tokens.curr.fud();
  5348. } else {
  5349. for (;;) {
  5350. expression(0, "for");
  5351. if (state.tokens.next.id !== ",") {
  5352. break;
  5353. }
  5354. comma();
  5355. }
  5356. }
  5357. }
  5358. nolinebreak(state.tokens.curr);
  5359. advance(";");
  5360. // start loopage after the first ; as the next two expressions are executed
  5361. // on every loop
  5362. state.funct["(loopage)"] += 1;
  5363. if (state.tokens.next.id !== ";") {
  5364. checkCondAssignment(expression(0));
  5365. }
  5366. nolinebreak(state.tokens.curr);
  5367. advance(";");
  5368. if (state.tokens.next.id === ";") {
  5369. error("E021", state.tokens.next, ")", ";");
  5370. }
  5371. if (state.tokens.next.id !== ")") {
  5372. for (;;) {
  5373. expression(0, "for");
  5374. if (state.tokens.next.id !== ",") {
  5375. break;
  5376. }
  5377. comma();
  5378. }
  5379. }
  5380. advance(")", t);
  5381. state.funct["(breakage)"] += 1;
  5382. block(true, true);
  5383. state.funct["(breakage)"] -= 1;
  5384. state.funct["(loopage)"] -= 1;
  5385. }
  5386. // unstack loop blockscope
  5387. if (letscope) {
  5388. state.funct["(scope)"].unstack();
  5389. }
  5390. return this;
  5391. }).labelled = true;
  5392. stmt("break", function() {
  5393. var v = state.tokens.next.value;
  5394. if (!state.option.asi)
  5395. nolinebreak(this);
  5396. if (state.tokens.next.id !== ";" && !state.tokens.next.reach &&
  5397. state.tokens.curr.line === startLine(state.tokens.next)) {
  5398. if (!state.funct["(scope)"].funct.hasBreakLabel(v)) {
  5399. warning("W090", state.tokens.next, v);
  5400. }
  5401. this.first = state.tokens.next;
  5402. advance();
  5403. } else {
  5404. if (state.funct["(breakage)"] === 0)
  5405. warning("W052", state.tokens.next, this.value);
  5406. }
  5407. reachable(this);
  5408. return this;
  5409. }).exps = true;
  5410. stmt("continue", function() {
  5411. var v = state.tokens.next.value;
  5412. if (state.funct["(breakage)"] === 0)
  5413. warning("W052", state.tokens.next, this.value);
  5414. if (!state.funct["(loopage)"])
  5415. warning("W052", state.tokens.next, this.value);
  5416. if (!state.option.asi)
  5417. nolinebreak(this);
  5418. if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
  5419. if (state.tokens.curr.line === startLine(state.tokens.next)) {
  5420. if (!state.funct["(scope)"].funct.hasBreakLabel(v)) {
  5421. warning("W090", state.tokens.next, v);
  5422. }
  5423. this.first = state.tokens.next;
  5424. advance();
  5425. }
  5426. }
  5427. reachable(this);
  5428. return this;
  5429. }).exps = true;
  5430. stmt("return", function() {
  5431. if (this.line === startLine(state.tokens.next)) {
  5432. if (state.tokens.next.id !== ";" && !state.tokens.next.reach) {
  5433. this.first = expression(0);
  5434. if (this.first &&
  5435. this.first.type === "(punctuator)" && this.first.value === "=" &&
  5436. !this.first.paren && !state.option.boss) {
  5437. warningAt("W093", this.first.line, this.first.character);
  5438. }
  5439. }
  5440. } else {
  5441. if (state.tokens.next.type === "(punctuator)" &&
  5442. ["[", "{", "+", "-"].indexOf(state.tokens.next.value) > -1) {
  5443. nolinebreak(this); // always warn (Line breaking error)
  5444. }
  5445. }
  5446. reachable(this);
  5447. return this;
  5448. }).exps = true;
  5449. (function(x) {
  5450. x.exps = true;
  5451. x.lbp = 25;
  5452. }(prefix("yield", function() {
  5453. var prev = state.tokens.prev;
  5454. if (state.inES6(true) && !state.funct["(generator)"]) {
  5455. // If it's a yield within a catch clause inside a generator then that's ok
  5456. if (!("(catch)" === state.funct["(name)"] && state.funct["(context)"]["(generator)"])) {
  5457. error("E046", state.tokens.curr, "yield");
  5458. }
  5459. } else if (!state.inES6()) {
  5460. warning("W104", state.tokens.curr, "yield", "6");
  5461. }
  5462. state.funct["(generator)"] = "yielded";
  5463. var delegatingYield = false;
  5464. if (state.tokens.next.value === "*") {
  5465. delegatingYield = true;
  5466. advance("*");
  5467. }
  5468. if (this.line === startLine(state.tokens.next) || !state.inMoz()) {
  5469. if (delegatingYield ||
  5470. (state.tokens.next.id !== ";" && !state.option.asi &&
  5471. !state.tokens.next.reach && state.tokens.next.nud)) {
  5472. nobreaknonadjacent(state.tokens.curr, state.tokens.next);
  5473. this.first = expression(10);
  5474. if (this.first.type === "(punctuator)" && this.first.value === "=" &&
  5475. !this.first.paren && !state.option.boss) {
  5476. warningAt("W093", this.first.line, this.first.character);
  5477. }
  5478. }
  5479. if (state.inMoz() && state.tokens.next.id !== ")" &&
  5480. (prev.lbp > 30 || (!prev.assign && !isEndOfExpr()) || prev.id === "yield")) {
  5481. error("E050", this);
  5482. }
  5483. } else if (!state.option.asi) {
  5484. nolinebreak(this); // always warn (Line breaking error)
  5485. }
  5486. return this;
  5487. })));
  5488. stmt("throw", function() {
  5489. nolinebreak(this);
  5490. this.first = expression(20);
  5491. reachable(this);
  5492. return this;
  5493. }).exps = true;
  5494. stmt("import", function() {
  5495. if (!state.inES6()) {
  5496. warning("W119", state.tokens.curr, "import", "6");
  5497. }
  5498. if (state.tokens.next.type === "(string)") {
  5499. // ModuleSpecifier :: StringLiteral
  5500. advance("(string)");
  5501. return this;
  5502. }
  5503. if (state.tokens.next.identifier) {
  5504. // ImportClause :: ImportedDefaultBinding
  5505. this.name = identifier();
  5506. // Import bindings are immutable (see ES6 8.1.1.5.5)
  5507. state.funct["(scope)"].addlabel(this.name, {
  5508. type: "const",
  5509. token: state.tokens.curr });
  5510. if (state.tokens.next.value === ",") {
  5511. // ImportClause :: ImportedDefaultBinding , NameSpaceImport
  5512. // ImportClause :: ImportedDefaultBinding , NamedImports
  5513. advance(",");
  5514. // At this point, we intentionally fall through to continue matching
  5515. // either NameSpaceImport or NamedImports.
  5516. // Discussion:
  5517. // https://github.com/jshint/jshint/pull/2144#discussion_r23978406
  5518. } else {
  5519. advance("from");
  5520. advance("(string)");
  5521. return this;
  5522. }
  5523. }
  5524. if (state.tokens.next.id === "*") {
  5525. // ImportClause :: NameSpaceImport
  5526. advance("*");
  5527. advance("as");
  5528. if (state.tokens.next.identifier) {
  5529. this.name = identifier();
  5530. // Import bindings are immutable (see ES6 8.1.1.5.5)
  5531. state.funct["(scope)"].addlabel(this.name, {
  5532. type: "const",
  5533. token: state.tokens.curr });
  5534. }
  5535. } else {
  5536. // ImportClause :: NamedImports
  5537. advance("{");
  5538. for (;;) {
  5539. if (state.tokens.next.value === "}") {
  5540. advance("}");
  5541. break;
  5542. }
  5543. var importName;
  5544. if (state.tokens.next.type === "default") {
  5545. importName = "default";
  5546. advance("default");
  5547. } else {
  5548. importName = identifier();
  5549. }
  5550. if (state.tokens.next.value === "as") {
  5551. advance("as");
  5552. importName = identifier();
  5553. }
  5554. // Import bindings are immutable (see ES6 8.1.1.5.5)
  5555. state.funct["(scope)"].addlabel(importName, {
  5556. type: "const",
  5557. token: state.tokens.curr });
  5558. if (state.tokens.next.value === ",") {
  5559. advance(",");
  5560. } else if (state.tokens.next.value === "}") {
  5561. advance("}");
  5562. break;
  5563. } else {
  5564. error("E024", state.tokens.next, state.tokens.next.value);
  5565. break;
  5566. }
  5567. }
  5568. }
  5569. // FromClause
  5570. advance("from");
  5571. advance("(string)");
  5572. return this;
  5573. }).exps = true;
  5574. stmt("export", function() {
  5575. var ok = true;
  5576. var token;
  5577. var identifier;
  5578. if (!state.inES6()) {
  5579. warning("W119", state.tokens.curr, "export", "6");
  5580. ok = false;
  5581. }
  5582. if (!state.funct["(scope)"].block.isGlobal()) {
  5583. error("E053", state.tokens.curr);
  5584. ok = false;
  5585. }
  5586. if (state.tokens.next.value === "*") {
  5587. // ExportDeclaration :: export * FromClause
  5588. advance("*");
  5589. advance("from");
  5590. advance("(string)");
  5591. return this;
  5592. }
  5593. if (state.tokens.next.type === "default") {
  5594. // ExportDeclaration ::
  5595. // export default [lookahead  { function, class }] AssignmentExpression[In] ;
  5596. // export default HoistableDeclaration
  5597. // export default ClassDeclaration
  5598. state.nameStack.set(state.tokens.next);
  5599. advance("default");
  5600. var exportType = state.tokens.next.id;
  5601. if (exportType === "function" || exportType === "class") {
  5602. this.block = true;
  5603. }
  5604. token = peek();
  5605. expression(10);
  5606. identifier = token.value;
  5607. if (this.block) {
  5608. state.funct["(scope)"].addlabel(identifier, {
  5609. type: exportType,
  5610. token: token });
  5611. state.funct["(scope)"].setExported(identifier, token);
  5612. }
  5613. return this;
  5614. }
  5615. if (state.tokens.next.value === "{") {
  5616. // ExportDeclaration :: export ExportClause
  5617. advance("{");
  5618. var exportedTokens = [];
  5619. for (;;) {
  5620. if (!state.tokens.next.identifier) {
  5621. error("E030", state.tokens.next, state.tokens.next.value);
  5622. }
  5623. advance();
  5624. exportedTokens.push(state.tokens.curr);
  5625. if (state.tokens.next.value === "as") {
  5626. advance("as");
  5627. if (!state.tokens.next.identifier) {
  5628. error("E030", state.tokens.next, state.tokens.next.value);
  5629. }
  5630. advance();
  5631. }
  5632. if (state.tokens.next.value === ",") {
  5633. advance(",");
  5634. } else if (state.tokens.next.value === "}") {
  5635. advance("}");
  5636. break;
  5637. } else {
  5638. error("E024", state.tokens.next, state.tokens.next.value);
  5639. break;
  5640. }
  5641. }
  5642. if (state.tokens.next.value === "from") {
  5643. // ExportDeclaration :: export ExportClause FromClause
  5644. advance("from");
  5645. advance("(string)");
  5646. } else if (ok) {
  5647. exportedTokens.forEach(function(token) {
  5648. state.funct["(scope)"].setExported(token.value, token);
  5649. });
  5650. }
  5651. return this;
  5652. }
  5653. if (state.tokens.next.id === "var") {
  5654. // ExportDeclaration :: export VariableStatement
  5655. advance("var");
  5656. state.tokens.curr.fud({ inexport:true });
  5657. } else if (state.tokens.next.id === "let") {
  5658. // ExportDeclaration :: export VariableStatement
  5659. advance("let");
  5660. state.tokens.curr.fud({ inexport:true });
  5661. } else if (state.tokens.next.id === "const") {
  5662. // ExportDeclaration :: export VariableStatement
  5663. advance("const");
  5664. state.tokens.curr.fud({ inexport:true });
  5665. } else if (state.tokens.next.id === "function") {
  5666. // ExportDeclaration :: export Declaration
  5667. this.block = true;
  5668. advance("function");
  5669. state.syntax["function"].fud({ inexport:true });
  5670. } else if (state.tokens.next.id === "class") {
  5671. // ExportDeclaration :: export Declaration
  5672. this.block = true;
  5673. advance("class");
  5674. var classNameToken = state.tokens.next;
  5675. state.syntax["class"].fud();
  5676. state.funct["(scope)"].setExported(classNameToken.value, classNameToken);
  5677. } else {
  5678. error("E024", state.tokens.next, state.tokens.next.value);
  5679. }
  5680. return this;
  5681. }).exps = true;
  5682. // Future Reserved Words
  5683. FutureReservedWord("abstract");
  5684. FutureReservedWord("boolean");
  5685. FutureReservedWord("byte");
  5686. FutureReservedWord("char");
  5687. FutureReservedWord("class", { es5: true, nud: classdef });
  5688. FutureReservedWord("double");
  5689. FutureReservedWord("enum", { es5: true });
  5690. FutureReservedWord("export", { es5: true });
  5691. FutureReservedWord("extends", { es5: true });
  5692. FutureReservedWord("final");
  5693. FutureReservedWord("float");
  5694. FutureReservedWord("goto");
  5695. FutureReservedWord("implements", { es5: true, strictOnly: true });
  5696. FutureReservedWord("import", { es5: true });
  5697. FutureReservedWord("int");
  5698. FutureReservedWord("interface", { es5: true, strictOnly: true });
  5699. FutureReservedWord("long");
  5700. FutureReservedWord("native");
  5701. FutureReservedWord("package", { es5: true, strictOnly: true });
  5702. FutureReservedWord("private", { es5: true, strictOnly: true });
  5703. FutureReservedWord("protected", { es5: true, strictOnly: true });
  5704. FutureReservedWord("public", { es5: true, strictOnly: true });
  5705. FutureReservedWord("short");
  5706. FutureReservedWord("static", { es5: true, strictOnly: true });
  5707. FutureReservedWord("super", { es5: true });
  5708. FutureReservedWord("synchronized");
  5709. FutureReservedWord("transient");
  5710. FutureReservedWord("volatile");
  5711. // this function is used to determine whether a squarebracket or a curlybracket
  5712. // expression is a comprehension array, destructuring assignment or a json value.
  5713. var lookupBlockType = function() {
  5714. var pn, pn1, prev;
  5715. var i = -1;
  5716. var bracketStack = 0;
  5717. var ret = {};
  5718. if (checkPunctuators(state.tokens.curr, ["[", "{"])) {
  5719. bracketStack += 1;
  5720. }
  5721. do {
  5722. prev = i === -1 ? state.tokens.curr : pn;
  5723. pn = i === -1 ? state.tokens.next : peek(i);
  5724. pn1 = peek(i + 1);
  5725. i = i + 1;
  5726. if (checkPunctuators(pn, ["[", "{"])) {
  5727. bracketStack += 1;
  5728. } else if (checkPunctuators(pn, ["]", "}"])) {
  5729. bracketStack -= 1;
  5730. }
  5731. if (bracketStack === 1 && pn.identifier && pn.value === "for" &&
  5732. !checkPunctuator(prev, ".")) {
  5733. ret.isCompArray = true;
  5734. ret.notJson = true;
  5735. break;
  5736. }
  5737. if (bracketStack === 0 && checkPunctuators(pn, ["}", "]"])) {
  5738. if (pn1.value === "=") {
  5739. ret.isDestAssign = true;
  5740. ret.notJson = true;
  5741. break;
  5742. } else if (pn1.value === ".") {
  5743. ret.notJson = true;
  5744. break;
  5745. }
  5746. }
  5747. if (checkPunctuator(pn, ";")) {
  5748. ret.isBlock = true;
  5749. ret.notJson = true;
  5750. }
  5751. } while (bracketStack > 0 && pn.id !== "(end)");
  5752. return ret;
  5753. };
  5754. function saveProperty(props, name, tkn, isClass, isStatic) {
  5755. var msg = ["key", "class method", "static class method"];
  5756. msg = msg[(isClass || false) + (isStatic || false)];
  5757. if (tkn.identifier) {
  5758. name = tkn.value;
  5759. }
  5760. if (props[name] && name !== "__proto__") {
  5761. warning("W075", state.tokens.next, msg, name);
  5762. } else {
  5763. props[name] = Object.create(null);
  5764. }
  5765. props[name].basic = true;
  5766. props[name].basictkn = tkn;
  5767. }
  5768. /**
  5769. * @param {string} accessorType - Either "get" or "set"
  5770. * @param {object} props - a collection of all properties of the object to
  5771. * which the current accessor is being assigned
  5772. * @param {object} tkn - the identifier token representing the accessor name
  5773. * @param {boolean} isClass - whether the accessor is part of an ES6 Class
  5774. * definition
  5775. * @param {boolean} isStatic - whether the accessor is a static method
  5776. */
  5777. function saveAccessor(accessorType, props, name, tkn, isClass, isStatic) {
  5778. var flagName = accessorType === "get" ? "getterToken" : "setterToken";
  5779. var msg = "";
  5780. if (isClass) {
  5781. if (isStatic) {
  5782. msg += "static ";
  5783. }
  5784. msg += accessorType + "ter method";
  5785. } else {
  5786. msg = "key";
  5787. }
  5788. state.tokens.curr.accessorType = accessorType;
  5789. state.nameStack.set(tkn);
  5790. if (props[name]) {
  5791. if ((props[name].basic || props[name][flagName]) && name !== "__proto__") {
  5792. warning("W075", state.tokens.next, msg, name);
  5793. }
  5794. } else {
  5795. props[name] = Object.create(null);
  5796. }
  5797. props[name][flagName] = tkn;
  5798. }
  5799. function computedPropertyName() {
  5800. advance("[");
  5801. if (!state.inES6()) {
  5802. warning("W119", state.tokens.curr, "computed property names", "6");
  5803. }
  5804. var value = expression(10);
  5805. advance("]");
  5806. return value;
  5807. }
  5808. /**
  5809. * Test whether a given token is a punctuator matching one of the specified values
  5810. * @param {Token} token
  5811. * @param {Array.<string>} values
  5812. * @returns {boolean}
  5813. */
  5814. function checkPunctuators(token, values) {
  5815. if (token.type === "(punctuator)") {
  5816. return _.contains(values, token.value);
  5817. }
  5818. return false;
  5819. }
  5820. /**
  5821. * Test whether a given token is a punctuator matching the specified value
  5822. * @param {Token} token
  5823. * @param {string} value
  5824. * @returns {boolean}
  5825. */
  5826. function checkPunctuator(token, value) {
  5827. return token.type === "(punctuator)" && token.value === value;
  5828. }
  5829. // Check whether this function has been reached for a destructuring assign with undeclared values
  5830. function destructuringAssignOrJsonValue() {
  5831. // lookup for the assignment (ECMAScript 6 only)
  5832. // if it has semicolons, it is a block, so go parse it as a block
  5833. // or it's not a block, but there are assignments, check for undeclared variables
  5834. var block = lookupBlockType();
  5835. if (block.notJson) {
  5836. if (!state.inES6() && block.isDestAssign) {
  5837. warning("W104", state.tokens.curr, "destructuring assignment", "6");
  5838. }
  5839. statements();
  5840. // otherwise parse json value
  5841. } else {
  5842. state.option.laxbreak = true;
  5843. state.jsonMode = true;
  5844. jsonValue();
  5845. }
  5846. }
  5847. // array comprehension parsing function
  5848. // parses and defines the three states of the list comprehension in order
  5849. // to avoid defining global variables, but keeping them to the list comprehension scope
  5850. // only. The order of the states are as follows:
  5851. // * "use" which will be the returned iterative part of the list comprehension
  5852. // * "define" which will define the variables local to the list comprehension
  5853. // * "filter" which will help filter out values
  5854. var arrayComprehension = function() {
  5855. var CompArray = function() {
  5856. this.mode = "use";
  5857. this.variables = [];
  5858. };
  5859. var _carrays = [];
  5860. var _current;
  5861. function declare(v) {
  5862. var l = _current.variables.filter(function(elt) {
  5863. // if it has, change its undef state
  5864. if (elt.value === v) {
  5865. elt.undef = false;
  5866. return v;
  5867. }
  5868. }).length;
  5869. return l !== 0;
  5870. }
  5871. function use(v) {
  5872. var l = _current.variables.filter(function(elt) {
  5873. // and if it has been defined
  5874. if (elt.value === v && !elt.undef) {
  5875. if (elt.unused === true) {
  5876. elt.unused = false;
  5877. }
  5878. return v;
  5879. }
  5880. }).length;
  5881. // otherwise we warn about it
  5882. return (l === 0);
  5883. }
  5884. return { stack: function() {
  5885. _current = new CompArray();
  5886. _carrays.push(_current);
  5887. },
  5888. unstack: function() {
  5889. _current.variables.filter(function(v) {
  5890. if (v.unused)
  5891. warning("W098", v.token, v.raw_text || v.value);
  5892. if (v.undef)
  5893. state.funct["(scope)"].block.use(v.value, v.token);
  5894. });
  5895. _carrays.splice(-1, 1);
  5896. _current = _carrays[_carrays.length - 1];
  5897. },
  5898. setState: function(s) {
  5899. if (_.contains(["use", "define", "generate", "filter"], s))
  5900. _current.mode = s;
  5901. },
  5902. check: function(v) {
  5903. if (!_current) {
  5904. return;
  5905. }
  5906. // When we are in "use" state of the list comp, we enqueue that var
  5907. if (_current && _current.mode === "use") {
  5908. if (use(v)) {
  5909. _current.variables.push({
  5910. funct: state.funct,
  5911. token: state.tokens.curr,
  5912. value: v,
  5913. undef: true,
  5914. unused: false
  5915. });
  5916. }
  5917. return true;
  5918. // When we are in "define" state of the list comp,
  5919. } else if (_current && _current.mode === "define") {
  5920. // check if the variable has been used previously
  5921. if (!declare(v)) {
  5922. _current.variables.push({
  5923. funct: state.funct,
  5924. token: state.tokens.curr,
  5925. value: v,
  5926. undef: false,
  5927. unused: true
  5928. });
  5929. }
  5930. return true;
  5931. // When we are in the "generate" state of the list comp,
  5932. } else if (_current && _current.mode === "generate") {
  5933. state.funct["(scope)"].block.use(v, state.tokens.curr);
  5934. return true;
  5935. // When we are in "filter" state,
  5936. } else if (_current && _current.mode === "filter") {
  5937. // we check whether current variable has been declared
  5938. if (use(v)) {
  5939. // if not we warn about it
  5940. state.funct["(scope)"].block.use(v, state.tokens.curr);
  5941. }
  5942. return true;
  5943. }
  5944. return false;
  5945. }
  5946. };
  5947. };
  5948. // Parse JSON
  5949. function jsonValue() {
  5950. function jsonObject() {
  5951. var o = {}, t = state.tokens.next;
  5952. advance("{");
  5953. if (state.tokens.next.id !== "}") {
  5954. for (;;) {
  5955. if (state.tokens.next.id === "(end)") {
  5956. error("E026", state.tokens.next, t.line);
  5957. } else if (state.tokens.next.id === "}") {
  5958. warning("W094", state.tokens.curr);
  5959. break;
  5960. } else if (state.tokens.next.id === ",") {
  5961. error("E028", state.tokens.next);
  5962. } else if (state.tokens.next.id !== "(string)") {
  5963. warning("W095", state.tokens.next, state.tokens.next.value);
  5964. }
  5965. if (o[state.tokens.next.value] === true) {
  5966. warning("W075", state.tokens.next, "key", state.tokens.next.value);
  5967. } else if ((state.tokens.next.value === "__proto__" &&
  5968. !state.option.proto) || (state.tokens.next.value === "__iterator__" &&
  5969. !state.option.iterator)) {
  5970. warning("W096", state.tokens.next, state.tokens.next.value);
  5971. } else {
  5972. o[state.tokens.next.value] = true;
  5973. }
  5974. advance();
  5975. advance(":");
  5976. jsonValue();
  5977. if (state.tokens.next.id !== ",") {
  5978. break;
  5979. }
  5980. advance(",");
  5981. }
  5982. }
  5983. advance("}");
  5984. }
  5985. function jsonArray() {
  5986. var t = state.tokens.next;
  5987. advance("[");
  5988. if (state.tokens.next.id !== "]") {
  5989. for (;;) {
  5990. if (state.tokens.next.id === "(end)") {
  5991. error("E027", state.tokens.next, t.line);
  5992. } else if (state.tokens.next.id === "]") {
  5993. warning("W094", state.tokens.curr);
  5994. break;
  5995. } else if (state.tokens.next.id === ",") {
  5996. error("E028", state.tokens.next);
  5997. }
  5998. jsonValue();
  5999. if (state.tokens.next.id !== ",") {
  6000. break;
  6001. }
  6002. advance(",");
  6003. }
  6004. }
  6005. advance("]");
  6006. }
  6007. switch (state.tokens.next.id) {
  6008. case "{":
  6009. jsonObject();
  6010. break;
  6011. case "[":
  6012. jsonArray();
  6013. break;
  6014. case "true":
  6015. case "false":
  6016. case "null":
  6017. case "(number)":
  6018. case "(string)":
  6019. advance();
  6020. break;
  6021. case "-":
  6022. advance("-");
  6023. advance("(number)");
  6024. break;
  6025. default:
  6026. error("E003", state.tokens.next);
  6027. }
  6028. }
  6029. var escapeRegex = function(str) {
  6030. return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
  6031. };
  6032. // The actual JSHINT function itself.
  6033. var itself = function(s, o, g) {
  6034. var i, k, x, reIgnoreStr, reIgnore;
  6035. var optionKeys;
  6036. var newOptionObj = {};
  6037. var newIgnoredObj = {};
  6038. o = _.clone(o);
  6039. state.reset();
  6040. if (o && o.scope) {
  6041. JSHINT.scope = o.scope;
  6042. } else {
  6043. JSHINT.errors = [];
  6044. JSHINT.undefs = [];
  6045. JSHINT.internals = [];
  6046. JSHINT.blacklist = {};
  6047. JSHINT.scope = "(main)";
  6048. }
  6049. predefined = Object.create(null);
  6050. combine(predefined, vars.ecmaIdentifiers[3]);
  6051. combine(predefined, vars.reservedVars);
  6052. combine(predefined, g || {});
  6053. declared = Object.create(null);
  6054. var exported = Object.create(null); // Variables that live outside the current file
  6055. function each(obj, cb) {
  6056. if (!obj)
  6057. return;
  6058. if (!Array.isArray(obj) && typeof obj === "object")
  6059. obj = Object.keys(obj);
  6060. obj.forEach(cb);
  6061. }
  6062. if (o) {
  6063. each(o.predef || null, function(item) {
  6064. var slice, prop;
  6065. if (item[0] === "-") {
  6066. slice = item.slice(1);
  6067. JSHINT.blacklist[slice] = slice;
  6068. // remove from predefined if there
  6069. delete predefined[slice];
  6070. } else {
  6071. prop = Object.getOwnPropertyDescriptor(o.predef, item);
  6072. predefined[item] = prop ? prop.value : false;
  6073. }
  6074. });
  6075. each(o.exported || null, function(item) {
  6076. exported[item] = true;
  6077. });
  6078. delete o.predef;
  6079. delete o.exported;
  6080. optionKeys = Object.keys(o);
  6081. for (x = 0; x < optionKeys.length; x++) {
  6082. if (/^-W\d{3}$/g.test(optionKeys[x])) {
  6083. newIgnoredObj[optionKeys[x].slice(1)] = true;
  6084. } else {
  6085. var optionKey = optionKeys[x];
  6086. newOptionObj[optionKey] = o[optionKey];
  6087. if ((optionKey === "esversion" && o[optionKey] === 5) ||
  6088. (optionKey === "es5" && o[optionKey])) {
  6089. warning("I003");
  6090. }
  6091. if (optionKeys[x] === "newcap" && o[optionKey] === false)
  6092. newOptionObj["(explicitNewcap)"] = true;
  6093. }
  6094. }
  6095. }
  6096. state.option = newOptionObj;
  6097. state.ignored = newIgnoredObj;
  6098. state.option.indent = state.option.indent || 4;
  6099. state.option.maxerr = state.option.maxerr || 50;
  6100. indent = 1;
  6101. var scopeManagerInst = scopeManager(state, predefined, exported, declared);
  6102. scopeManagerInst.on("warning", function(ev) {
  6103. warning.apply(null, [ ev.code, ev.token].concat(ev.data));
  6104. });
  6105. scopeManagerInst.on("error", function(ev) {
  6106. error.apply(null, [ ev.code, ev.token ].concat(ev.data));
  6107. });
  6108. state.funct = functor("(global)", null, {
  6109. "(global)" : true,
  6110. "(scope)" : scopeManagerInst,
  6111. "(comparray)" : arrayComprehension(),
  6112. "(metrics)" : createMetrics(state.tokens.next)
  6113. });
  6114. functions = [state.funct];
  6115. urls = [];
  6116. stack = null;
  6117. member = {};
  6118. membersOnly = null;
  6119. inblock = false;
  6120. lookahead = [];
  6121. if (!isString(s) && !Array.isArray(s)) {
  6122. errorAt("E004", 0);
  6123. return false;
  6124. }
  6125. api = {
  6126. get isJSON() {
  6127. return state.jsonMode;
  6128. },
  6129. getOption: function(name) {
  6130. return state.option[name] || null;
  6131. },
  6132. getCache: function(name) {
  6133. return state.cache[name];
  6134. },
  6135. setCache: function(name, value) {
  6136. state.cache[name] = value;
  6137. },
  6138. warn: function(code, data) {
  6139. warningAt.apply(null, [ code, data.line, data.char ].concat(data.data));
  6140. },
  6141. on: function(names, listener) {
  6142. names.split(" ").forEach(function(name) {
  6143. emitter.on(name, listener);
  6144. }.bind(this));
  6145. }
  6146. };
  6147. emitter.removeAllListeners();
  6148. (extraModules || []).forEach(function(func) {
  6149. func(api);
  6150. });
  6151. state.tokens.prev = state.tokens.curr = state.tokens.next = state.syntax["(begin)"];
  6152. if (o && o.ignoreDelimiters) {
  6153. if (!Array.isArray(o.ignoreDelimiters)) {
  6154. o.ignoreDelimiters = [o.ignoreDelimiters];
  6155. }
  6156. o.ignoreDelimiters.forEach(function(delimiterPair) {
  6157. if (!delimiterPair.start || !delimiterPair.end)
  6158. return;
  6159. reIgnoreStr = escapeRegex(delimiterPair.start) +
  6160. "[\\s\\S]*?" +
  6161. escapeRegex(delimiterPair.end);
  6162. reIgnore = new RegExp(reIgnoreStr, "ig");
  6163. s = s.replace(reIgnore, function(match) {
  6164. return match.replace(/./g, " ");
  6165. });
  6166. });
  6167. }
  6168. lex = new Lexer(s);
  6169. lex.on("warning", function(ev) {
  6170. warningAt.apply(null, [ ev.code, ev.line, ev.character].concat(ev.data));
  6171. });
  6172. lex.on("error", function(ev) {
  6173. errorAt.apply(null, [ ev.code, ev.line, ev.character ].concat(ev.data));
  6174. });
  6175. lex.on("fatal", function(ev) {
  6176. quit("E041", ev.line, ev.from);
  6177. });
  6178. lex.on("Identifier", function(ev) {
  6179. emitter.emit("Identifier", ev);
  6180. });
  6181. lex.on("String", function(ev) {
  6182. emitter.emit("String", ev);
  6183. });
  6184. lex.on("Number", function(ev) {
  6185. emitter.emit("Number", ev);
  6186. });
  6187. lex.start();
  6188. // Check options
  6189. for (var name in o) {
  6190. if (_.has(o, name)) {
  6191. checkOption(name, state.tokens.curr);
  6192. }
  6193. }
  6194. assume();
  6195. // combine the passed globals after we've assumed all our options
  6196. combine(predefined, g || {});
  6197. //reset values
  6198. comma.first = true;
  6199. try {
  6200. advance();
  6201. switch (state.tokens.next.id) {
  6202. case "{":
  6203. case "[":
  6204. destructuringAssignOrJsonValue();
  6205. break;
  6206. default:
  6207. directives();
  6208. if (state.directive["use strict"]) {
  6209. if (state.option.strict !== "global") {
  6210. warning("W097", state.tokens.prev);
  6211. }
  6212. }
  6213. statements();
  6214. }
  6215. if (state.tokens.next.id !== "(end)") {
  6216. quit("E041", state.tokens.curr.line);
  6217. }
  6218. state.funct["(scope)"].unstack();
  6219. } catch (err) {
  6220. if (err && err.name === "JSHintError") {
  6221. var nt = state.tokens.next || {};
  6222. JSHINT.errors.push({
  6223. scope : "(main)",
  6224. raw : err.raw,
  6225. code : err.code,
  6226. reason : err.message,
  6227. line : err.line || nt.line,
  6228. character : err.character || nt.from
  6229. }, null);
  6230. } else {
  6231. throw err;
  6232. }
  6233. }
  6234. // Loop over the listed "internals", and check them as well.
  6235. if (JSHINT.scope === "(main)") {
  6236. o = o || {};
  6237. for (i = 0; i < JSHINT.internals.length; i += 1) {
  6238. k = JSHINT.internals[i];
  6239. o.scope = k.elem;
  6240. itself(k.value, o, g);
  6241. }
  6242. }
  6243. return JSHINT.errors.length === 0;
  6244. };
  6245. // Modules.
  6246. itself.addModule = function(func) {
  6247. extraModules.push(func);
  6248. };
  6249. itself.addModule(style.register);
  6250. // Data summary.
  6251. itself.data = function() {
  6252. var data = {
  6253. functions: [],
  6254. options: state.option
  6255. };
  6256. var fu, f, i, j, n, globals;
  6257. if (itself.errors.length) {
  6258. data.errors = itself.errors;
  6259. }
  6260. if (state.jsonMode) {
  6261. data.json = true;
  6262. }
  6263. var impliedGlobals = state.funct["(scope)"].getImpliedGlobals();
  6264. if (impliedGlobals.length > 0) {
  6265. data.implieds = impliedGlobals;
  6266. }
  6267. if (urls.length > 0) {
  6268. data.urls = urls;
  6269. }
  6270. globals = state.funct["(scope)"].getUsedOrDefinedGlobals();
  6271. if (globals.length > 0) {
  6272. data.globals = globals;
  6273. }
  6274. for (i = 1; i < functions.length; i += 1) {
  6275. f = functions[i];
  6276. fu = {};
  6277. for (j = 0; j < functionicity.length; j += 1) {
  6278. fu[functionicity[j]] = [];
  6279. }
  6280. for (j = 0; j < functionicity.length; j += 1) {
  6281. if (fu[functionicity[j]].length === 0) {
  6282. delete fu[functionicity[j]];
  6283. }
  6284. }
  6285. fu.name = f["(name)"];
  6286. fu.param = f["(params)"];
  6287. fu.line = f["(line)"];
  6288. fu.character = f["(character)"];
  6289. fu.last = f["(last)"];
  6290. fu.lastcharacter = f["(lastcharacter)"];
  6291. fu.metrics = {
  6292. complexity: f["(metrics)"].ComplexityCount,
  6293. parameters: f["(metrics)"].arity,
  6294. statements: f["(metrics)"].statementCount
  6295. };
  6296. data.functions.push(fu);
  6297. }
  6298. var unuseds = state.funct["(scope)"].getUnuseds();
  6299. if (unuseds.length > 0) {
  6300. data.unused = unuseds;
  6301. }
  6302. for (n in member) {
  6303. if (typeof member[n] === "number") {
  6304. data.member = member;
  6305. break;
  6306. }
  6307. }
  6308. return data;
  6309. };
  6310. itself.jshint = itself;
  6311. return itself;
  6312. }());
  6313. // Make JSHINT a Node module, if possible.
  6314. if (typeof exports === "object" && exports) {
  6315. exports.JSHINT = JSHINT;
  6316. }
  6317. },{"../lodash":"/node_modules/jshint/lodash.js","./lex.js":"/node_modules/jshint/src/lex.js","./messages.js":"/node_modules/jshint/src/messages.js","./options.js":"/node_modules/jshint/src/options.js","./reg.js":"/node_modules/jshint/src/reg.js","./scope-manager.js":"/node_modules/jshint/src/scope-manager.js","./state.js":"/node_modules/jshint/src/state.js","./style.js":"/node_modules/jshint/src/style.js","./vars.js":"/node_modules/jshint/src/vars.js","events":"/node_modules/browserify/node_modules/events/events.js"}],"/node_modules/jshint/src/lex.js":[function(_dereq_,module,exports){
  6318. /*
  6319. * Lexical analysis and token construction.
  6320. */
  6321. "use strict";
  6322. var _ = _dereq_("../lodash");
  6323. var events = _dereq_("events");
  6324. var reg = _dereq_("./reg.js");
  6325. var state = _dereq_("./state.js").state;
  6326. var unicodeData = _dereq_("../data/ascii-identifier-data.js");
  6327. var asciiIdentifierStartTable = unicodeData.asciiIdentifierStartTable;
  6328. var asciiIdentifierPartTable = unicodeData.asciiIdentifierPartTable;
  6329. // Some of these token types are from JavaScript Parser API
  6330. // while others are specific to JSHint parser.
  6331. // JS Parser API: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
  6332. var Token = {
  6333. Identifier: 1,
  6334. Punctuator: 2,
  6335. NumericLiteral: 3,
  6336. StringLiteral: 4,
  6337. Comment: 5,
  6338. Keyword: 6,
  6339. NullLiteral: 7,
  6340. BooleanLiteral: 8,
  6341. RegExp: 9,
  6342. TemplateHead: 10,
  6343. TemplateMiddle: 11,
  6344. TemplateTail: 12,
  6345. NoSubstTemplate: 13
  6346. };
  6347. var Context = {
  6348. Block: 1,
  6349. Template: 2
  6350. };
  6351. // Object that handles postponed lexing verifications that checks the parsed
  6352. // environment state.
  6353. function asyncTrigger() {
  6354. var _checks = [];
  6355. return {
  6356. push: function(fn) {
  6357. _checks.push(fn);
  6358. },
  6359. check: function() {
  6360. for (var check = 0; check < _checks.length; ++check) {
  6361. _checks[check]();
  6362. }
  6363. _checks.splice(0, _checks.length);
  6364. }
  6365. };
  6366. }
  6367. /*
  6368. * Lexer for JSHint.
  6369. *
  6370. * This object does a char-by-char scan of the provided source code
  6371. * and produces a sequence of tokens.
  6372. *
  6373. * var lex = new Lexer("var i = 0;");
  6374. * lex.start();
  6375. * lex.token(); // returns the next token
  6376. *
  6377. * You have to use the token() method to move the lexer forward
  6378. * but you don't have to use its return value to get tokens. In addition
  6379. * to token() method returning the next token, the Lexer object also
  6380. * emits events.
  6381. *
  6382. * lex.on("Identifier", function(data) {
  6383. * if (data.name.indexOf("_") >= 0) {
  6384. * // Produce a warning.
  6385. * }
  6386. * });
  6387. *
  6388. * Note that the token() method returns tokens in a JSLint-compatible
  6389. * format while the event emitter uses a slightly modified version of
  6390. * Mozilla's JavaScript Parser API. Eventually, we will move away from
  6391. * JSLint format.
  6392. */
  6393. function Lexer(source) {
  6394. var lines = source;
  6395. if (typeof lines === "string") {
  6396. lines = lines
  6397. .replace(/\r\n/g, "\n")
  6398. .replace(/\r/g, "\n")
  6399. .split("\n");
  6400. }
  6401. // If the first line is a shebang (#!), make it a blank and move on.
  6402. // Shebangs are used by Node scripts.
  6403. if (lines[0] && lines[0].substr(0, 2) === "#!") {
  6404. if (lines[0].indexOf("node") !== -1) {
  6405. state.option.node = true;
  6406. }
  6407. lines[0] = "";
  6408. }
  6409. this.emitter = new events.EventEmitter();
  6410. this.source = source;
  6411. this.setLines(lines);
  6412. this.prereg = true;
  6413. this.line = 0;
  6414. this.char = 1;
  6415. this.from = 1;
  6416. this.input = "";
  6417. this.inComment = false;
  6418. this.context = [];
  6419. this.templateStarts = [];
  6420. for (var i = 0; i < state.option.indent; i += 1) {
  6421. state.tab += " ";
  6422. }
  6423. // Blank out non-multi-line-commented lines when ignoring linter errors
  6424. this.ignoreLinterErrors = false;
  6425. }
  6426. Lexer.prototype = {
  6427. _lines: [],
  6428. inContext: function(ctxType) {
  6429. return this.context.length > 0 && this.context[this.context.length - 1].type === ctxType;
  6430. },
  6431. pushContext: function(ctxType) {
  6432. this.context.push({ type: ctxType });
  6433. },
  6434. popContext: function() {
  6435. return this.context.pop();
  6436. },
  6437. isContext: function(context) {
  6438. return this.context.length > 0 && this.context[this.context.length - 1] === context;
  6439. },
  6440. currentContext: function() {
  6441. return this.context.length > 0 && this.context[this.context.length - 1];
  6442. },
  6443. getLines: function() {
  6444. this._lines = state.lines;
  6445. return this._lines;
  6446. },
  6447. setLines: function(val) {
  6448. this._lines = val;
  6449. state.lines = this._lines;
  6450. },
  6451. /*
  6452. * Return the next i character without actually moving the
  6453. * char pointer.
  6454. */
  6455. peek: function(i) {
  6456. return this.input.charAt(i || 0);
  6457. },
  6458. /*
  6459. * Move the char pointer forward i times.
  6460. */
  6461. skip: function(i) {
  6462. i = i || 1;
  6463. this.char += i;
  6464. this.input = this.input.slice(i);
  6465. },
  6466. /*
  6467. * Subscribe to a token event. The API for this method is similar
  6468. * Underscore.js i.e. you can subscribe to multiple events with
  6469. * one call:
  6470. *
  6471. * lex.on("Identifier Number", function(data) {
  6472. * // ...
  6473. * });
  6474. */
  6475. on: function(names, listener) {
  6476. names.split(" ").forEach(function(name) {
  6477. this.emitter.on(name, listener);
  6478. }.bind(this));
  6479. },
  6480. /*
  6481. * Trigger a token event. All arguments will be passed to each
  6482. * listener.
  6483. */
  6484. trigger: function() {
  6485. this.emitter.emit.apply(this.emitter, Array.prototype.slice.call(arguments));
  6486. },
  6487. /*
  6488. * Postpone a token event. the checking condition is set as
  6489. * last parameter, and the trigger function is called in a
  6490. * stored callback. To be later called using the check() function
  6491. * by the parser. This avoids parser's peek() to give the lexer
  6492. * a false context.
  6493. */
  6494. triggerAsync: function(type, args, checks, fn) {
  6495. checks.push(function() {
  6496. if (fn()) {
  6497. this.trigger(type, args);
  6498. }
  6499. }.bind(this));
  6500. },
  6501. /*
  6502. * Extract a punctuator out of the next sequence of characters
  6503. * or return 'null' if its not possible.
  6504. *
  6505. * This method's implementation was heavily influenced by the
  6506. * scanPunctuator function in the Esprima parser's source code.
  6507. */
  6508. scanPunctuator: function() {
  6509. var ch1 = this.peek();
  6510. var ch2, ch3, ch4;
  6511. switch (ch1) {
  6512. // Most common single-character punctuators
  6513. case ".":
  6514. if ((/^[0-9]$/).test(this.peek(1))) {
  6515. return null;
  6516. }
  6517. if (this.peek(1) === "." && this.peek(2) === ".") {
  6518. return {
  6519. type: Token.Punctuator,
  6520. value: "..."
  6521. };
  6522. }
  6523. /* falls through */
  6524. case "(":
  6525. case ")":
  6526. case ";":
  6527. case ",":
  6528. case "[":
  6529. case "]":
  6530. case ":":
  6531. case "~":
  6532. case "?":
  6533. return {
  6534. type: Token.Punctuator,
  6535. value: ch1
  6536. };
  6537. // A block/object opener
  6538. case "{":
  6539. this.pushContext(Context.Block);
  6540. return {
  6541. type: Token.Punctuator,
  6542. value: ch1
  6543. };
  6544. // A block/object closer
  6545. case "}":
  6546. if (this.inContext(Context.Block)) {
  6547. this.popContext();
  6548. }
  6549. return {
  6550. type: Token.Punctuator,
  6551. value: ch1
  6552. };
  6553. // A pound sign (for Node shebangs)
  6554. case "#":
  6555. return {
  6556. type: Token.Punctuator,
  6557. value: ch1
  6558. };
  6559. // We're at the end of input
  6560. case "":
  6561. return null;
  6562. }
  6563. // Peek more characters
  6564. ch2 = this.peek(1);
  6565. ch3 = this.peek(2);
  6566. ch4 = this.peek(3);
  6567. // 4-character punctuator: >>>=
  6568. if (ch1 === ">" && ch2 === ">" && ch3 === ">" && ch4 === "=") {
  6569. return {
  6570. type: Token.Punctuator,
  6571. value: ">>>="
  6572. };
  6573. }
  6574. // 3-character punctuators: === !== >>> <<= >>=
  6575. if (ch1 === "=" && ch2 === "=" && ch3 === "=") {
  6576. return {
  6577. type: Token.Punctuator,
  6578. value: "==="
  6579. };
  6580. }
  6581. if (ch1 === "!" && ch2 === "=" && ch3 === "=") {
  6582. return {
  6583. type: Token.Punctuator,
  6584. value: "!=="
  6585. };
  6586. }
  6587. if (ch1 === ">" && ch2 === ">" && ch3 === ">") {
  6588. return {
  6589. type: Token.Punctuator,
  6590. value: ">>>"
  6591. };
  6592. }
  6593. if (ch1 === "<" && ch2 === "<" && ch3 === "=") {
  6594. return {
  6595. type: Token.Punctuator,
  6596. value: "<<="
  6597. };
  6598. }
  6599. if (ch1 === ">" && ch2 === ">" && ch3 === "=") {
  6600. return {
  6601. type: Token.Punctuator,
  6602. value: ">>="
  6603. };
  6604. }
  6605. // Fat arrow punctuator
  6606. if (ch1 === "=" && ch2 === ">") {
  6607. return {
  6608. type: Token.Punctuator,
  6609. value: ch1 + ch2
  6610. };
  6611. }
  6612. // 2-character punctuators: <= >= == != ++ -- << >> && ||
  6613. // += -= *= %= &= |= ^= (but not /=, see below)
  6614. if (ch1 === ch2 && ("+-<>&|".indexOf(ch1) >= 0)) {
  6615. return {
  6616. type: Token.Punctuator,
  6617. value: ch1 + ch2
  6618. };
  6619. }
  6620. if ("<>=!+-*%&|^".indexOf(ch1) >= 0) {
  6621. if (ch2 === "=") {
  6622. return {
  6623. type: Token.Punctuator,
  6624. value: ch1 + ch2
  6625. };
  6626. }
  6627. return {
  6628. type: Token.Punctuator,
  6629. value: ch1
  6630. };
  6631. }
  6632. // Special case: /=.
  6633. if (ch1 === "/") {
  6634. if (ch2 === "=") {
  6635. return {
  6636. type: Token.Punctuator,
  6637. value: "/="
  6638. };
  6639. }
  6640. return {
  6641. type: Token.Punctuator,
  6642. value: "/"
  6643. };
  6644. }
  6645. return null;
  6646. },
  6647. /*
  6648. * Extract a comment out of the next sequence of characters and/or
  6649. * lines or return 'null' if its not possible. Since comments can
  6650. * span across multiple lines this method has to move the char
  6651. * pointer.
  6652. *
  6653. * In addition to normal JavaScript comments (// and /*) this method
  6654. * also recognizes JSHint- and JSLint-specific comments such as
  6655. * /*jshint, /*jslint, /*globals and so on.
  6656. */
  6657. scanComments: function() {
  6658. var ch1 = this.peek();
  6659. var ch2 = this.peek(1);
  6660. var rest = this.input.substr(2);
  6661. var startLine = this.line;
  6662. var startChar = this.char;
  6663. var self = this;
  6664. // Create a comment token object and make sure it
  6665. // has all the data JSHint needs to work with special
  6666. // comments.
  6667. function commentToken(label, body, opt) {
  6668. var special = ["jshint", "jslint", "members", "member", "globals", "global", "exported"];
  6669. var isSpecial = false;
  6670. var value = label + body;
  6671. var commentType = "plain";
  6672. opt = opt || {};
  6673. if (opt.isMultiline) {
  6674. value += "*/";
  6675. }
  6676. body = body.replace(/\n/g, " ");
  6677. if (label === "/*" && reg.fallsThrough.test(body)) {
  6678. isSpecial = true;
  6679. commentType = "falls through";
  6680. }
  6681. special.forEach(function(str) {
  6682. if (isSpecial) {
  6683. return;
  6684. }
  6685. // Don't recognize any special comments other than jshint for single-line
  6686. // comments. This introduced many problems with legit comments.
  6687. if (label === "//" && str !== "jshint") {
  6688. return;
  6689. }
  6690. if (body.charAt(str.length) === " " && body.substr(0, str.length) === str) {
  6691. isSpecial = true;
  6692. label = label + str;
  6693. body = body.substr(str.length);
  6694. }
  6695. if (!isSpecial && body.charAt(0) === " " && body.charAt(str.length + 1) === " " &&
  6696. body.substr(1, str.length) === str) {
  6697. isSpecial = true;
  6698. label = label + " " + str;
  6699. body = body.substr(str.length + 1);
  6700. }
  6701. if (!isSpecial) {
  6702. return;
  6703. }
  6704. switch (str) {
  6705. case "member":
  6706. commentType = "members";
  6707. break;
  6708. case "global":
  6709. commentType = "globals";
  6710. break;
  6711. default:
  6712. var options = body.split(":").map(function(v) {
  6713. return v.replace(/^\s+/, "").replace(/\s+$/, "");
  6714. });
  6715. if (options.length === 2) {
  6716. switch (options[0]) {
  6717. case "ignore":
  6718. switch (options[1]) {
  6719. case "start":
  6720. self.ignoringLinterErrors = true;
  6721. isSpecial = false;
  6722. break;
  6723. case "end":
  6724. self.ignoringLinterErrors = false;
  6725. isSpecial = false;
  6726. break;
  6727. }
  6728. }
  6729. }
  6730. commentType = str;
  6731. }
  6732. });
  6733. return {
  6734. type: Token.Comment,
  6735. commentType: commentType,
  6736. value: value,
  6737. body: body,
  6738. isSpecial: isSpecial,
  6739. isMultiline: opt.isMultiline || false,
  6740. isMalformed: opt.isMalformed || false
  6741. };
  6742. }
  6743. // End of unbegun comment. Raise an error and skip that input.
  6744. if (ch1 === "*" && ch2 === "/") {
  6745. this.trigger("error", {
  6746. code: "E018",
  6747. line: startLine,
  6748. character: startChar
  6749. });
  6750. this.skip(2);
  6751. return null;
  6752. }
  6753. // Comments must start either with // or /*
  6754. if (ch1 !== "/" || (ch2 !== "*" && ch2 !== "/")) {
  6755. return null;
  6756. }
  6757. // One-line comment
  6758. if (ch2 === "/") {
  6759. this.skip(this.input.length); // Skip to the EOL.
  6760. return commentToken("//", rest);
  6761. }
  6762. var body = "";
  6763. /* Multi-line comment */
  6764. if (ch2 === "*") {
  6765. this.inComment = true;
  6766. this.skip(2);
  6767. while (this.peek() !== "*" || this.peek(1) !== "/") {
  6768. if (this.peek() === "") { // End of Line
  6769. body += "\n";
  6770. // If we hit EOF and our comment is still unclosed,
  6771. // trigger an error and end the comment implicitly.
  6772. if (!this.nextLine()) {
  6773. this.trigger("error", {
  6774. code: "E017",
  6775. line: startLine,
  6776. character: startChar
  6777. });
  6778. this.inComment = false;
  6779. return commentToken("/*", body, {
  6780. isMultiline: true,
  6781. isMalformed: true
  6782. });
  6783. }
  6784. } else {
  6785. body += this.peek();
  6786. this.skip();
  6787. }
  6788. }
  6789. this.skip(2);
  6790. this.inComment = false;
  6791. return commentToken("/*", body, { isMultiline: true });
  6792. }
  6793. },
  6794. /*
  6795. * Extract a keyword out of the next sequence of characters or
  6796. * return 'null' if its not possible.
  6797. */
  6798. scanKeyword: function() {
  6799. var result = /^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input);
  6800. var keywords = [
  6801. "if", "in", "do", "var", "for", "new",
  6802. "try", "let", "this", "else", "case",
  6803. "void", "with", "enum", "while", "break",
  6804. "catch", "throw", "const", "yield", "class",
  6805. "super", "return", "typeof", "delete",
  6806. "switch", "export", "import", "default",
  6807. "finally", "extends", "function", "continue",
  6808. "debugger", "instanceof"
  6809. ];
  6810. if (result && keywords.indexOf(result[0]) >= 0) {
  6811. return {
  6812. type: Token.Keyword,
  6813. value: result[0]
  6814. };
  6815. }
  6816. return null;
  6817. },
  6818. /*
  6819. * Extract a JavaScript identifier out of the next sequence of
  6820. * characters or return 'null' if its not possible. In addition,
  6821. * to Identifier this method can also produce BooleanLiteral
  6822. * (true/false) and NullLiteral (null).
  6823. */
  6824. scanIdentifier: function() {
  6825. var id = "";
  6826. var index = 0;
  6827. var type, char;
  6828. function isNonAsciiIdentifierStart(code) {
  6829. return code > 256;
  6830. }
  6831. function isNonAsciiIdentifierPart(code) {
  6832. return code > 256;
  6833. }
  6834. function isHexDigit(str) {
  6835. return (/^[0-9a-fA-F]$/).test(str);
  6836. }
  6837. var readUnicodeEscapeSequence = function() {
  6838. /*jshint validthis:true */
  6839. index += 1;
  6840. if (this.peek(index) !== "u") {
  6841. return null;
  6842. }
  6843. var ch1 = this.peek(index + 1);
  6844. var ch2 = this.peek(index + 2);
  6845. var ch3 = this.peek(index + 3);
  6846. var ch4 = this.peek(index + 4);
  6847. var code;
  6848. if (isHexDigit(ch1) && isHexDigit(ch2) && isHexDigit(ch3) && isHexDigit(ch4)) {
  6849. code = parseInt(ch1 + ch2 + ch3 + ch4, 16);
  6850. if (asciiIdentifierPartTable[code] || isNonAsciiIdentifierPart(code)) {
  6851. index += 5;
  6852. return "\\u" + ch1 + ch2 + ch3 + ch4;
  6853. }
  6854. return null;
  6855. }
  6856. return null;
  6857. }.bind(this);
  6858. var getIdentifierStart = function() {
  6859. /*jshint validthis:true */
  6860. var chr = this.peek(index);
  6861. var code = chr.charCodeAt(0);
  6862. if (code === 92) {
  6863. return readUnicodeEscapeSequence();
  6864. }
  6865. if (code < 128) {
  6866. if (asciiIdentifierStartTable[code]) {
  6867. index += 1;
  6868. return chr;
  6869. }
  6870. return null;
  6871. }
  6872. if (isNonAsciiIdentifierStart(code)) {
  6873. index += 1;
  6874. return chr;
  6875. }
  6876. return null;
  6877. }.bind(this);
  6878. var getIdentifierPart = function() {
  6879. /*jshint validthis:true */
  6880. var chr = this.peek(index);
  6881. var code = chr.charCodeAt(0);
  6882. if (code === 92) {
  6883. return readUnicodeEscapeSequence();
  6884. }
  6885. if (code < 128) {
  6886. if (asciiIdentifierPartTable[code]) {
  6887. index += 1;
  6888. return chr;
  6889. }
  6890. return null;
  6891. }
  6892. if (isNonAsciiIdentifierPart(code)) {
  6893. index += 1;
  6894. return chr;
  6895. }
  6896. return null;
  6897. }.bind(this);
  6898. function removeEscapeSequences(id) {
  6899. return id.replace(/\\u([0-9a-fA-F]{4})/g, function(m0, codepoint) {
  6900. return String.fromCharCode(parseInt(codepoint, 16));
  6901. });
  6902. }
  6903. char = getIdentifierStart();
  6904. if (char === null) {
  6905. return null;
  6906. }
  6907. id = char;
  6908. for (;;) {
  6909. char = getIdentifierPart();
  6910. if (char === null) {
  6911. break;
  6912. }
  6913. id += char;
  6914. }
  6915. switch (id) {
  6916. case "true":
  6917. case "false":
  6918. type = Token.BooleanLiteral;
  6919. break;
  6920. case "null":
  6921. type = Token.NullLiteral;
  6922. break;
  6923. default:
  6924. type = Token.Identifier;
  6925. }
  6926. return {
  6927. type: type,
  6928. value: removeEscapeSequences(id),
  6929. text: id,
  6930. tokenLength: id.length
  6931. };
  6932. },
  6933. /*
  6934. * Extract a numeric literal out of the next sequence of
  6935. * characters or return 'null' if its not possible. This method
  6936. * supports all numeric literals described in section 7.8.3
  6937. * of the EcmaScript 5 specification.
  6938. *
  6939. * This method's implementation was heavily influenced by the
  6940. * scanNumericLiteral function in the Esprima parser's source code.
  6941. */
  6942. scanNumericLiteral: function() {
  6943. var index = 0;
  6944. var value = "";
  6945. var length = this.input.length;
  6946. var char = this.peek(index);
  6947. var bad;
  6948. var isAllowedDigit = isDecimalDigit;
  6949. var base = 10;
  6950. var isLegacy = false;
  6951. function isDecimalDigit(str) {
  6952. return (/^[0-9]$/).test(str);
  6953. }
  6954. function isOctalDigit(str) {
  6955. return (/^[0-7]$/).test(str);
  6956. }
  6957. function isBinaryDigit(str) {
  6958. return (/^[01]$/).test(str);
  6959. }
  6960. function isHexDigit(str) {
  6961. return (/^[0-9a-fA-F]$/).test(str);
  6962. }
  6963. function isIdentifierStart(ch) {
  6964. return (ch === "$") || (ch === "_") || (ch === "\\") ||
  6965. (ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z");
  6966. }
  6967. // Numbers must start either with a decimal digit or a point.
  6968. if (char !== "." && !isDecimalDigit(char)) {
  6969. return null;
  6970. }
  6971. if (char !== ".") {
  6972. value = this.peek(index);
  6973. index += 1;
  6974. char = this.peek(index);
  6975. if (value === "0") {
  6976. // Base-16 numbers.
  6977. if (char === "x" || char === "X") {
  6978. isAllowedDigit = isHexDigit;
  6979. base = 16;
  6980. index += 1;
  6981. value += char;
  6982. }
  6983. // Base-8 numbers.
  6984. if (char === "o" || char === "O") {
  6985. isAllowedDigit = isOctalDigit;
  6986. base = 8;
  6987. if (!state.inES6(true)) {
  6988. this.trigger("warning", {
  6989. code: "W119",
  6990. line: this.line,
  6991. character: this.char,
  6992. data: [ "Octal integer literal", "6" ]
  6993. });
  6994. }
  6995. index += 1;
  6996. value += char;
  6997. }
  6998. // Base-2 numbers.
  6999. if (char === "b" || char === "B") {
  7000. isAllowedDigit = isBinaryDigit;
  7001. base = 2;
  7002. if (!state.inES6(true)) {
  7003. this.trigger("warning", {
  7004. code: "W119",
  7005. line: this.line,
  7006. character: this.char,
  7007. data: [ "Binary integer literal", "6" ]
  7008. });
  7009. }
  7010. index += 1;
  7011. value += char;
  7012. }
  7013. // Legacy base-8 numbers.
  7014. if (isOctalDigit(char)) {
  7015. isAllowedDigit = isOctalDigit;
  7016. base = 8;
  7017. isLegacy = true;
  7018. bad = false;
  7019. index += 1;
  7020. value += char;
  7021. }
  7022. // Decimal numbers that start with '0' such as '09' are illegal
  7023. // but we still parse them and return as malformed.
  7024. if (!isOctalDigit(char) && isDecimalDigit(char)) {
  7025. index += 1;
  7026. value += char;
  7027. }
  7028. }
  7029. while (index < length) {
  7030. char = this.peek(index);
  7031. if (isLegacy && isDecimalDigit(char)) {
  7032. // Numbers like '019' (note the 9) are not valid octals
  7033. // but we still parse them and mark as malformed.
  7034. bad = true;
  7035. } else if (!isAllowedDigit(char)) {
  7036. break;
  7037. }
  7038. value += char;
  7039. index += 1;
  7040. }
  7041. if (isAllowedDigit !== isDecimalDigit) {
  7042. if (!isLegacy && value.length <= 2) { // 0x
  7043. return {
  7044. type: Token.NumericLiteral,
  7045. value: value,
  7046. isMalformed: true
  7047. };
  7048. }
  7049. if (index < length) {
  7050. char = this.peek(index);
  7051. if (isIdentifierStart(char)) {
  7052. return null;
  7053. }
  7054. }
  7055. return {
  7056. type: Token.NumericLiteral,
  7057. value: value,
  7058. base: base,
  7059. isLegacy: isLegacy,
  7060. isMalformed: false
  7061. };
  7062. }
  7063. }
  7064. // Decimal digits.
  7065. if (char === ".") {
  7066. value += char;
  7067. index += 1;
  7068. while (index < length) {
  7069. char = this.peek(index);
  7070. if (!isDecimalDigit(char)) {
  7071. break;
  7072. }
  7073. value += char;
  7074. index += 1;
  7075. }
  7076. }
  7077. // Exponent part.
  7078. if (char === "e" || char === "E") {
  7079. value += char;
  7080. index += 1;
  7081. char = this.peek(index);
  7082. if (char === "+" || char === "-") {
  7083. value += this.peek(index);
  7084. index += 1;
  7085. }
  7086. char = this.peek(index);
  7087. if (isDecimalDigit(char)) {
  7088. value += char;
  7089. index += 1;
  7090. while (index < length) {
  7091. char = this.peek(index);
  7092. if (!isDecimalDigit(char)) {
  7093. break;
  7094. }
  7095. value += char;
  7096. index += 1;
  7097. }
  7098. } else {
  7099. return null;
  7100. }
  7101. }
  7102. if (index < length) {
  7103. char = this.peek(index);
  7104. if (isIdentifierStart(char)) {
  7105. return null;
  7106. }
  7107. }
  7108. return {
  7109. type: Token.NumericLiteral,
  7110. value: value,
  7111. base: base,
  7112. isMalformed: !isFinite(value)
  7113. };
  7114. },
  7115. // Assumes previously parsed character was \ (=== '\\') and was not skipped.
  7116. scanEscapeSequence: function(checks) {
  7117. var allowNewLine = false;
  7118. var jump = 1;
  7119. this.skip();
  7120. var char = this.peek();
  7121. switch (char) {
  7122. case "'":
  7123. this.triggerAsync("warning", {
  7124. code: "W114",
  7125. line: this.line,
  7126. character: this.char,
  7127. data: [ "\\'" ]
  7128. }, checks, function() {return state.jsonMode; });
  7129. break;
  7130. case "b":
  7131. char = "\\b";
  7132. break;
  7133. case "f":
  7134. char = "\\f";
  7135. break;
  7136. case "n":
  7137. char = "\\n";
  7138. break;
  7139. case "r":
  7140. char = "\\r";
  7141. break;
  7142. case "t":
  7143. char = "\\t";
  7144. break;
  7145. case "0":
  7146. char = "\\0";
  7147. // Octal literals fail in strict mode.
  7148. // Check if the number is between 00 and 07.
  7149. var n = parseInt(this.peek(1), 10);
  7150. this.triggerAsync("warning", {
  7151. code: "W115",
  7152. line: this.line,
  7153. character: this.char
  7154. }, checks,
  7155. function() { return n >= 0 && n <= 7 && state.isStrict(); });
  7156. break;
  7157. case "u":
  7158. var hexCode = this.input.substr(1, 4);
  7159. var code = parseInt(hexCode, 16);
  7160. if (isNaN(code)) {
  7161. this.trigger("warning", {
  7162. code: "W052",
  7163. line: this.line,
  7164. character: this.char,
  7165. data: [ "u" + hexCode ]
  7166. });
  7167. }
  7168. char = String.fromCharCode(code);
  7169. jump = 5;
  7170. break;
  7171. case "v":
  7172. this.triggerAsync("warning", {
  7173. code: "W114",
  7174. line: this.line,
  7175. character: this.char,
  7176. data: [ "\\v" ]
  7177. }, checks, function() { return state.jsonMode; });
  7178. char = "\v";
  7179. break;
  7180. case "x":
  7181. var x = parseInt(this.input.substr(1, 2), 16);
  7182. this.triggerAsync("warning", {
  7183. code: "W114",
  7184. line: this.line,
  7185. character: this.char,
  7186. data: [ "\\x-" ]
  7187. }, checks, function() { return state.jsonMode; });
  7188. char = String.fromCharCode(x);
  7189. jump = 3;
  7190. break;
  7191. case "\\":
  7192. char = "\\\\";
  7193. break;
  7194. case "\"":
  7195. char = "\\\"";
  7196. break;
  7197. case "/":
  7198. break;
  7199. case "":
  7200. allowNewLine = true;
  7201. char = "";
  7202. break;
  7203. }
  7204. return { char: char, jump: jump, allowNewLine: allowNewLine };
  7205. },
  7206. /*
  7207. * Extract a template literal out of the next sequence of characters
  7208. * and/or lines or return 'null' if its not possible. Since template
  7209. * literals can span across multiple lines, this method has to move
  7210. * the char pointer.
  7211. */
  7212. scanTemplateLiteral: function(checks) {
  7213. var tokenType;
  7214. var value = "";
  7215. var ch;
  7216. var startLine = this.line;
  7217. var startChar = this.char;
  7218. var depth = this.templateStarts.length;
  7219. if (!state.inES6(true)) {
  7220. // Only lex template strings in ESNext mode.
  7221. return null;
  7222. } else if (this.peek() === "`") {
  7223. // Template must start with a backtick.
  7224. tokenType = Token.TemplateHead;
  7225. this.templateStarts.push({ line: this.line, char: this.char });
  7226. depth = this.templateStarts.length;
  7227. this.skip(1);
  7228. this.pushContext(Context.Template);
  7229. } else if (this.inContext(Context.Template) && this.peek() === "}") {
  7230. // If we're in a template context, and we have a '}', lex a TemplateMiddle.
  7231. tokenType = Token.TemplateMiddle;
  7232. } else {
  7233. // Go lex something else.
  7234. return null;
  7235. }
  7236. while (this.peek() !== "`") {
  7237. while ((ch = this.peek()) === "") {
  7238. value += "\n";
  7239. if (!this.nextLine()) {
  7240. // Unclosed template literal --- point to the starting "`"
  7241. var startPos = this.templateStarts.pop();
  7242. this.trigger("error", {
  7243. code: "E052",
  7244. line: startPos.line,
  7245. character: startPos.char
  7246. });
  7247. return {
  7248. type: tokenType,
  7249. value: value,
  7250. startLine: startLine,
  7251. startChar: startChar,
  7252. isUnclosed: true,
  7253. depth: depth,
  7254. context: this.popContext()
  7255. };
  7256. }
  7257. }
  7258. if (ch === '$' && this.peek(1) === '{') {
  7259. value += '${';
  7260. this.skip(2);
  7261. return {
  7262. type: tokenType,
  7263. value: value,
  7264. startLine: startLine,
  7265. startChar: startChar,
  7266. isUnclosed: false,
  7267. depth: depth,
  7268. context: this.currentContext()
  7269. };
  7270. } else if (ch === '\\') {
  7271. var escape = this.scanEscapeSequence(checks);
  7272. value += escape.char;
  7273. this.skip(escape.jump);
  7274. } else if (ch !== '`') {
  7275. // Otherwise, append the value and continue.
  7276. value += ch;
  7277. this.skip(1);
  7278. }
  7279. }
  7280. // Final value is either NoSubstTemplate or TemplateTail
  7281. tokenType = tokenType === Token.TemplateHead ? Token.NoSubstTemplate : Token.TemplateTail;
  7282. this.skip(1);
  7283. this.templateStarts.pop();
  7284. return {
  7285. type: tokenType,
  7286. value: value,
  7287. startLine: startLine,
  7288. startChar: startChar,
  7289. isUnclosed: false,
  7290. depth: depth,
  7291. context: this.popContext()
  7292. };
  7293. },
  7294. /*
  7295. * Extract a string out of the next sequence of characters and/or
  7296. * lines or return 'null' if its not possible. Since strings can
  7297. * span across multiple lines this method has to move the char
  7298. * pointer.
  7299. *
  7300. * This method recognizes pseudo-multiline JavaScript strings:
  7301. *
  7302. * var str = "hello\
  7303. * world";
  7304. */
  7305. scanStringLiteral: function(checks) {
  7306. /*jshint loopfunc:true */
  7307. var quote = this.peek();
  7308. // String must start with a quote.
  7309. if (quote !== "\"" && quote !== "'") {
  7310. return null;
  7311. }
  7312. // In JSON strings must always use double quotes.
  7313. this.triggerAsync("warning", {
  7314. code: "W108",
  7315. line: this.line,
  7316. character: this.char // +1?
  7317. }, checks, function() { return state.jsonMode && quote !== "\""; });
  7318. var value = "";
  7319. var startLine = this.line;
  7320. var startChar = this.char;
  7321. var allowNewLine = false;
  7322. this.skip();
  7323. while (this.peek() !== quote) {
  7324. if (this.peek() === "") { // End Of Line
  7325. // If an EOL is not preceded by a backslash, show a warning
  7326. // and proceed like it was a legit multi-line string where
  7327. // author simply forgot to escape the newline symbol.
  7328. //
  7329. // Another approach is to implicitly close a string on EOL
  7330. // but it generates too many false positives.
  7331. if (!allowNewLine) {
  7332. this.trigger("warning", {
  7333. code: "W112",
  7334. line: this.line,
  7335. character: this.char
  7336. });
  7337. } else {
  7338. allowNewLine = false;
  7339. // Otherwise show a warning if multistr option was not set.
  7340. // For JSON, show warning no matter what.
  7341. this.triggerAsync("warning", {
  7342. code: "W043",
  7343. line: this.line,
  7344. character: this.char
  7345. }, checks, function() { return !state.option.multistr; });
  7346. this.triggerAsync("warning", {
  7347. code: "W042",
  7348. line: this.line,
  7349. character: this.char
  7350. }, checks, function() { return state.jsonMode && state.option.multistr; });
  7351. }
  7352. // If we get an EOF inside of an unclosed string, show an
  7353. // error and implicitly close it at the EOF point.
  7354. if (!this.nextLine()) {
  7355. this.trigger("error", {
  7356. code: "E029",
  7357. line: startLine,
  7358. character: startChar
  7359. });
  7360. return {
  7361. type: Token.StringLiteral,
  7362. value: value,
  7363. startLine: startLine,
  7364. startChar: startChar,
  7365. isUnclosed: true,
  7366. quote: quote
  7367. };
  7368. }
  7369. } else { // Any character other than End Of Line
  7370. allowNewLine = false;
  7371. var char = this.peek();
  7372. var jump = 1; // A length of a jump, after we're done
  7373. // parsing this character.
  7374. if (char < " ") {
  7375. // Warn about a control character in a string.
  7376. this.trigger("warning", {
  7377. code: "W113",
  7378. line: this.line,
  7379. character: this.char,
  7380. data: [ "<non-printable>" ]
  7381. });
  7382. }
  7383. // Special treatment for some escaped characters.
  7384. if (char === "\\") {
  7385. var parsed = this.scanEscapeSequence(checks);
  7386. char = parsed.char;
  7387. jump = parsed.jump;
  7388. allowNewLine = parsed.allowNewLine;
  7389. }
  7390. value += char;
  7391. this.skip(jump);
  7392. }
  7393. }
  7394. this.skip();
  7395. return {
  7396. type: Token.StringLiteral,
  7397. value: value,
  7398. startLine: startLine,
  7399. startChar: startChar,
  7400. isUnclosed: false,
  7401. quote: quote
  7402. };
  7403. },
  7404. /*
  7405. * Extract a regular expression out of the next sequence of
  7406. * characters and/or lines or return 'null' if its not possible.
  7407. *
  7408. * This method is platform dependent: it accepts almost any
  7409. * regular expression values but then tries to compile and run
  7410. * them using system's RegExp object. This means that there are
  7411. * rare edge cases where one JavaScript engine complains about
  7412. * your regular expression while others don't.
  7413. */
  7414. scanRegExp: function() {
  7415. var index = 0;
  7416. var length = this.input.length;
  7417. var char = this.peek();
  7418. var value = char;
  7419. var body = "";
  7420. var flags = [];
  7421. var malformed = false;
  7422. var isCharSet = false;
  7423. var terminated;
  7424. var scanUnexpectedChars = function() {
  7425. // Unexpected control character
  7426. if (char < " ") {
  7427. malformed = true;
  7428. this.trigger("warning", {
  7429. code: "W048",
  7430. line: this.line,
  7431. character: this.char
  7432. });
  7433. }
  7434. // Unexpected escaped character
  7435. if (char === "<") {
  7436. malformed = true;
  7437. this.trigger("warning", {
  7438. code: "W049",
  7439. line: this.line,
  7440. character: this.char,
  7441. data: [ char ]
  7442. });
  7443. }
  7444. }.bind(this);
  7445. // Regular expressions must start with '/'
  7446. if (!this.prereg || char !== "/") {
  7447. return null;
  7448. }
  7449. index += 1;
  7450. terminated = false;
  7451. // Try to get everything in between slashes. A couple of
  7452. // cases aside (see scanUnexpectedChars) we don't really
  7453. // care whether the resulting expression is valid or not.
  7454. // We will check that later using the RegExp object.
  7455. while (index < length) {
  7456. char = this.peek(index);
  7457. value += char;
  7458. body += char;
  7459. if (isCharSet) {
  7460. if (char === "]") {
  7461. if (this.peek(index - 1) !== "\\" || this.peek(index - 2) === "\\") {
  7462. isCharSet = false;
  7463. }
  7464. }
  7465. if (char === "\\") {
  7466. index += 1;
  7467. char = this.peek(index);
  7468. body += char;
  7469. value += char;
  7470. scanUnexpectedChars();
  7471. }
  7472. index += 1;
  7473. continue;
  7474. }
  7475. if (char === "\\") {
  7476. index += 1;
  7477. char = this.peek(index);
  7478. body += char;
  7479. value += char;
  7480. scanUnexpectedChars();
  7481. if (char === "/") {
  7482. index += 1;
  7483. continue;
  7484. }
  7485. if (char === "[") {
  7486. index += 1;
  7487. continue;
  7488. }
  7489. }
  7490. if (char === "[") {
  7491. isCharSet = true;
  7492. index += 1;
  7493. continue;
  7494. }
  7495. if (char === "/") {
  7496. body = body.substr(0, body.length - 1);
  7497. terminated = true;
  7498. index += 1;
  7499. break;
  7500. }
  7501. index += 1;
  7502. }
  7503. // A regular expression that was never closed is an
  7504. // error from which we cannot recover.
  7505. if (!terminated) {
  7506. this.trigger("error", {
  7507. code: "E015",
  7508. line: this.line,
  7509. character: this.from
  7510. });
  7511. return void this.trigger("fatal", {
  7512. line: this.line,
  7513. from: this.from
  7514. });
  7515. }
  7516. // Parse flags (if any).
  7517. while (index < length) {
  7518. char = this.peek(index);
  7519. if (!/[gim]/.test(char)) {
  7520. break;
  7521. }
  7522. flags.push(char);
  7523. value += char;
  7524. index += 1;
  7525. }
  7526. // Check regular expression for correctness.
  7527. try {
  7528. new RegExp(body, flags.join(""));
  7529. } catch (err) {
  7530. malformed = true;
  7531. this.trigger("error", {
  7532. code: "E016",
  7533. line: this.line,
  7534. character: this.char,
  7535. data: [ err.message ] // Platform dependent!
  7536. });
  7537. }
  7538. return {
  7539. type: Token.RegExp,
  7540. value: value,
  7541. flags: flags,
  7542. isMalformed: malformed
  7543. };
  7544. },
  7545. /*
  7546. * Scan for any occurrence of non-breaking spaces. Non-breaking spaces
  7547. * can be mistakenly typed on OS X with option-space. Non UTF-8 web
  7548. * pages with non-breaking pages produce syntax errors.
  7549. */
  7550. scanNonBreakingSpaces: function() {
  7551. return state.option.nonbsp ?
  7552. this.input.search(/(\u00A0)/) : -1;
  7553. },
  7554. /*
  7555. * Scan for characters that get silently deleted by one or more browsers.
  7556. */
  7557. scanUnsafeChars: function() {
  7558. return this.input.search(reg.unsafeChars);
  7559. },
  7560. /*
  7561. * Produce the next raw token or return 'null' if no tokens can be matched.
  7562. * This method skips over all space characters.
  7563. */
  7564. next: function(checks) {
  7565. this.from = this.char;
  7566. // Move to the next non-space character.
  7567. var start;
  7568. if (/\s/.test(this.peek())) {
  7569. start = this.char;
  7570. while (/\s/.test(this.peek())) {
  7571. this.from += 1;
  7572. this.skip();
  7573. }
  7574. }
  7575. // Methods that work with multi-line structures and move the
  7576. // character pointer.
  7577. var match = this.scanComments() ||
  7578. this.scanStringLiteral(checks) ||
  7579. this.scanTemplateLiteral(checks);
  7580. if (match) {
  7581. return match;
  7582. }
  7583. // Methods that don't move the character pointer.
  7584. match =
  7585. this.scanRegExp() ||
  7586. this.scanPunctuator() ||
  7587. this.scanKeyword() ||
  7588. this.scanIdentifier() ||
  7589. this.scanNumericLiteral();
  7590. if (match) {
  7591. this.skip(match.tokenLength || match.value.length);
  7592. return match;
  7593. }
  7594. // No token could be matched, give up.
  7595. return null;
  7596. },
  7597. /*
  7598. * Switch to the next line and reset all char pointers. Once
  7599. * switched, this method also checks for other minor warnings.
  7600. */
  7601. nextLine: function() {
  7602. var char;
  7603. if (this.line >= this.getLines().length) {
  7604. return false;
  7605. }
  7606. this.input = this.getLines()[this.line];
  7607. this.line += 1;
  7608. this.char = 1;
  7609. this.from = 1;
  7610. var inputTrimmed = this.input.trim();
  7611. var startsWith = function() {
  7612. return _.some(arguments, function(prefix) {
  7613. return inputTrimmed.indexOf(prefix) === 0;
  7614. });
  7615. };
  7616. var endsWith = function() {
  7617. return _.some(arguments, function(suffix) {
  7618. return inputTrimmed.indexOf(suffix, inputTrimmed.length - suffix.length) !== -1;
  7619. });
  7620. };
  7621. // If we are ignoring linter errors, replace the input with empty string
  7622. // if it doesn't already at least start or end a multi-line comment
  7623. if (this.ignoringLinterErrors === true) {
  7624. if (!startsWith("/*", "//") && !(this.inComment && endsWith("*/"))) {
  7625. this.input = "";
  7626. }
  7627. }
  7628. char = this.scanNonBreakingSpaces();
  7629. if (char >= 0) {
  7630. this.trigger("warning", { code: "W125", line: this.line, character: char + 1 });
  7631. }
  7632. this.input = this.input.replace(/\t/g, state.tab);
  7633. char = this.scanUnsafeChars();
  7634. if (char >= 0) {
  7635. this.trigger("warning", { code: "W100", line: this.line, character: char });
  7636. }
  7637. // If there is a limit on line length, warn when lines get too
  7638. // long.
  7639. if (!this.ignoringLinterErrors && state.option.maxlen &&
  7640. state.option.maxlen < this.input.length) {
  7641. var inComment = this.inComment ||
  7642. startsWith.call(inputTrimmed, "//") ||
  7643. startsWith.call(inputTrimmed, "/*");
  7644. var shouldTriggerError = !inComment || !reg.maxlenException.test(inputTrimmed);
  7645. if (shouldTriggerError) {
  7646. this.trigger("warning", { code: "W101", line: this.line, character: this.input.length });
  7647. }
  7648. }
  7649. return true;
  7650. },
  7651. /*
  7652. * This is simply a synonym for nextLine() method with a friendlier
  7653. * public name.
  7654. */
  7655. start: function() {
  7656. this.nextLine();
  7657. },
  7658. /*
  7659. * Produce the next token. This function is called by advance() to get
  7660. * the next token. It returns a token in a JSLint-compatible format.
  7661. */
  7662. token: function() {
  7663. /*jshint loopfunc:true */
  7664. var checks = asyncTrigger();
  7665. var token;
  7666. function isReserved(token, isProperty) {
  7667. if (!token.reserved) {
  7668. return false;
  7669. }
  7670. var meta = token.meta;
  7671. if (meta && meta.isFutureReservedWord && state.inES5()) {
  7672. // ES3 FutureReservedWord in an ES5 environment.
  7673. if (!meta.es5) {
  7674. return false;
  7675. }
  7676. // Some ES5 FutureReservedWord identifiers are active only
  7677. // within a strict mode environment.
  7678. if (meta.strictOnly) {
  7679. if (!state.option.strict && !state.isStrict()) {
  7680. return false;
  7681. }
  7682. }
  7683. if (isProperty) {
  7684. return false;
  7685. }
  7686. }
  7687. return true;
  7688. }
  7689. // Produce a token object.
  7690. var create = function(type, value, isProperty, token) {
  7691. /*jshint validthis:true */
  7692. var obj;
  7693. if (type !== "(endline)" && type !== "(end)") {
  7694. this.prereg = false;
  7695. }
  7696. if (type === "(punctuator)") {
  7697. switch (value) {
  7698. case ".":
  7699. case ")":
  7700. case "~":
  7701. case "#":
  7702. case "]":
  7703. case "++":
  7704. case "--":
  7705. this.prereg = false;
  7706. break;
  7707. default:
  7708. this.prereg = true;
  7709. }
  7710. obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
  7711. }
  7712. if (type === "(identifier)") {
  7713. if (value === "return" || value === "case" || value === "typeof") {
  7714. this.prereg = true;
  7715. }
  7716. if (_.has(state.syntax, value)) {
  7717. obj = Object.create(state.syntax[value] || state.syntax["(error)"]);
  7718. // If this can't be a reserved keyword, reset the object.
  7719. if (!isReserved(obj, isProperty && type === "(identifier)")) {
  7720. obj = null;
  7721. }
  7722. }
  7723. }
  7724. if (!obj) {
  7725. obj = Object.create(state.syntax[type]);
  7726. }
  7727. obj.identifier = (type === "(identifier)");
  7728. obj.type = obj.type || type;
  7729. obj.value = value;
  7730. obj.line = this.line;
  7731. obj.character = this.char;
  7732. obj.from = this.from;
  7733. if (obj.identifier && token) obj.raw_text = token.text || token.value;
  7734. if (token && token.startLine && token.startLine !== this.line) {
  7735. obj.startLine = token.startLine;
  7736. }
  7737. if (token && token.context) {
  7738. // Context of current token
  7739. obj.context = token.context;
  7740. }
  7741. if (token && token.depth) {
  7742. // Nested template depth
  7743. obj.depth = token.depth;
  7744. }
  7745. if (token && token.isUnclosed) {
  7746. // Mark token as unclosed string / template literal
  7747. obj.isUnclosed = token.isUnclosed;
  7748. }
  7749. if (isProperty && obj.identifier) {
  7750. obj.isProperty = isProperty;
  7751. }
  7752. obj.check = checks.check;
  7753. return obj;
  7754. }.bind(this);
  7755. for (;;) {
  7756. if (!this.input.length) {
  7757. if (this.nextLine()) {
  7758. return create("(endline)", "");
  7759. }
  7760. if (this.exhausted) {
  7761. return null;
  7762. }
  7763. this.exhausted = true;
  7764. return create("(end)", "");
  7765. }
  7766. token = this.next(checks);
  7767. if (!token) {
  7768. if (this.input.length) {
  7769. // Unexpected character.
  7770. this.trigger("error", {
  7771. code: "E024",
  7772. line: this.line,
  7773. character: this.char,
  7774. data: [ this.peek() ]
  7775. });
  7776. this.input = "";
  7777. }
  7778. continue;
  7779. }
  7780. switch (token.type) {
  7781. case Token.StringLiteral:
  7782. this.triggerAsync("String", {
  7783. line: this.line,
  7784. char: this.char,
  7785. from: this.from,
  7786. startLine: token.startLine,
  7787. startChar: token.startChar,
  7788. value: token.value,
  7789. quote: token.quote
  7790. }, checks, function() { return true; });
  7791. return create("(string)", token.value, null, token);
  7792. case Token.TemplateHead:
  7793. this.trigger("TemplateHead", {
  7794. line: this.line,
  7795. char: this.char,
  7796. from: this.from,
  7797. startLine: token.startLine,
  7798. startChar: token.startChar,
  7799. value: token.value
  7800. });
  7801. return create("(template)", token.value, null, token);
  7802. case Token.TemplateMiddle:
  7803. this.trigger("TemplateMiddle", {
  7804. line: this.line,
  7805. char: this.char,
  7806. from: this.from,
  7807. startLine: token.startLine,
  7808. startChar: token.startChar,
  7809. value: token.value
  7810. });
  7811. return create("(template middle)", token.value, null, token);
  7812. case Token.TemplateTail:
  7813. this.trigger("TemplateTail", {
  7814. line: this.line,
  7815. char: this.char,
  7816. from: this.from,
  7817. startLine: token.startLine,
  7818. startChar: token.startChar,
  7819. value: token.value
  7820. });
  7821. return create("(template tail)", token.value, null, token);
  7822. case Token.NoSubstTemplate:
  7823. this.trigger("NoSubstTemplate", {
  7824. line: this.line,
  7825. char: this.char,
  7826. from: this.from,
  7827. startLine: token.startLine,
  7828. startChar: token.startChar,
  7829. value: token.value
  7830. });
  7831. return create("(no subst template)", token.value, null, token);
  7832. case Token.Identifier:
  7833. this.triggerAsync("Identifier", {
  7834. line: this.line,
  7835. char: this.char,
  7836. from: this.form,
  7837. name: token.value,
  7838. raw_name: token.text,
  7839. isProperty: state.tokens.curr.id === "."
  7840. }, checks, function() { return true; });
  7841. /* falls through */
  7842. case Token.Keyword:
  7843. case Token.NullLiteral:
  7844. case Token.BooleanLiteral:
  7845. return create("(identifier)", token.value, state.tokens.curr.id === ".", token);
  7846. case Token.NumericLiteral:
  7847. if (token.isMalformed) {
  7848. this.trigger("warning", {
  7849. code: "W045",
  7850. line: this.line,
  7851. character: this.char,
  7852. data: [ token.value ]
  7853. });
  7854. }
  7855. this.triggerAsync("warning", {
  7856. code: "W114",
  7857. line: this.line,
  7858. character: this.char,
  7859. data: [ "0x-" ]
  7860. }, checks, function() { return token.base === 16 && state.jsonMode; });
  7861. this.triggerAsync("warning", {
  7862. code: "W115",
  7863. line: this.line,
  7864. character: this.char
  7865. }, checks, function() {
  7866. return state.isStrict() && token.base === 8 && token.isLegacy;
  7867. });
  7868. this.trigger("Number", {
  7869. line: this.line,
  7870. char: this.char,
  7871. from: this.from,
  7872. value: token.value,
  7873. base: token.base,
  7874. isMalformed: token.malformed
  7875. });
  7876. return create("(number)", token.value);
  7877. case Token.RegExp:
  7878. return create("(regexp)", token.value);
  7879. case Token.Comment:
  7880. state.tokens.curr.comment = true;
  7881. if (token.isSpecial) {
  7882. return {
  7883. id: '(comment)',
  7884. value: token.value,
  7885. body: token.body,
  7886. type: token.commentType,
  7887. isSpecial: token.isSpecial,
  7888. line: this.line,
  7889. character: this.char,
  7890. from: this.from
  7891. };
  7892. }
  7893. break;
  7894. case "":
  7895. break;
  7896. default:
  7897. return create("(punctuator)", token.value);
  7898. }
  7899. }
  7900. }
  7901. };
  7902. exports.Lexer = Lexer;
  7903. exports.Context = Context;
  7904. },{"../data/ascii-identifier-data.js":"/node_modules/jshint/data/ascii-identifier-data.js","../lodash":"/node_modules/jshint/lodash.js","./reg.js":"/node_modules/jshint/src/reg.js","./state.js":"/node_modules/jshint/src/state.js","events":"/node_modules/browserify/node_modules/events/events.js"}],"/node_modules/jshint/src/messages.js":[function(_dereq_,module,exports){
  7905. "use strict";
  7906. var _ = _dereq_("../lodash");
  7907. var errors = {
  7908. // JSHint options
  7909. E001: "Bad option: '{a}'.",
  7910. E002: "Bad option value.",
  7911. // JSHint input
  7912. E003: "Expected a JSON value.",
  7913. E004: "Input is neither a string nor an array of strings.",
  7914. E005: "Input is empty.",
  7915. E006: "Unexpected early end of program.",
  7916. // Strict mode
  7917. E007: "Missing \"use strict\" statement.",
  7918. E008: "Strict violation.",
  7919. E009: "Option 'validthis' can't be used in a global scope.",
  7920. E010: "'with' is not allowed in strict mode.",
  7921. // Constants
  7922. E011: "'{a}' has already been declared.",
  7923. E012: "const '{a}' is initialized to 'undefined'.",
  7924. E013: "Attempting to override '{a}' which is a constant.",
  7925. // Regular expressions
  7926. E014: "A regular expression literal can be confused with '/='.",
  7927. E015: "Unclosed regular expression.",
  7928. E016: "Invalid regular expression.",
  7929. // Tokens
  7930. E017: "Unclosed comment.",
  7931. E018: "Unbegun comment.",
  7932. E019: "Unmatched '{a}'.",
  7933. E020: "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
  7934. E021: "Expected '{a}' and instead saw '{b}'.",
  7935. E022: "Line breaking error '{a}'.",
  7936. E023: "Missing '{a}'.",
  7937. E024: "Unexpected '{a}'.",
  7938. E025: "Missing ':' on a case clause.",
  7939. E026: "Missing '}' to match '{' from line {a}.",
  7940. E027: "Missing ']' to match '[' from line {a}.",
  7941. E028: "Illegal comma.",
  7942. E029: "Unclosed string.",
  7943. // Everything else
  7944. E030: "Expected an identifier and instead saw '{a}'.",
  7945. E031: "Bad assignment.", // FIXME: Rephrase
  7946. E032: "Expected a small integer or 'false' and instead saw '{a}'.",
  7947. E033: "Expected an operator and instead saw '{a}'.",
  7948. E034: "get/set are ES5 features.",
  7949. E035: "Missing property name.",
  7950. E036: "Expected to see a statement and instead saw a block.",
  7951. E037: null,
  7952. E038: null,
  7953. E039: "Function declarations are not invocable. Wrap the whole function invocation in parens.",
  7954. E040: "Each value should have its own case label.",
  7955. E041: "Unrecoverable syntax error.",
  7956. E042: "Stopping.",
  7957. E043: "Too many errors.",
  7958. E044: null,
  7959. E045: "Invalid for each loop.",
  7960. E046: "A yield statement shall be within a generator function (with syntax: `function*`)",
  7961. E047: null,
  7962. E048: "{a} declaration not directly within block.",
  7963. E049: "A {a} cannot be named '{b}'.",
  7964. E050: "Mozilla requires the yield expression to be parenthesized here.",
  7965. E051: null,
  7966. E052: "Unclosed template literal.",
  7967. E053: "Export declaration must be in global scope.",
  7968. E054: "Class properties must be methods. Expected '(' but instead saw '{a}'.",
  7969. E055: "The '{a}' option cannot be set after any executable code.",
  7970. E056: "'{a}' was used before it was declared, which is illegal for '{b}' variables.",
  7971. E057: "Invalid meta property: '{a}.{b}'.",
  7972. E058: "Missing semicolon."
  7973. };
  7974. var warnings = {
  7975. W001: "'hasOwnProperty' is a really bad name.",
  7976. W002: "Value of '{a}' may be overwritten in IE 8 and earlier.",
  7977. W003: "'{a}' was used before it was defined.",
  7978. W004: "'{a}' is already defined.",
  7979. W005: "A dot following a number can be confused with a decimal point.",
  7980. W006: "Confusing minuses.",
  7981. W007: "Confusing plusses.",
  7982. W008: "A leading decimal point can be confused with a dot: '{a}'.",
  7983. W009: "The array literal notation [] is preferable.",
  7984. W010: "The object literal notation {} is preferable.",
  7985. W011: null,
  7986. W012: null,
  7987. W013: null,
  7988. W014: "Bad line breaking before '{a}'.",
  7989. W015: null,
  7990. W016: "Unexpected use of '{a}'.",
  7991. W017: "Bad operand.",
  7992. W018: "Confusing use of '{a}'.",
  7993. W019: "Use the isNaN function to compare with NaN.",
  7994. W020: "Read only.",
  7995. W021: "Reassignment of '{a}', which is is a {b}. " +
  7996. "Use 'var' or 'let' to declare bindings that may change.",
  7997. W022: "Do not assign to the exception parameter.",
  7998. W023: "Expected an identifier in an assignment and instead saw a function invocation.",
  7999. W024: "Expected an identifier and instead saw '{a}' (a reserved word).",
  8000. W025: "Missing name in function declaration.",
  8001. W026: "Inner functions should be listed at the top of the outer function.",
  8002. W027: "Unreachable '{a}' after '{b}'.",
  8003. W028: "Label '{a}' on {b} statement.",
  8004. W030: "Expected an assignment or function call and instead saw an expression.",
  8005. W031: "Do not use 'new' for side effects.",
  8006. W032: "Unnecessary semicolon.",
  8007. W033: "Missing semicolon.",
  8008. W034: "Unnecessary directive \"{a}\".",
  8009. W035: "Empty block.",
  8010. W036: "Unexpected /*member '{a}'.",
  8011. W037: "'{a}' is a statement label.",
  8012. W038: "'{a}' used out of scope.",
  8013. W039: "'{a}' is not allowed.",
  8014. W040: "Possible strict violation.",
  8015. W041: "Use '{a}' to compare with '{b}'.",
  8016. W042: "Avoid EOL escaping.",
  8017. W043: "Bad escaping of EOL. Use option multistr if needed.",
  8018. W044: "Bad or unnecessary escaping.", /* TODO(caitp): remove W044 */
  8019. W045: "Bad number '{a}'.",
  8020. W046: "Don't use extra leading zeros '{a}'.",
  8021. W047: "A trailing decimal point can be confused with a dot: '{a}'.",
  8022. W048: "Unexpected control character in regular expression.",
  8023. W049: "Unexpected escaped character '{a}' in regular expression.",
  8024. W050: "JavaScript URL.",
  8025. W051: "Variables should not be deleted.",
  8026. W052: "Unexpected '{a}'.",
  8027. W053: "Do not use {a} as a constructor.",
  8028. W054: "The Function constructor is a form of eval.",
  8029. W055: "A constructor name should start with an uppercase letter.",
  8030. W056: "Bad constructor.",
  8031. W057: "Weird construction. Is 'new' necessary?",
  8032. W058: "Missing '()' invoking a constructor.",
  8033. W059: "Avoid arguments.{a}.",
  8034. W060: "document.write can be a form of eval.",
  8035. W061: "eval can be harmful.",
  8036. W062: "Wrap an immediate function invocation in parens " +
  8037. "to assist the reader in understanding that the expression " +
  8038. "is the result of a function, and not the function itself.",
  8039. W063: "Math is not a function.",
  8040. W064: "Missing 'new' prefix when invoking a constructor.",
  8041. W065: "Missing radix parameter.",
  8042. W066: "Implied eval. Consider passing a function instead of a string.",
  8043. W067: "Bad invocation.",
  8044. W068: "Wrapping non-IIFE function literals in parens is unnecessary.",
  8045. W069: "['{a}'] is better written in dot notation.",
  8046. W070: "Extra comma. (it breaks older versions of IE)",
  8047. W071: "This function has too many statements. ({a})",
  8048. W072: "This function has too many parameters. ({a})",
  8049. W073: "Blocks are nested too deeply. ({a})",
  8050. W074: "This function's cyclomatic complexity is too high. ({a})",
  8051. W075: "Duplicate {a} '{b}'.",
  8052. W076: "Unexpected parameter '{a}' in get {b} function.",
  8053. W077: "Expected a single parameter in set {a} function.",
  8054. W078: "Setter is defined without getter.",
  8055. W079: "Redefinition of '{a}'.",
  8056. W080: "It's not necessary to initialize '{a}' to 'undefined'.",
  8057. W081: null,
  8058. W082: "Function declarations should not be placed in blocks. " +
  8059. "Use a function expression or move the statement to the top of " +
  8060. "the outer function.",
  8061. W083: "Don't make functions within a loop.",
  8062. W084: "Assignment in conditional expression",
  8063. W085: "Don't use 'with'.",
  8064. W086: "Expected a 'break' statement before '{a}'.",
  8065. W087: "Forgotten 'debugger' statement?",
  8066. W088: "Creating global 'for' variable. Should be 'for (var {a} ...'.",
  8067. W089: "The body of a for in should be wrapped in an if statement to filter " +
  8068. "unwanted properties from the prototype.",
  8069. W090: "'{a}' is not a statement label.",
  8070. W091: null,
  8071. W093: "Did you mean to return a conditional instead of an assignment?",
  8072. W094: "Unexpected comma.",
  8073. W095: "Expected a string and instead saw {a}.",
  8074. W096: "The '{a}' key may produce unexpected results.",
  8075. W097: "Use the function form of \"use strict\".",
  8076. W098: "'{a}' is defined but never used.",
  8077. W099: null,
  8078. W100: "This character may get silently deleted by one or more browsers.",
  8079. W101: "Line is too long.",
  8080. W102: null,
  8081. W103: "The '{a}' property is deprecated.",
  8082. W104: "'{a}' is available in ES{b} (use 'esversion: {b}') or Mozilla JS extensions (use moz).",
  8083. W105: "Unexpected {a} in '{b}'.",
  8084. W106: "Identifier '{a}' is not in camel case.",
  8085. W107: "Script URL.",
  8086. W108: "Strings must use doublequote.",
  8087. W109: "Strings must use singlequote.",
  8088. W110: "Mixed double and single quotes.",
  8089. W112: "Unclosed string.",
  8090. W113: "Control character in string: {a}.",
  8091. W114: "Avoid {a}.",
  8092. W115: "Octal literals are not allowed in strict mode.",
  8093. W116: "Expected '{a}' and instead saw '{b}'.",
  8094. W117: "'{a}' is not defined.",
  8095. W118: "'{a}' is only available in Mozilla JavaScript extensions (use moz option).",
  8096. W119: "'{a}' is only available in ES{b} (use 'esversion: {b}').",
  8097. W120: "You might be leaking a variable ({a}) here.",
  8098. W121: "Extending prototype of native object: '{a}'.",
  8099. W122: "Invalid typeof value '{a}'",
  8100. W123: "'{a}' is already defined in outer scope.",
  8101. W124: "A generator function shall contain a yield statement.",
  8102. W125: "This line contains non-breaking spaces: http://jshint.com/doc/options/#nonbsp",
  8103. W126: "Unnecessary grouping operator.",
  8104. W127: "Unexpected use of a comma operator.",
  8105. W128: "Empty array elements require elision=true.",
  8106. W129: "'{a}' is defined in a future version of JavaScript. Use a " +
  8107. "different variable name to avoid migration issues.",
  8108. W130: "Invalid element after rest element.",
  8109. W131: "Invalid parameter after rest parameter.",
  8110. W132: "`var` declarations are forbidden. Use `let` or `const` instead.",
  8111. W133: "Invalid for-{a} loop left-hand-side: {b}.",
  8112. W134: "The '{a}' option is only available when linting ECMAScript {b} code.",
  8113. W135: "{a} may not be supported by non-browser environments.",
  8114. W136: "'{a}' must be in function scope.",
  8115. W137: "Empty destructuring.",
  8116. W138: "Regular parameters should not come after default parameters."
  8117. };
  8118. var info = {
  8119. I001: "Comma warnings can be turned off with 'laxcomma'.",
  8120. I002: null,
  8121. I003: "ES5 option is now set per default"
  8122. };
  8123. exports.errors = {};
  8124. exports.warnings = {};
  8125. exports.info = {};
  8126. _.each(errors, function(desc, code) {
  8127. exports.errors[code] = { code: code, desc: desc };
  8128. });
  8129. _.each(warnings, function(desc, code) {
  8130. exports.warnings[code] = { code: code, desc: desc };
  8131. });
  8132. _.each(info, function(desc, code) {
  8133. exports.info[code] = { code: code, desc: desc };
  8134. });
  8135. },{"../lodash":"/node_modules/jshint/lodash.js"}],"/node_modules/jshint/src/name-stack.js":[function(_dereq_,module,exports){
  8136. "use strict";
  8137. function NameStack() {
  8138. this._stack = [];
  8139. }
  8140. Object.defineProperty(NameStack.prototype, "length", {
  8141. get: function() {
  8142. return this._stack.length;
  8143. }
  8144. });
  8145. /**
  8146. * Create a new entry in the stack. Useful for tracking names across
  8147. * expressions.
  8148. */
  8149. NameStack.prototype.push = function() {
  8150. this._stack.push(null);
  8151. };
  8152. /**
  8153. * Discard the most recently-created name on the stack.
  8154. */
  8155. NameStack.prototype.pop = function() {
  8156. this._stack.pop();
  8157. };
  8158. /**
  8159. * Update the most recent name on the top of the stack.
  8160. *
  8161. * @param {object} token The token to consider as the source for the most
  8162. * recent name.
  8163. */
  8164. NameStack.prototype.set = function(token) {
  8165. this._stack[this.length - 1] = token;
  8166. };
  8167. /**
  8168. * Generate a string representation of the most recent name.
  8169. *
  8170. * @returns {string}
  8171. */
  8172. NameStack.prototype.infer = function() {
  8173. var nameToken = this._stack[this.length - 1];
  8174. var prefix = "";
  8175. var type;
  8176. // During expected operation, the topmost entry on the stack will only
  8177. // reflect the current function's name when the function is declared without
  8178. // the `function` keyword (i.e. for in-line accessor methods). In other
  8179. // cases, the `function` expression itself will introduce an empty entry on
  8180. // the top of the stack, and this should be ignored.
  8181. if (!nameToken || nameToken.type === "class") {
  8182. nameToken = this._stack[this.length - 2];
  8183. }
  8184. if (!nameToken) {
  8185. return "(empty)";
  8186. }
  8187. type = nameToken.type;
  8188. if (type !== "(string)" && type !== "(number)" && type !== "(identifier)" && type !== "default") {
  8189. return "(expression)";
  8190. }
  8191. if (nameToken.accessorType) {
  8192. prefix = nameToken.accessorType + " ";
  8193. }
  8194. return prefix + nameToken.value;
  8195. };
  8196. module.exports = NameStack;
  8197. },{}],"/node_modules/jshint/src/options.js":[function(_dereq_,module,exports){
  8198. "use strict";
  8199. // These are the JSHint boolean options.
  8200. exports.bool = {
  8201. enforcing: {
  8202. /**
  8203. * This option prohibits the use of bitwise operators such as `^` (XOR),
  8204. * `|` (OR) and others. Bitwise operators are very rare in JavaScript
  8205. * programs and quite often `&` is simply a mistyped `&&`.
  8206. */
  8207. bitwise : true,
  8208. /**
  8209. *
  8210. * This options prohibits overwriting prototypes of native objects such as
  8211. * `Array`, `Date` and so on.
  8212. *
  8213. * // jshint freeze:true
  8214. * Array.prototype.count = function (value) { return 4; };
  8215. * // -> Warning: Extending prototype of native object: 'Array'.
  8216. */
  8217. freeze : true,
  8218. /**
  8219. * This option allows you to force all variable names to use either
  8220. * camelCase style or UPPER_CASE with underscores.
  8221. *
  8222. * @deprecated JSHint is limiting its scope to issues of code correctness.
  8223. * If you would like to enforce rules relating to code style,
  8224. * check out [the JSCS
  8225. * project](https://github.com/jscs-dev/node-jscs).
  8226. */
  8227. camelcase : true,
  8228. /**
  8229. * This option requires you to always put curly braces around blocks in
  8230. * loops and conditionals. JavaScript allows you to omit curly braces when
  8231. * the block consists of only one statement, for example:
  8232. *
  8233. * while (day)
  8234. * shuffle();
  8235. *
  8236. * However, in some circumstances, it can lead to bugs (you'd think that
  8237. * `sleep()` is a part of the loop while in reality it is not):
  8238. *
  8239. * while (day)
  8240. * shuffle();
  8241. * sleep();
  8242. */
  8243. curly : true,
  8244. /**
  8245. * This options prohibits the use of `==` and `!=` in favor of `===` and
  8246. * `!==`. The former try to coerce values before comparing them which can
  8247. * lead to some unexpected results. The latter don't do any coercion so
  8248. * they are generally safer. If you would like to learn more about type
  8249. * coercion in JavaScript, we recommend [Truth, Equality and
  8250. * JavaScript](http://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/)
  8251. * by Angus Croll.
  8252. */
  8253. eqeqeq : true,
  8254. /**
  8255. * This option enables warnings about the use of identifiers which are
  8256. * defined in future versions of JavaScript. Although overwriting them has
  8257. * no effect in contexts where they are not implemented, this practice can
  8258. * cause issues when migrating codebases to newer versions of the language.
  8259. */
  8260. futurehostile: true,
  8261. /**
  8262. * This option suppresses warnings about invalid `typeof` operator values.
  8263. * This operator has only [a limited set of possible return
  8264. * values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof).
  8265. * By default, JSHint warns when you compare its result with an invalid
  8266. * value which often can be a typo.
  8267. *
  8268. * // 'fuction' instead of 'function'
  8269. * if (typeof a == "fuction") { // Invalid typeof value 'fuction'
  8270. * // ...
  8271. * }
  8272. *
  8273. * Do not use this option unless you're absolutely sure you don't want
  8274. * these checks.
  8275. */
  8276. notypeof : true,
  8277. /**
  8278. * This option tells JSHint that your code needs to adhere to ECMAScript 3
  8279. * specification. Use this option if you need your program to be executable
  8280. * in older browsers—such as Internet Explorer 6/7/8/9—and other legacy
  8281. * JavaScript environments.
  8282. *
  8283. * @deprecated Use `esversion: 3` instead.
  8284. */
  8285. es3 : true,
  8286. /**
  8287. * This option enables syntax first defined in [the ECMAScript 5.1
  8288. * specification](http://es5.github.io/). This includes allowing reserved
  8289. * keywords as object properties.
  8290. *
  8291. * @deprecated Use `esversion: 5` instead.
  8292. */
  8293. es5 : true,
  8294. /**
  8295. * This option requires all `for in` loops to filter object's items. The
  8296. * for in statement allows for looping through the names of all of the
  8297. * properties of an object including those inherited through the prototype
  8298. * chain. This behavior can lead to unexpected items in your object so it
  8299. * is generally safer to always filter inherited properties out as shown in
  8300. * the example:
  8301. *
  8302. * for (key in obj) {
  8303. * if (obj.hasOwnProperty(key)) {
  8304. * // We are sure that obj[key] belongs to the object and was not inherited.
  8305. * }
  8306. * }
  8307. *
  8308. * For more in-depth understanding of `for in` loops in JavaScript, read
  8309. * [Exploring JavaScript for-in
  8310. * loops](http://javascriptweblog.wordpress.com/2011/01/04/exploring-javascript-for-in-loops/)
  8311. * by Angus Croll.
  8312. */
  8313. forin : true,
  8314. /**
  8315. * This option suppresses warnings about declaring variables inside of
  8316. * control
  8317. * structures while accessing them later from the outside. Even though
  8318. * JavaScript has only two real scopes—global and function—such practice
  8319. * leads to confusion among people new to the language and hard-to-debug
  8320. * bugs. This is why, by default, JSHint warns about variables that are
  8321. * used outside of their intended scope.
  8322. *
  8323. * function test() {
  8324. * if (true) {
  8325. * var x = 0;
  8326. * }
  8327. *
  8328. * x += 1; // Default: 'x' used out of scope.
  8329. * // No warning when funcscope:true
  8330. * }
  8331. */
  8332. funcscope : true,
  8333. /**
  8334. * This option prohibits the use of immediate function invocations without
  8335. * wrapping them in parentheses. Wrapping parentheses assists readers of
  8336. * your code in understanding that the expression is the result of a
  8337. * function, and not the function itself.
  8338. *
  8339. * @deprecated JSHint is limiting its scope to issues of code correctness.
  8340. * If you would like to enforce rules relating to code style,
  8341. * check out [the JSCS
  8342. * project](https://github.com/jscs-dev/node-jscs).
  8343. */
  8344. immed : true,
  8345. /**
  8346. * This option suppresses warnings about the `__iterator__` property. This
  8347. * property is not supported by all browsers so use it carefully.
  8348. */
  8349. iterator : true,
  8350. /**
  8351. * This option requires you to capitalize names of constructor functions.
  8352. * Capitalizing functions that are intended to be used with `new` operator
  8353. * is just a convention that helps programmers to visually distinguish
  8354. * constructor functions from other types of functions to help spot
  8355. * mistakes when using `this`.
  8356. *
  8357. * Not doing so won't break your code in any browsers or environments but
  8358. * it will be a bit harder to figure out—by reading the code—if the
  8359. * function was supposed to be used with or without new. And this is
  8360. * important because when the function that was intended to be used with
  8361. * `new` is used without it, `this` will point to the global object instead
  8362. * of a new object.
  8363. *
  8364. * @deprecated JSHint is limiting its scope to issues of code correctness.
  8365. * If you would like to enforce rules relating to code style,
  8366. * check out [the JSCS
  8367. * project](https://github.com/jscs-dev/node-jscs).
  8368. */
  8369. newcap : true,
  8370. /**
  8371. * This option prohibits the use of `arguments.caller` and
  8372. * `arguments.callee`. Both `.caller` and `.callee` make quite a few
  8373. * optimizations impossible so they were deprecated in future versions of
  8374. * JavaScript. In fact, ECMAScript 5 forbids the use of `arguments.callee`
  8375. * in strict mode.
  8376. */
  8377. noarg : true,
  8378. /**
  8379. * This option prohibits the use of the comma operator. When misused, the
  8380. * comma operator can obscure the value of a statement and promote
  8381. * incorrect code.
  8382. */
  8383. nocomma : true,
  8384. /**
  8385. * This option warns when you have an empty block in your code. JSLint was
  8386. * originally warning for all empty blocks and we simply made it optional.
  8387. * There were no studies reporting that empty blocks in JavaScript break
  8388. * your code in any way.
  8389. *
  8390. * @deprecated JSHint is limiting its scope to issues of code correctness.
  8391. * If you would like to enforce rules relating to code style,
  8392. * check out [the JSCS
  8393. * project](https://github.com/jscs-dev/node-jscs).
  8394. */
  8395. noempty : true,
  8396. /**
  8397. * This option warns about "non-breaking whitespace" characters. These
  8398. * characters can be entered with option-space on Mac computers and have a
  8399. * potential of breaking non-UTF8 web pages.
  8400. */
  8401. nonbsp : true,
  8402. /**
  8403. * This option prohibits the use of constructor functions for side-effects.
  8404. * Some people like to call constructor functions without assigning its
  8405. * result to any variable:
  8406. *
  8407. * new MyConstructor();
  8408. *
  8409. * There is no advantage in this approach over simply calling
  8410. * `MyConstructor` since the object that the operator `new` creates isn't
  8411. * used anywhere so you should generally avoid constructors like this one.
  8412. */
  8413. nonew : true,
  8414. /**
  8415. * This option prohibits the use of explicitly undeclared variables. This
  8416. * option is very useful for spotting leaking and mistyped variables.
  8417. *
  8418. * // jshint undef:true
  8419. *
  8420. * function test() {
  8421. * var myVar = 'Hello, World';
  8422. * console.log(myvar); // Oops, typoed here. JSHint with undef will complain
  8423. * }
  8424. *
  8425. * If your variable is defined in another file, you can use the `global`
  8426. * directive to tell JSHint about it.
  8427. */
  8428. undef : true,
  8429. /**
  8430. * This option prohibits the use of the grouping operator when it is not
  8431. * strictly required. Such usage commonly reflects a misunderstanding of
  8432. * unary operators, for example:
  8433. *
  8434. * // jshint singleGroups: true
  8435. *
  8436. * delete(obj.attr); // Warning: Unnecessary grouping operator.
  8437. */
  8438. singleGroups: false,
  8439. /**
  8440. * When set to true, the use of VariableStatements are forbidden.
  8441. * For example:
  8442. *
  8443. * // jshint varstmt: true
  8444. *
  8445. * var a; // Warning: `var` declarations are forbidden. Use `let` or `const` instead.
  8446. */
  8447. varstmt: false,
  8448. /**
  8449. * This option is a short hand for the most strict JSHint configuration as
  8450. * available in JSHint version 2.6.3. It enables all enforcing options and
  8451. * disables all relaxing options that were defined in that release.
  8452. *
  8453. * @deprecated The option cannot be maintained without automatically opting
  8454. * users in to new features. This can lead to unexpected
  8455. * warnings/errors in when upgrading between minor versions of
  8456. * JSHint.
  8457. */
  8458. enforceall : false
  8459. },
  8460. relaxing: {
  8461. /**
  8462. * This option suppresses warnings about missing semicolons. There is a lot
  8463. * of FUD about semicolon spread by quite a few people in the community.
  8464. * The common myths are that semicolons are required all the time (they are
  8465. * not) and that they are unreliable. JavaScript has rules about semicolons
  8466. * which are followed by *all* browsers so it is up to you to decide
  8467. * whether you should or should not use semicolons in your code.
  8468. *
  8469. * For more information about semicolons in JavaScript read [An Open Letter
  8470. * to JavaScript Leaders Regarding
  8471. * Semicolons](http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding)
  8472. * by Isaac Schlueter and [JavaScript Semicolon
  8473. * Insertion](http://inimino.org/~inimino/blog/javascript_semicolons).
  8474. */
  8475. asi : true,
  8476. /**
  8477. * This option suppresses warnings about multi-line strings. Multi-line
  8478. * strings can be dangerous in JavaScript because all hell breaks loose if
  8479. * you accidentally put a whitespace in between the escape character (`\`)
  8480. * and a new line.
  8481. *
  8482. * Note that even though this option allows correct multi-line strings, it
  8483. * still warns about multi-line strings without escape characters or with
  8484. * anything in between the escape character and a whitespace.
  8485. *
  8486. * // jshint multistr:true
  8487. *
  8488. * var text = "Hello\
  8489. * World"; // All good.
  8490. *
  8491. * text = "Hello
  8492. * World"; // Warning, no escape character.
  8493. *
  8494. * text = "Hello\
  8495. * World"; // Warning, there is a space after \
  8496. *
  8497. * @deprecated JSHint is limiting its scope to issues of code correctness.
  8498. * If you would like to enforce rules relating to code style,
  8499. * check out [the JSCS
  8500. * project](https://github.com/jscs-dev/node-jscs).
  8501. */
  8502. multistr : true,
  8503. /**
  8504. * This option suppresses warnings about the `debugger` statements in your
  8505. * code.
  8506. */
  8507. debug : true,
  8508. /**
  8509. * This option suppresses warnings about the use of assignments in cases
  8510. * where comparisons are expected. More often than not, code like `if (a =
  8511. * 10) {}` is a typo. However, it can be useful in cases like this one:
  8512. *
  8513. * for (var i = 0, person; person = people[i]; i++) {}
  8514. *
  8515. * You can silence this error on a per-use basis by surrounding the assignment
  8516. * with parenthesis, such as:
  8517. *
  8518. * for (var i = 0, person; (person = people[i]); i++) {}
  8519. */
  8520. boss : true,
  8521. /**
  8522. * This option suppresses warnings about the use of `eval`. The use of
  8523. * `eval` is discouraged because it can make your code vulnerable to
  8524. * various injection attacks and it makes it hard for JavaScript
  8525. * interpreter to do certain optimizations.
  8526. */
  8527. evil : true,
  8528. /**
  8529. * This option suppresses warnings about the use of global strict mode.
  8530. * Global strict mode can break third-party widgets so it is not
  8531. * recommended.
  8532. *
  8533. * For more info about strict mode see the `strict` option.
  8534. *
  8535. * @deprecated Use `strict: "global"`.
  8536. */
  8537. globalstrict: true,
  8538. /**
  8539. * This option prohibits the use of unary increment and decrement
  8540. * operators. Some people think that `++` and `--` reduces the quality of
  8541. * their coding styles and there are programming languages—such as
  8542. * Python—that go completely without these operators.
  8543. */
  8544. plusplus : true,
  8545. /**
  8546. * This option suppresses warnings about the `__proto__` property.
  8547. */
  8548. proto : true,
  8549. /**
  8550. * This option suppresses warnings about the use of script-targeted
  8551. * URLs—such as `javascript:...`.
  8552. */
  8553. scripturl : true,
  8554. /**
  8555. * This option suppresses warnings about using `[]` notation when it can be
  8556. * expressed in dot notation: `person['name']` vs. `person.name`.
  8557. *
  8558. * @deprecated JSHint is limiting its scope to issues of code correctness.
  8559. * If you would like to enforce rules relating to code style,
  8560. * check out [the JSCS
  8561. * project](https://github.com/jscs-dev/node-jscs).
  8562. */
  8563. sub : true,
  8564. /**
  8565. * This option suppresses warnings about "weird" constructions like
  8566. * `new function () { ... }` and `new Object;`. Such constructions are
  8567. * sometimes used to produce singletons in JavaScript:
  8568. *
  8569. * var singleton = new function() {
  8570. * var privateVar;
  8571. *
  8572. * this.publicMethod = function () {}
  8573. * this.publicMethod2 = function () {}
  8574. * };
  8575. */
  8576. supernew : true,
  8577. /**
  8578. * This option suppresses most of the warnings about possibly unsafe line
  8579. * breakings in your code. It doesn't suppress warnings about comma-first
  8580. * coding style. To suppress those you have to use `laxcomma` (see below).
  8581. *
  8582. * @deprecated JSHint is limiting its scope to issues of code correctness.
  8583. * If you would like to enforce rules relating to code style,
  8584. * check out [the JSCS
  8585. * project](https://github.com/jscs-dev/node-jscs).
  8586. */
  8587. laxbreak : true,
  8588. /**
  8589. * This option suppresses warnings about comma-first coding style:
  8590. *
  8591. * var obj = {
  8592. * name: 'Anton'
  8593. * , handle: 'valueof'
  8594. * , role: 'SW Engineer'
  8595. * };
  8596. *
  8597. * @deprecated JSHint is limiting its scope to issues of code correctness.
  8598. * If you would like to enforce rules relating to code style,
  8599. * check out [the JSCS
  8600. * project](https://github.com/jscs-dev/node-jscs).
  8601. */
  8602. laxcomma : true,
  8603. /**
  8604. * This option suppresses warnings about possible strict violations when
  8605. * the code is running in strict mode and you use `this` in a
  8606. * non-constructor function. You should use this option—in a function scope
  8607. * only—when you are positive that your use of `this` is valid in the
  8608. * strict mode (for example, if you call your function using
  8609. * `Function.call`).
  8610. *
  8611. * **Note:** This option can be used only inside of a function scope.
  8612. * JSHint will fail with an error if you will try to set this option
  8613. * globally.
  8614. */
  8615. validthis : true,
  8616. /**
  8617. * This option suppresses warnings about the use of the `with` statement.
  8618. * The semantics of the `with` statement can cause confusion among
  8619. * developers and accidental definition of global variables.
  8620. *
  8621. * More info:
  8622. *
  8623. * * [with Statement Considered
  8624. * Harmful](http://yuiblog.com/blog/2006/04/11/with-statement-considered-harmful/)
  8625. */
  8626. withstmt : true,
  8627. /**
  8628. * This options tells JSHint that your code uses Mozilla JavaScript
  8629. * extensions. Unless you develop specifically for the Firefox web browser
  8630. * you don't need this option.
  8631. *
  8632. * More info:
  8633. *
  8634. * * [New in JavaScript
  8635. * 1.7](https://developer.mozilla.org/en-US/docs/JavaScript/New_in_JavaScript/1.7)
  8636. */
  8637. moz : true,
  8638. /**
  8639. * This option suppresses warnings about generator functions with no
  8640. * `yield` statement in them.
  8641. */
  8642. noyield : true,
  8643. /**
  8644. * This option suppresses warnings about `== null` comparisons. Such
  8645. * comparisons are often useful when you want to check if a variable is
  8646. * `null` or `undefined`.
  8647. */
  8648. eqnull : true,
  8649. /**
  8650. * This option suppresses warnings about missing semicolons, but only when
  8651. * the semicolon is omitted for the last statement in a one-line block:
  8652. *
  8653. * var name = (function() { return 'Anton' }());
  8654. *
  8655. * This is a very niche use case that is useful only when you use automatic
  8656. * JavaScript code generators.
  8657. */
  8658. lastsemic : true,
  8659. /**
  8660. * This option suppresses warnings about functions inside of loops.
  8661. * Defining functions inside of loops can lead to bugs such as this one:
  8662. *
  8663. * var nums = [];
  8664. *
  8665. * for (var i = 0; i < 10; i++) {
  8666. * nums[i] = function (j) {
  8667. * return i + j;
  8668. * };
  8669. * }
  8670. *
  8671. * nums[0](2); // Prints 12 instead of 2
  8672. *
  8673. * To fix the code above you need to copy the value of `i`:
  8674. *
  8675. * var nums = [];
  8676. *
  8677. * for (var i = 0; i < 10; i++) {
  8678. * (function (i) {
  8679. * nums[i] = function (j) {
  8680. * return i + j;
  8681. * };
  8682. * }(i));
  8683. * }
  8684. */
  8685. loopfunc : true,
  8686. /**
  8687. * This option suppresses warnings about the use of expressions where
  8688. * normally you would expect to see assignments or function calls. Most of
  8689. * the time, such code is a typo. However, it is not forbidden by the spec
  8690. * and that's why this warning is optional.
  8691. */
  8692. expr : true,
  8693. /**
  8694. * This option tells JSHint that your code uses ECMAScript 6 specific
  8695. * syntax. Note that these features are not finalized yet and not all
  8696. * browsers implement them.
  8697. *
  8698. * More info:
  8699. *
  8700. * * [Specification for ECMAScript
  8701. * 6](http://www.ecma-international.org/ecma-262/6.0/index.html)
  8702. *
  8703. * @deprecated Use `esversion: 6` instead.
  8704. */
  8705. esnext : true,
  8706. /**
  8707. * This option tells JSHint that your code uses ES3 array elision elements,
  8708. * or empty elements (for example, `[1, , , 4, , , 7]`).
  8709. */
  8710. elision : true,
  8711. },
  8712. // Third party globals
  8713. environments: {
  8714. /**
  8715. * This option defines globals exposed by the
  8716. * [MooTools](http://mootools.net/) JavaScript framework.
  8717. */
  8718. mootools : true,
  8719. /**
  8720. * This option defines globals exposed by
  8721. * [CouchDB](http://couchdb.apache.org/). CouchDB is a document-oriented
  8722. * database that can be queried and indexed in a MapReduce fashion using
  8723. * JavaScript.
  8724. */
  8725. couch : true,
  8726. /**
  8727. * This option defines globals exposed by [the Jasmine unit testing
  8728. * framework](https://jasmine.github.io/).
  8729. */
  8730. jasmine : true,
  8731. /**
  8732. * This option defines globals exposed by the [jQuery](http://jquery.com/)
  8733. * JavaScript library.
  8734. */
  8735. jquery : true,
  8736. /**
  8737. * This option defines globals available when your code is running inside
  8738. * of the Node runtime environment. [Node.js](http://nodejs.org/) is a
  8739. * server-side JavaScript environment that uses an asynchronous
  8740. * event-driven model. This option also skips some warnings that make sense
  8741. * in the browser environments but don't make sense in Node such as
  8742. * file-level `use strict` pragmas and `console.log` statements.
  8743. */
  8744. node : true,
  8745. /**
  8746. * This option defines globals exposed by [the QUnit unit testing
  8747. * framework](http://qunitjs.com/).
  8748. */
  8749. qunit : true,
  8750. /**
  8751. * This option defines globals available when your code is running inside
  8752. * of the Rhino runtime environment. [Rhino](http://www.mozilla.org/rhino/)
  8753. * is an open-source implementation of JavaScript written entirely in Java.
  8754. */
  8755. rhino : true,
  8756. /**
  8757. * This option defines globals exposed by [the ShellJS
  8758. * library](http://documentup.com/arturadib/shelljs).
  8759. */
  8760. shelljs : true,
  8761. /**
  8762. * This option defines globals exposed by the
  8763. * [Prototype](http://www.prototypejs.org/) JavaScript framework.
  8764. */
  8765. prototypejs : true,
  8766. /**
  8767. * This option defines globals exposed by the [YUI](http://yuilibrary.com/)
  8768. * JavaScript framework.
  8769. */
  8770. yui : true,
  8771. /**
  8772. * This option defines globals exposed by the "BDD" and "TDD" UIs of the
  8773. * [Mocha unit testing framework](http://mochajs.org/).
  8774. */
  8775. mocha : true,
  8776. /**
  8777. * This option informs JSHint that the input code describes an ECMAScript 6
  8778. * module. All module code is interpreted as strict mode code.
  8779. */
  8780. module : true,
  8781. /**
  8782. * This option defines globals available when your code is running as a
  8783. * script for the [Windows Script
  8784. * Host](http://en.wikipedia.org/wiki/Windows_Script_Host).
  8785. */
  8786. wsh : true,
  8787. /**
  8788. * This option defines globals available when your code is running inside
  8789. * of a Web Worker. [Web
  8790. * Workers](https://developer.mozilla.org/en/Using_web_workers) provide a
  8791. * simple means for web content to run scripts in background threads.
  8792. */
  8793. worker : true,
  8794. /**
  8795. * This option defines non-standard but widely adopted globals such as
  8796. * `escape` and `unescape`.
  8797. */
  8798. nonstandard : true,
  8799. /**
  8800. * This option defines globals exposed by modern browsers: all the way from
  8801. * good old `document` and `navigator` to the HTML5 `FileReader` and other
  8802. * new developments in the browser world.
  8803. *
  8804. * **Note:** This option doesn't expose variables like `alert` or
  8805. * `console`. See option `devel` for more information.
  8806. */
  8807. browser : true,
  8808. /**
  8809. * This option defines globals available when using [the Browserify
  8810. * tool](http://browserify.org/) to build a project.
  8811. */
  8812. browserify : true,
  8813. /**
  8814. * This option defines globals that are usually used for logging poor-man's
  8815. * debugging: `console`, `alert`, etc. It is usually a good idea to not
  8816. * ship them in production because, for example, `console.log` breaks in
  8817. * legacy versions of Internet Explorer.
  8818. */
  8819. devel : true,
  8820. /**
  8821. * This option defines globals exposed by the [Dojo
  8822. * Toolkit](http://dojotoolkit.org/).
  8823. */
  8824. dojo : true,
  8825. /**
  8826. * This option defines globals for typed array constructors.
  8827. *
  8828. * More info:
  8829. *
  8830. * * [JavaScript typed
  8831. * arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays)
  8832. */
  8833. typed : true,
  8834. /**
  8835. * This option defines globals available when your core is running inside
  8836. * of the PhantomJS runtime environment. [PhantomJS](http://phantomjs.org/)
  8837. * is a headless WebKit scriptable with a JavaScript API. It has fast and
  8838. * native support for various web standards: DOM handling, CSS selector,
  8839. * JSON, Canvas, and SVG.
  8840. */
  8841. phantom : true
  8842. },
  8843. // Obsolete options
  8844. obsolete: {
  8845. onecase : true, // if one case switch statements should be allowed
  8846. regexp : true, // if the . should not be allowed in regexp literals
  8847. regexdash : true // if unescaped first/last dash (-) inside brackets
  8848. // should be tolerated
  8849. }
  8850. };
  8851. // These are the JSHint options that can take any value
  8852. // (we use this object to detect invalid options)
  8853. exports.val = {
  8854. /**
  8855. * This option lets you set the maximum length of a line.
  8856. *
  8857. * @deprecated JSHint is limiting its scope to issues of code correctness. If
  8858. * you would like to enforce rules relating to code style, check
  8859. * out [the JSCS project](https://github.com/jscs-dev/node-jscs).
  8860. */
  8861. maxlen : false,
  8862. /**
  8863. * This option sets a specific tab width for your code.
  8864. *
  8865. * @deprecated JSHint is limiting its scope to issues of code correctness. If
  8866. * you would like to enforce rules relating to code style, check
  8867. * out [the JSCS project](https://github.com/jscs-dev/node-jscs).
  8868. */
  8869. indent : false,
  8870. /**
  8871. * This options allows you to set the maximum amount of warnings JSHint will
  8872. * produce before giving up. Default is 50.
  8873. */
  8874. maxerr : false,
  8875. /**
  8876. * This option allows you to control which variables JSHint considers to be
  8877. * implicitly defined in the environment. Configure it with an array of
  8878. * string values. Prefixing a variable name with a hyphen (-) character will
  8879. * remove that name from the collection of predefined variables.
  8880. *
  8881. * JSHint will consider variables declared in this way to be read-only.
  8882. *
  8883. * This option cannot be specified in-line; it may only be used via the
  8884. * JavaScript API or from an external configuration file.
  8885. */
  8886. predef : false,
  8887. /**
  8888. * This option can be used to specify a white list of global variables that
  8889. * are not formally defined in the source code. This is most useful when
  8890. * combined with the `undef` option in order to suppress warnings for
  8891. * project-specific global variables.
  8892. *
  8893. * Setting an entry to `true` enables reading and writing to that variable.
  8894. * Setting it to `false` will trigger JSHint to consider that variable
  8895. * read-only.
  8896. *
  8897. * See also the "environment" options: a set of options to be used as short
  8898. * hand for enabling global variables defined in common JavaScript
  8899. * environments.
  8900. *
  8901. * To configure `globals` within an individual file, see [Inline
  8902. * Configuration](http://jshint.com/docs/#inline-configuration).
  8903. */
  8904. globals : false,
  8905. /**
  8906. * This option enforces the consistency of quotation marks used throughout
  8907. * your code. It accepts three values: `true` if you don't want to enforce
  8908. * one particular style but want some consistency, `"single"` if you want to
  8909. * allow only single quotes and `"double"` if you want to allow only double
  8910. * quotes.
  8911. *
  8912. * @deprecated JSHint is limiting its scope to issues of code correctness. If
  8913. * you would like to enforce rules relating to code style, check
  8914. * out [the JSCS project](https://github.com/jscs-dev/node-jscs).
  8915. */
  8916. quotmark : false,
  8917. scope : false,
  8918. /**
  8919. * This option lets you set the max number of statements allowed per function:
  8920. *
  8921. * // jshint maxstatements:4
  8922. *
  8923. * function main() {
  8924. * var i = 0;
  8925. * var j = 0;
  8926. *
  8927. * // Function declarations count as one statement. Their bodies
  8928. * // don't get taken into account for the outer function.
  8929. * function inner() {
  8930. * var i2 = 1;
  8931. * var j2 = 1;
  8932. *
  8933. * return i2 + j2;
  8934. * }
  8935. *
  8936. * j = i + j;
  8937. * return j; // JSHint: Too many statements per function. (5)
  8938. * }
  8939. */
  8940. maxstatements: false,
  8941. /**
  8942. * This option lets you control how nested do you want your blocks to be:
  8943. *
  8944. * // jshint maxdepth:2
  8945. *
  8946. * function main(meaning) {
  8947. * var day = true;
  8948. *
  8949. * if (meaning === 42) {
  8950. * while (day) {
  8951. * shuffle();
  8952. *
  8953. * if (tired) { // JSHint: Blocks are nested too deeply (3).
  8954. * sleep();
  8955. * }
  8956. * }
  8957. * }
  8958. * }
  8959. */
  8960. maxdepth : false,
  8961. /**
  8962. * This option lets you set the max number of formal parameters allowed per
  8963. * function:
  8964. *
  8965. * // jshint maxparams:3
  8966. *
  8967. * function login(request, onSuccess) {
  8968. * // ...
  8969. * }
  8970. *
  8971. * // JSHint: Too many parameters per function (4).
  8972. * function logout(request, isManual, whereAmI, onSuccess) {
  8973. * // ...
  8974. * }
  8975. */
  8976. maxparams : false,
  8977. /**
  8978. * This option lets you control cyclomatic complexity throughout your code.
  8979. * Cyclomatic complexity measures the number of linearly independent paths
  8980. * through a program's source code. Read more about [cyclomatic complexity on
  8981. * Wikipedia](http://en.wikipedia.org/wiki/Cyclomatic_complexity).
  8982. */
  8983. maxcomplexity: false,
  8984. /**
  8985. * This option suppresses warnings about variable shadowing i.e. declaring a
  8986. * variable that had been already declared somewhere in the outer scope.
  8987. *
  8988. * - "inner" - check for variables defined in the same scope only
  8989. * - "outer" - check for variables defined in outer scopes as well
  8990. * - false - same as inner
  8991. * - true - allow variable shadowing
  8992. */
  8993. shadow : false,
  8994. /**
  8995. * This option requires the code to run in ECMAScript 5's strict mode.
  8996. * [Strict mode](https://developer.mozilla.org/en/JavaScript/Strict_mode)
  8997. * is a way to opt in to a restricted variant of JavaScript. Strict mode
  8998. * eliminates some JavaScript pitfalls that didn't cause errors by changing
  8999. * them to produce errors. It also fixes mistakes that made it difficult
  9000. * for the JavaScript engines to perform certain optimizations.
  9001. *
  9002. * - "func" - there must be a `"use strict";` directive at function level
  9003. * - "global" - there must be a `"use strict";` directive at global level
  9004. * - "implied" - lint the code as if there is the `"use strict";` directive
  9005. * - false - disable warnings about strict mode
  9006. * - true - same as `"func"`, but environment options have precedence over
  9007. * this (e.g. `node`, `module`, `browserify` and `phantomjs` can
  9008. * set `strict: global`)
  9009. */
  9010. strict : true,
  9011. /**
  9012. * This option warns when you define and never use your variables. It is very
  9013. * useful for general code cleanup, especially when used in addition to
  9014. * `undef`.
  9015. *
  9016. * // jshint unused:true
  9017. *
  9018. * function test(a, b) {
  9019. * var c, d = 2;
  9020. *
  9021. * return a + d;
  9022. * }
  9023. *
  9024. * test(1, 2);
  9025. *
  9026. * // Line 3: 'b' was defined but never used.
  9027. * // Line 4: 'c' was defined but never used.
  9028. *
  9029. * In addition to that, this option will warn you about unused global
  9030. * variables declared via the `global` directive.
  9031. *
  9032. * This can be set to `vars` to only check for variables, not function
  9033. * parameters, or `strict` to check all variables and parameters. The
  9034. * default (true) behavior is to allow unused parameters that are followed by
  9035. * a used parameter.
  9036. */
  9037. unused : true,
  9038. /**
  9039. * This option prohibits the use of a variable before it was defined.
  9040. * JavaScript has function scope only and, in addition to that, all variables
  9041. * are always moved—or hoisted— to the top of the function. This behavior can
  9042. * lead to some very nasty bugs and that's why it is safer to always use
  9043. * variable only after they have been explicitly defined.
  9044. *
  9045. * Setting this option to "nofunc" will allow function declarations to be
  9046. * ignored.
  9047. *
  9048. * For more in-depth understanding of scoping and hoisting in JavaScript,
  9049. * read [JavaScript Scoping and
  9050. * Hoisting](http://www.adequatelygood.com/2010/2/JavaScript-Scoping-and-Hoisting)
  9051. * by Ben Cherry.
  9052. */
  9053. latedef : false,
  9054. ignore : false, // start/end ignoring lines of code, bypassing the lexer
  9055. // start - start ignoring lines, including the current line
  9056. // end - stop ignoring lines, starting on the next line
  9057. // line - ignore warnings / errors for just a single line
  9058. // (this option does not bypass the lexer)
  9059. ignoreDelimiters: false, // array of start/end delimiters used to ignore
  9060. // certain chunks from code
  9061. /**
  9062. * This option is used to specify the ECMAScript version to which the code
  9063. * must adhere. It can assume one of the following values:
  9064. * - `3` - If you need your program to be executable
  9065. * in older browsers—such as Internet Explorer 6/7/8/9—and other legacy
  9066. * JavaScript environments
  9067. * - `5` - To enable syntax first defined in [the ECMAScript 5.1
  9068. * specification](http://www.ecma-international.org/ecma-262/5.1/index.html).
  9069. * This includes allowing reserved keywords as object properties.
  9070. * - `6` - To tell JSHint that your code uses [ECMAScript
  9071. * 6](http://www.ecma-international.org/ecma-262/6.0/index.html) specific
  9072. * syntax. Note that not all browsers implement them.
  9073. */
  9074. esversion: 5
  9075. };
  9076. // These are JSHint boolean options which are shared with JSLint
  9077. // where the definition in JSHint is opposite JSLint
  9078. exports.inverted = {
  9079. bitwise : true,
  9080. forin : true,
  9081. newcap : true,
  9082. plusplus: true,
  9083. regexp : true,
  9084. undef : true,
  9085. // Inverted and renamed, use JSHint name here
  9086. eqeqeq : true,
  9087. strict : true
  9088. };
  9089. exports.validNames = Object.keys(exports.val)
  9090. .concat(Object.keys(exports.bool.relaxing))
  9091. .concat(Object.keys(exports.bool.enforcing))
  9092. .concat(Object.keys(exports.bool.obsolete))
  9093. .concat(Object.keys(exports.bool.environments));
  9094. // These are JSHint boolean options which are shared with JSLint
  9095. // where the name has been changed but the effect is unchanged
  9096. exports.renamed = {
  9097. eqeq : "eqeqeq",
  9098. windows: "wsh",
  9099. sloppy : "strict"
  9100. };
  9101. exports.removed = {
  9102. nomen: true,
  9103. onevar: true,
  9104. passfail: true,
  9105. white: true,
  9106. gcl: true,
  9107. smarttabs: true,
  9108. trailing: true
  9109. };
  9110. // Add options here which should not be automatically enforced by
  9111. // `enforceall`.
  9112. exports.noenforceall = {
  9113. varstmt: true,
  9114. strict: true
  9115. };
  9116. },{}],"/node_modules/jshint/src/reg.js":[function(_dereq_,module,exports){
  9117. /*
  9118. * Regular expressions. Some of these are stupidly long.
  9119. */
  9120. /*jshint maxlen:1000 */
  9121. "use strict";
  9122. // Unsafe comment or string (ax)
  9123. exports.unsafeString =
  9124. /@cc|<\/?|script|\]\s*\]|<\s*!|&lt/i;
  9125. // Unsafe characters that are silently deleted by one or more browsers (cx)
  9126. exports.unsafeChars =
  9127. /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
  9128. // Characters in strings that need escaping (nx and nxg)
  9129. exports.needEsc =
  9130. /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
  9131. exports.needEscGlobal =
  9132. /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
  9133. // Star slash (lx)
  9134. exports.starSlash = /\*\//;
  9135. // Identifier (ix)
  9136. exports.identifier = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
  9137. // JavaScript URL (jx)
  9138. exports.javascriptURL = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
  9139. // Catches /* falls through */ comments (ft)
  9140. exports.fallsThrough = /^\s*falls?\sthrough\s*$/;
  9141. // very conservative rule (eg: only one space between the start of the comment and the first character)
  9142. // to relax the maxlen option
  9143. exports.maxlenException = /^(?:(?:\/\/|\/\*|\*) ?)?[^ ]+$/;
  9144. },{}],"/node_modules/jshint/src/scope-manager.js":[function(_dereq_,module,exports){
  9145. "use strict";
  9146. var _ = _dereq_("../lodash");
  9147. var events = _dereq_("events");
  9148. // Used to denote membership in lookup tables (a primitive value such as `true`
  9149. // would be silently rejected for the property name "__proto__" in some
  9150. // environments)
  9151. var marker = {};
  9152. /**
  9153. * Creates a scope manager that handles variables and labels, storing usages
  9154. * and resolving when variables are used and undefined
  9155. */
  9156. var scopeManager = function(state, predefined, exported, declared) {
  9157. var _current;
  9158. var _scopeStack = [];
  9159. function _newScope(type) {
  9160. _current = {
  9161. "(labels)": Object.create(null),
  9162. "(usages)": Object.create(null),
  9163. "(breakLabels)": Object.create(null),
  9164. "(parent)": _current,
  9165. "(type)": type,
  9166. "(params)": (type === "functionparams" || type === "catchparams") ? [] : null
  9167. };
  9168. _scopeStack.push(_current);
  9169. }
  9170. _newScope("global");
  9171. _current["(predefined)"] = predefined;
  9172. var _currentFunctBody = _current; // this is the block after the params = function
  9173. var usedPredefinedAndGlobals = Object.create(null);
  9174. var impliedGlobals = Object.create(null);
  9175. var unuseds = [];
  9176. var emitter = new events.EventEmitter();
  9177. function warning(code, token) {
  9178. emitter.emit("warning", {
  9179. code: code,
  9180. token: token,
  9181. data: _.slice(arguments, 2)
  9182. });
  9183. }
  9184. function error(code, token) {
  9185. emitter.emit("warning", {
  9186. code: code,
  9187. token: token,
  9188. data: _.slice(arguments, 2)
  9189. });
  9190. }
  9191. function _setupUsages(labelName) {
  9192. if (!_current["(usages)"][labelName]) {
  9193. _current["(usages)"][labelName] = {
  9194. "(modified)": [],
  9195. "(reassigned)": [],
  9196. "(tokens)": []
  9197. };
  9198. }
  9199. }
  9200. var _getUnusedOption = function(unused_opt) {
  9201. if (unused_opt === undefined) {
  9202. unused_opt = state.option.unused;
  9203. }
  9204. if (unused_opt === true) {
  9205. unused_opt = "last-param";
  9206. }
  9207. return unused_opt;
  9208. };
  9209. var _warnUnused = function(name, tkn, type, unused_opt) {
  9210. var line = tkn.line;
  9211. var chr = tkn.from;
  9212. var raw_name = tkn.raw_text || name;
  9213. unused_opt = _getUnusedOption(unused_opt);
  9214. var warnable_types = {
  9215. "vars": ["var"],
  9216. "last-param": ["var", "param"],
  9217. "strict": ["var", "param", "last-param"]
  9218. };
  9219. if (unused_opt) {
  9220. if (warnable_types[unused_opt] && warnable_types[unused_opt].indexOf(type) !== -1) {
  9221. warning("W098", { line: line, from: chr }, raw_name);
  9222. }
  9223. }
  9224. // inconsistent - see gh-1894
  9225. if (unused_opt || type === "var") {
  9226. unuseds.push({
  9227. name: name,
  9228. line: line,
  9229. character: chr
  9230. });
  9231. }
  9232. };
  9233. /**
  9234. * Checks the current scope for unused identifiers
  9235. */
  9236. function _checkForUnused() {
  9237. // function params are handled specially
  9238. // assume that parameters are the only thing declared in the param scope
  9239. if (_current["(type)"] === "functionparams") {
  9240. _checkParams();
  9241. return;
  9242. }
  9243. var curentLabels = _current["(labels)"];
  9244. for (var labelName in curentLabels) {
  9245. if (curentLabels[labelName]) {
  9246. if (curentLabels[labelName]["(type)"] !== "exception" &&
  9247. curentLabels[labelName]["(unused)"]) {
  9248. _warnUnused(labelName, curentLabels[labelName]["(token)"], "var");
  9249. }
  9250. }
  9251. }
  9252. }
  9253. /**
  9254. * Checks the current scope for unused parameters
  9255. * Must be called in a function parameter scope
  9256. */
  9257. function _checkParams() {
  9258. var params = _current["(params)"];
  9259. if (!params) {
  9260. return;
  9261. }
  9262. var param = params.pop();
  9263. var unused_opt;
  9264. while (param) {
  9265. var label = _current["(labels)"][param];
  9266. unused_opt = _getUnusedOption(state.funct["(unusedOption)"]);
  9267. // 'undefined' is a special case for (function(window, undefined) { ... })();
  9268. // patterns.
  9269. if (param === "undefined")
  9270. return;
  9271. if (label["(unused)"]) {
  9272. _warnUnused(param, label["(token)"], "param", state.funct["(unusedOption)"]);
  9273. } else if (unused_opt === "last-param") {
  9274. return;
  9275. }
  9276. param = params.pop();
  9277. }
  9278. }
  9279. /**
  9280. * Finds the relevant label's scope, searching from nearest outwards
  9281. * @returns {Object} the scope the label was found in
  9282. */
  9283. function _getLabel(labelName) {
  9284. for (var i = _scopeStack.length - 1 ; i >= 0; --i) {
  9285. var scopeLabels = _scopeStack[i]["(labels)"];
  9286. if (scopeLabels[labelName]) {
  9287. return scopeLabels;
  9288. }
  9289. }
  9290. }
  9291. function usedSoFarInCurrentFunction(labelName) {
  9292. // used so far in this whole function and any sub functions
  9293. for (var i = _scopeStack.length - 1; i >= 0; i--) {
  9294. var current = _scopeStack[i];
  9295. if (current["(usages)"][labelName]) {
  9296. return current["(usages)"][labelName];
  9297. }
  9298. if (current === _currentFunctBody) {
  9299. break;
  9300. }
  9301. }
  9302. return false;
  9303. }
  9304. function _checkOuterShadow(labelName, token) {
  9305. // only check if shadow is outer
  9306. if (state.option.shadow !== "outer") {
  9307. return;
  9308. }
  9309. var isGlobal = _currentFunctBody["(type)"] === "global",
  9310. isNewFunction = _current["(type)"] === "functionparams";
  9311. var outsideCurrentFunction = !isGlobal;
  9312. for (var i = 0; i < _scopeStack.length; i++) {
  9313. var stackItem = _scopeStack[i];
  9314. if (!isNewFunction && _scopeStack[i + 1] === _currentFunctBody) {
  9315. outsideCurrentFunction = false;
  9316. }
  9317. if (outsideCurrentFunction && stackItem["(labels)"][labelName]) {
  9318. warning("W123", token, labelName);
  9319. }
  9320. if (stackItem["(breakLabels)"][labelName]) {
  9321. warning("W123", token, labelName);
  9322. }
  9323. }
  9324. }
  9325. function _latedefWarning(type, labelName, token) {
  9326. if (state.option.latedef) {
  9327. // if either latedef is strict and this is a function
  9328. // or this is not a function
  9329. if ((state.option.latedef === true && type === "function") ||
  9330. type !== "function") {
  9331. warning("W003", token, labelName);
  9332. }
  9333. }
  9334. }
  9335. var scopeManagerInst = {
  9336. on: function(names, listener) {
  9337. names.split(" ").forEach(function(name) {
  9338. emitter.on(name, listener);
  9339. });
  9340. },
  9341. isPredefined: function(labelName) {
  9342. return !this.has(labelName) && _.has(_scopeStack[0]["(predefined)"], labelName);
  9343. },
  9344. /**
  9345. * Tell the manager we are entering a new block of code
  9346. * @param {string} [type] - The type of the block. Valid values are
  9347. * "functionparams", "catchparams" and
  9348. * "functionouter"
  9349. */
  9350. stack: function(type) {
  9351. var previousScope = _current;
  9352. _newScope(type);
  9353. if (!type && previousScope["(type)"] === "functionparams") {
  9354. _current["(isFuncBody)"] = true;
  9355. _current["(context)"] = _currentFunctBody;
  9356. _currentFunctBody = _current;
  9357. }
  9358. },
  9359. unstack: function() {
  9360. // jshint proto: true
  9361. var subScope = _scopeStack.length > 1 ? _scopeStack[_scopeStack.length - 2] : null;
  9362. var isUnstackingFunctionBody = _current === _currentFunctBody,
  9363. isUnstackingFunctionParams = _current["(type)"] === "functionparams",
  9364. isUnstackingFunctionOuter = _current["(type)"] === "functionouter";
  9365. var i, j;
  9366. var currentUsages = _current["(usages)"];
  9367. var currentLabels = _current["(labels)"];
  9368. var usedLabelNameList = Object.keys(currentUsages);
  9369. if (currentUsages.__proto__ && usedLabelNameList.indexOf("__proto__") === -1) {
  9370. usedLabelNameList.push("__proto__");
  9371. }
  9372. for (i = 0; i < usedLabelNameList.length; i++) {
  9373. var usedLabelName = usedLabelNameList[i];
  9374. var usage = currentUsages[usedLabelName];
  9375. var usedLabel = currentLabels[usedLabelName];
  9376. if (usedLabel) {
  9377. var usedLabelType = usedLabel["(type)"];
  9378. if (usedLabel["(useOutsideOfScope)"] && !state.option.funcscope) {
  9379. var usedTokens = usage["(tokens)"];
  9380. if (usedTokens) {
  9381. for (j = 0; j < usedTokens.length; j++) {
  9382. // Keep the consistency of https://github.com/jshint/jshint/issues/2409
  9383. if (usedLabel["(function)"] === usedTokens[j]["(function)"]) {
  9384. error("W038", usedTokens[j], usedLabelName);
  9385. }
  9386. }
  9387. }
  9388. }
  9389. // mark the label used
  9390. _current["(labels)"][usedLabelName]["(unused)"] = false;
  9391. // check for modifying a const
  9392. if (usedLabelType === "const" && usage["(modified)"]) {
  9393. for (j = 0; j < usage["(modified)"].length; j++) {
  9394. error("E013", usage["(modified)"][j], usedLabelName);
  9395. }
  9396. }
  9397. // check for re-assigning a function declaration
  9398. if ((usedLabelType === "function" || usedLabelType === "class") &&
  9399. usage["(reassigned)"]) {
  9400. for (j = 0; j < usage["(reassigned)"].length; j++) {
  9401. error("W021", usage["(reassigned)"][j], usedLabelName, usedLabelType);
  9402. }
  9403. }
  9404. continue;
  9405. }
  9406. if (isUnstackingFunctionOuter) {
  9407. state.funct["(isCapturing)"] = true;
  9408. }
  9409. if (subScope) {
  9410. // not exiting the global scope, so copy the usage down in case its an out of scope usage
  9411. if (!subScope["(usages)"][usedLabelName]) {
  9412. subScope["(usages)"][usedLabelName] = usage;
  9413. if (isUnstackingFunctionBody) {
  9414. subScope["(usages)"][usedLabelName]["(onlyUsedSubFunction)"] = true;
  9415. }
  9416. } else {
  9417. var subScopeUsage = subScope["(usages)"][usedLabelName];
  9418. subScopeUsage["(modified)"] = subScopeUsage["(modified)"].concat(usage["(modified)"]);
  9419. subScopeUsage["(tokens)"] = subScopeUsage["(tokens)"].concat(usage["(tokens)"]);
  9420. subScopeUsage["(reassigned)"] =
  9421. subScopeUsage["(reassigned)"].concat(usage["(reassigned)"]);
  9422. subScopeUsage["(onlyUsedSubFunction)"] = false;
  9423. }
  9424. } else {
  9425. // this is exiting global scope, so we finalise everything here - we are at the end of the file
  9426. if (typeof _current["(predefined)"][usedLabelName] === "boolean") {
  9427. // remove the declared token, so we know it is used
  9428. delete declared[usedLabelName];
  9429. // note it as used so it can be reported
  9430. usedPredefinedAndGlobals[usedLabelName] = marker;
  9431. // check for re-assigning a read-only (set to false) predefined
  9432. if (_current["(predefined)"][usedLabelName] === false && usage["(reassigned)"]) {
  9433. for (j = 0; j < usage["(reassigned)"].length; j++) {
  9434. warning("W020", usage["(reassigned)"][j]);
  9435. }
  9436. }
  9437. }
  9438. else {
  9439. // label usage is not predefined and we have not found a declaration
  9440. // so report as undeclared
  9441. if (usage["(tokens)"]) {
  9442. for (j = 0; j < usage["(tokens)"].length; j++) {
  9443. var undefinedToken = usage["(tokens)"][j];
  9444. // if its not a forgiven undefined (e.g. typof x)
  9445. if (!undefinedToken.forgiveUndef) {
  9446. // if undef is on and undef was on when the token was defined
  9447. if (state.option.undef && !undefinedToken.ignoreUndef) {
  9448. warning("W117", undefinedToken, usedLabelName);
  9449. }
  9450. if (impliedGlobals[usedLabelName]) {
  9451. impliedGlobals[usedLabelName].line.push(undefinedToken.line);
  9452. } else {
  9453. impliedGlobals[usedLabelName] = {
  9454. name: usedLabelName,
  9455. line: [undefinedToken.line]
  9456. };
  9457. }
  9458. }
  9459. }
  9460. }
  9461. }
  9462. }
  9463. }
  9464. // if exiting the global scope, we can warn about declared globals that haven't been used yet
  9465. if (!subScope) {
  9466. Object.keys(declared)
  9467. .forEach(function(labelNotUsed) {
  9468. _warnUnused(labelNotUsed, declared[labelNotUsed], "var");
  9469. });
  9470. }
  9471. // if we have a sub scope we can copy too and we are still within the function boundary
  9472. if (subScope && !isUnstackingFunctionBody &&
  9473. !isUnstackingFunctionParams && !isUnstackingFunctionOuter) {
  9474. var labelNames = Object.keys(currentLabels);
  9475. for (i = 0; i < labelNames.length; i++) {
  9476. var defLabelName = labelNames[i];
  9477. // if its function scoped and
  9478. // not already defined (caught with shadow, shouldn't also trigger out of scope)
  9479. if (!currentLabels[defLabelName]["(blockscoped)"] &&
  9480. currentLabels[defLabelName]["(type)"] !== "exception" &&
  9481. !this.funct.has(defLabelName, { excludeCurrent: true })) {
  9482. subScope["(labels)"][defLabelName] = currentLabels[defLabelName];
  9483. // we do not warn about out of scope usages in the global scope
  9484. if (_currentFunctBody["(type)"] !== "global") {
  9485. subScope["(labels)"][defLabelName]["(useOutsideOfScope)"] = true;
  9486. }
  9487. delete currentLabels[defLabelName];
  9488. }
  9489. }
  9490. }
  9491. _checkForUnused();
  9492. _scopeStack.pop();
  9493. if (isUnstackingFunctionBody) {
  9494. _currentFunctBody = _scopeStack[_.findLastIndex(_scopeStack, function(scope) {
  9495. // if function or if global (which is at the bottom so it will only return true if we call back)
  9496. return scope["(isFuncBody)"] || scope["(type)"] === "global";
  9497. })];
  9498. }
  9499. _current = subScope;
  9500. },
  9501. /**
  9502. * Add a param to the current scope
  9503. * @param {string} labelName
  9504. * @param {Token} token
  9505. * @param {string} [type="param"] param type
  9506. */
  9507. addParam: function(labelName, token, type) {
  9508. type = type || "param";
  9509. if (type === "exception") {
  9510. // if defined in the current function
  9511. var previouslyDefinedLabelType = this.funct.labeltype(labelName);
  9512. if (previouslyDefinedLabelType && previouslyDefinedLabelType !== "exception") {
  9513. // and has not been used yet in the current function scope
  9514. if (!state.option.node) {
  9515. warning("W002", state.tokens.next, labelName);
  9516. }
  9517. }
  9518. }
  9519. // The variable was declared in the current scope
  9520. if (_.has(_current["(labels)"], labelName)) {
  9521. _current["(labels)"][labelName].duplicated = true;
  9522. // The variable was declared in an outer scope
  9523. } else {
  9524. // if this scope has the variable defined, it's a re-definition error
  9525. _checkOuterShadow(labelName, token, type);
  9526. _current["(labels)"][labelName] = {
  9527. "(type)" : type,
  9528. "(token)": token,
  9529. "(unused)": true };
  9530. _current["(params)"].push(labelName);
  9531. }
  9532. if (_.has(_current["(usages)"], labelName)) {
  9533. var usage = _current["(usages)"][labelName];
  9534. // if its in a sub function it is not necessarily an error, just latedef
  9535. if (usage["(onlyUsedSubFunction)"]) {
  9536. _latedefWarning(type, labelName, token);
  9537. } else {
  9538. // this is a clear illegal usage for block scoped variables
  9539. warning("E056", token, labelName, type);
  9540. }
  9541. }
  9542. },
  9543. validateParams: function() {
  9544. // This method only concerns errors for function parameters
  9545. if (_currentFunctBody["(type)"] === "global") {
  9546. return;
  9547. }
  9548. var isStrict = state.isStrict();
  9549. var currentFunctParamScope = _currentFunctBody["(parent)"];
  9550. if (!currentFunctParamScope["(params)"]) {
  9551. return;
  9552. }
  9553. currentFunctParamScope["(params)"].forEach(function(labelName) {
  9554. var label = currentFunctParamScope["(labels)"][labelName];
  9555. if (label && label.duplicated) {
  9556. if (isStrict) {
  9557. warning("E011", label["(token)"], labelName);
  9558. } else if (state.option.shadow !== true) {
  9559. warning("W004", label["(token)"], labelName);
  9560. }
  9561. }
  9562. });
  9563. },
  9564. getUsedOrDefinedGlobals: function() {
  9565. // jshint proto: true
  9566. var list = Object.keys(usedPredefinedAndGlobals);
  9567. // If `__proto__` is used as a global variable name, its entry in the
  9568. // lookup table may not be enumerated by `Object.keys` (depending on the
  9569. // environment).
  9570. if (usedPredefinedAndGlobals.__proto__ === marker &&
  9571. list.indexOf("__proto__") === -1) {
  9572. list.push("__proto__");
  9573. }
  9574. return list;
  9575. },
  9576. /**
  9577. * Gets an array of implied globals
  9578. * @returns {Array.<{ name: string, line: Array.<number>}>}
  9579. */
  9580. getImpliedGlobals: function() {
  9581. // jshint proto: true
  9582. var values = _.values(impliedGlobals);
  9583. var hasProto = false;
  9584. // If `__proto__` is an implied global variable, its entry in the lookup
  9585. // table may not be enumerated by `_.values` (depending on the
  9586. // environment).
  9587. if (impliedGlobals.__proto__) {
  9588. hasProto = values.some(function(value) {
  9589. return value.name === "__proto__";
  9590. });
  9591. if (!hasProto) {
  9592. values.push(impliedGlobals.__proto__);
  9593. }
  9594. }
  9595. return values;
  9596. },
  9597. /**
  9598. * Returns a list of unused variables
  9599. * @returns {Array}
  9600. */
  9601. getUnuseds: function() {
  9602. return unuseds;
  9603. },
  9604. has: function(labelName) {
  9605. return Boolean(_getLabel(labelName));
  9606. },
  9607. labeltype: function(labelName) {
  9608. // returns a labels type or null if not present
  9609. var scopeLabels = _getLabel(labelName);
  9610. if (scopeLabels) {
  9611. return scopeLabels[labelName]["(type)"];
  9612. }
  9613. return null;
  9614. },
  9615. /**
  9616. * for the exported options, indicating a variable is used outside the file
  9617. */
  9618. addExported: function(labelName) {
  9619. var globalLabels = _scopeStack[0]["(labels)"];
  9620. if (_.has(declared, labelName)) {
  9621. // remove the declared token, so we know it is used
  9622. delete declared[labelName];
  9623. } else if (_.has(globalLabels, labelName)) {
  9624. globalLabels[labelName]["(unused)"] = false;
  9625. } else {
  9626. for (var i = 1; i < _scopeStack.length; i++) {
  9627. var scope = _scopeStack[i];
  9628. // if `scope.(type)` is not defined, it is a block scope
  9629. if (!scope["(type)"]) {
  9630. if (_.has(scope["(labels)"], labelName) &&
  9631. !scope["(labels)"][labelName]["(blockscoped)"]) {
  9632. scope["(labels)"][labelName]["(unused)"] = false;
  9633. return;
  9634. }
  9635. } else {
  9636. break;
  9637. }
  9638. }
  9639. exported[labelName] = true;
  9640. }
  9641. },
  9642. /**
  9643. * Mark an indentifier as es6 module exported
  9644. */
  9645. setExported: function(labelName, token) {
  9646. this.block.use(labelName, token);
  9647. },
  9648. /**
  9649. * adds an indentifier to the relevant current scope and creates warnings/errors as necessary
  9650. * @param {string} labelName
  9651. * @param {Object} opts
  9652. * @param {String} opts.type - the type of the label e.g. "param", "var", "let, "const", "function"
  9653. * @param {Token} opts.token - the token pointing at the declaration
  9654. */
  9655. addlabel: function(labelName, opts) {
  9656. var type = opts.type;
  9657. var token = opts.token;
  9658. var isblockscoped = type === "let" || type === "const" || type === "class";
  9659. var isexported = (isblockscoped ? _current : _currentFunctBody)["(type)"] === "global" &&
  9660. _.has(exported, labelName);
  9661. // outer shadow check (inner is only on non-block scoped)
  9662. _checkOuterShadow(labelName, token, type);
  9663. // if is block scoped (let or const)
  9664. if (isblockscoped) {
  9665. var declaredInCurrentScope = _current["(labels)"][labelName];
  9666. // for block scoped variables, params are seen in the current scope as the root function
  9667. // scope, so check these too.
  9668. if (!declaredInCurrentScope && _current === _currentFunctBody &&
  9669. _current["(type)"] !== "global") {
  9670. declaredInCurrentScope = !!_currentFunctBody["(parent)"]["(labels)"][labelName];
  9671. }
  9672. // if its not already defined (which is an error, so ignore) and is used in TDZ
  9673. if (!declaredInCurrentScope && _current["(usages)"][labelName]) {
  9674. var usage = _current["(usages)"][labelName];
  9675. // if its in a sub function it is not necessarily an error, just latedef
  9676. if (usage["(onlyUsedSubFunction)"]) {
  9677. _latedefWarning(type, labelName, token);
  9678. } else {
  9679. // this is a clear illegal usage for block scoped variables
  9680. warning("E056", token, labelName, type);
  9681. }
  9682. }
  9683. // if this scope has the variable defined, its a re-definition error
  9684. if (declaredInCurrentScope) {
  9685. warning("E011", token, labelName);
  9686. }
  9687. else if (state.option.shadow === "outer") {
  9688. // if shadow is outer, for block scope we want to detect any shadowing within this function
  9689. if (scopeManagerInst.funct.has(labelName)) {
  9690. warning("W004", token, labelName);
  9691. }
  9692. }
  9693. scopeManagerInst.block.add(labelName, type, token, !isexported);
  9694. } else {
  9695. var declaredInCurrentFunctionScope = scopeManagerInst.funct.has(labelName);
  9696. // check for late definition, ignore if already declared
  9697. if (!declaredInCurrentFunctionScope && usedSoFarInCurrentFunction(labelName)) {
  9698. _latedefWarning(type, labelName, token);
  9699. }
  9700. // defining with a var or a function when a block scope variable of the same name
  9701. // is in scope is an error
  9702. if (scopeManagerInst.funct.has(labelName, { onlyBlockscoped: true })) {
  9703. warning("E011", token, labelName);
  9704. } else if (state.option.shadow !== true) {
  9705. // now since we didn't get any block scope variables, test for var/function
  9706. // shadowing
  9707. if (declaredInCurrentFunctionScope && labelName !== "__proto__") {
  9708. // see https://github.com/jshint/jshint/issues/2400
  9709. if (_currentFunctBody["(type)"] !== "global") {
  9710. warning("W004", token, labelName);
  9711. }
  9712. }
  9713. }
  9714. scopeManagerInst.funct.add(labelName, type, token, !isexported);
  9715. if (_currentFunctBody["(type)"] === "global") {
  9716. usedPredefinedAndGlobals[labelName] = marker;
  9717. }
  9718. }
  9719. },
  9720. funct: {
  9721. /**
  9722. * Returns the label type given certain options
  9723. * @param labelName
  9724. * @param {Object=} options
  9725. * @param {Boolean=} options.onlyBlockscoped - only include block scoped labels
  9726. * @param {Boolean=} options.excludeParams - exclude the param scope
  9727. * @param {Boolean=} options.excludeCurrent - exclude the current scope
  9728. * @returns {String}
  9729. */
  9730. labeltype: function(labelName, options) {
  9731. var onlyBlockscoped = options && options.onlyBlockscoped;
  9732. var excludeParams = options && options.excludeParams;
  9733. var currentScopeIndex = _scopeStack.length - (options && options.excludeCurrent ? 2 : 1);
  9734. for (var i = currentScopeIndex; i >= 0; i--) {
  9735. var current = _scopeStack[i];
  9736. if (current["(labels)"][labelName] &&
  9737. (!onlyBlockscoped || current["(labels)"][labelName]["(blockscoped)"])) {
  9738. return current["(labels)"][labelName]["(type)"];
  9739. }
  9740. var scopeCheck = excludeParams ? _scopeStack[ i - 1 ] : current;
  9741. if (scopeCheck && scopeCheck["(type)"] === "functionparams") {
  9742. return null;
  9743. }
  9744. }
  9745. return null;
  9746. },
  9747. /**
  9748. * Returns if a break label exists in the function scope
  9749. * @param {string} labelName
  9750. * @returns {boolean}
  9751. */
  9752. hasBreakLabel: function(labelName) {
  9753. for (var i = _scopeStack.length - 1; i >= 0; i--) {
  9754. var current = _scopeStack[i];
  9755. if (current["(breakLabels)"][labelName]) {
  9756. return true;
  9757. }
  9758. if (current["(type)"] === "functionparams") {
  9759. return false;
  9760. }
  9761. }
  9762. return false;
  9763. },
  9764. /**
  9765. * Returns if the label is in the current function scope
  9766. * See scopeManager.funct.labelType for options
  9767. */
  9768. has: function(labelName, options) {
  9769. return Boolean(this.labeltype(labelName, options));
  9770. },
  9771. /**
  9772. * Adds a new function scoped variable
  9773. * see block.add for block scoped
  9774. */
  9775. add: function(labelName, type, tok, unused) {
  9776. _current["(labels)"][labelName] = {
  9777. "(type)" : type,
  9778. "(token)": tok,
  9779. "(blockscoped)": false,
  9780. "(function)": _currentFunctBody,
  9781. "(unused)": unused };
  9782. }
  9783. },
  9784. block: {
  9785. /**
  9786. * is the current block global?
  9787. * @returns Boolean
  9788. */
  9789. isGlobal: function() {
  9790. return _current["(type)"] === "global";
  9791. },
  9792. use: function(labelName, token) {
  9793. // if resolves to current function params, then do not store usage just resolve
  9794. // this is because function(a) { var a; a = a; } will resolve to the param, not
  9795. // to the unset var
  9796. // first check the param is used
  9797. var paramScope = _currentFunctBody["(parent)"];
  9798. if (paramScope && paramScope["(labels)"][labelName] &&
  9799. paramScope["(labels)"][labelName]["(type)"] === "param") {
  9800. // then check its not declared by a block scope variable
  9801. if (!scopeManagerInst.funct.has(labelName,
  9802. { excludeParams: true, onlyBlockscoped: true })) {
  9803. paramScope["(labels)"][labelName]["(unused)"] = false;
  9804. }
  9805. }
  9806. if (token && (state.ignored.W117 || state.option.undef === false)) {
  9807. token.ignoreUndef = true;
  9808. }
  9809. _setupUsages(labelName);
  9810. if (token) {
  9811. token["(function)"] = _currentFunctBody;
  9812. _current["(usages)"][labelName]["(tokens)"].push(token);
  9813. }
  9814. },
  9815. reassign: function(labelName, token) {
  9816. this.modify(labelName, token);
  9817. _current["(usages)"][labelName]["(reassigned)"].push(token);
  9818. },
  9819. modify: function(labelName, token) {
  9820. _setupUsages(labelName);
  9821. _current["(usages)"][labelName]["(modified)"].push(token);
  9822. },
  9823. /**
  9824. * Adds a new variable
  9825. */
  9826. add: function(labelName, type, tok, unused) {
  9827. _current["(labels)"][labelName] = {
  9828. "(type)" : type,
  9829. "(token)": tok,
  9830. "(blockscoped)": true,
  9831. "(unused)": unused };
  9832. },
  9833. addBreakLabel: function(labelName, opts) {
  9834. var token = opts.token;
  9835. if (scopeManagerInst.funct.hasBreakLabel(labelName)) {
  9836. warning("E011", token, labelName);
  9837. }
  9838. else if (state.option.shadow === "outer") {
  9839. if (scopeManagerInst.funct.has(labelName)) {
  9840. warning("W004", token, labelName);
  9841. } else {
  9842. _checkOuterShadow(labelName, token);
  9843. }
  9844. }
  9845. _current["(breakLabels)"][labelName] = token;
  9846. }
  9847. }
  9848. };
  9849. return scopeManagerInst;
  9850. };
  9851. module.exports = scopeManager;
  9852. },{"../lodash":"/node_modules/jshint/lodash.js","events":"/node_modules/browserify/node_modules/events/events.js"}],"/node_modules/jshint/src/state.js":[function(_dereq_,module,exports){
  9853. "use strict";
  9854. var NameStack = _dereq_("./name-stack.js");
  9855. var state = {
  9856. syntax: {},
  9857. /**
  9858. * Determine if the code currently being linted is strict mode code.
  9859. *
  9860. * @returns {boolean}
  9861. */
  9862. isStrict: function() {
  9863. return this.directive["use strict"] || this.inClassBody ||
  9864. this.option.module || this.option.strict === "implied";
  9865. },
  9866. // Assumption: chronologically ES3 < ES5 < ES6 < Moz
  9867. inMoz: function() {
  9868. return this.option.moz;
  9869. },
  9870. /**
  9871. * @param {boolean} strict - When `true`, only consider ES6 when in
  9872. * "esversion: 6" code and *not* in "moz".
  9873. */
  9874. inES6: function() {
  9875. return this.option.moz || this.option.esversion >= 6;
  9876. },
  9877. /**
  9878. * @param {boolean} strict - When `true`, return `true` only when
  9879. * esversion is exactly 5
  9880. */
  9881. inES5: function(strict) {
  9882. if (strict) {
  9883. return (!this.option.esversion || this.option.esversion === 5) && !this.option.moz;
  9884. }
  9885. return !this.option.esversion || this.option.esversion >= 5 || this.option.moz;
  9886. },
  9887. reset: function() {
  9888. this.tokens = {
  9889. prev: null,
  9890. next: null,
  9891. curr: null
  9892. };
  9893. this.option = {};
  9894. this.funct = null;
  9895. this.ignored = {};
  9896. this.directive = {};
  9897. this.jsonMode = false;
  9898. this.jsonWarnings = [];
  9899. this.lines = [];
  9900. this.tab = "";
  9901. this.cache = {}; // Node.JS doesn't have Map. Sniff.
  9902. this.ignoredLines = {};
  9903. this.forinifcheckneeded = false;
  9904. this.nameStack = new NameStack();
  9905. this.inClassBody = false;
  9906. }
  9907. };
  9908. exports.state = state;
  9909. },{"./name-stack.js":"/node_modules/jshint/src/name-stack.js"}],"/node_modules/jshint/src/style.js":[function(_dereq_,module,exports){
  9910. "use strict";
  9911. exports.register = function(linter) {
  9912. // Check for properties named __proto__. This special property was
  9913. // deprecated and then re-introduced for ES6.
  9914. linter.on("Identifier", function style_scanProto(data) {
  9915. if (linter.getOption("proto")) {
  9916. return;
  9917. }
  9918. if (data.name === "__proto__") {
  9919. linter.warn("W103", {
  9920. line: data.line,
  9921. char: data.char,
  9922. data: [ data.name, "6" ]
  9923. });
  9924. }
  9925. });
  9926. // Check for properties named __iterator__. This is a special property
  9927. // available only in browsers with JavaScript 1.7 implementation, but
  9928. // it is deprecated for ES6
  9929. linter.on("Identifier", function style_scanIterator(data) {
  9930. if (linter.getOption("iterator")) {
  9931. return;
  9932. }
  9933. if (data.name === "__iterator__") {
  9934. linter.warn("W103", {
  9935. line: data.line,
  9936. char: data.char,
  9937. data: [ data.name ]
  9938. });
  9939. }
  9940. });
  9941. // Check that all identifiers are using camelCase notation.
  9942. // Exceptions: names like MY_VAR and _myVar.
  9943. linter.on("Identifier", function style_scanCamelCase(data) {
  9944. if (!linter.getOption("camelcase")) {
  9945. return;
  9946. }
  9947. if (data.name.replace(/^_+|_+$/g, "").indexOf("_") > -1 && !data.name.match(/^[A-Z0-9_]*$/)) {
  9948. linter.warn("W106", {
  9949. line: data.line,
  9950. char: data.from,
  9951. data: [ data.name ]
  9952. });
  9953. }
  9954. });
  9955. // Enforce consistency in style of quoting.
  9956. linter.on("String", function style_scanQuotes(data) {
  9957. var quotmark = linter.getOption("quotmark");
  9958. var code;
  9959. if (!quotmark) {
  9960. return;
  9961. }
  9962. // If quotmark is set to 'single' warn about all double-quotes.
  9963. if (quotmark === "single" && data.quote !== "'") {
  9964. code = "W109";
  9965. }
  9966. // If quotmark is set to 'double' warn about all single-quotes.
  9967. if (quotmark === "double" && data.quote !== "\"") {
  9968. code = "W108";
  9969. }
  9970. // If quotmark is set to true, remember the first quotation style
  9971. // and then warn about all others.
  9972. if (quotmark === true) {
  9973. if (!linter.getCache("quotmark")) {
  9974. linter.setCache("quotmark", data.quote);
  9975. }
  9976. if (linter.getCache("quotmark") !== data.quote) {
  9977. code = "W110";
  9978. }
  9979. }
  9980. if (code) {
  9981. linter.warn(code, {
  9982. line: data.line,
  9983. char: data.char,
  9984. });
  9985. }
  9986. });
  9987. linter.on("Number", function style_scanNumbers(data) {
  9988. if (data.value.charAt(0) === ".") {
  9989. // Warn about a leading decimal point.
  9990. linter.warn("W008", {
  9991. line: data.line,
  9992. char: data.char,
  9993. data: [ data.value ]
  9994. });
  9995. }
  9996. if (data.value.substr(data.value.length - 1) === ".") {
  9997. // Warn about a trailing decimal point.
  9998. linter.warn("W047", {
  9999. line: data.line,
  10000. char: data.char,
  10001. data: [ data.value ]
  10002. });
  10003. }
  10004. if (/^00+/.test(data.value)) {
  10005. // Multiple leading zeroes.
  10006. linter.warn("W046", {
  10007. line: data.line,
  10008. char: data.char,
  10009. data: [ data.value ]
  10010. });
  10011. }
  10012. });
  10013. // Warn about script URLs.
  10014. linter.on("String", function style_scanJavaScriptURLs(data) {
  10015. var re = /^(?:javascript|jscript|ecmascript|vbscript|livescript)\s*:/i;
  10016. if (linter.getOption("scripturl")) {
  10017. return;
  10018. }
  10019. if (re.test(data.value)) {
  10020. linter.warn("W107", {
  10021. line: data.line,
  10022. char: data.char
  10023. });
  10024. }
  10025. });
  10026. };
  10027. },{}],"/node_modules/jshint/src/vars.js":[function(_dereq_,module,exports){
  10028. // jshint -W001
  10029. "use strict";
  10030. // Identifiers provided by the ECMAScript standard.
  10031. exports.reservedVars = {
  10032. arguments : false,
  10033. NaN : false
  10034. };
  10035. exports.ecmaIdentifiers = {
  10036. 3: {
  10037. Array : false,
  10038. Boolean : false,
  10039. Date : false,
  10040. decodeURI : false,
  10041. decodeURIComponent : false,
  10042. encodeURI : false,
  10043. encodeURIComponent : false,
  10044. Error : false,
  10045. "eval" : false,
  10046. EvalError : false,
  10047. Function : false,
  10048. hasOwnProperty : false,
  10049. isFinite : false,
  10050. isNaN : false,
  10051. Math : false,
  10052. Number : false,
  10053. Object : false,
  10054. parseInt : false,
  10055. parseFloat : false,
  10056. RangeError : false,
  10057. ReferenceError : false,
  10058. RegExp : false,
  10059. String : false,
  10060. SyntaxError : false,
  10061. TypeError : false,
  10062. URIError : false
  10063. },
  10064. 5: {
  10065. JSON : false
  10066. },
  10067. 6: {
  10068. Map : false,
  10069. Promise : false,
  10070. Proxy : false,
  10071. Reflect : false,
  10072. Set : false,
  10073. Symbol : false,
  10074. WeakMap : false,
  10075. WeakSet : false
  10076. }
  10077. };
  10078. // Global variables commonly provided by a web browser environment.
  10079. exports.browser = {
  10080. Audio : false,
  10081. Blob : false,
  10082. addEventListener : false,
  10083. applicationCache : false,
  10084. atob : false,
  10085. blur : false,
  10086. btoa : false,
  10087. cancelAnimationFrame : false,
  10088. CanvasGradient : false,
  10089. CanvasPattern : false,
  10090. CanvasRenderingContext2D: false,
  10091. CSS : false,
  10092. clearInterval : false,
  10093. clearTimeout : false,
  10094. close : false,
  10095. closed : false,
  10096. Comment : false,
  10097. CustomEvent : false,
  10098. DOMParser : false,
  10099. defaultStatus : false,
  10100. Document : false,
  10101. document : false,
  10102. DocumentFragment : false,
  10103. Element : false,
  10104. ElementTimeControl : false,
  10105. Event : false,
  10106. event : false,
  10107. fetch : false,
  10108. FileReader : false,
  10109. FormData : false,
  10110. focus : false,
  10111. frames : false,
  10112. getComputedStyle : false,
  10113. HTMLElement : false,
  10114. HTMLAnchorElement : false,
  10115. HTMLBaseElement : false,
  10116. HTMLBlockquoteElement: false,
  10117. HTMLBodyElement : false,
  10118. HTMLBRElement : false,
  10119. HTMLButtonElement : false,
  10120. HTMLCanvasElement : false,
  10121. HTMLCollection : false,
  10122. HTMLDirectoryElement : false,
  10123. HTMLDivElement : false,
  10124. HTMLDListElement : false,
  10125. HTMLFieldSetElement : false,
  10126. HTMLFontElement : false,
  10127. HTMLFormElement : false,
  10128. HTMLFrameElement : false,
  10129. HTMLFrameSetElement : false,
  10130. HTMLHeadElement : false,
  10131. HTMLHeadingElement : false,
  10132. HTMLHRElement : false,
  10133. HTMLHtmlElement : false,
  10134. HTMLIFrameElement : false,
  10135. HTMLImageElement : false,
  10136. HTMLInputElement : false,
  10137. HTMLIsIndexElement : false,
  10138. HTMLLabelElement : false,
  10139. HTMLLayerElement : false,
  10140. HTMLLegendElement : false,
  10141. HTMLLIElement : false,
  10142. HTMLLinkElement : false,
  10143. HTMLMapElement : false,
  10144. HTMLMenuElement : false,
  10145. HTMLMetaElement : false,
  10146. HTMLModElement : false,
  10147. HTMLObjectElement : false,
  10148. HTMLOListElement : false,
  10149. HTMLOptGroupElement : false,
  10150. HTMLOptionElement : false,
  10151. HTMLParagraphElement : false,
  10152. HTMLParamElement : false,
  10153. HTMLPreElement : false,
  10154. HTMLQuoteElement : false,
  10155. HTMLScriptElement : false,
  10156. HTMLSelectElement : false,
  10157. HTMLStyleElement : false,
  10158. HTMLTableCaptionElement: false,
  10159. HTMLTableCellElement : false,
  10160. HTMLTableColElement : false,
  10161. HTMLTableElement : false,
  10162. HTMLTableRowElement : false,
  10163. HTMLTableSectionElement: false,
  10164. HTMLTemplateElement : false,
  10165. HTMLTextAreaElement : false,
  10166. HTMLTitleElement : false,
  10167. HTMLUListElement : false,
  10168. HTMLVideoElement : false,
  10169. history : false,
  10170. Image : false,
  10171. Intl : false,
  10172. length : false,
  10173. localStorage : false,
  10174. location : false,
  10175. matchMedia : false,
  10176. MessageChannel : false,
  10177. MessageEvent : false,
  10178. MessagePort : false,
  10179. MouseEvent : false,
  10180. moveBy : false,
  10181. moveTo : false,
  10182. MutationObserver : false,
  10183. name : false,
  10184. Node : false,
  10185. NodeFilter : false,
  10186. NodeList : false,
  10187. Notification : false,
  10188. navigator : false,
  10189. onbeforeunload : true,
  10190. onblur : true,
  10191. onerror : true,
  10192. onfocus : true,
  10193. onload : true,
  10194. onresize : true,
  10195. onunload : true,
  10196. open : false,
  10197. openDatabase : false,
  10198. opener : false,
  10199. Option : false,
  10200. parent : false,
  10201. performance : false,
  10202. print : false,
  10203. Range : false,
  10204. requestAnimationFrame : false,
  10205. removeEventListener : false,
  10206. resizeBy : false,
  10207. resizeTo : false,
  10208. screen : false,
  10209. scroll : false,
  10210. scrollBy : false,
  10211. scrollTo : false,
  10212. sessionStorage : false,
  10213. setInterval : false,
  10214. setTimeout : false,
  10215. SharedWorker : false,
  10216. status : false,
  10217. SVGAElement : false,
  10218. SVGAltGlyphDefElement: false,
  10219. SVGAltGlyphElement : false,
  10220. SVGAltGlyphItemElement: false,
  10221. SVGAngle : false,
  10222. SVGAnimateColorElement: false,
  10223. SVGAnimateElement : false,
  10224. SVGAnimateMotionElement: false,
  10225. SVGAnimateTransformElement: false,
  10226. SVGAnimatedAngle : false,
  10227. SVGAnimatedBoolean : false,
  10228. SVGAnimatedEnumeration: false,
  10229. SVGAnimatedInteger : false,
  10230. SVGAnimatedLength : false,
  10231. SVGAnimatedLengthList: false,
  10232. SVGAnimatedNumber : false,
  10233. SVGAnimatedNumberList: false,
  10234. SVGAnimatedPathData : false,
  10235. SVGAnimatedPoints : false,
  10236. SVGAnimatedPreserveAspectRatio: false,
  10237. SVGAnimatedRect : false,
  10238. SVGAnimatedString : false,
  10239. SVGAnimatedTransformList: false,
  10240. SVGAnimationElement : false,
  10241. SVGCSSRule : false,
  10242. SVGCircleElement : false,
  10243. SVGClipPathElement : false,
  10244. SVGColor : false,
  10245. SVGColorProfileElement: false,
  10246. SVGColorProfileRule : false,
  10247. SVGComponentTransferFunctionElement: false,
  10248. SVGCursorElement : false,
  10249. SVGDefsElement : false,
  10250. SVGDescElement : false,
  10251. SVGDocument : false,
  10252. SVGElement : false,
  10253. SVGElementInstance : false,
  10254. SVGElementInstanceList: false,
  10255. SVGEllipseElement : false,
  10256. SVGExternalResourcesRequired: false,
  10257. SVGFEBlendElement : false,
  10258. SVGFEColorMatrixElement: false,
  10259. SVGFEComponentTransferElement: false,
  10260. SVGFECompositeElement: false,
  10261. SVGFEConvolveMatrixElement: false,
  10262. SVGFEDiffuseLightingElement: false,
  10263. SVGFEDisplacementMapElement: false,
  10264. SVGFEDistantLightElement: false,
  10265. SVGFEFloodElement : false,
  10266. SVGFEFuncAElement : false,
  10267. SVGFEFuncBElement : false,
  10268. SVGFEFuncGElement : false,
  10269. SVGFEFuncRElement : false,
  10270. SVGFEGaussianBlurElement: false,
  10271. SVGFEImageElement : false,
  10272. SVGFEMergeElement : false,
  10273. SVGFEMergeNodeElement: false,
  10274. SVGFEMorphologyElement: false,
  10275. SVGFEOffsetElement : false,
  10276. SVGFEPointLightElement: false,
  10277. SVGFESpecularLightingElement: false,
  10278. SVGFESpotLightElement: false,
  10279. SVGFETileElement : false,
  10280. SVGFETurbulenceElement: false,
  10281. SVGFilterElement : false,
  10282. SVGFilterPrimitiveStandardAttributes: false,
  10283. SVGFitToViewBox : false,
  10284. SVGFontElement : false,
  10285. SVGFontFaceElement : false,
  10286. SVGFontFaceFormatElement: false,
  10287. SVGFontFaceNameElement: false,
  10288. SVGFontFaceSrcElement: false,
  10289. SVGFontFaceUriElement: false,
  10290. SVGForeignObjectElement: false,
  10291. SVGGElement : false,
  10292. SVGGlyphElement : false,
  10293. SVGGlyphRefElement : false,
  10294. SVGGradientElement : false,
  10295. SVGHKernElement : false,
  10296. SVGICCColor : false,
  10297. SVGImageElement : false,
  10298. SVGLangSpace : false,
  10299. SVGLength : false,
  10300. SVGLengthList : false,
  10301. SVGLineElement : false,
  10302. SVGLinearGradientElement: false,
  10303. SVGLocatable : false,
  10304. SVGMPathElement : false,
  10305. SVGMarkerElement : false,
  10306. SVGMaskElement : false,
  10307. SVGMatrix : false,
  10308. SVGMetadataElement : false,
  10309. SVGMissingGlyphElement: false,
  10310. SVGNumber : false,
  10311. SVGNumberList : false,
  10312. SVGPaint : false,
  10313. SVGPathElement : false,
  10314. SVGPathSeg : false,
  10315. SVGPathSegArcAbs : false,
  10316. SVGPathSegArcRel : false,
  10317. SVGPathSegClosePath : false,
  10318. SVGPathSegCurvetoCubicAbs: false,
  10319. SVGPathSegCurvetoCubicRel: false,
  10320. SVGPathSegCurvetoCubicSmoothAbs: false,
  10321. SVGPathSegCurvetoCubicSmoothRel: false,
  10322. SVGPathSegCurvetoQuadraticAbs: false,
  10323. SVGPathSegCurvetoQuadraticRel: false,
  10324. SVGPathSegCurvetoQuadraticSmoothAbs: false,
  10325. SVGPathSegCurvetoQuadraticSmoothRel: false,
  10326. SVGPathSegLinetoAbs : false,
  10327. SVGPathSegLinetoHorizontalAbs: false,
  10328. SVGPathSegLinetoHorizontalRel: false,
  10329. SVGPathSegLinetoRel : false,
  10330. SVGPathSegLinetoVerticalAbs: false,
  10331. SVGPathSegLinetoVerticalRel: false,
  10332. SVGPathSegList : false,
  10333. SVGPathSegMovetoAbs : false,
  10334. SVGPathSegMovetoRel : false,
  10335. SVGPatternElement : false,
  10336. SVGPoint : false,
  10337. SVGPointList : false,
  10338. SVGPolygonElement : false,
  10339. SVGPolylineElement : false,
  10340. SVGPreserveAspectRatio: false,
  10341. SVGRadialGradientElement: false,
  10342. SVGRect : false,
  10343. SVGRectElement : false,
  10344. SVGRenderingIntent : false,
  10345. SVGSVGElement : false,
  10346. SVGScriptElement : false,
  10347. SVGSetElement : false,
  10348. SVGStopElement : false,
  10349. SVGStringList : false,
  10350. SVGStylable : false,
  10351. SVGStyleElement : false,
  10352. SVGSwitchElement : false,
  10353. SVGSymbolElement : false,
  10354. SVGTRefElement : false,
  10355. SVGTSpanElement : false,
  10356. SVGTests : false,
  10357. SVGTextContentElement: false,
  10358. SVGTextElement : false,
  10359. SVGTextPathElement : false,
  10360. SVGTextPositioningElement: false,
  10361. SVGTitleElement : false,
  10362. SVGTransform : false,
  10363. SVGTransformList : false,
  10364. SVGTransformable : false,
  10365. SVGURIReference : false,
  10366. SVGUnitTypes : false,
  10367. SVGUseElement : false,
  10368. SVGVKernElement : false,
  10369. SVGViewElement : false,
  10370. SVGViewSpec : false,
  10371. SVGZoomAndPan : false,
  10372. Text : false,
  10373. TextDecoder : false,
  10374. TextEncoder : false,
  10375. TimeEvent : false,
  10376. top : false,
  10377. URL : false,
  10378. WebGLActiveInfo : false,
  10379. WebGLBuffer : false,
  10380. WebGLContextEvent : false,
  10381. WebGLFramebuffer : false,
  10382. WebGLProgram : false,
  10383. WebGLRenderbuffer : false,
  10384. WebGLRenderingContext: false,
  10385. WebGLShader : false,
  10386. WebGLShaderPrecisionFormat: false,
  10387. WebGLTexture : false,
  10388. WebGLUniformLocation : false,
  10389. WebSocket : false,
  10390. window : false,
  10391. Window : false,
  10392. Worker : false,
  10393. XDomainRequest : false,
  10394. XMLHttpRequest : false,
  10395. XMLSerializer : false,
  10396. XPathEvaluator : false,
  10397. XPathException : false,
  10398. XPathExpression : false,
  10399. XPathNamespace : false,
  10400. XPathNSResolver : false,
  10401. XPathResult : false
  10402. };
  10403. exports.devel = {
  10404. alert : false,
  10405. confirm: false,
  10406. console: false,
  10407. Debug : false,
  10408. opera : false,
  10409. prompt : false
  10410. };
  10411. exports.worker = {
  10412. importScripts : true,
  10413. postMessage : true,
  10414. self : true,
  10415. FileReaderSync : true
  10416. };
  10417. // Widely adopted global names that are not part of ECMAScript standard
  10418. exports.nonstandard = {
  10419. escape : false,
  10420. unescape: false
  10421. };
  10422. // Globals provided by popular JavaScript environments.
  10423. exports.couch = {
  10424. "require" : false,
  10425. respond : false,
  10426. getRow : false,
  10427. emit : false,
  10428. send : false,
  10429. start : false,
  10430. sum : false,
  10431. log : false,
  10432. exports : false,
  10433. module : false,
  10434. provides : false
  10435. };
  10436. exports.node = {
  10437. __filename : false,
  10438. __dirname : false,
  10439. GLOBAL : false,
  10440. global : false,
  10441. module : false,
  10442. require : false,
  10443. // These globals are writeable because Node allows the following
  10444. // usage pattern: var Buffer = require("buffer").Buffer;
  10445. Buffer : true,
  10446. console : true,
  10447. exports : true,
  10448. process : true,
  10449. setTimeout : true,
  10450. clearTimeout : true,
  10451. setInterval : true,
  10452. clearInterval : true,
  10453. setImmediate : true, // v0.9.1+
  10454. clearImmediate: true // v0.9.1+
  10455. };
  10456. exports.browserify = {
  10457. __filename : false,
  10458. __dirname : false,
  10459. global : false,
  10460. module : false,
  10461. require : false,
  10462. Buffer : true,
  10463. exports : true,
  10464. process : true
  10465. };
  10466. exports.phantom = {
  10467. phantom : true,
  10468. require : true,
  10469. WebPage : true,
  10470. console : true, // in examples, but undocumented
  10471. exports : true // v1.7+
  10472. };
  10473. exports.qunit = {
  10474. asyncTest : false,
  10475. deepEqual : false,
  10476. equal : false,
  10477. expect : false,
  10478. module : false,
  10479. notDeepEqual : false,
  10480. notEqual : false,
  10481. notPropEqual : false,
  10482. notStrictEqual : false,
  10483. ok : false,
  10484. propEqual : false,
  10485. QUnit : false,
  10486. raises : false,
  10487. start : false,
  10488. stop : false,
  10489. strictEqual : false,
  10490. test : false,
  10491. "throws" : false
  10492. };
  10493. exports.rhino = {
  10494. defineClass : false,
  10495. deserialize : false,
  10496. gc : false,
  10497. help : false,
  10498. importClass : false,
  10499. importPackage: false,
  10500. "java" : false,
  10501. load : false,
  10502. loadClass : false,
  10503. Packages : false,
  10504. print : false,
  10505. quit : false,
  10506. readFile : false,
  10507. readUrl : false,
  10508. runCommand : false,
  10509. seal : false,
  10510. serialize : false,
  10511. spawn : false,
  10512. sync : false,
  10513. toint32 : false,
  10514. version : false
  10515. };
  10516. exports.shelljs = {
  10517. target : false,
  10518. echo : false,
  10519. exit : false,
  10520. cd : false,
  10521. pwd : false,
  10522. ls : false,
  10523. find : false,
  10524. cp : false,
  10525. rm : false,
  10526. mv : false,
  10527. mkdir : false,
  10528. test : false,
  10529. cat : false,
  10530. sed : false,
  10531. grep : false,
  10532. which : false,
  10533. dirs : false,
  10534. pushd : false,
  10535. popd : false,
  10536. env : false,
  10537. exec : false,
  10538. chmod : false,
  10539. config : false,
  10540. error : false,
  10541. tempdir : false
  10542. };
  10543. exports.typed = {
  10544. ArrayBuffer : false,
  10545. ArrayBufferView : false,
  10546. DataView : false,
  10547. Float32Array : false,
  10548. Float64Array : false,
  10549. Int16Array : false,
  10550. Int32Array : false,
  10551. Int8Array : false,
  10552. Uint16Array : false,
  10553. Uint32Array : false,
  10554. Uint8Array : false,
  10555. Uint8ClampedArray : false
  10556. };
  10557. exports.wsh = {
  10558. ActiveXObject : true,
  10559. Enumerator : true,
  10560. GetObject : true,
  10561. ScriptEngine : true,
  10562. ScriptEngineBuildVersion : true,
  10563. ScriptEngineMajorVersion : true,
  10564. ScriptEngineMinorVersion : true,
  10565. VBArray : true,
  10566. WSH : true,
  10567. WScript : true,
  10568. XDomainRequest : true
  10569. };
  10570. // Globals provided by popular JavaScript libraries.
  10571. exports.dojo = {
  10572. dojo : false,
  10573. dijit : false,
  10574. dojox : false,
  10575. define : false,
  10576. "require": false
  10577. };
  10578. exports.jquery = {
  10579. "$" : false,
  10580. jQuery : false
  10581. };
  10582. exports.mootools = {
  10583. "$" : false,
  10584. "$$" : false,
  10585. Asset : false,
  10586. Browser : false,
  10587. Chain : false,
  10588. Class : false,
  10589. Color : false,
  10590. Cookie : false,
  10591. Core : false,
  10592. Document : false,
  10593. DomReady : false,
  10594. DOMEvent : false,
  10595. DOMReady : false,
  10596. Drag : false,
  10597. Element : false,
  10598. Elements : false,
  10599. Event : false,
  10600. Events : false,
  10601. Fx : false,
  10602. Group : false,
  10603. Hash : false,
  10604. HtmlTable : false,
  10605. IFrame : false,
  10606. IframeShim : false,
  10607. InputValidator: false,
  10608. instanceOf : false,
  10609. Keyboard : false,
  10610. Locale : false,
  10611. Mask : false,
  10612. MooTools : false,
  10613. Native : false,
  10614. Options : false,
  10615. OverText : false,
  10616. Request : false,
  10617. Scroller : false,
  10618. Slick : false,
  10619. Slider : false,
  10620. Sortables : false,
  10621. Spinner : false,
  10622. Swiff : false,
  10623. Tips : false,
  10624. Type : false,
  10625. typeOf : false,
  10626. URI : false,
  10627. Window : false
  10628. };
  10629. exports.prototypejs = {
  10630. "$" : false,
  10631. "$$" : false,
  10632. "$A" : false,
  10633. "$F" : false,
  10634. "$H" : false,
  10635. "$R" : false,
  10636. "$break" : false,
  10637. "$continue" : false,
  10638. "$w" : false,
  10639. Abstract : false,
  10640. Ajax : false,
  10641. Class : false,
  10642. Enumerable : false,
  10643. Element : false,
  10644. Event : false,
  10645. Field : false,
  10646. Form : false,
  10647. Hash : false,
  10648. Insertion : false,
  10649. ObjectRange : false,
  10650. PeriodicalExecuter: false,
  10651. Position : false,
  10652. Prototype : false,
  10653. Selector : false,
  10654. Template : false,
  10655. Toggle : false,
  10656. Try : false,
  10657. Autocompleter : false,
  10658. Builder : false,
  10659. Control : false,
  10660. Draggable : false,
  10661. Draggables : false,
  10662. Droppables : false,
  10663. Effect : false,
  10664. Sortable : false,
  10665. SortableObserver : false,
  10666. Sound : false,
  10667. Scriptaculous : false
  10668. };
  10669. exports.yui = {
  10670. YUI : false,
  10671. Y : false,
  10672. YUI_config: false
  10673. };
  10674. exports.mocha = {
  10675. // Global (for config etc.)
  10676. mocha : false,
  10677. // BDD
  10678. describe : false,
  10679. xdescribe : false,
  10680. it : false,
  10681. xit : false,
  10682. context : false,
  10683. xcontext : false,
  10684. before : false,
  10685. after : false,
  10686. beforeEach : false,
  10687. afterEach : false,
  10688. // TDD
  10689. suite : false,
  10690. test : false,
  10691. setup : false,
  10692. teardown : false,
  10693. suiteSetup : false,
  10694. suiteTeardown : false
  10695. };
  10696. exports.jasmine = {
  10697. jasmine : false,
  10698. describe : false,
  10699. xdescribe : false,
  10700. it : false,
  10701. xit : false,
  10702. beforeEach : false,
  10703. afterEach : false,
  10704. setFixtures : false,
  10705. loadFixtures: false,
  10706. spyOn : false,
  10707. expect : false,
  10708. // Jasmine 1.3
  10709. runs : false,
  10710. waitsFor : false,
  10711. waits : false,
  10712. // Jasmine 2.1
  10713. beforeAll : false,
  10714. afterAll : false,
  10715. fail : false,
  10716. fdescribe : false,
  10717. fit : false,
  10718. pending : false
  10719. };
  10720. },{}]},{},["/node_modules/jshint/src/jshint.js"]);
  10721. });