Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 459KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700
  1. <a name="eslint-plugin-jsdoc"></a>
  2. # eslint-plugin-jsdoc
  3. [![GitSpo Mentions](https://gitspo.com/badges/mentions/gajus/eslint-plugin-jsdoc?style=flat-square)](https://gitspo.com/mentions/gajus/eslint-plugin-jsdoc)
  4. [![NPM version](https://img.shields.io/npm/v/eslint-plugin-jsdoc.svg?style=flat-square)](https://www.npmjs.org/package/eslint-plugin-jsdoc)
  5. [![Travis build status](https://img.shields.io/travis/gajus/eslint-plugin-jsdoc/master.svg?style=flat-square)](https://travis-ci.org/gajus/eslint-plugin-jsdoc)
  6. [![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)
  7. [![Discord Chat](https://img.shields.io/badge/chat-on%20disord-green.svg?logo=discord)](https://discord.gg/kFFy3nc)
  8. JSDoc linting rules for ESLint.
  9. * [eslint-plugin-jsdoc](#eslint-plugin-jsdoc)
  10. * [Installation](#eslint-plugin-jsdoc-installation)
  11. * [Configuration](#eslint-plugin-jsdoc-configuration)
  12. * [Options](#eslint-plugin-jsdoc-options)
  13. * [Settings](#eslint-plugin-jsdoc-settings)
  14. * [Allow tags (`@private` or `@internal`) to disable rules for that comment block](#eslint-plugin-jsdoc-settings-allow-tags-private-or-internal-to-disable-rules-for-that-comment-block)
  15. * [`maxLines` and `minLines`](#eslint-plugin-jsdoc-settings-maxlines-and-minlines)
  16. * [Mode](#eslint-plugin-jsdoc-settings-mode)
  17. * [Alias Preference](#eslint-plugin-jsdoc-settings-alias-preference)
  18. * [`@override`/`@augments`/`@extends`/`@implements`/`@ignore` Without Accompanying `@param`/`@description`/`@example`/`@returns`/`@throws`/`@yields`](#eslint-plugin-jsdoc-settings-override-augments-extends-implements-ignore-without-accompanying-param-description-example-returns-throws-yields)
  19. * [Settings to Configure `check-types` and `no-undefined-types`](#eslint-plugin-jsdoc-settings-settings-to-configure-check-types-and-no-undefined-types)
  20. * [`structuredTags`](#eslint-plugin-jsdoc-settings-structuredtags)
  21. * [Advanced](#eslint-plugin-jsdoc-advanced)
  22. * [AST and Selectors](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  23. * [Rules](#eslint-plugin-jsdoc-rules)
  24. * [`check-access`](#eslint-plugin-jsdoc-rules-check-access)
  25. * [`check-alignment`](#eslint-plugin-jsdoc-rules-check-alignment)
  26. * [`check-examples`](#eslint-plugin-jsdoc-rules-check-examples)
  27. * [`check-indentation`](#eslint-plugin-jsdoc-rules-check-indentation)
  28. * [`check-line-alignment`](#eslint-plugin-jsdoc-rules-check-line-alignment)
  29. * [`check-param-names`](#eslint-plugin-jsdoc-rules-check-param-names)
  30. * [`check-property-names`](#eslint-plugin-jsdoc-rules-check-property-names)
  31. * [`check-syntax`](#eslint-plugin-jsdoc-rules-check-syntax)
  32. * [`check-tag-names`](#eslint-plugin-jsdoc-rules-check-tag-names)
  33. * [`check-types`](#eslint-plugin-jsdoc-rules-check-types)
  34. * [`check-values`](#eslint-plugin-jsdoc-rules-check-values)
  35. * [`empty-tags`](#eslint-plugin-jsdoc-rules-empty-tags)
  36. * [`implements-on-classes`](#eslint-plugin-jsdoc-rules-implements-on-classes)
  37. * [`match-description`](#eslint-plugin-jsdoc-rules-match-description)
  38. * [`match-name`](#eslint-plugin-jsdoc-rules-match-name)
  39. * [`multiline-blocks`](#eslint-plugin-jsdoc-rules-multiline-blocks)
  40. * [`newline-after-description`](#eslint-plugin-jsdoc-rules-newline-after-description)
  41. * [`no-bad-blocks`](#eslint-plugin-jsdoc-rules-no-bad-blocks)
  42. * [`no-defaults`](#eslint-plugin-jsdoc-rules-no-defaults)
  43. * [`no-missing-syntax`](#eslint-plugin-jsdoc-rules-no-missing-syntax)
  44. * [`no-multi-asterisks`](#eslint-plugin-jsdoc-rules-no-multi-asterisks)
  45. * [`no-restricted-syntax`](#eslint-plugin-jsdoc-rules-no-restricted-syntax)
  46. * [`no-types`](#eslint-plugin-jsdoc-rules-no-types)
  47. * [`no-undefined-types`](#eslint-plugin-jsdoc-rules-no-undefined-types)
  48. * [`require-asterisk-prefix`](#eslint-plugin-jsdoc-rules-require-asterisk-prefix)
  49. * [`require-description-complete-sentence`](#eslint-plugin-jsdoc-rules-require-description-complete-sentence)
  50. * [`require-description`](#eslint-plugin-jsdoc-rules-require-description)
  51. * [`require-example`](#eslint-plugin-jsdoc-rules-require-example)
  52. * [`require-file-overview`](#eslint-plugin-jsdoc-rules-require-file-overview)
  53. * [`require-hyphen-before-param-description`](#eslint-plugin-jsdoc-rules-require-hyphen-before-param-description)
  54. * [`require-jsdoc`](#eslint-plugin-jsdoc-rules-require-jsdoc)
  55. * [`require-param-description`](#eslint-plugin-jsdoc-rules-require-param-description)
  56. * [`require-param-name`](#eslint-plugin-jsdoc-rules-require-param-name)
  57. * [`require-param-type`](#eslint-plugin-jsdoc-rules-require-param-type)
  58. * [`require-param`](#eslint-plugin-jsdoc-rules-require-param)
  59. * [`require-property`](#eslint-plugin-jsdoc-rules-require-property)
  60. * [`require-property-description`](#eslint-plugin-jsdoc-rules-require-property-description)
  61. * [`require-property-name`](#eslint-plugin-jsdoc-rules-require-property-name)
  62. * [`require-property-type`](#eslint-plugin-jsdoc-rules-require-property-type)
  63. * [`require-returns-check`](#eslint-plugin-jsdoc-rules-require-returns-check)
  64. * [`require-returns-description`](#eslint-plugin-jsdoc-rules-require-returns-description)
  65. * [`require-returns-type`](#eslint-plugin-jsdoc-rules-require-returns-type)
  66. * [`require-returns`](#eslint-plugin-jsdoc-rules-require-returns)
  67. * [`require-throws`](#eslint-plugin-jsdoc-rules-require-throws)
  68. * [`require-yields`](#eslint-plugin-jsdoc-rules-require-yields)
  69. * [`require-yields-check`](#eslint-plugin-jsdoc-rules-require-yields-check)
  70. * [`tag-lines`](#eslint-plugin-jsdoc-rules-tag-lines)
  71. * [`valid-types`](#eslint-plugin-jsdoc-rules-valid-types)
  72. <a name="eslint-plugin-jsdoc-installation"></a>
  73. ## Installation
  74. Install [ESLint](https://www.github.com/eslint/eslint) either locally or
  75. globally.
  76. ```sh
  77. npm install --save-dev eslint
  78. ```
  79. If you have installed `ESLint` globally, you have to install JSDoc plugin
  80. globally too. Otherwise, install it locally.
  81. ```sh
  82. npm install --save-dev eslint-plugin-jsdoc
  83. ```
  84. <a name="eslint-plugin-jsdoc-configuration"></a>
  85. ## Configuration
  86. Add `plugins` section to [.eslintrc.*](https://eslint.org/docs/user-guide/configuring#configuration-file-formats)
  87. and specify `eslint-plugin-jsdoc` as a plugin.
  88. ```json
  89. {
  90. "plugins": [
  91. "jsdoc"
  92. ]
  93. }
  94. ```
  95. Finally, enable all of the rules that you would like to use.
  96. ```javascript
  97. {
  98. "rules": {
  99. "jsdoc/check-access": 1, // Recommended
  100. "jsdoc/check-alignment": 1, // Recommended
  101. "jsdoc/check-examples": 1,
  102. "jsdoc/check-indentation": 1,
  103. "jsdoc/check-line-alignment": 1,
  104. "jsdoc/check-param-names": 1, // Recommended
  105. "jsdoc/check-property-names": 1, // Recommended
  106. "jsdoc/check-syntax": 1,
  107. "jsdoc/check-tag-names": 1, // Recommended
  108. "jsdoc/check-types": 1, // Recommended
  109. "jsdoc/check-values": 1, // Recommended
  110. "jsdoc/empty-tags": 1, // Recommended
  111. "jsdoc/implements-on-classes": 1, // Recommended
  112. "jsdoc/match-description": 1,
  113. "jsdoc/multiline-blocks": 1, // Recommended
  114. "jsdoc/newline-after-description": 1, // Recommended
  115. "jsdoc/no-bad-blocks": 1,
  116. "jsdoc/no-defaults": 1,
  117. "jsdoc/no-missing-syntax": 1,
  118. "jsdoc/no-multi-asterisks": 1, // Recommended
  119. "jsdoc/no-restricted-syntax": 1,
  120. "jsdoc/no-types": 1,
  121. "jsdoc/no-undefined-types": 1, // Recommended
  122. "jsdoc/require-asterisk-prefix": 1,
  123. "jsdoc/require-description": 1,
  124. "jsdoc/require-description-complete-sentence": 1,
  125. "jsdoc/require-example": 1,
  126. "jsdoc/require-file-overview": 1,
  127. "jsdoc/require-hyphen-before-param-description": 1,
  128. "jsdoc/require-jsdoc": 1, // Recommended
  129. "jsdoc/require-param": 1, // Recommended
  130. "jsdoc/require-param-description": 1, // Recommended
  131. "jsdoc/require-param-name": 1, // Recommended
  132. "jsdoc/require-param-type": 1, // Recommended
  133. "jsdoc/require-property": 1, // Recommended
  134. "jsdoc/require-property-description": 1, // Recommended
  135. "jsdoc/require-property-name": 1, // Recommended
  136. "jsdoc/require-property-type": 1, // Recommended
  137. "jsdoc/require-returns": 1, // Recommended
  138. "jsdoc/require-returns-check": 1, // Recommended
  139. "jsdoc/require-returns-description": 1, // Recommended
  140. "jsdoc/require-returns-type": 1, // Recommended
  141. "jsdoc/require-throws": 1,
  142. "jsdoc/require-yields": 1, // Recommended
  143. "jsdoc/require-yields-check": 1, // Recommended
  144. "jsdoc/tag-lines": 1, // Recommended
  145. "jsdoc/valid-types": 1 // Recommended
  146. }
  147. }
  148. ```
  149. Or you can simply add the following to [.eslintrc.*](https://eslint.org/docs/user-guide/configuring#configuration-file-formats),
  150. which enables the rules commented above as "recommended":
  151. ```json
  152. {
  153. "extends": ["plugin:jsdoc/recommended"]
  154. }
  155. ```
  156. You can then selectively add to or override the recommended rules.
  157. <a name="eslint-plugin-jsdoc-options"></a>
  158. ## Options
  159. Rules may, as per the [ESLint user guide](https://eslint.org/docs/user-guide/configuring), have their own individual options. In `eslint-plugin-jsdoc`, a few options,
  160. such as, `exemptedBy` and `contexts`, may be used across different rules.
  161. `eslint-plugin-jsdoc` options, if present, are generally in the form of an
  162. object supplied as the second argument in an array after the error level
  163. (any exceptions to this format are explained within that rule's docs).
  164. ```js
  165. // `.eslintrc.js`
  166. {
  167. rules: {
  168. 'jsdoc/require-example': [
  169. // The Error level should be `error`, `warn`, or `off` (or 2, 1, or 0)
  170. 'error',
  171. // The options vary by rule, but are generally added to an options
  172. // object as follows:
  173. {
  174. avoidExampleOnConstructors: true,
  175. exemptedBy: ['type']
  176. }
  177. ]
  178. }
  179. }
  180. ```
  181. <a name="eslint-plugin-jsdoc-settings"></a>
  182. ## Settings
  183. <a name="eslint-plugin-jsdoc-settings-allow-tags-private-or-internal-to-disable-rules-for-that-comment-block"></a>
  184. ### Allow tags (<code>@private</code> or <code>@internal</code>) to disable rules for that comment block
  185. - `settings.jsdoc.ignorePrivate` - Disables all rules for the comment block
  186. on which a `@private` tag (or `@access private`) occurs. Defaults to
  187. `false`. Note: This has no effect with the rule `check-access` (whose
  188. purpose is to check access modifiers) or `empty-tags` (which checks
  189. `@private` itself).
  190. - `settings.jsdoc.ignoreInternal` - Disables all rules for the comment block
  191. on which a `@internal` tag occurs. Defaults to `false`. Note: This has no
  192. effect with the rule `empty-tags` (which checks `@internal` itself).
  193. <a name="eslint-plugin-jsdoc-settings-maxlines-and-minlines"></a>
  194. ### <code>maxLines</code> and <code>minLines</code>
  195. One can use `minLines` and `maxLines` to indicate how many line breaks
  196. (if any) will be checked to find a jsdoc comment block before the given
  197. code block. These settings default to `0` and `1` respectively.
  198. In conjunction with the `require-jsdoc` rule, these settings can
  199. be enforced so as to report problems if a jsdoc block is not found within
  200. the specified boundaries. The settings are also used in the fixer to determine
  201. how many line breaks to add when a block is missing.
  202. <a name="eslint-plugin-jsdoc-settings-mode"></a>
  203. ### Mode
  204. - `settings.jsdoc.mode` - Set to `typescript`, `closure`, or `jsdoc` (the
  205. default unless the `@typescript-eslint` parser is in use in which case
  206. `typescript` will be the default).
  207. Note that if you do not wish to use separate `.eslintrc.*` files for a
  208. project containing both JavaScript and TypeScript, you can also use
  209. [`overrides`](https://eslint.org/docs/user-guide/configuring). You may also
  210. set to `"permissive"` to try to be as accommodating to any of the styles,
  211. but this is not recommended. Currently is used for the following:
  212. - `check-tag-names`: Determine valid tags and aliases
  213. - `no-undefined-types`: Only check `@template` for types in "closure" and
  214. "typescript" modes
  215. - `check-syntax`: determines aspects that may be enforced
  216. - `valid-types`: in non-Closure mode, `@extends`, `@package` and access tags
  217. (e.g., `@private`) with a bracketed type are reported as are missing
  218. names with `@typedef`
  219. - For type/namepath-checking rules, determine which tags will be checked for
  220. types/namepaths (Closure allows types on some tags which the others do not,
  221. so these tags will additionally be checked in "closure" mode)
  222. - For type-checking rules, impacts parsing of types (through
  223. [jsdoctypeparser](https://github.com/jsdoctypeparser/jsdoctypeparser)
  224. dependency); note that some TypeScript features are
  225. [not yet](https://github.com/gajus/eslint-plugin-jsdoc/issues/145)
  226. [supported](https://github.com/jsdoctypeparser/jsdoctypeparser/issues/50)
  227. - Check preferred tag names
  228. - Disallows namepath on `@interface` for "closure" mode in `valid-types` (and
  229. avoids checking in other rules)
  230. <a name="eslint-plugin-jsdoc-settings-alias-preference"></a>
  231. ### Alias Preference
  232. Use `settings.jsdoc.tagNamePreference` to configure a preferred alias name for
  233. a JSDoc tag. The format of the configuration is:
  234. `<primary tag name>: <preferred alias name>`, e.g.
  235. ```json
  236. {
  237. "rules": {},
  238. "settings": {
  239. "jsdoc": {
  240. "tagNamePreference": {
  241. "param": "arg",
  242. "returns": "return"
  243. }
  244. }
  245. }
  246. }
  247. ```
  248. Note: ESLint does not allow settings to have keys which conflict with
  249. `Object.prototype` e.g. `'constructor'`. To work around this, you can use the
  250. key `'tag constructor'`.
  251. One may also use an object with a `message` and `replacement`.
  252. The following will report the message
  253. `@extends is to be used over @augments as it is more evocative of classes than @augments`
  254. upon encountering `@augments`.
  255. ```json
  256. {
  257. "rules": {},
  258. "settings": {
  259. "jsdoc": {
  260. "tagNamePreference": {
  261. "augments": {
  262. "message": "@extends is to be used over @augments as it is more evocative of classes than @augments",
  263. "replacement": "extends"
  264. }
  265. }
  266. }
  267. }
  268. }
  269. ```
  270. If one wishes to reject a normally valid tag, e.g., `@todo`, one may set the
  271. tag to `false`:
  272. ```json
  273. {
  274. "rules": {},
  275. "settings": {
  276. "jsdoc": {
  277. "tagNamePreference": {
  278. "todo": false
  279. }
  280. }
  281. }
  282. }
  283. ```
  284. A project wishing to ensure no blocks are left excluded from entering the
  285. documentation, might wish to prevent the `@ignore` tag in the above manner.
  286. Or one may set the targeted tag to an object with a custom `message`, but
  287. without a `replacement` property:
  288. ```json
  289. {
  290. "rules": {},
  291. "settings": {
  292. "jsdoc": {
  293. "tagNamePreference": {
  294. "todo": {
  295. "message": "We expect immediate perfection, so don't leave to-dos in your code."
  296. }
  297. }
  298. }
  299. }
  300. }
  301. ```
  302. Note that the preferred tags indicated in the
  303. `settings.jsdoc.tagNamePreference` map will be assumed to be defined by
  304. `check-tag-names`.
  305. See `check-tag-names` for how that fact can be used to set an alias to itself
  306. to allow both the alias and the default (since aliases are otherwise not
  307. permitted unless used in `tagNamePreference`).
  308. <a name="eslint-plugin-jsdoc-settings-alias-preference-default-preferred-aliases"></a>
  309. #### Default Preferred Aliases
  310. The defaults in `eslint-plugin-jsdoc` (for tags which offer
  311. aliases) are as follows:
  312. - `@abstract` (over `@virtual`)
  313. - `@augments` (over `@extends`)
  314. - `@class` (over `@constructor`)
  315. - `@constant` (over `@const`)
  316. - `@default` (over `@defaultvalue`)
  317. - `@description` (over `@desc`)
  318. - `@external` (over `@host`)
  319. - `@file` (over `@fileoverview`, `@overview`)
  320. - `@fires` (over `@emits`)
  321. - `@function` (over `@func`, `@method`)
  322. - `@member` (over `@var`)
  323. - `@param` (over `@arg`, `@argument`)
  324. - `@property` (over `@prop`)
  325. - `@returns` (over `@return`)
  326. - `@throws` (over `@exception`)
  327. - `@yields` (over `@yield`)
  328. This setting is utilized by the the rule for tag name checking
  329. (`check-tag-names`) as well as in the `@param` and `@require` rules:
  330. - `check-param-names`
  331. - `check-tag-names`
  332. - `require-hyphen-before-param-description`
  333. - `require-description`
  334. - `require-param`
  335. - `require-param-description`
  336. - `require-param-name`
  337. - `require-param-type`
  338. - `require-returns`
  339. - `require-returns-check`
  340. - `require-returns-description`
  341. - `require-returns-type`
  342. <a name="eslint-plugin-jsdoc-settings-override-augments-extends-implements-ignore-without-accompanying-param-description-example-returns-throws-yields"></a>
  343. ### <code>@override</code>/<code>@augments</code>/<code>@extends</code>/<code>@implements</code>/<code>@ignore</code> Without Accompanying <code>@param</code>/<code>@description</code>/<code>@example</code>/<code>@returns</code>/<code>@throws</code>/<code>@yields</code>
  344. The following settings allows the element(s) they reference to be omitted
  345. on the JSDoc comment block of the function or that of its parent class
  346. for any of the "require" rules (i.e., `require-param`, `require-description`,
  347. `require-example`, `require-returns`, `require-throws`, `require-yields`).
  348. * `settings.jsdoc.ignoreReplacesDocs` (`@ignore`) - Defaults to `true`
  349. * `settings.jsdoc.overrideReplacesDocs` (`@override`) - Defaults to `true`
  350. * `settings.jsdoc.augmentsExtendsReplacesDocs` (`@augments` or its alias
  351. `@extends`) - Defaults to `false`.
  352. * `settings.jsdoc.implementsReplacesDocs` (`@implements`) - Defaults to `false`
  353. The format of the configuration is as follows:
  354. ```json
  355. {
  356. "rules": {},
  357. "settings": {
  358. "jsdoc": {
  359. "ignoreReplacesDocs": true,
  360. "overrideReplacesDocs": true,
  361. "augmentsExtendsReplacesDocs": true,
  362. "implementsReplacesDocs": true
  363. }
  364. }
  365. }
  366. ```
  367. <a name="eslint-plugin-jsdoc-settings-settings-to-configure-check-types-and-no-undefined-types"></a>
  368. ### Settings to Configure <code>check-types</code> and <code>no-undefined-types</code>
  369. - `settings.jsdoc.preferredTypes` An option map to indicate preferred
  370. or forbidden types (if default types are indicated here, these will
  371. have precedence over the default recommendations for `check-types`).
  372. The keys of this map are the types to be replaced (or forbidden).
  373. These keys may include:
  374. 1. The "ANY" type, `*`
  375. 1. The pseudo-type `[]` which we use to denote the parent (array)
  376. types used in the syntax `string[]`, `number[]`, etc.
  377. 1. The pseudo-type `.<>` (or `.`) to represent the format `Array.<value>`
  378. or `Object.<key, value>`
  379. 1. The pseudo-type `<>` to represent the format `Array<value>` or
  380. `Object<key, value>`
  381. 1. A plain string type, e.g., `MyType`
  382. 1. A plain string type followed by one of the above pseudo-types (except
  383. for `[]` which is always assumed to be an `Array`), e.g., `Array.`, or
  384. `SpecialObject<>`.
  385. If a bare pseudo-type is used, it will match all parent types of that form.
  386. If a pseudo-type prefixed with a type name is used, it will only match
  387. parent types of that form and type name.
  388. The values can be:
  389. - `false` to forbid the type
  390. - a string to indicate the type that should be preferred in its place
  391. (and which `fix` mode can replace); this can be one of the formats
  392. of the keys described above.
  393. - Note that the format will not be changed unless you use a pseudo-type
  394. in the replacement. (For example, `'Array.<>': 'MyArray'` will change
  395. `Array.<string>` to `MyArray.<string>`, preserving the dot. To get rid
  396. of the dot, you must use the pseudo-type with `<>`, i.e.,
  397. `'Array.<>': 'MyArray<>'`, which will change `Array.<string>` to
  398. `MyArray<string>`).
  399. - If you use a _bare_ pseudo-type in the replacement (e.g.,
  400. `'MyArray.<>': '<>'`), the type will be converted to the format
  401. of the pseudo-type without changing the type name. For example,
  402. `MyArray.<string>` will become `MyArray<string>` but `Array.<string>`
  403. will not be modified.
  404. - an object with:
  405. - the key `message` to provide a specific error message
  406. when encountering the discouraged type.
  407. - The message string will have the substrings with special meaning,
  408. `{{tagName}}` and `{{tagValue}}`, replaced with their
  409. corresponding value.
  410. - an optional key `replacement` with either of the following values:
  411. - a string type to be preferred in its place (and which `fix` mode
  412. can replace)
  413. - `false` (for forbidding the type)
  414. Note that the preferred types indicated as targets in
  415. `settings.jsdoc.preferredTypes` map will be assumed to be defined by
  416. `no-undefined-types`.
  417. See the option of `check-types`, `unifyParentAndChildTypeChecks`, for
  418. how the keys of `preferredTypes` may have `<>` or `.<>` (or just `.`)
  419. appended and its bearing on whether types are checked as parents/children
  420. only (e.g., to match `Array` if the type is `Array` vs. `Array.<string>`).
  421. Note that if a value is present both as a key and as a value, neither the
  422. key nor the value will be reported. Thus in `check-types`, this fact can
  423. be used to allow both `object` and `Object` if one has a `preferredTypes`
  424. key `object: 'Object'` and `Object: 'object'`.
  425. <a name="eslint-plugin-jsdoc-settings-structuredtags"></a>
  426. ### <code>structuredTags</code>
  427. An object indicating tags whose types and names/namepaths (whether defining or
  428. referencing namepaths) will be checked, subject to configuration. If the tags
  429. have predefined behavior or `allowEmptyNamepaths` behavior, this option will
  430. override that behavior for any specified tags, though this option can also be
  431. used for tags without predefined behavior. Its keys are tag names and its
  432. values are objects with the following optional properties:
  433. - `name` - String set to one of the following:
  434. - `"text"` - When a name is present, plain text will be allowed in the
  435. name position (non-whitespace immediately after the tag and whitespace),
  436. e.g., in `@throws This is an error`, "This" would normally be the name,
  437. but "text" allows non-name text here also. This is the default.
  438. - `"namepath-defining"` - As with `namepath-referencing`, but also
  439. indicates the tag adds a namepath to definitions, e.g., to prevent
  440. `no-undefined-types` from reporting references to that namepath.
  441. - `"namepath-referencing"` - This will cause any name position to be
  442. checked to ensure it is a valid namepath. You might use this to ensure
  443. that tags which normally allow free text, e.g., `@see` will instead
  444. require a namepath.
  445. - `false` - This will disallow any text in the name position.
  446. - `type`:
  447. - `true` - Allows valid types within brackets. This is the default.
  448. - `false` - Explicitly disallows any brackets or bracketed type. You
  449. might use this with `@throws` to suggest that only free form text
  450. is being input or with `@augments` (for jsdoc mode) to disallow
  451. Closure-style bracketed usage along with a required namepath.
  452. - (An array of strings) - A list of permissible types.
  453. - `required` - Array of one of the following (defaults to an empty array,
  454. meaning none are required):
  455. - One or both of the following strings (if both are included, then both
  456. are required):
  457. - `"name"` - Indicates that a name position is required (not just that
  458. if present, it is a valid namepath). You might use this with `see`
  459. to insist that a value (or namepath, depending on the `name` value)
  460. is always present.
  461. - `"type"` - Indicates that the type position (within curly brackets)
  462. is required (not just that if present, it is a valid type). You
  463. might use this with `@throws` or `@typedef` which might otherwise
  464. normally have their types optional. See the type groups 3-5 above.
  465. - `"typeOrName"` - Must have either type (e.g., `@throws {aType}`) or
  466. name (`@throws Some text`); does not require that both exist but
  467. disallows just an empty tag.
  468. <a name="eslint-plugin-jsdoc-advanced"></a>
  469. ## Advanced
  470. <a name="eslint-plugin-jsdoc-advanced-ast-and-selectors"></a>
  471. ### AST and Selectors
  472. For various rules, one can add to the environments to which the rule applies
  473. by using the `contexts` option.
  474. This option works with [ESLint's selectors](https://eslint.org/docs/developer-guide/selectors) which are [esquery](https://github.com/estools/esquery/#readme)
  475. expressions one may use to target a specific node type or types, including
  476. subsets of the type(s) such as nodes with certain children or attributes.
  477. These expressions are used within ESLint plugins to find those parts of
  478. your files' code which are of interest to check. However, in
  479. `eslint-plugin-jsdoc`, we also allow you to use these selectors to define
  480. additional contexts where you wish our own rules to be applied.
  481. <a name="eslint-plugin-jsdoc-advanced-ast-and-selectors-contexts-format"></a>
  482. #### <code>contexts</code> format
  483. While at their simplest, these can be an array of string selectors, one can
  484. also supply an object with `context` (in place of the string) and one of two
  485. properties:
  486. 1. For `require-jsdoc`, there is also a `inlineCommentBlock` property. See
  487. that rule for details.
  488. 1. For `no-missing-syntax` and `no-restricted-syntax`, there is also a
  489. `message` property which allows customization of the message to be shown
  490. when the rule is triggered.
  491. 1. For `no-missing-syntax`, there is also a `minimum` property. See that rule.
  492. 1. For other rules, there is a `comment` property which adds to the `context`
  493. in requiring that the `comment` AST condition is also met, e.g., to
  494. require that certain tags are present and/or or types and type operators
  495. are in use. Note that this AST (either for `Jsdoc*` or `JsdocType*` AST)
  496. has not been standardized and should be considered experimental.
  497. Note that this property might also become obsolete if parsers begin to
  498. include JSDoc-structured AST. A
  499. [parser](https://github.com/brettz9/jsdoc-eslint-parser/) is available
  500. which aims to support comment AST as
  501. a first class citizen where comment/comment types can be used anywhere
  502. within a normal AST selector but this should only be considered
  503. experimental. When using such a parser, you need not use `comment` and
  504. can just use a plain string context. The determination of the node on
  505. which the comment is attached is also subject to change. It may be
  506. currently possible for different structures to map to the same comment
  507. block. This is because normally when querying to find either the
  508. declaration of the function expression for
  509. `const quux = function () {}`, the associated comment would,
  510. in both cases, generally be expected to be on the line above both, rather
  511. than to be immediately preceding the funciton (in the case of the
  512. function). See [@es-joy/jsdoccomment](https://github.com/es-joy/jsdoccomment)
  513. for the precise structure of the comment (and comment type) nodes.
  514. <a name="eslint-plugin-jsdoc-advanced-ast-and-selectors-discovering-available-ast-definitions"></a>
  515. #### Discovering available AST definitions
  516. To know all of the AST definitions one may target, it will depend on the
  517. [parser](https://eslint.org/docs/user-guide/configuring#specifying-parser)
  518. you are using with ESLint (e.g., `espree` is the default parser for ESLint,
  519. and this follows [EStree AST](https://github.com/estree/estree) but
  520. to support the the latest experimental features of JavaScript, one may use
  521. `@babel/eslint-parser` or to be able to have one's rules (including JSDoc rules)
  522. apply to TypeScript, one may use `@typescript-eslint/parser`, etc.
  523. So you can look up a particular parser to see its rules, e.g., browse through
  524. the [ESTree docs](https://github.com/estree/estree) as used by Espree or see
  525. ESLint's [overview of the structure of AST](https://eslint.org/docs/developer-guide/working-with-custom-parsers#the-ast-specification).
  526. However, it can sometimes be even more helpful to get an idea of AST by just
  527. providing some of your JavaScript to the wonderful
  528. [AST Explorer](https://astexplorer.net/) tool and see what AST is built out
  529. of your code. You can set the tool to the specific parser which you are using.
  530. <a name="eslint-plugin-jsdoc-advanced-ast-and-selectors-uses-tips-for-ast"></a>
  531. #### Uses/Tips for AST
  532. And if you wish to introspect on the AST of code within your projects, you can
  533. use [eslint-plugin-query](https://github.com/brettz9/eslint-plugin-query).
  534. Though it also works as a plugin, you can use it with its own CLI, e.g.,
  535. to search your files for matching esquery selectors, optionally showing
  536. it as AST JSON.
  537. Tip: If you want to more deeply understand not just the resulting AST tree
  538. structures for any given code but also the syntax for esquery selectors so
  539. that you can, for example, find only those nodes with a child of a certain
  540. type, you can set the "Transform" feature to ESLint and test out
  541. esquery selectors in place of the selector expression (e.g., replace
  542. `'VariableDeclaration > VariableDeclarator > Identifier[name="someVar"]'` as
  543. we have
  544. [here](https://astexplorer.net/#/gist/71a93130c19599d6f197bddb29c13a59/latest))
  545. to the selector you wish so as to get messages reported in the bottom right
  546. pane which match your [esquery](https://github.com/estools/esquery/#readme)
  547. selector).
  548. <a name="eslint-plugin-jsdoc-rules"></a>
  549. ## Rules
  550. <a name="eslint-plugin-jsdoc-rules-check-access"></a>
  551. ### <code>check-access</code>
  552. Checks that `@access` tags use one of the following values:
  553. - "package", "private", "protected", "public"
  554. Also reports:
  555. - Mixing of `@access` with `@public`, `@private`, `@protected`, or `@package`
  556. on the same doc block.
  557. - Use of multiple instances of `@access` (or the `@public`, etc. style tags)
  558. on the same doc block.
  559. |||
  560. |---|---|
  561. |Context|everywhere|
  562. |Tags|`@access`|
  563. |Recommended|false|
  564. |Settings||
  565. |Options||
  566. The following patterns are considered problems:
  567. ````js
  568. /**
  569. * @access foo
  570. */
  571. function quux (foo) {
  572. }
  573. // Message: Missing valid JSDoc @access level.
  574. /**
  575. * @access foo
  576. */
  577. function quux (foo) {
  578. }
  579. // Settings: {"jsdoc":{"ignorePrivate":true}}
  580. // Message: Missing valid JSDoc @access level.
  581. /**
  582. * @accessLevel foo
  583. */
  584. function quux (foo) {
  585. }
  586. // Settings: {"jsdoc":{"tagNamePreference":{"access":"accessLevel"}}}
  587. // Message: Missing valid JSDoc @accessLevel level.
  588. /**
  589. * @access
  590. */
  591. function quux (foo) {
  592. }
  593. // Settings: {"jsdoc":{"tagNamePreference":{"access":false}}}
  594. // Message: Unexpected tag `@access`
  595. class MyClass {
  596. /**
  597. * @access
  598. */
  599. myClassField = 1
  600. }
  601. // Message: Missing valid JSDoc @access level.
  602. /**
  603. * @access public
  604. * @public
  605. */
  606. function quux (foo) {
  607. }
  608. // Message: The @access tag may not be used with specific access-control tags (@package, @private, @protected, or @public).
  609. /**
  610. * @access public
  611. * @access private
  612. */
  613. function quux (foo) {
  614. }
  615. // Message: At most one access-control tag may be present on a jsdoc block.
  616. /**
  617. * @access public
  618. * @access private
  619. */
  620. function quux (foo) {
  621. }
  622. // Settings: {"jsdoc":{"ignorePrivate":true}}
  623. // Message: At most one access-control tag may be present on a jsdoc block.
  624. /**
  625. * @public
  626. * @private
  627. */
  628. function quux (foo) {
  629. }
  630. // Message: At most one access-control tag may be present on a jsdoc block.
  631. /**
  632. * @public
  633. * @private
  634. */
  635. function quux (foo) {
  636. }
  637. // Settings: {"jsdoc":{"ignorePrivate":true}}
  638. // Message: At most one access-control tag may be present on a jsdoc block.
  639. /**
  640. * @public
  641. * @public
  642. */
  643. function quux (foo) {
  644. }
  645. // Message: At most one access-control tag may be present on a jsdoc block.
  646. ````
  647. The following patterns are not considered problems:
  648. ````js
  649. /**
  650. *
  651. */
  652. function quux (foo) {
  653. }
  654. /**
  655. * @access public
  656. */
  657. function quux (foo) {
  658. }
  659. /**
  660. * @accessLevel package
  661. */
  662. function quux (foo) {
  663. }
  664. // Settings: {"jsdoc":{"tagNamePreference":{"access":"accessLevel"}}}
  665. class MyClass {
  666. /**
  667. * @access private
  668. */
  669. myClassField = 1
  670. }
  671. /**
  672. * @public
  673. */
  674. function quux (foo) {
  675. }
  676. /**
  677. * @private
  678. */
  679. function quux (foo) {
  680. }
  681. // Settings: {"jsdoc":{"ignorePrivate":true}}
  682. ````
  683. <a name="eslint-plugin-jsdoc-rules-check-alignment"></a>
  684. ### <code>check-alignment</code>
  685. Reports invalid alignment of JSDoc block asterisks.
  686. |||
  687. |---|---|
  688. |Context|everywhere|
  689. |Tags|N/A|
  690. |Recommended|true|
  691. The following patterns are considered problems:
  692. ````js
  693. /**
  694. * @param {Number} foo
  695. */
  696. function quux (foo) {
  697. // with spaces
  698. }
  699. // Message: Expected JSDoc block to be aligned.
  700. /**
  701. * @param {Number} foo
  702. */
  703. function quux (foo) {
  704. // with tabs
  705. }
  706. // Message: Expected JSDoc block to be aligned.
  707. /**
  708. * @param {Number} foo
  709. */
  710. function quux (foo) {
  711. // with spaces
  712. }
  713. // Message: Expected JSDoc block to be aligned.
  714. /**
  715. * @param {Number} foo
  716. */
  717. function quux (foo) {
  718. // with spaces
  719. }
  720. // Message: Expected JSDoc block to be aligned.
  721. /**
  722. * @param {Number} foo
  723. */
  724. function quux (foo) {
  725. }
  726. // Message: Expected JSDoc block to be aligned.
  727. /**
  728. * @param {Number} foo
  729. */
  730. function quux (foo) {
  731. }
  732. // Message: Expected JSDoc block to be aligned.
  733. /**
  734. * @param {Number} foo
  735. */
  736. function quux (foo) {
  737. }
  738. // Message: Expected JSDoc block to be aligned.
  739. /**
  740. * @param {Number} foo
  741. */
  742. function quux (foo) {
  743. }
  744. // Message: Expected JSDoc block to be aligned.
  745. /**
  746. * A jsdoc not attached to any node.
  747. */
  748. // Message: Expected JSDoc block to be aligned.
  749. class Foo {
  750. /**
  751. * Some method
  752. * @param a
  753. */
  754. quux(a) {}
  755. }
  756. // Message: Expected JSDoc block to be aligned.
  757. ````
  758. The following patterns are not considered problems:
  759. ````js
  760. /**
  761. * Desc
  762. *
  763. * @param {Number} foo
  764. */
  765. function quux (foo) {
  766. }
  767. /**
  768. * Desc
  769. *
  770. * @param {{
  771. foo: Bar,
  772. bar: Baz
  773. * }} foo
  774. *
  775. */
  776. function quux (foo) {
  777. }
  778. /* <- JSDoc must start with 2 stars.
  779. * So this is unchecked.
  780. */
  781. function quux (foo) {}
  782. /**
  783. * @param {Number} foo
  784. * @private
  785. */
  786. function quux (foo) {
  787. // with spaces
  788. }
  789. // Settings: {"jsdoc":{"ignorePrivate":true}}
  790. /**
  791. * @param {Number} foo
  792. * @access private
  793. */
  794. function quux (foo) {
  795. // with spaces
  796. }
  797. // Settings: {"jsdoc":{"ignorePrivate":true}}
  798. ````
  799. <a name="eslint-plugin-jsdoc-rules-check-examples"></a>
  800. ### <code>check-examples</code>
  801. Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules. Also
  802. has options to lint the default values of optional `@param`/`@arg`/`@argument`
  803. and `@property`/`@prop` tags or the values of `@default`/`@defaultvalue` tags.
  804. <a name="eslint-plugin-jsdoc-rules-check-examples-options-1"></a>
  805. #### Options
  806. The options below all default to no-op/`false` except as noted.
  807. <a name="eslint-plugin-jsdoc-rules-check-examples-options-1-captionrequired"></a>
  808. ##### <code>captionRequired</code>
  809. JSDoc specs use of an optional `<caption>` element at the beginning of
  810. `@example`.
  811. The option `captionRequired` insists on a `<caption>` being present at
  812. the beginning of any `@example`.
  813. Used only for `@example`.
  814. <a name="eslint-plugin-jsdoc-rules-check-examples-options-1-examplecoderegex-and-rejectexamplecoderegex"></a>
  815. ##### <code>exampleCodeRegex</code> and <code>rejectExampleCodeRegex</code>
  816. JSDoc does not specify a formal means for delimiting code blocks within
  817. `@example` (it uses generic syntax highlighting techniques for its own
  818. syntax highlighting). The following options determine whether a given
  819. `@example` tag will have the `check-examples` checks applied to it:
  820. * `exampleCodeRegex` - Regex which whitelists lintable
  821. examples. If a parenthetical group is used, the first one will be used,
  822. so you may wish to use `(?:...)` groups where you do not wish the
  823. first such group treated as one to include. If no parenthetical group
  824. exists or matches, the whole matching expression will be used.
  825. An example might be ````"^```(?:js|javascript)([\\s\\S]*)```\s*$"````
  826. to only match explicitly fenced JavaScript blocks. Defaults to only
  827. using the `u` flag, so to add your own flags, encapsulate your
  828. expression as a string, but like a literal, e.g., ````/```js.*```/gi````.
  829. Note that specifying a global regular expression (i.e., with `g`) will
  830. allow independent linting of matched blocks within a single `@example`.
  831. * `rejectExampleCodeRegex` - Regex blacklist which rejects
  832. non-lintable examples (has priority over `exampleCodeRegex`). An example
  833. might be ```"^`"``` to avoid linting fenced blocks which may indicate
  834. a non-JavaScript language. See `exampleCodeRegex` on how to add flags
  835. if the default `u` is not sufficient.
  836. If neither is in use, all examples will be matched. Note also that even if
  837. `captionRequired` is not set, any initial `<caption>` will be stripped out
  838. before doing the regex matching.
  839. <a name="eslint-plugin-jsdoc-rules-check-examples-options-1-paddedindent"></a>
  840. ##### <code>paddedIndent</code>
  841. This integer property allows one to add a fixed amount of whitespace at the
  842. beginning of the second or later lines of the example to be stripped so as
  843. to avoid linting issues with the decorative whitespace. For example, if set
  844. to a value of `4`, the initial whitespace below will not trigger `indent`
  845. rule errors as the extra 4 spaces on each subsequent line will be stripped
  846. out before evaluation.
  847. ```js
  848. /**
  849. * @example
  850. * anArray.filter((a) => {
  851. * return a.b;
  852. * });
  853. */
  854. ```
  855. Only applied to `@example` linting.
  856. <a name="eslint-plugin-jsdoc-rules-check-examples-options-1-reportunuseddisabledirectives"></a>
  857. ##### <code>reportUnusedDisableDirectives</code>
  858. If not set to `false`, `reportUnusedDisableDirectives` will report disabled
  859. directives which are not used (and thus not needed). Defaults to `true`.
  860. Corresponds to ESLint's [`--report-unused-disable-directives`](https://eslint.org/docs/user-guide/command-line-interface#--report-unused-disable-directives).
  861. Inline ESLint config within `@example` JavaScript is allowed (or within
  862. `@default`, etc.), though the disabling of ESLint directives which are not
  863. needed by the resolved rules will be reported as with the ESLint
  864. `--report-unused-disable-directives` command.
  865. <a name="eslint-plugin-jsdoc-rules-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig"></a>
  866. #### Options for Determining ESLint Rule Applicability (<code>allowInlineConfig</code>, <code>noDefaultExampleRules</code>, <code>matchingFileName</code>, <code>configFile</code>, <code>checkEslintrc</code>, and <code>baseConfig</code>)
  867. The following options determine which individual ESLint rules will be
  868. applied to the JavaScript found within the `@example` tags (as determined
  869. to be applicable by the above regex options) or for the other tags checked by
  870. `checkDefaults`, `checkParams`, or `checkProperties` options. They are ordered
  871. by decreasing precedence:
  872. * `allowInlineConfig` - If not set to `false`, will allow
  873. inline config within the `@example` to override other config. Defaults
  874. to `true`.
  875. * `noDefaultExampleRules` - Setting to `true` will disable the
  876. default rules which are expected to be troublesome for most documentation
  877. use. See the section below for the specific default rules.
  878. * `configFile` - A config file. Corresponds to ESLint's [`-c`](https://eslint.org/docs/user-guide/command-line-interface#-c---config).
  879. * `matchingFileName` - Option for a file name (even non-existent) to trigger
  880. specific rules defined in one's config; usable with ESLint `.eslintrc.*`
  881. `overrides` -> `files` globs, to apply a desired subset of rules with
  882. `@example` (besides allowing for rules specific to examples, this option
  883. can be useful for enabling reuse of the same rules within `@example` as
  884. with JavaScript Markdown lintable by
  885. [other plugins](https://github.com/eslint/eslint-plugin-markdown), e.g.,
  886. if one sets `matchingFileName` to `dummy.md/*.js` so that `@example`
  887. rules will follow rules for fenced JavaScript blocks within one's Markdown
  888. rules). (In ESLint 6's processor API and `eslint-plugin-markdown` < 2, one
  889. would instead use `dummy.md`.) For `@example` only.
  890. * `matchingFileNameDefaults` - As with `matchingFileName` but for use with
  891. `checkDefaults` and defaulting to `.jsdoc-defaults` as extension.
  892. * `matchingFileNameParams` - As with `matchingFileName` but for use with
  893. `checkParams` and defaulting to `.jsdoc-params` as extension.
  894. * `matchingFileNameProperties` As with `matchingFileName` but for use with
  895. `checkProperties` and defaulting to `.jsdoc-properties` as extension.
  896. * `checkEslintrc` - Defaults to `true` in adding rules
  897. based on an `.eslintrc.*` file. Setting to `false` corresponds to
  898. ESLint's [`--no-eslintrc`](https://eslint.org/docs/user-guide/command-line-interface#--no-eslintrc).
  899. If `matchingFileName` is set, this will automatically be `true` and
  900. will use the config corresponding to that file. If `matchingFileName` is
  901. not set and this value is set to `false`, the `.eslintrc.*` configs will
  902. not be checked. If `matchingFileName` is not set, and this is unset or
  903. set to `true`, the `.eslintrc.*` configs will be checked as though the file
  904. name were the same as the file containing the example, with any file
  905. extension changed to `".md/*.js"` (and if there is no file extension,
  906. `"dummy.md/*.js"` will be the result). This allows convenient sharing of
  907. similar rules with often also context-free Markdown as well as use of
  908. `overrides` as described under `matchingFileName`. Note that this option
  909. (whether set by `matchingFileName` or set manually to `true`) may come at
  910. somewhat of a performance penalty as the file's existence is checked by
  911. eslint.
  912. * `baseConfig` - Set to an object of rules with the same schema
  913. as `.eslintrc.*` for defaults.
  914. <a name="eslint-plugin-jsdoc-rules-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig-rules-disabled-by-default-unless-nodefaultexamplerules-is-set-to-true"></a>
  915. ##### Rules Disabled by Default Unless <code>noDefaultExampleRules</code> is Set to <code>true</code>
  916. * `eol-last` - Insisting that a newline "always" be at the end is less likely
  917. to be desired in sample code as with the code file convention.
  918. * `no-console` - This rule is unlikely to have inadvertent temporary debugging
  919. within examples.
  920. * `no-multiple-empty-lines` - This rule may be problematic for projects which
  921. use an initial newline just to start an example. Also, projects may wish to
  922. use extra lines within examples just for easier illustration
  923. purposes.
  924. * `no-undef` - Many variables in examples will be `undefined`.
  925. * `no-unused-vars` - It is common to define variables for clarity without
  926. always using them within examples.
  927. * `padded-blocks` - It can generally look nicer to pad a little even if one's
  928. code follows more stringency as far as block padding.
  929. * `jsdoc/require-file-overview` - Shouldn't check example for jsdoc blocks.
  930. * `jsdoc/require-jsdoc` - Wouldn't expect jsdoc blocks within jsdoc blocks.
  931. * `import/no-unresolved` - One wouldn't generally expect example paths to
  932. resolve relative to the current JavaScript file as one would with real code.
  933. * `import/unambiguous` - Snippets in examples are likely too short to always
  934. include full import/export info.
  935. * `node/no-missing-import` - See `import/no-unresolved`.
  936. * `node/no-missing-require` - See `import/no-unresolved`.
  937. For `checkDefaults`, `checkParams`, and `checkProperties`, the following
  938. expression-oriented rules will be used by default as well:
  939. * `quotes` - Will insist on "double".
  940. * `semi` - Will insist on "never".
  941. * `strict` - Disabled.
  942. * `no-empty-function` - Disabled.
  943. * `no-new` - Disabled.
  944. * `no-unused-expressions` - Disabled.
  945. * `chai-friendly/no-unused-expressions` - Disabled.
  946. <a name="eslint-plugin-jsdoc-rules-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc-and-baseconfig-options-for-checking-other-than-example-checkdefaults-checkparams-or-checkproperties"></a>
  947. ##### Options for checking other than <code>@example</code> (<code>checkDefaults</code>, <code>checkParams</code>, or <code>checkProperties</code>)
  948. * `checkDefaults` - Whether to check the values of `@default`/`@defaultvalue` tags
  949. * `checkParams` - Whether to check `@param`/`@arg`/`@argument` default values
  950. * `checkProperties` - Whether to check `@property`/`@prop` default values
  951. |||
  952. |---|---|
  953. |Context|everywhere|
  954. |Tags|`example`|
  955. |Recommended|false|
  956. |Options| *See above* |
  957. The following patterns are considered problems:
  958. ````js
  959. /**
  960. * @example alert('hello')
  961. */
  962. function quux () {
  963. }
  964. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"no-alert":2,"semi":["error","always"]}},"checkEslintrc":false}]
  965. // Message: @example error (no-alert): Unexpected alert.
  966. /**
  967. * @example alert('hello')
  968. */
  969. class quux {
  970. }
  971. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"no-alert":2,"semi":["error","always"]}},"checkEslintrc":false}]
  972. // Message: @example error (no-alert): Unexpected alert.
  973. /**
  974. * @example ```js
  975. alert('hello');
  976. ```
  977. */
  978. function quux () {
  979. }
  980. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
  981. // Message: @example error (semi): Extra semicolon.
  982. /**
  983. * @example
  984. *
  985. * ```js alert('hello'); ```
  986. */
  987. function quux () {
  988. }
  989. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"exampleCodeRegex":"```js ([\\s\\S]*)```"}]
  990. // Message: @example error (semi): Extra semicolon.
  991. /**
  992. * @example
  993. * ```js alert('hello'); ```
  994. */
  995. var quux = {
  996. };
  997. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"exampleCodeRegex":"```js ([\\s\\S]*)```"}]
  998. // Message: @example error (semi): Extra semicolon.
  999. /**
  1000. * @example ```
  1001. * js alert('hello'); ```
  1002. */
  1003. function quux () {
  1004. }
  1005. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"exampleCodeRegex":"```\njs ([\\s\\S]*)```"}]
  1006. // Message: @example error (semi): Extra semicolon.
  1007. /**
  1008. * @example <b>Not JavaScript</b>
  1009. */
  1010. function quux () {
  1011. }
  1012. /**
  1013. * @example quux2();
  1014. */
  1015. function quux2 () {
  1016. }
  1017. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"rejectExampleCodeRegex":"^\\s*<.*>\\s*$"}]
  1018. // Message: @example error (semi): Extra semicolon.
  1019. /**
  1020. * @example
  1021. * quux(); // does something useful
  1022. */
  1023. function quux () {
  1024. }
  1025. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"no-undef":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":true}]
  1026. // Message: @example error (no-undef): 'quux' is not defined.
  1027. /**
  1028. * @example <caption>Valid usage</caption>
  1029. * quux(); // does something useful
  1030. *
  1031. * @example
  1032. * quux('random unwanted arg'); // results in an error
  1033. */
  1034. function quux () {
  1035. }
  1036. // "jsdoc/check-examples": ["error"|"warn", {"captionRequired":true,"checkEslintrc":false}]
  1037. // Message: Caption is expected for examples.
  1038. /**
  1039. * @example quux();
  1040. */
  1041. function quux () {
  1042. }
  1043. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
  1044. // Message: @example error (indent): Expected indentation of 0 spaces but found 1.
  1045. /**
  1046. * @example test() // eslint-disable-line semi
  1047. */
  1048. function quux () {}
  1049. // "jsdoc/check-examples": ["error"|"warn", {"checkEslintrc":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":true}]
  1050. // Message: @example error: Unused eslint-disable directive (no problems were reported from 'semi').
  1051. /**
  1052. * @example
  1053. test() // eslint-disable-line semi
  1054. */
  1055. function quux () {}
  1056. // "jsdoc/check-examples": ["error"|"warn", {"allowInlineConfig":false,"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc":false,"noDefaultExampleRules":true}]
  1057. // Message: @example error (semi): Missing semicolon.
  1058. /**
  1059. * @example const i = 5;
  1060. * quux2()
  1061. */
  1062. function quux2 () {
  1063. }
  1064. // "jsdoc/check-examples": ["error"|"warn", {"matchingFileName":"../../jsdocUtils.js"}]
  1065. // Message: @example warning (id-length): Identifier name 'i' is too short (< 2).
  1066. /**
  1067. * @example const i = 5;
  1068. * quux2()
  1069. */
  1070. function quux2 () {
  1071. }
  1072. // "jsdoc/check-examples": ["error"|"warn", {"configFile":".eslintrc.json","matchingFileName":"../../jsdocUtils.js"}]
  1073. // Message: @example warning (id-length): Identifier name 'i' is too short (< 2).
  1074. /**
  1075. * @example const i = 5;
  1076. * quux2()
  1077. */
  1078. function quux2 () {
  1079. }
  1080. // Message: @example warning (id-length): Identifier name 'i' is too short (< 2).
  1081. /**
  1082. * @example const i = 5;
  1083. * quux2()
  1084. */
  1085. function quux2 () {
  1086. }
  1087. // "jsdoc/check-examples": ["error"|"warn", {"paddedIndent":2}]
  1088. // Message: @example warning (id-length): Identifier name 'i' is too short (< 2).
  1089. /**
  1090. * @example
  1091. * const i = 5;
  1092. * quux2()
  1093. */
  1094. function quux2 () {
  1095. }
  1096. // Message: @example warning (id-length): Identifier name 'i' is too short (< 2).
  1097. /**
  1098. * @example const idx = 5;
  1099. * quux2()
  1100. */
  1101. function quux2 () {
  1102. }
  1103. // "jsdoc/check-examples": ["error"|"warn", {"matchingFileName":"dummy.js"}]
  1104. // Message: @example error (semi): Missing semicolon.
  1105. /**
  1106. * @example const idx = 5;
  1107. *
  1108. * quux2()
  1109. */
  1110. function quux2 () {
  1111. }
  1112. // "jsdoc/check-examples": ["error"|"warn", {"matchingFileName":"dummy.js"}]
  1113. // Message: @example error (semi): Missing semicolon.
  1114. /**
  1115. * @example const idx = 5;
  1116. *
  1117. * quux2()
  1118. */
  1119. function quux2 () {
  1120. }
  1121. // "jsdoc/check-examples": ["error"|"warn", {"checkEslintrc":false,"matchingFileName":"dummy.js"}]
  1122. // Message: @example error: Parsing error: The keyword 'const' is reserved
  1123. /**
  1124. * @example // begin
  1125. alert('hello')
  1126. // end
  1127. */
  1128. function quux () {
  1129. }
  1130. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["warn","always"]}},"checkEslintrc":false,"exampleCodeRegex":"// begin[\\s\\S]*// end","noDefaultExampleRules":true}]
  1131. // Message: @example warning (semi): Missing semicolon.
  1132. /**
  1133. * @typedef {string} Foo
  1134. * @example <caption></caption>
  1135. * 'foo'
  1136. */
  1137. // "jsdoc/check-examples": ["error"|"warn", {"captionRequired":true,"checkEslintrc":false}]
  1138. // Message: Caption is expected for examples.
  1139. /**
  1140. * @example
  1141. * const list: number[] = [1, 2, 3]
  1142. * quux(list);
  1143. */
  1144. function quux () {
  1145. }
  1146. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}},"checkEslintrc":false}]
  1147. // Message: @example error (semi): Missing semicolon.
  1148. /**
  1149. * @example
  1150. * const test = something.find((_) => {
  1151. * return _
  1152. * });
  1153. */
  1154. function quux () {
  1155. }
  1156. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}}}]
  1157. // Message: @example error (semi): Missing semicolon.
  1158. /**
  1159. * @example <caption>Say `Hello!` to the user.</caption>
  1160. * First, import the function:
  1161. *
  1162. * ```js
  1163. * import popup from './popup'
  1164. * const aConstInSameScope = 5;
  1165. * ```
  1166. *
  1167. * Then use it like this:
  1168. *
  1169. * ```js
  1170. * const aConstInSameScope = 7;
  1171. * popup('Hello!')
  1172. * ```
  1173. *
  1174. * Here is the result on macOS:
  1175. *
  1176. * ![Screenshot](path/to/screenshot.jpg)
  1177. */
  1178. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parserOptions":{"ecmaVersion":2015,"sourceType":"module"},"rules":{"semi":["error","always"]}},"checkEslintrc":false,"exampleCodeRegex":"/^```(?:js|javascript)\\n([\\s\\S]*?)```$/gm"}]
  1179. // Message: @example error (semi): Missing semicolon.
  1180. /**
  1181. * @example // begin
  1182. alert('hello')
  1183. // end
  1184. * And here is another example:
  1185. // begin
  1186. alert('there')
  1187. // end
  1188. */
  1189. function quux () {
  1190. }
  1191. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["warn","always"]}},"checkEslintrc":false,"exampleCodeRegex":"/\\/\\/ begin[\\s\\S]*?// end/g","noDefaultExampleRules":true}]
  1192. // Message: @example warning (semi): Missing semicolon.
  1193. /**
  1194. * @example
  1195. * quux();
  1196. */
  1197. function quux () {
  1198. }
  1199. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
  1200. // Message: @example error (indent): Expected indentation of 0 spaces but found 2.
  1201. /**
  1202. * @default 'abc'
  1203. */
  1204. const str = 'abc';
  1205. // "jsdoc/check-examples": ["error"|"warn", {"checkDefaults":true}]
  1206. // Message: @default error (quotes): Strings must use doublequote.
  1207. /**
  1208. * @param {myType} [name='abc']
  1209. */
  1210. function quux () {
  1211. }
  1212. // "jsdoc/check-examples": ["error"|"warn", {"checkParams":true}]
  1213. // Message: @param error (quotes): Strings must use doublequote.
  1214. /**
  1215. * @property {myType} [name='abc']
  1216. */
  1217. const obj = {};
  1218. // "jsdoc/check-examples": ["error"|"warn", {"checkProperties":true}]
  1219. // Message: @property error (quotes): Strings must use doublequote.
  1220. /**
  1221. * Test function.
  1222. *
  1223. * @example <caption>functionName (paramOne: string, paramTwo?: any,
  1224. * paramThree?: any): boolean</caption> test()
  1225. *
  1226. * @param {string} paramOne Parameter description.
  1227. * @param {any} [paramTwo] Parameter description.
  1228. * @param {any} [paramThree] Parameter description.
  1229. * @returns {boolean} Return description.
  1230. */
  1231. const functionName = function (paramOne, paramTwo,
  1232. paramThree) {
  1233. return false;
  1234. };
  1235. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parserOptions":{"ecmaVersion":2015,"sourceType":"module"},"rules":{"semi":["error","always"]}},"captionRequired":true,"checkEslintrc":false}]
  1236. // Message: @example error (semi): Missing semicolon.
  1237. ````
  1238. The following patterns are not considered problems:
  1239. ````js
  1240. /**
  1241. * @example ```js
  1242. alert('hello');
  1243. ```
  1244. */
  1245. function quux () {
  1246. }
  1247. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
  1248. /**
  1249. * @example ```js
  1250. alert('hello');
  1251. ```
  1252. */
  1253. function quux () {
  1254. }
  1255. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc":false,"exampleCodeRegex":"/```js([\\s\\S]*)```/"}]
  1256. /**
  1257. * @example
  1258. * // arbitrary example content
  1259. */
  1260. function quux () {
  1261. }
  1262. // "jsdoc/check-examples": ["error"|"warn", {"checkEslintrc":false}]
  1263. /**
  1264. * @example
  1265. * quux(); // does something useful
  1266. */
  1267. function quux () {
  1268. }
  1269. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"no-undef":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
  1270. /**
  1271. * @example quux();
  1272. */
  1273. function quux () {
  1274. }
  1275. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
  1276. /**
  1277. * @example <caption>Valid usage</caption>
  1278. * quux(); // does something useful
  1279. *
  1280. * @example <caption>Invalid usage</caption>
  1281. * quux('random unwanted arg'); // results in an error
  1282. */
  1283. function quux () {
  1284. }
  1285. // "jsdoc/check-examples": ["error"|"warn", {"captionRequired":true,"checkEslintrc":false}]
  1286. /**
  1287. * @example test() // eslint-disable-line semi
  1288. */
  1289. function quux () {}
  1290. // "jsdoc/check-examples": ["error"|"warn", {"checkEslintrc":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":false}]
  1291. /**
  1292. * @example
  1293. test() // eslint-disable-line semi
  1294. */
  1295. function quux () {}
  1296. // "jsdoc/check-examples": ["error"|"warn", {"allowInlineConfig":true,"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc":false,"noDefaultExampleRules":true}]
  1297. /**
  1298. * @example ```js
  1299. alert('hello')
  1300. ```
  1301. */
  1302. var quux = {
  1303. };
  1304. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
  1305. /**
  1306. * @example
  1307. * foo(function (err) {
  1308. * throw err;
  1309. * });
  1310. */
  1311. function quux () {}
  1312. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
  1313. /**
  1314. * @example
  1315. * const list: number[] = [1, 2, 3];
  1316. * quux(list);
  1317. */
  1318. function quux () {
  1319. }
  1320. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}},"checkEslintrc":false}]
  1321. /**
  1322. * @example const ident = 5;
  1323. * quux2();
  1324. * bar();
  1325. */
  1326. function quux2 () {
  1327. }
  1328. // "jsdoc/check-examples": ["error"|"warn", {"paddedIndent":2}]
  1329. /**
  1330. * @example
  1331. * function quux() {
  1332. * bar();
  1333. * }
  1334. */
  1335. function quux () {
  1336. }
  1337. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
  1338. // Comment
  1339. a();
  1340. export default {};
  1341. /**
  1342. *
  1343. */
  1344. function f () {
  1345. }
  1346. /**
  1347. * Does quux
  1348. * @example
  1349. * // Do it!
  1350. * quux();
  1351. */
  1352. function quux () {
  1353. }
  1354. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"plugins":["jsdoc"],"rules":{"jsdoc/require-file-overview":["error"]}},"checkEslintrc":false,"noDefaultExampleRules":false}]
  1355. /**
  1356. * @default "abc"
  1357. */
  1358. const str = 'abc';
  1359. // "jsdoc/check-examples": ["error"|"warn", {"checkDefaults":true}]
  1360. /**
  1361. * @default
  1362. */
  1363. const str = 'abc';
  1364. // "jsdoc/check-examples": ["error"|"warn", {"checkDefaults":true}]
  1365. /**
  1366. * @param {myType} [name="abc"]
  1367. */
  1368. function quux () {
  1369. }
  1370. // "jsdoc/check-examples": ["error"|"warn", {"checkParams":true}]
  1371. /**
  1372. * @param {myType} name
  1373. */
  1374. function quux () {
  1375. }
  1376. // "jsdoc/check-examples": ["error"|"warn", {"checkParams":true}]
  1377. /**
  1378. * @property {myType} [name="abc"]
  1379. */
  1380. const obj = {};
  1381. // "jsdoc/check-examples": ["error"|"warn", {"checkProperties":true}]
  1382. /**
  1383. * @property {myType} [name]
  1384. */
  1385. const obj = {};
  1386. // "jsdoc/check-examples": ["error"|"warn", {"checkProperties":true}]
  1387. /**
  1388. * @default 'abc'
  1389. */
  1390. const str = 'abc';
  1391. // "jsdoc/check-examples": ["error"|"warn", {"checkDefaults":false,"matchingFileNameDefaults":"dummy.js"}]
  1392. /**
  1393. * @param {myType} [name='abc']
  1394. */
  1395. function quux () {
  1396. }
  1397. // "jsdoc/check-examples": ["error"|"warn", {"checkParams":false,"matchingFileNameParams":"dummy.js"}]
  1398. /**
  1399. * @property {myType} [name='abc']
  1400. */
  1401. const obj = {};
  1402. // "jsdoc/check-examples": ["error"|"warn", {"checkProperties":false,"matchingFileNameProperties":"dummy.js"}]
  1403. /**
  1404. * Test function.
  1405. *
  1406. * @example <caption>functionName (paramOne: string, paramTwo?: any,
  1407. * paramThree?: any): boolean</caption> test();
  1408. *
  1409. * @param {string} paramOne Parameter description.
  1410. * @param {any} [paramTwo] Parameter description.
  1411. * @param {any} [paramThree] Parameter description.
  1412. * @returns {boolean} Return description.
  1413. */
  1414. const functionName = function (paramOne, paramTwo,
  1415. paramThree) {
  1416. return false;
  1417. };
  1418. // "jsdoc/check-examples": ["error"|"warn", {"baseConfig":{"parserOptions":{"ecmaVersion":2015,"sourceType":"module"},"rules":{"semi":["error","always"]}},"captionRequired":true,"checkEslintrc":false}]
  1419. ````
  1420. <a name="eslint-plugin-jsdoc-rules-check-indentation"></a>
  1421. ### <code>check-indentation</code>
  1422. Reports invalid padding inside JSDoc blocks.
  1423. Ignores parts enclosed in Markdown "code block"'s. For example,
  1424. the following description is not reported:
  1425. ```js
  1426. /**
  1427. * Some description:
  1428. * ```html
  1429. * <section>
  1430. * <title>test</title>
  1431. * </section>
  1432. * ```
  1433. */
  1434. ```
  1435. <a name="eslint-plugin-jsdoc-rules-check-indentation-options-2"></a>
  1436. #### Options
  1437. This rule has an object option.
  1438. <a name="eslint-plugin-jsdoc-rules-check-indentation-options-2-excludetags"></a>
  1439. ##### <code>excludeTags</code>
  1440. Array of tags (e.g., `['example', 'description']`) whose content will be
  1441. "hidden" from the `check-indentation` rule. Defaults to `['example']`.
  1442. By default, the whole JSDoc block will be checked for invalid padding.
  1443. That would include `@example` blocks too, which can get in the way
  1444. of adding full, readable examples of code without ending up with multiple
  1445. linting issues.
  1446. When disabled (by passing `excludeTags: []` option), the following code *will*
  1447. report a padding issue:
  1448. ```js
  1449. /**
  1450. * @example
  1451. * anArray.filter((a) => {
  1452. * return a.b;
  1453. * });
  1454. */
  1455. ```
  1456. |||
  1457. |---|---|
  1458. |Context|everywhere|
  1459. |Tags|N/A|
  1460. |Recommended|false|
  1461. |Options| `excludeTags` |
  1462. The following patterns are considered problems:
  1463. ````js
  1464. /** foo */
  1465. function quux () {
  1466. }
  1467. // Message: There must be no indentation.
  1468. /**
  1469. * foo
  1470. *
  1471. * @param bar
  1472. * baz
  1473. */
  1474. function quux () {
  1475. }
  1476. // Message: There must be no indentation.
  1477. /**
  1478. * Foo
  1479. * bar
  1480. */
  1481. class Moo {}
  1482. // Message: There must be no indentation.
  1483. /**
  1484. * foo
  1485. *
  1486. * @example
  1487. * anArray.filter((a) => {
  1488. * return a.b;
  1489. * });
  1490. */
  1491. function quux () {
  1492. }
  1493. // "jsdoc/check-indentation": ["error"|"warn", {"excludeTags":[]}]
  1494. // Message: There must be no indentation.
  1495. /**
  1496. * foo
  1497. *
  1498. * @example
  1499. * aaaa
  1500. * @returns
  1501. * eeee
  1502. */
  1503. function quux () {
  1504. }
  1505. // Message: There must be no indentation.
  1506. /**
  1507. * foo
  1508. * ```html
  1509. * <section>
  1510. * <title>test</title>
  1511. * </section>
  1512. * ```
  1513. * @returns
  1514. * eeee
  1515. */
  1516. function quux () {
  1517. }
  1518. // Message: There must be no indentation.
  1519. /**
  1520. * foo
  1521. * ``` aaaa```
  1522. * @returns
  1523. * eeee
  1524. */
  1525. function quux () {
  1526. }
  1527. // Message: There must be no indentation.
  1528. /**
  1529. * @example <caption>
  1530. * Here is a long
  1531. * indented summary of this
  1532. * example
  1533. * </caption>
  1534. * ```js
  1535. * function hi () {
  1536. * alert('Hello');
  1537. * }
  1538. * ```
  1539. */
  1540. // "jsdoc/check-indentation": ["error"|"warn", {"excludeTags":[]}]
  1541. // Message: There must be no indentation.
  1542. /**
  1543. * @example <caption>
  1544. * Here is a long
  1545. * summary of this
  1546. * example
  1547. * </caption>
  1548. * // Code is not wrapped into fenced code block
  1549. * function hi () {
  1550. * alert('Hello');
  1551. * }
  1552. */
  1553. // "jsdoc/check-indentation": ["error"|"warn", {"excludeTags":[]}]
  1554. // Message: There must be no indentation.
  1555. ````
  1556. The following patterns are not considered problems:
  1557. ````js
  1558. /**
  1559. * foo
  1560. *
  1561. * @param bar
  1562. * baz
  1563. */
  1564. function quux () {
  1565. }
  1566. /*** foo */
  1567. function quux () {
  1568. }
  1569. /**
  1570. * foo
  1571. *
  1572. * @example
  1573. * anArray.filter((a) => {
  1574. * return a.b;
  1575. * });
  1576. */
  1577. function quux () {
  1578. }
  1579. /**
  1580. * foo
  1581. *
  1582. * @example
  1583. * anArray.filter((a) => {
  1584. * return a.b;
  1585. * });
  1586. * @returns
  1587. * eeee
  1588. */
  1589. function quux () {
  1590. }
  1591. // "jsdoc/check-indentation": ["error"|"warn", {"excludeTags":["example","returns"]}]
  1592. /**
  1593. * foo
  1594. * ```html
  1595. * <section>
  1596. * <title>test</title>
  1597. * </section>
  1598. * ```
  1599. * @returns eeee
  1600. */
  1601. function quux () {
  1602. }
  1603. /**
  1604. * foo
  1605. * ``` aaaa```
  1606. * @returns eeee
  1607. */
  1608. function quux () {
  1609. }
  1610. /**
  1611. * @example <caption>
  1612. * Here is a long
  1613. * summary of this
  1614. * example
  1615. * </caption>
  1616. * ```js
  1617. * function hi () {
  1618. * alert('Hello');
  1619. * }
  1620. * ```
  1621. */
  1622. // "jsdoc/check-indentation": ["error"|"warn", {"excludeTags":[]}]
  1623. ````
  1624. <a name="eslint-plugin-jsdoc-rules-check-line-alignment"></a>
  1625. ### <code>check-line-alignment</code>
  1626. Reports invalid alignment of JSDoc block lines. This is a
  1627. [standard recommended to WordPress code](https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/javascript/#aligning-comments),
  1628. for example.
  1629. <a name="eslint-plugin-jsdoc-rules-check-line-alignment-options-3"></a>
  1630. #### Options
  1631. This rule allows one optional string argument. If it is `"always"` then a
  1632. problem is raised when the lines are not aligned. If it is `"never"` then
  1633. a problem should be raised when there is more than one space between each
  1634. line's parts. Defaults to `"never"`.
  1635. Note that in addition to alignment, both options will ensure at least one
  1636. space is present after the asterisk delimiter.
  1637. After the string, an options object is allowed with the following properties.
  1638. <a name="eslint-plugin-jsdoc-rules-check-line-alignment-options-3-tags"></a>
  1639. ##### <code>tags</code>
  1640. Use this to change the tags which are sought for alignment changes. *Currently*
  1641. *only works with the "never" option.* Defaults to an array of
  1642. `['param', 'arg', 'argument', 'property', 'prop', 'returns', 'return']`.
  1643. <a name="eslint-plugin-jsdoc-rules-check-line-alignment-options-3-customspacings"></a>
  1644. ##### <code>customSpacings</code>
  1645. An object with any of the following keys set to an integer. Affects spacing:
  1646. - `postDelimiter` - after the asterisk (e.g., `* @param`)
  1647. - `postTag` - after the tag (e.g., `* @param `)
  1648. - `postType` - after the type (e.g., `* @param {someType} `)
  1649. - `postName` - after the name (e.g., `* @param {someType} name `)
  1650. If a spacing is not defined, it defaults to one.
  1651. |||
  1652. |---|---|
  1653. |Context|everywhere|
  1654. |Options|(a string matching `"always" or "never"` and optional object with `tags` and `customSpacings`)|
  1655. |Tags|`param`, `property`, `returns` and others added by `tags`|
  1656. |Aliases|`arg`, `argument`, `prop`, `return`|
  1657. |Recommended|false|
  1658. The following patterns are considered problems:
  1659. ````js
  1660. /**
  1661. * Function description.
  1662. *
  1663. * @param {string} lorem Description.
  1664. * @param {int} sit Description multi words.
  1665. */
  1666. const fn = ( lorem, sit ) => {}
  1667. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1668. // Message: Expected JSDoc block lines to be aligned.
  1669. /**
  1670. * With tabs.
  1671. *
  1672. * @param {string} lorem Description.
  1673. * @param {int} sit Description multi words.
  1674. */
  1675. const fn = ( lorem, sit ) => {}
  1676. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1677. // Message: Expected JSDoc block lines to be aligned.
  1678. /**
  1679. * Function description.
  1680. *
  1681. * @param {string} lorem - Description.
  1682. * @param {int} sit - Description multi words.
  1683. */
  1684. const fn = ( lorem, sit ) => {}
  1685. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1686. // Message: Expected JSDoc block lines to be aligned.
  1687. /**
  1688. * Function description.
  1689. *
  1690. * @param {string} lorem Description.
  1691. * @param {int} sit Description multi words.
  1692. */
  1693. const fn = ( lorem, sit ) => {}
  1694. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1695. // Message: Expected JSDoc block lines to be aligned.
  1696. /**
  1697. * Function description.
  1698. *
  1699. * @param {string} lorem Description.
  1700. * @param {int} sit Description multi words.
  1701. */
  1702. const fn = ( lorem, sit ) => {}
  1703. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1704. // Message: Expected JSDoc block lines to be aligned.
  1705. /**
  1706. * Function description.
  1707. *
  1708. * @param {string} lorem Description.
  1709. * @param {int} sit Description multi words.
  1710. */
  1711. const fn = ( lorem, sit ) => {}
  1712. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1713. // Message: Expected JSDoc block lines to be aligned.
  1714. /**
  1715. * Function description.
  1716. *
  1717. * @param {string} lorem Description.
  1718. * @param {int} sit Description multi words.
  1719. */
  1720. const fn = ( lorem, sit ) => {}
  1721. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1722. // Message: Expected JSDoc block lines to be aligned.
  1723. /**
  1724. * Function description.
  1725. *
  1726. * @param {string} lorem Description.
  1727. * @param {int} sit Description multi words.
  1728. */
  1729. function fn( lorem, sit ) {}
  1730. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1731. // Message: Expected JSDoc block lines to be aligned.
  1732. const object = {
  1733. /**
  1734. * Function description.
  1735. *
  1736. * @param {string} lorem Description.
  1737. * @param {int} sit Description multi words.
  1738. */
  1739. fn( lorem, sit ) {}
  1740. }
  1741. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1742. // Message: Expected JSDoc block lines to be aligned.
  1743. class ClassName {
  1744. /**
  1745. * Function description.
  1746. *
  1747. * @param {string} lorem Description.
  1748. * @param {int} sit Description multi words.
  1749. */
  1750. fn( lorem, sit ) {}
  1751. }
  1752. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1753. // Message: Expected JSDoc block lines to be aligned.
  1754. /**
  1755. * Function description.
  1756. *
  1757. * @arg {string} lorem Description.
  1758. * @arg {int} sit Description multi words.
  1759. */
  1760. const fn = ( lorem, sit ) => {}
  1761. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1762. // Message: Expected JSDoc block lines to be aligned.
  1763. /**
  1764. * @namespace
  1765. * @property {object} defaults Description.
  1766. * @property {int} defaults.lorem Description multi words.
  1767. */
  1768. const config = {
  1769. defaults: {
  1770. lorem: 1
  1771. }
  1772. }
  1773. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1774. // Message: Expected JSDoc block lines to be aligned.
  1775. /**
  1776. * My object.
  1777. *
  1778. * @typedef {Object} MyObject
  1779. *
  1780. * @property {string} lorem Description.
  1781. * @property {int} sit Description multi words.
  1782. */
  1783. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1784. // Message: Expected JSDoc block lines to be aligned.
  1785. /**
  1786. * My object.
  1787. *
  1788. * @typedef {Object} MyObject
  1789. *
  1790. * @property {{a: number, b: string, c}} lorem Description.
  1791. * @property {Object.<string, Class>} sit Description multi words.
  1792. * @property {Object.<string, Class>} amet Description} weird {multi} {{words}}.
  1793. * @property {Object.<string, Class>} dolor
  1794. */
  1795. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1796. // Message: Expected JSDoc block lines to be aligned.
  1797. /**
  1798. * My object.
  1799. *
  1800. * @typedef {Object} MyObject
  1801. *
  1802. * @property {{a: number, b: string, c}} lorem Description.
  1803. * @property {Object.<string, Class>} sit Description multi words.
  1804. * @property {Object.<string, Class>} amet Description} weird {multi} {{words}}.
  1805. * @property {Object.<string, Class>} dolor
  1806. */
  1807. // "jsdoc/check-line-alignment": ["error"|"warn", "always",{"tags":["typedef","property"]}]
  1808. // Message: Expected JSDoc block lines to be aligned.
  1809. /**
  1810. * My function.
  1811. *
  1812. * @param {string} lorem Description.
  1813. * @param {int} sit Description multi words.
  1814. */
  1815. const fn = ( lorem, sit ) => {}
  1816. // "jsdoc/check-line-alignment": ["error"|"warn", "never"]
  1817. // Message: Expected JSDoc block lines to not be aligned.
  1818. /**
  1819. * My function.
  1820. *
  1821. * @param {string} lorem Description.
  1822. * @param {int} sit Description multi words.
  1823. */
  1824. const fn = ( lorem, sit ) => {}
  1825. // "jsdoc/check-line-alignment": ["error"|"warn", "never"]
  1826. // Message: Expected JSDoc block lines to not be aligned.
  1827. /**
  1828. * My function.
  1829. *
  1830. * @param {string} lorem Description.
  1831. * @param {int} sit
  1832. */
  1833. const fn = ( lorem, sit ) => {}
  1834. // "jsdoc/check-line-alignment": ["error"|"warn", "never"]
  1835. // Message: Expected JSDoc block lines to not be aligned.
  1836. /**
  1837. * My function.
  1838. *
  1839. * @param {string} lorem Description.
  1840. * @param {int} sit
  1841. */
  1842. const fn = ( lorem, sit ) => {}
  1843. // Message: Expected JSDoc block lines to not be aligned.
  1844. /**
  1845. * Function description.
  1846. *
  1847. * @param {string} lorem Description.
  1848. * @param {int} sit Description multi
  1849. line without *.
  1850. */
  1851. const fn = ( lorem, sit ) => {}
  1852. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1853. // Message: Expected JSDoc block lines to be aligned.
  1854. /**
  1855. * My function.
  1856. *
  1857. * @param {string} lorem Description.
  1858. * @param {int} sit
  1859. *
  1860. * @return {string} Return description
  1861. * with multi line, but don't touch.
  1862. */
  1863. const fn = ( lorem, sit ) => {}
  1864. // "jsdoc/check-line-alignment": ["error"|"warn", "always",{"tags":["param"]}]
  1865. // Message: Expected JSDoc block lines to be aligned.
  1866. /**
  1867. * Only return doc.
  1868. *
  1869. * @return {boolean} Return description.
  1870. */
  1871. const fn = ( lorem, sit ) => {}
  1872. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1873. // Message: Expected JSDoc block lines to be aligned.
  1874. /**
  1875. * Creates OS based shortcuts for files, folders, and applications.
  1876. *
  1877. * @param {object} options Options object for each OS.
  1878. * @return {boolean} True = success, false = failed to create the icon
  1879. */
  1880. function quux () {}
  1881. // "jsdoc/check-line-alignment": ["error"|"warn", "never"]
  1882. // Message: Expected JSDoc block lines to not be aligned.
  1883. /**
  1884. * Creates OS based shortcuts for files, folders, and applications.
  1885. *
  1886. * @param {object} options Options object for each OS.
  1887. * @return {boolean} True = success, false = failed to create the icon
  1888. */
  1889. function quux () {}
  1890. // "jsdoc/check-line-alignment": ["error"|"warn", "never"]
  1891. // Message: Expected JSDoc block lines to not be aligned.
  1892. /**
  1893. * Creates OS based shortcuts for files, folders, and applications.
  1894. *
  1895. * @param {object} options Options object for each OS.
  1896. * @return True = success, false = failed to create the icon
  1897. */
  1898. function quux () {}
  1899. // "jsdoc/check-line-alignment": ["error"|"warn", "never"]
  1900. // Message: Expected JSDoc block lines to not be aligned.
  1901. /**
  1902. * Creates OS based shortcuts for files, folders, and applications.
  1903. *
  1904. * @param options Options object for each OS.
  1905. * @return True = success, false = failed to create the icon
  1906. */
  1907. function quux () {}
  1908. // "jsdoc/check-line-alignment": ["error"|"warn", "never"]
  1909. // Message: Expected JSDoc block lines to not be aligned.
  1910. /**
  1911. * Creates OS based shortcuts for files, folders, and applications.
  1912. *
  1913. * @param {object} options Options object for each OS.
  1914. * @param {object} other Other.
  1915. * @return True = success, false = failed to create the icon
  1916. */
  1917. function quux () {}
  1918. // "jsdoc/check-line-alignment": ["error"|"warn", "never",{"tags":["param","return"]}]
  1919. // Message: Expected JSDoc block lines to not be aligned.
  1920. /**
  1921. * Returns the value stored in the process.env for a given
  1922. * environment variable.
  1923. *
  1924. * @param {string} withPercents '%USERNAME%'
  1925. * @param {string} withoutPercents 'USERNAME'
  1926. * @return {string} 'bob' || '%USERNAME%'
  1927. */
  1928. function quux () {}
  1929. // "jsdoc/check-line-alignment": ["error"|"warn", "never"]
  1930. // Message: Expected JSDoc block lines to not be aligned.
  1931. /**
  1932. * Function description
  1933. * description with post delimiter.
  1934. *
  1935. * @param {string} lorem Description.
  1936. * @param {int} sit Description multi words.
  1937. */
  1938. const fn = ( lorem, sit ) => {}
  1939. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1940. // Message: Expected JSDoc block lines to be aligned.
  1941. /**
  1942. * Function description.
  1943. *
  1944. * @param {string} lorem Description.
  1945. * @param {int} sit Description multi words.
  1946. *
  1947. * @return {string} Return description.
  1948. */
  1949. const fn = ( lorem, sit ) => {}
  1950. // "jsdoc/check-line-alignment": ["error"|"warn", "always",{"customSpacings":{"postDelimiter":2,"postTag":3,"postType":2}}]
  1951. // Message: Expected JSDoc block lines to be aligned.
  1952. /**
  1953. * Function description.
  1954. *
  1955. * @param {string} lorem Description.
  1956. * @param {int} sit Description multi words.
  1957. *
  1958. * @return {string} Return description.
  1959. */
  1960. const fn = ( lorem, sit ) => {}
  1961. // "jsdoc/check-line-alignment": ["error"|"warn", "always",{"customSpacings":{"postName":3}}]
  1962. // Message: Expected JSDoc block lines to be aligned.
  1963. /**
  1964. * Function description.
  1965. *
  1966. * @param {string} lorem Description.
  1967. * @param {int} sit Description multi words.
  1968. */
  1969. const fn = ( lorem, sit ) => {}
  1970. // "jsdoc/check-line-alignment": ["error"|"warn", "never",{"customSpacings":{"postDelimiter":2,"postTag":3,"postType":2}}]
  1971. // Message: Expected JSDoc block lines to not be aligned.
  1972. /**
  1973. * Function description.
  1974. *
  1975. * @param {string} lorem Description.
  1976. * @param {int} sit Description multi words.
  1977. */
  1978. const fn = ( lorem, sit ) => {}
  1979. // "jsdoc/check-line-alignment": ["error"|"warn", "never",{"customSpacings":{"postName":3}}]
  1980. // Message: Expected JSDoc block lines to not be aligned.
  1981. /**
  1982. * Function description.
  1983. *
  1984. * @param {string} lorem Description.
  1985. * @param {int} sit Description multi words.
  1986. * @param {string} sth Multi
  1987. * line description.
  1988. */
  1989. const fn = ( lorem, sit ) => {}
  1990. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  1991. // Message: Expected JSDoc block lines to be aligned.
  1992. ````
  1993. The following patterns are not considered problems:
  1994. ````js
  1995. /**
  1996. * Function description.
  1997. *
  1998. * @param {string} lorem Description.
  1999. * @param {int} sit Description multi words.
  2000. */
  2001. const fn = ( lorem, sit ) => {}
  2002. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2003. /**
  2004. * With tabs.
  2005. *
  2006. * @param {string} lorem Description.
  2007. * @param {int} sit Description multi words.
  2008. */
  2009. const fn = ( lorem, sit ) => {}
  2010. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2011. /**
  2012. * Function description.
  2013. *
  2014. * @param {string} lorem - Description.
  2015. * @param {int} sit - Description multi words.
  2016. */
  2017. const fn = ( lorem, sit ) => {}
  2018. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2019. /**
  2020. * @param {string} lorem Description.
  2021. * @param {int} sit
  2022. */
  2023. const fn = ( lorem, sit ) => {}
  2024. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2025. /**
  2026. * @param {int} sit
  2027. * @param {string} lorem Description.
  2028. */
  2029. const fn = ( lorem, sit ) => {}
  2030. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2031. /**
  2032. * No params.
  2033. */
  2034. const fn = () => {}
  2035. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2036. const fn = ( lorem, sit ) => {}
  2037. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2038. /**
  2039. * Function description.
  2040. *
  2041. * @param {string} lorem Description.
  2042. * @param {int} sit Description multi words.
  2043. */
  2044. function fn( lorem, sit ) {}
  2045. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2046. const object = {
  2047. /**
  2048. * Function description.
  2049. *
  2050. * @param {string} lorem Description.
  2051. * @param {int} sit Description multi words.
  2052. */
  2053. fn( lorem, sit ) {},
  2054. }
  2055. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2056. class ClassName {
  2057. /**
  2058. * Function description.
  2059. *
  2060. * @param {string} lorem Description.
  2061. * @param {int} sit Description multi words.
  2062. */
  2063. fn( lorem, sit ) {}
  2064. }
  2065. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2066. /**
  2067. * Function description.
  2068. *
  2069. * @arg {string} lorem Description.
  2070. * @arg {int} sit Description multi words.
  2071. */
  2072. const fn = ( lorem, sit ) => {}
  2073. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2074. /**
  2075. * @namespace
  2076. * @property {object} defaults Description.
  2077. * @property {int} defaults.lorem Description multi words.
  2078. */
  2079. const config = {
  2080. defaults: {
  2081. lorem: 1
  2082. }
  2083. }
  2084. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2085. /**
  2086. * My object.
  2087. *
  2088. * @typedef {Object} MyObject
  2089. *
  2090. * @property {string} lorem Description.
  2091. * @property {int} sit Description multi words.
  2092. */
  2093. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2094. /**
  2095. * My object.
  2096. *
  2097. * @typedef {Object} MyObject
  2098. *
  2099. * @property {{a: number, b: string, c}} lorem Description.
  2100. * @property {Object.<string, Class>} sit Description multi words.
  2101. * @property {Object.<string, Class>} amet Description} weird {multi} {{words}}.
  2102. * @property {Object.<string, Class>} dolor
  2103. */
  2104. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2105. /**
  2106. * My object.
  2107. *
  2108. * @typedef {Object} MyObject
  2109. *
  2110. * @property {{a: number, b: string, c}} lorem Description.
  2111. * @property {Object.<string, Class>} sit Description multi words.
  2112. * @property {Object.<string, Class>} amet Description} weird {multi} {{words}}.
  2113. * @property {Object.<string, Class>} dolor
  2114. */
  2115. // "jsdoc/check-line-alignment": ["error"|"warn", "always",{"tags":["typedef","property"]}]
  2116. /**
  2117. * My object.
  2118. *
  2119. * @template T
  2120. * @template W,X,Y,Z
  2121. * @template {string} K - K must be a string or string literal
  2122. * @template {{ serious(): string }} Seriousalizable - must have a serious method
  2123. *
  2124. * @param {{a: number, b: string, c}} lorem Description.
  2125. */
  2126. // "jsdoc/check-line-alignment": ["error"|"warn", "always",{"tags":["template","param"]}]
  2127. /** @param {number} lorem */
  2128. const fn = ( lorem ) => {}
  2129. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2130. /**
  2131. * Creates OS based shortcuts for files, folders, and applications.
  2132. *
  2133. * @param {object} options Options object for each OS.
  2134. * @return {boolean} True = success, false = failed to create the icon
  2135. */
  2136. function quux () {}
  2137. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2138. /**
  2139. * Creates OS based shortcuts for files, folders, and applications.
  2140. *
  2141. * @param {object} options Options object for each OS.
  2142. * @return {boolean}
  2143. */
  2144. function quux () {}
  2145. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2146. /**
  2147. * Only return doc.
  2148. *
  2149. * @return {boolean} Return description.
  2150. */
  2151. function quux () {}
  2152. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2153. /**
  2154. * Not validating without option.
  2155. *
  2156. * @param {string} lorem Description.
  2157. * @param {int} sit Description multi words.
  2158. */
  2159. const fn = ( lorem, sit ) => {}
  2160. /**
  2161. * Creates OS based shortcuts for files, folders, and applications.
  2162. *
  2163. * @param {object} options Options object for each OS.
  2164. * @return {boolean} True = success, false = failed to create the icon
  2165. */
  2166. function quux (options) {}
  2167. /**
  2168. * Creates OS based shortcuts for files, folders, and applications.
  2169. *
  2170. * @param {object} options Options object for each OS.
  2171. * @param {object} other Other.
  2172. * @return True = success, false = failed to create the icon
  2173. */
  2174. function quux () {}
  2175. // "jsdoc/check-line-alignment": ["error"|"warn", "never",{"tags":["param"]}]
  2176. /**
  2177. * @param parameter Description.
  2178. */
  2179. function func(parameter){
  2180. }
  2181. /**
  2182. * Function description
  2183. * description with post delimiter.
  2184. *
  2185. * @param {string} lorem Description.
  2186. * @param {int} sit Description multi words.
  2187. */
  2188. const fn = ( lorem, sit ) => {}
  2189. // "jsdoc/check-line-alignment": ["error"|"warn", "always",{"preserveMainDescriptionPostDelimiter":true}]
  2190. /**
  2191. * Function description.
  2192. *
  2193. * @param {string} lorem Description.
  2194. * @param {int} sit Description multi words.
  2195. *
  2196. * @return {string} Return description.
  2197. */
  2198. const fn = ( lorem, sit ) => {}
  2199. // "jsdoc/check-line-alignment": ["error"|"warn", "always",{"customSpacings":{"postDelimiter":2,"postTag":3,"postType":2}}]
  2200. /**
  2201. * Function description.
  2202. *
  2203. * @param {string} lorem Description.
  2204. * @param {int} sit Description multi words.
  2205. *
  2206. * @return {string} Return description.
  2207. */
  2208. const fn = ( lorem, sit ) => {}
  2209. // "jsdoc/check-line-alignment": ["error"|"warn", "never",{"customSpacings":{"postDelimiter":2,"postTag":3,"postType":2}}]
  2210. /**
  2211. * @param {{
  2212. * ids: number[]
  2213. * }} params
  2214. */
  2215. const fn = ({ids}) => {}
  2216. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2217. /**
  2218. * Function description.
  2219. *
  2220. * @param {string} lorem Description.
  2221. * @param {int} sit Description multi words.
  2222. * @param {string} sth Multi
  2223. * line description.
  2224. */
  2225. const fn = ( lorem, sit ) => {}
  2226. // "jsdoc/check-line-alignment": ["error"|"warn", "always"]
  2227. ````
  2228. <a name="eslint-plugin-jsdoc-rules-check-param-names"></a>
  2229. ### <code>check-param-names</code>
  2230. Ensures that parameter names in JSDoc match those in the function declaration.
  2231. <a name="eslint-plugin-jsdoc-rules-check-param-names-destructuring"></a>
  2232. #### Destructuring
  2233. Note that by default the rule will not report parameters present on the docs
  2234. but non-existing on the function signature when an object rest property is part
  2235. of that function signature since the seemingly non-existing properties might
  2236. actually be a part of the object rest property.
  2237. ```js
  2238. /**
  2239. * @param options
  2240. * @param options.foo
  2241. */
  2242. function quux ({foo, ...extra}) {}
  2243. ```
  2244. To require that `extra` be documented--and that any extraneous properties
  2245. get reported--e.g., if there had been a `@param options.bar` above--you
  2246. can use the `checkRestProperty` option which insists that the rest
  2247. property be documented (and that there be no other implicit properties).
  2248. Note, however, that jsdoc [does not appear](https://github.com/jsdoc/jsdoc/issues/1773)
  2249. to currently support syntax or output to distinguish rest properties from
  2250. other properties, so in looking at the docs alone without looking at the
  2251. function signature, the disadvantage of enabling this option is that it
  2252. may appear that there is an actual property named `extra`.
  2253. <a name="eslint-plugin-jsdoc-rules-check-param-names-options-4"></a>
  2254. #### Options
  2255. <a name="eslint-plugin-jsdoc-rules-check-param-names-options-4-checkrestproperty"></a>
  2256. ##### <code>checkRestProperty</code>
  2257. See the "Destructuring" section. Defaults to `false`.
  2258. <a name="eslint-plugin-jsdoc-rules-check-param-names-options-4-checktypespattern"></a>
  2259. ##### <code>checkTypesPattern</code>
  2260. See `require-param` under the option of the same name.
  2261. <a name="eslint-plugin-jsdoc-rules-check-param-names-options-4-enablefixer"></a>
  2262. ##### <code>enableFixer</code>
  2263. Set to `true` to auto-remove `@param` duplicates (based on identical
  2264. names).
  2265. Note that this option will remove duplicates of the same name even if
  2266. the definitions do not match in other ways (e.g., the second param will
  2267. be removed even if it has a different type or description).
  2268. <a name="eslint-plugin-jsdoc-rules-check-param-names-options-4-allowextratrailingparamdocs"></a>
  2269. ##### <code>allowExtraTrailingParamDocs</code>
  2270. If set to `true`, this option will allow extra `@param` definitions (e.g.,
  2271. representing future expected or virtual params) to be present without needing
  2272. their presence within the function signature. Other inconsistencies between
  2273. `@param`'s and present function parameters will still be reported.
  2274. <a name="eslint-plugin-jsdoc-rules-check-param-names-options-4-checkdestructured"></a>
  2275. ##### <code>checkDestructured</code>
  2276. Whether to check destructured properties. Defaults to `true`.
  2277. <a name="eslint-plugin-jsdoc-rules-check-param-names-options-4-usedefaultobjectproperties"></a>
  2278. ##### <code>useDefaultObjectProperties</code>
  2279. Set to `true` if you wish to avoid reporting of child property documentation
  2280. where instead of destructuring, a whole plain object is supplied as default
  2281. value but you wish its keys to be considered as signalling that the properties
  2282. are present and can therefore be documented. Defaults to `false`.
  2283. <a name="eslint-plugin-jsdoc-rules-check-param-names-options-4-disableextrapropertyreporting"></a>
  2284. ##### <code>disableExtraPropertyReporting</code>
  2285. Whether to check for extra destructured properties. Defaults to `false`. Change
  2286. to `true` if you want to be able to document properties which are not actually
  2287. destructured. Keep as `false` if you expect properties to be documented in
  2288. their own types. Note that extra properties will always be reported if another
  2289. item at the same level is destructured as destructuring will prevent other
  2290. access and this option is only intended to permit documenting extra properties
  2291. that are available and actually used in the function.
  2292. |||
  2293. |---|---|
  2294. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
  2295. |Options|`allowExtraTrailingParamDocs`, `checkDestructured`, `checkRestProperty`, `checkTypesPattern`, `useDefaultObjectProperties`, `disableExtraPropertyReporting`|
  2296. |Tags|`param`|
  2297. |Aliases|`arg`, `argument`|
  2298. |Recommended|true|
  2299. The following patterns are considered problems:
  2300. ````js
  2301. /**
  2302. * @param Foo
  2303. */
  2304. function quux (foo = 'FOO') {
  2305. }
  2306. // Message: Expected @param names to be "foo". Got "Foo".
  2307. /**
  2308. * @arg Foo
  2309. */
  2310. function quux (foo = 'FOO') {
  2311. }
  2312. // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
  2313. // Message: Expected @arg names to be "foo". Got "Foo".
  2314. /**
  2315. * @param Foo
  2316. */
  2317. function quux (foo) {
  2318. }
  2319. // Message: Expected @param names to be "foo". Got "Foo".
  2320. /**
  2321. * @param Foo.Bar
  2322. */
  2323. function quux (foo) {
  2324. }
  2325. // Message: @param path declaration ("Foo.Bar") appears before any real parameter.
  2326. /**
  2327. * @param foo
  2328. * @param Foo.Bar
  2329. */
  2330. function quux (foo) {
  2331. }
  2332. // Message: @param path declaration ("Foo.Bar") root node name ("Foo") does not match previous real parameter name ("foo").
  2333. /**
  2334. * Assign the project to a list of employees.
  2335. * @param {string} employees[].name - The name of an employee.
  2336. * @param {string} employees[].department - The employee's department.
  2337. */
  2338. function assign (employees) {
  2339. };
  2340. // Message: @param path declaration ("employees[].name") appears before any real parameter.
  2341. /**
  2342. * Assign the project to a list of employees.
  2343. * @param {string} employees[].name - The name of an employee.
  2344. * @param {string} employees[].name - The employee's department.
  2345. */
  2346. function assign (employees) {
  2347. };
  2348. // "jsdoc/check-param-names": ["error"|"warn", {"enableFixer":true}]
  2349. // Message: Duplicate @param "employees[].name"
  2350. /**
  2351. * @param foo
  2352. * @param foo.bar
  2353. * @param bar
  2354. */
  2355. function quux (bar, foo) {
  2356. }
  2357. // Message: Expected @param names to be "bar, foo". Got "foo, bar".
  2358. /**
  2359. * @param foo
  2360. * @param bar
  2361. */
  2362. function quux (foo) {
  2363. }
  2364. // Message: @param "bar" does not match an existing function parameter.
  2365. /**
  2366. * @param foo
  2367. * @param foo
  2368. */
  2369. function quux (foo) {
  2370. }
  2371. // "jsdoc/check-param-names": ["error"|"warn", {"enableFixer":true}]
  2372. // Message: Duplicate @param "foo"
  2373. class bar {
  2374. /**
  2375. * @param foo
  2376. * @param foo
  2377. */
  2378. quux (foo) {
  2379. }
  2380. }
  2381. // "jsdoc/check-param-names": ["error"|"warn", {"enableFixer":true}]
  2382. // Message: Duplicate @param "foo"
  2383. /**
  2384. * @param foo
  2385. * @param foo
  2386. */
  2387. function quux (foo, bar) {
  2388. }
  2389. // "jsdoc/check-param-names": ["error"|"warn", {"enableFixer":true}]
  2390. // Message: Duplicate @param "foo"
  2391. /**
  2392. * @param foo
  2393. * @param foo
  2394. */
  2395. function quux (foo, foo) {
  2396. }
  2397. // "jsdoc/check-param-names": ["error"|"warn", {"enableFixer":true}]
  2398. // Message: Duplicate @param "foo"
  2399. /**
  2400. * @param cfg
  2401. * @param cfg.foo
  2402. * @param cfg.foo
  2403. */
  2404. function quux ({foo}) {
  2405. }
  2406. // "jsdoc/check-param-names": ["error"|"warn", {"enableFixer":true}]
  2407. // Message: Duplicate @param "cfg.foo"
  2408. /**
  2409. * @param cfg
  2410. * @param cfg.foo
  2411. * @param cfg.foo
  2412. */
  2413. function quux ({foo}) {
  2414. }
  2415. // Message: Duplicate @param "cfg.foo"
  2416. /**
  2417. * @param cfg
  2418. * @param cfg.foo
  2419. */
  2420. function quux ({foo, bar}) {
  2421. }
  2422. // Message: Missing @param "cfg.bar"
  2423. /**
  2424. * @param cfg
  2425. * @param cfg.foo
  2426. * @param [cfg.foo]
  2427. * @param baz
  2428. */
  2429. function quux ({foo}, baz) {
  2430. }
  2431. // "jsdoc/check-param-names": ["error"|"warn", {"enableFixer":true}]
  2432. // Message: Duplicate @param "cfg.foo"
  2433. /**
  2434. * @param cfg
  2435. * @param cfg.foo
  2436. * @param [cfg.foo="with a default"]
  2437. * @param baz
  2438. */
  2439. function quux ({foo, bar}, baz) {
  2440. }
  2441. // Message: Missing @param "cfg.bar"
  2442. /**
  2443. * @param cfg
  2444. * @param cfg.foo
  2445. * @param [cfg.foo="with a default"]
  2446. * @param baz
  2447. */
  2448. function quux ({foo}, baz) {
  2449. }
  2450. // "jsdoc/check-param-names": ["error"|"warn", {"enableFixer":true}]
  2451. // Message: Duplicate @param "cfg.foo"
  2452. /**
  2453. * @param cfg
  2454. * @param [cfg.foo="with a default"]
  2455. * @param baz
  2456. */
  2457. function quux ({foo, bar}, baz) {
  2458. }
  2459. // Message: Missing @param "cfg.bar"
  2460. /**
  2461. * @param args
  2462. */
  2463. function quux ({a, b}) {
  2464. }
  2465. // Message: Missing @param "args.a"
  2466. /**
  2467. * @param args
  2468. */
  2469. function quux ({a, b} = {}) {
  2470. }
  2471. // Message: Missing @param "args.a"
  2472. export class SomeClass {
  2473. /**
  2474. * @param prop
  2475. */
  2476. constructor(private property: string) {}
  2477. }
  2478. // Message: Expected @param names to be "property". Got "prop".
  2479. export class SomeClass {
  2480. /**
  2481. * @param prop
  2482. * @param prop.foo
  2483. */
  2484. constructor(prop: { foo: string, bar: string }) {}
  2485. }
  2486. // Message: Missing @param "prop.bar"
  2487. export class SomeClass {
  2488. /**
  2489. * @param prop
  2490. * @param prop.foo
  2491. * @param prop.bar
  2492. */
  2493. constructor(options: { foo: string, bar: string }) {}
  2494. }
  2495. // Message: @param "prop" does not match parameter name "options"
  2496. export class SomeClass {
  2497. /**
  2498. * @param options
  2499. * @param options.foo
  2500. * @param options.bar
  2501. */
  2502. constructor(options: { foo: string }) {}
  2503. }
  2504. // Message: @param "options.bar" does not exist on options
  2505. /**
  2506. * @param foo
  2507. */
  2508. function quux (foo) {
  2509. }
  2510. // Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
  2511. // Message: Unexpected tag `@param`
  2512. /**
  2513. * @param {Error} error Exit code
  2514. * @param {number} [code = 1] Exit code
  2515. */
  2516. function quux (error, cde = 1) {
  2517. };
  2518. // Message: Expected @param names to be "error, cde". Got "error, code".
  2519. /**
  2520. * @param foo
  2521. */
  2522. function quux ([a, b] = []) {
  2523. }
  2524. // Message: Missing @param "foo."0""
  2525. /**
  2526. * @param options
  2527. * @param options.foo
  2528. */
  2529. function quux ({foo, ...extra}) {
  2530. }
  2531. // "jsdoc/check-param-names": ["error"|"warn", {"checkRestProperty":true}]
  2532. // Message: Missing @param "options.extra"
  2533. /**
  2534. * @param cfg
  2535. * @param cfg.foo
  2536. * @param cfg.bar
  2537. * @param cfg.extra
  2538. */
  2539. function quux ({foo, ...extra}) {
  2540. }
  2541. // "jsdoc/check-param-names": ["error"|"warn", {"checkRestProperty":true}]
  2542. // Message: @param "cfg.bar" does not exist on cfg
  2543. /**
  2544. * Converts an SVGRect into an object.
  2545. * @param {SVGRect} bbox - a SVGRect
  2546. */
  2547. const bboxToObj = function ({x, y, width, height}) {
  2548. return {x, y, width, height};
  2549. };
  2550. // "jsdoc/check-param-names": ["error"|"warn", {"checkTypesPattern":"SVGRect"}]
  2551. // Message: Missing @param "bbox.x"
  2552. /**
  2553. * Converts an SVGRect into an object.
  2554. * @param {object} bbox - a SVGRect
  2555. */
  2556. const bboxToObj = function ({x, y, width, height}) {
  2557. return {x, y, width, height};
  2558. };
  2559. // Message: Missing @param "bbox.x"
  2560. module.exports = class GraphQL {
  2561. /**
  2562. * @param fetchOptions
  2563. * @param cacheKey
  2564. */
  2565. fetch = ({ url, ...options }, cacheKey) => {
  2566. }
  2567. };
  2568. // "jsdoc/check-param-names": ["error"|"warn", {"checkRestProperty":true}]
  2569. // Message: Missing @param "fetchOptions.url"
  2570. /**
  2571. * Testing
  2572. *
  2573. * @param options
  2574. * @param options.one One
  2575. * @param options.two Two
  2576. * @param options.four Four
  2577. */
  2578. function testingEslint(options: {
  2579. one: string;
  2580. two: string;
  2581. three: string;
  2582. }): string {
  2583. return one + two + three;
  2584. }
  2585. // Message: Missing @param "options.three"
  2586. /**
  2587. *
  2588. */
  2589. function quux() {
  2590. }
  2591. // Settings: {"jsdoc":{"structuredTags":{"see":{"name":false,"required":["name"]}}}}
  2592. // Message: Cannot add "name" to `require` with the tag's `name` set to `false`
  2593. /**
  2594. * @param root
  2595. * @param foo
  2596. */
  2597. function quux ({foo, bar}, baz) {
  2598. }
  2599. // "jsdoc/check-param-names": ["error"|"warn", {"checkDestructured":false}]
  2600. // Message: Expected @param names to be "root, baz". Got "root, foo".
  2601. /**
  2602. * Description.
  2603. * @param {Object} options
  2604. * @param {FooBar} foo
  2605. */
  2606. function quux ({ foo: { bar } }) {}
  2607. // Message: Missing @param "options.foo"
  2608. /**
  2609. * Description.
  2610. * @param {Object} options
  2611. * @param options.foo
  2612. */
  2613. function quux ({ foo: { bar } }) {}
  2614. // Message: Missing @param "options.foo.bar"
  2615. /**
  2616. * Description.
  2617. * @param {object} options Options.
  2618. * @param {object} options.foo A description.
  2619. * @param {object} options.foo.bar
  2620. */
  2621. function foo({ foo: { bar: { baz } }}) {}
  2622. // Message: Missing @param "options.foo.bar.baz"
  2623. /**
  2624. * Returns a number.
  2625. * @param {Object} props Props.
  2626. * @param {Object} props.prop Prop.
  2627. * @param {string} props.prop.a String.
  2628. * @param {string} props.prop.b String.
  2629. * @return {number} A number.
  2630. */
  2631. export function testFn1 ({ prop = { a: 1, b: 2 } }) {
  2632. }
  2633. // "jsdoc/check-param-names": ["error"|"warn", {"useDefaultObjectProperties":false}]
  2634. // Message: @param "props.prop.a" does not exist on props
  2635. /**
  2636. * @param {object} cfg
  2637. * @param {string} cfg.foo
  2638. * @param {string} cfg.bar
  2639. * @param {object} cfg.extra
  2640. */
  2641. function quux ({foo}) {
  2642. }
  2643. // Message: @param "cfg.bar" does not exist on cfg
  2644. /**
  2645. * @param {object} cfg
  2646. * @param {string} cfg.foo
  2647. * @param {string} cfg.bar
  2648. * @param {object} cfg.extra
  2649. */
  2650. function quux ({foo}) {
  2651. }
  2652. // "jsdoc/check-param-names": ["error"|"warn", {"disableExtraPropertyReporting":true}]
  2653. // Message: @param "cfg.bar" does not exist on cfg
  2654. /**
  2655. * @param {object} root
  2656. * @param {object} root.cfg
  2657. * @param {object} root.cfg.a
  2658. * @param {string} root.cfg.a.foo
  2659. * @param {string} root.cfg.a.bar
  2660. * @param {object} root.cfg.a.extra
  2661. */
  2662. function quux ({cfg: {a: {foo}}}) {
  2663. }
  2664. // Message: @param "root.cfg.a.bar" does not exist on root
  2665. /**
  2666. * @param {object} root
  2667. * @param {object} root.cfg
  2668. * @param {object} root.cfg.a
  2669. * @param {string} root.cfg.a.foo
  2670. * @param {string} root.cfg.a.bar
  2671. * @param {object} root.cfg.a.extra
  2672. */
  2673. function quux ({cfg: {a: {foo}}}) {
  2674. }
  2675. // "jsdoc/check-param-names": ["error"|"warn", {"disableExtraPropertyReporting":true}]
  2676. // Message: @param "root.cfg.a.bar" does not exist on root
  2677. /**
  2678. * @param {object} root
  2679. * @param {object} root.cfg
  2680. * @param {string} root.cfg.foo
  2681. * @param {string} root.cfg.bar
  2682. * @param {object} root.cfg.extra
  2683. */
  2684. function quux ({cfg}) {
  2685. }
  2686. // Message: @param "root.cfg.foo" does not exist on root
  2687. /**
  2688. * @param foo
  2689. * @param foo
  2690. * on another line
  2691. */
  2692. function quux (foo) {
  2693. }
  2694. // "jsdoc/check-param-names": ["error"|"warn", {"enableFixer":true}]
  2695. // Message: Duplicate @param "foo"
  2696. ````
  2697. The following patterns are not considered problems:
  2698. ````js
  2699. /**
  2700. *
  2701. */
  2702. function quux (foo) {
  2703. }
  2704. /**
  2705. * @param foo
  2706. */
  2707. function quux (foo) {
  2708. }
  2709. /**
  2710. * @param foo
  2711. * @param bar
  2712. */
  2713. function quux (foo, bar) {
  2714. }
  2715. /**
  2716. * @param foo
  2717. * @param bar
  2718. */
  2719. function quux (foo, bar, baz) {
  2720. }
  2721. /**
  2722. * @param foo
  2723. * @param foo.foo
  2724. * @param bar
  2725. */
  2726. function quux (foo, bar) {
  2727. }
  2728. /**
  2729. * @param args
  2730. */
  2731. function quux (...args) {
  2732. }
  2733. /**
  2734. * @param foo
  2735. * @param foo.a
  2736. * @param foo.b
  2737. */
  2738. function quux ({a, b}) {
  2739. }
  2740. /**
  2741. * @param foo
  2742. * @param foo.a
  2743. * @param foo.b
  2744. */
  2745. function quux ({"a": A, b}) {
  2746. }
  2747. /**
  2748. * @param foo
  2749. * @param foo."a"
  2750. * @param foo.b
  2751. */
  2752. function quux ({a: A, b}) {
  2753. }
  2754. /**
  2755. * @param foo
  2756. * @param foo."a-b"
  2757. * @param foo.b
  2758. */
  2759. function quux ({"a-b": A, b}) {
  2760. }
  2761. /**
  2762. * @param foo
  2763. * @param foo.bar
  2764. * @param foo.baz
  2765. * @param bar
  2766. */
  2767. function quux (foo, bar) {
  2768. }
  2769. /**
  2770. * Assign the project to a list of employees.
  2771. * @param {object[]} employees - The employees who are responsible for the project.
  2772. * @param {string} employees[].name - The name of an employee.
  2773. * @param {string} employees[].department - The employee's department.
  2774. */
  2775. function assign (employees) {
  2776. };
  2777. export class SomeClass {
  2778. /**
  2779. * @param property
  2780. */
  2781. constructor(private property: string) {}
  2782. }
  2783. export class SomeClass {
  2784. /**
  2785. * @param options
  2786. * @param options.foo
  2787. * @param options.bar
  2788. */
  2789. constructor(options: { foo: string, bar: string }) {}
  2790. }
  2791. export class SomeClass {
  2792. /**
  2793. * @param options
  2794. * @param options.foo
  2795. * @param options.bar
  2796. */
  2797. constructor({ foo, bar }: { foo: string, bar: string }) {}
  2798. }
  2799. export class SomeClass {
  2800. /**
  2801. * @param options
  2802. * @param options.foo
  2803. * @param options.bar
  2804. */
  2805. constructor({ foo, bar }: { foo: string, bar: string }) {}
  2806. }
  2807. /**
  2808. * @param {Error} error Exit code
  2809. * @param {number} [code = 1] Exit code
  2810. */
  2811. function quux (error, code = 1) {
  2812. };
  2813. /**
  2814. * @param foo
  2815. * @param bar
  2816. */
  2817. function quux (foo) {
  2818. }
  2819. // "jsdoc/check-param-names": ["error"|"warn", {"allowExtraTrailingParamDocs":true}]
  2820. /**
  2821. * @param cfg
  2822. * @param cfg.foo
  2823. * @param baz
  2824. */
  2825. function quux ({foo}, baz) {
  2826. }
  2827. /**
  2828. * @param cfg
  2829. * @param cfg.foo
  2830. * @param cfg2
  2831. */
  2832. function quux ({foo}, cfg2) {
  2833. }
  2834. /**
  2835. * @param cfg
  2836. * @param cfg.foo
  2837. * @param baz
  2838. * @param baz.cfg
  2839. */
  2840. function quux ({foo}, {cfg}) {
  2841. }
  2842. /**
  2843. * @param options
  2844. * @param options.foo
  2845. */
  2846. function quux ({foo, ...extra}) {
  2847. }
  2848. /**
  2849. * @param foo
  2850. * @param bar
  2851. */
  2852. function quux (foo, bar, ...extra) {
  2853. }
  2854. /**
  2855. * Converts an SVGRect into an object.
  2856. * @param {SVGRect} bbox - a SVGRect
  2857. */
  2858. const bboxToObj = function ({x, y, width, height}) {
  2859. return {x, y, width, height};
  2860. };
  2861. /**
  2862. * Converts an SVGRect into an object.
  2863. * @param {SVGRect} bbox - a SVGRect
  2864. */
  2865. const bboxToObj = function ({x, y, width, height}) {
  2866. return {x, y, width, height};
  2867. };
  2868. /**
  2869. * Converts an SVGRect into an object.
  2870. * @param {object} bbox - a SVGRect
  2871. */
  2872. const bboxToObj = function ({x, y, width, height}) {
  2873. return {x, y, width, height};
  2874. };
  2875. // "jsdoc/check-param-names": ["error"|"warn", {"checkTypesPattern":"SVGRect"}]
  2876. class CSS {
  2877. /**
  2878. * Set one or more CSS properties for the set of matched elements.
  2879. *
  2880. * @param {Object} propertyObject - An object of property-value pairs to set.
  2881. */
  2882. setCssObject(propertyObject: {[key: string]: string | number}): void {
  2883. }
  2884. }
  2885. /**
  2886. * Logs a string.
  2887. *
  2888. * @param input - String to output.
  2889. */
  2890. export default function (input: {
  2891. [foo: string]: { a: string; b: string };
  2892. }): void {
  2893. input;
  2894. }
  2895. export class Thing {
  2896. foo: any;
  2897. /**
  2898. * @param {} C
  2899. */
  2900. constructor(C: { new (): any }) {
  2901. this.foo = new C();
  2902. }
  2903. }
  2904. /**
  2905. * @param foo
  2906. * @param root
  2907. */
  2908. function quux (foo, {bar}) {
  2909. }
  2910. // "jsdoc/check-param-names": ["error"|"warn", {"checkDestructured":false}]
  2911. class A {
  2912. /**
  2913. * Show a prompt.
  2914. * @param hideButton true if button should be hidden, false otherwise
  2915. * @param onHidden delegate to call when the prompt is hidden
  2916. */
  2917. public async showPrompt(hideButton: boolean, onHidden: {(): void}): Promise<void>
  2918. {
  2919. }
  2920. }
  2921. /**
  2922. * Description.
  2923. * @param {Object} options Options.
  2924. * @param {FooBar} options.foo foo description.
  2925. */
  2926. function quux ({ foo: { bar }}) {}
  2927. /**
  2928. * Description.
  2929. * @param {FooBar} options
  2930. * @param {Object} options.foo
  2931. */
  2932. function quux ({ foo: { bar } }) {}
  2933. // "jsdoc/check-param-names": ["error"|"warn", {"checkTypesPattern":"FooBar"}]
  2934. /**
  2935. * Description.
  2936. * @param {Object} options
  2937. * @param {FooBar} options.foo
  2938. * @param {FooBar} options.baz
  2939. */
  2940. function quux ({ foo: { bar }, baz: { cfg } }) {}
  2941. /**
  2942. * Item
  2943. *
  2944. * @param {object} props
  2945. * @param {object} props.data - case data
  2946. * @param {string} props.data.className - additional css class
  2947. * @param props.val
  2948. */
  2949. export default function Item({
  2950. data: {
  2951. className,
  2952. } = {},
  2953. val = 4
  2954. }) {
  2955. }
  2956. /**
  2957. * @param obj
  2958. * @param obj.data
  2959. * @param obj.data."0"
  2960. * @param obj.data."1"
  2961. * @param obj.data."2"
  2962. * @param obj.defaulting
  2963. * @param obj.defaulting."0"
  2964. * @param obj.defaulting."1"
  2965. */
  2966. function Item({
  2967. data: [foo, bar, ...baz],
  2968. defaulting: [quux, xyz] = []
  2969. }) {
  2970. }
  2971. /**
  2972. * Returns a number.
  2973. * @param {Object} props Props.
  2974. * @param {Object} props.prop Prop.
  2975. * @param {string} props.prop.a String.
  2976. * @param {string} props.prop.b String.
  2977. * @return {number} A number.
  2978. */
  2979. export function testFn1 ({ prop = { a: 1, b: 2 } }) {
  2980. }
  2981. // "jsdoc/check-param-names": ["error"|"warn", {"useDefaultObjectProperties":true}]
  2982. /**
  2983. * @param {object} root
  2984. * @param {object} root.cfg
  2985. * @param {string} root.cfg.foo
  2986. * @param {string} root.cfg.bar
  2987. * @param {object} root.cfg.extra
  2988. */
  2989. function quux ({cfg}) {
  2990. }
  2991. // "jsdoc/check-param-names": ["error"|"warn", {"disableExtraPropertyReporting":true}]
  2992. class A {
  2993. /**
  2994. * @param cfg
  2995. * @param cfg.abc
  2996. */
  2997. constructor({
  2998. [new.target.prop]: cX,
  2999. abc
  3000. }) {
  3001. }
  3002. }
  3003. /**
  3004. * @param root
  3005. * @param root."0" Ignored
  3006. * @param root."1" Our "b"
  3007. */
  3008. const foo = ([, b]) => b;
  3009. ````
  3010. <a name="eslint-plugin-jsdoc-rules-check-property-names"></a>
  3011. ### <code>check-property-names</code>
  3012. Ensures that property names in JSDoc are not duplicated on the same block
  3013. and that nested properties have defined roots.
  3014. <a name="eslint-plugin-jsdoc-rules-check-property-names-options-5"></a>
  3015. #### Options
  3016. <a name="eslint-plugin-jsdoc-rules-check-property-names-options-5-enablefixer-1"></a>
  3017. ##### <code>enableFixer</code>
  3018. Set to `true` to auto-remove `@property` duplicates (based on
  3019. identical names).
  3020. Note that this option will remove duplicates of the same name even if
  3021. the definitions do not match in other ways (e.g., the second property will
  3022. be removed even if it has a different type or description).
  3023. |||
  3024. |---|---|
  3025. |Context|Everywhere|
  3026. |Options|`enableFixer`|
  3027. |Tags|`property`|
  3028. |Aliases|`prop`|
  3029. |Recommended|true|
  3030. The following patterns are considered problems:
  3031. ````js
  3032. /**
  3033. * @typedef (SomeType) SomeTypedef
  3034. * @property Foo.Bar
  3035. */
  3036. // Message: @property path declaration ("Foo.Bar") appears before any real property.
  3037. /**
  3038. * @typedef (SomeType) SomeTypedef
  3039. * @property foo
  3040. * @property Foo.Bar
  3041. */
  3042. // Message: @property path declaration ("Foo.Bar") root node name ("Foo") does not match previous real property name ("foo").
  3043. /**
  3044. * Assign the project to a list of employees.
  3045. * @typedef (SomeType) SomeTypedef
  3046. * @property {string} employees[].name - The name of an employee.
  3047. * @property {string} employees[].department - The employee's department.
  3048. */
  3049. // Message: @property path declaration ("employees[].name") appears before any real property.
  3050. /**
  3051. * Assign the project to a list of employees.
  3052. * @typedef (SomeType) SomeTypedef
  3053. * @property {string} employees[].name - The name of an employee.
  3054. * @property {string} employees[].name - The employee's department.
  3055. */
  3056. // "jsdoc/check-property-names": ["error"|"warn", {"enableFixer":true}]
  3057. // Message: Duplicate @property "employees[].name"
  3058. /**
  3059. * @typedef (SomeType) SomeTypedef
  3060. * @property foo
  3061. * @property foo
  3062. */
  3063. // "jsdoc/check-property-names": ["error"|"warn", {"enableFixer":true}]
  3064. // Message: Duplicate @property "foo"
  3065. /**
  3066. * @typedef (SomeType) SomeTypedef
  3067. * @property foo
  3068. * @property foo
  3069. */
  3070. // Message: Duplicate @property "foo"
  3071. /**
  3072. * @typedef (SomeType) SomeTypedef
  3073. * @property cfg
  3074. * @property cfg.foo
  3075. * @property cfg.foo
  3076. */
  3077. function quux ({foo, bar}) {
  3078. }
  3079. // "jsdoc/check-property-names": ["error"|"warn", {"enableFixer":true}]
  3080. // Message: Duplicate @property "cfg.foo"
  3081. class Test {
  3082. /**
  3083. * @typedef (SomeType) SomeTypedef
  3084. * @property cfg
  3085. * @property cfg.foo
  3086. * @property cfg.foo
  3087. */
  3088. quux ({foo, bar}) {
  3089. }
  3090. }
  3091. // "jsdoc/check-property-names": ["error"|"warn", {"enableFixer":true}]
  3092. // Message: Duplicate @property "cfg.foo"
  3093. /**
  3094. * @typedef (SomeType) SomeTypedef
  3095. * @property cfg
  3096. * @property cfg.foo
  3097. * @property [cfg.foo]
  3098. * @property baz
  3099. */
  3100. function quux ({foo, bar}, baz) {
  3101. }
  3102. // "jsdoc/check-property-names": ["error"|"warn", {"enableFixer":true}]
  3103. // Message: Duplicate @property "cfg.foo"
  3104. /**
  3105. * @typedef (SomeType) SomeTypedef
  3106. * @property cfg
  3107. * @property cfg.foo
  3108. * @property [cfg.foo="with a default"]
  3109. * @property baz
  3110. */
  3111. function quux ({foo, bar}, baz) {
  3112. }
  3113. // "jsdoc/check-property-names": ["error"|"warn", {"enableFixer":true}]
  3114. // Message: Duplicate @property "cfg.foo"
  3115. /**
  3116. * @typedef (SomeType) SomeTypedef
  3117. * @prop foo
  3118. * @prop foo
  3119. */
  3120. // Settings: {"jsdoc":{"tagNamePreference":{"property":"prop"}}}
  3121. // "jsdoc/check-property-names": ["error"|"warn", {"enableFixer":true}]
  3122. // Message: Duplicate @prop "foo"
  3123. /**
  3124. * @typedef (SomeType) SomeTypedef
  3125. * @property foo
  3126. */
  3127. // Settings: {"jsdoc":{"tagNamePreference":{"property":false}}}
  3128. // Message: Unexpected tag `@property`
  3129. ````
  3130. The following patterns are not considered problems:
  3131. ````js
  3132. /**
  3133. *
  3134. */
  3135. /**
  3136. * @typedef (SomeType) SomeTypedef
  3137. * @property foo
  3138. */
  3139. /**
  3140. * @typedef (SomeType) SomeTypedef
  3141. * @prop foo
  3142. */
  3143. /**
  3144. * @typedef (SomeType) SomeTypedef
  3145. * @property foo
  3146. * @property bar
  3147. */
  3148. /**
  3149. * @typedef (SomeType) SomeTypedef
  3150. * @property foo
  3151. * @property foo.foo
  3152. * @property bar
  3153. */
  3154. /**
  3155. * Assign the project to a list of employees.
  3156. * @typedef (SomeType) SomeTypedef
  3157. * @property {object[]} employees - The employees who are responsible for the project.
  3158. * @property {string} employees[].name - The name of an employee.
  3159. * @property {string} employees[].department - The employee's department.
  3160. */
  3161. /**
  3162. * @typedef (SomeType) SomeTypedef
  3163. * @property {Error} error Exit code
  3164. * @property {number} [code = 1] Exit code
  3165. */
  3166. /**
  3167. * @namespace (SomeType) SomeNamespace
  3168. * @property {Error} error Exit code
  3169. * @property {number} [code = 1] Exit code
  3170. */
  3171. /**
  3172. * @class
  3173. * @property {Error} error Exit code
  3174. * @property {number} [code = 1] Exit code
  3175. */
  3176. function quux (code = 1) {
  3177. this.error = new Error('oops');
  3178. this.code = code;
  3179. }
  3180. /**
  3181. * @typedef (SomeType) SomeTypedef
  3182. * @property foo
  3183. * @property foo.bar
  3184. * @property foo.baz
  3185. * @property bar
  3186. */
  3187. ````
  3188. <a name="eslint-plugin-jsdoc-rules-check-syntax"></a>
  3189. ### <code>check-syntax</code>
  3190. Reports against syntax not encouraged for the mode (e.g., Google Closure
  3191. Compiler in "jsdoc" or "typescript" mode). Note that this rule will not check
  3192. for types that are wholly invalid for a given mode, as that is covered by
  3193. `valid-types`.
  3194. Currently checks against:
  3195. - Use of `=` in "jsdoc" or "typescript" mode
  3196. Note that "jsdoc" actually allows Closure syntax, but with another
  3197. option available for optional parameters (enclosing the name in brackets), the
  3198. rule is enforced (except under "permissive" and "closure" modes).
  3199. |||
  3200. |---|---|
  3201. |Context|everywhere|
  3202. |Tags|N/A|
  3203. |Recommended|false|
  3204. The following patterns are considered problems:
  3205. ````js
  3206. /**
  3207. * @param {string=} foo
  3208. */
  3209. function quux (foo) {
  3210. }
  3211. // Message: Syntax should not be Google Closure Compiler style.
  3212. ````
  3213. The following patterns are not considered problems:
  3214. ````js
  3215. /**
  3216. * @param {string=} foo
  3217. */
  3218. function quux (foo) {
  3219. }
  3220. // Settings: {"jsdoc":{"mode":"closure"}}
  3221. /**
  3222. * @param {string} [foo]
  3223. */
  3224. function quux (foo) {
  3225. }
  3226. /**
  3227. *
  3228. */
  3229. function quux (foo) {
  3230. }
  3231. ````
  3232. <a name="eslint-plugin-jsdoc-rules-check-tag-names"></a>
  3233. ### <code>check-tag-names</code>
  3234. Reports invalid block tag names.
  3235. Valid [JSDoc 3 Block Tags](https://jsdoc.app/#block-tags) are:
  3236. ```
  3237. abstract
  3238. access
  3239. alias
  3240. async
  3241. augments
  3242. author
  3243. borrows
  3244. callback
  3245. class
  3246. classdesc
  3247. constant
  3248. constructs
  3249. copyright
  3250. default
  3251. deprecated
  3252. description
  3253. enum
  3254. event
  3255. example
  3256. exports
  3257. external
  3258. file
  3259. fires
  3260. function
  3261. generator
  3262. global
  3263. hideconstructor
  3264. ignore
  3265. implements
  3266. inheritdoc
  3267. inner
  3268. instance
  3269. interface
  3270. kind
  3271. lends
  3272. license
  3273. listens
  3274. member
  3275. memberof
  3276. memberof!
  3277. mixes
  3278. mixin
  3279. module
  3280. name
  3281. namespace
  3282. override
  3283. package
  3284. param
  3285. private
  3286. property
  3287. protected
  3288. public
  3289. readonly
  3290. requires
  3291. returns
  3292. see
  3293. since
  3294. static
  3295. summary
  3296. this
  3297. throws
  3298. todo
  3299. tutorial
  3300. type
  3301. typedef
  3302. variation
  3303. version
  3304. yields
  3305. ```
  3306. `modifies` is also supported (see [source](https://github.com/jsdoc/jsdoc/blob/master/packages/jsdoc/lib/jsdoc/tag/dictionary/definitions.js#L594))
  3307. but is undocumented.
  3308. The following synonyms are also recognized if you set them in
  3309. `tagNamePreference` as a key (or replacement):
  3310. ```
  3311. arg
  3312. argument
  3313. const
  3314. constructor
  3315. defaultvalue
  3316. desc
  3317. emits
  3318. exception
  3319. extends
  3320. fileoverview
  3321. func
  3322. host
  3323. method
  3324. overview
  3325. prop
  3326. return
  3327. var
  3328. virtual
  3329. yield
  3330. ```
  3331. If you wish to allow in certain cases both a primary tag name and its
  3332. alias(es), you can set a normally non-preferred tag name to itself to indicate
  3333. that you want to allow both the default tag (in this case `@returns`) and a
  3334. non-default (in this case `return`):
  3335. ```js
  3336. "tagNamePreference": {
  3337. "return": "return",
  3338. }
  3339. ```
  3340. Because the tags indicated as replacements in
  3341. `settings.jsdoc.tagNamePreference` will automatically be considered as valid,
  3342. the above works.
  3343. Likewise are the tag keys of `settings.jsdoc.structuredTags` automatically
  3344. considered as valid (as their defining an expected structure for tags implies
  3345. the tags may be used).
  3346. For [TypeScript](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc)
  3347. (or Closure), when `settings.jsdoc.mode` is set to `typescript` or `closure`,
  3348. one may also use the following:
  3349. ```
  3350. template
  3351. ```
  3352. And for [Closure](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler),
  3353. when `settings.jsdoc.mode` is set to `closure`, one may use the following (in
  3354. addition to the jsdoc and TypeScript tags–though replacing `returns` with
  3355. `return`):
  3356. ```
  3357. define (synonym of `const` per jsdoc source)
  3358. dict
  3359. export
  3360. externs
  3361. final
  3362. implicitCast (casing distinct from that recognized by jsdoc internally)
  3363. inheritDoc (casing distinct from that recognized by jsdoc internally)
  3364. noalias
  3365. nocollapse
  3366. nocompile
  3367. noinline
  3368. nosideeffects
  3369. polymer
  3370. polymerBehavior
  3371. preserve
  3372. record (synonym of `interface` per jsdoc source)
  3373. struct
  3374. suppress
  3375. unrestricted
  3376. ```
  3377. ...and these undocumented tags which are only in [source](https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/Annotation.java):
  3378. ```
  3379. closurePrimitive
  3380. customElement
  3381. expose
  3382. hidden
  3383. idGenerator
  3384. meaning
  3385. mixinClass
  3386. mixinFunction
  3387. ngInject
  3388. owner
  3389. typeSummary
  3390. wizaction
  3391. ```
  3392. <a name="eslint-plugin-jsdoc-rules-check-tag-names-options-6"></a>
  3393. #### Options
  3394. <a name="eslint-plugin-jsdoc-rules-check-tag-names-options-6-definedtags"></a>
  3395. ##### <code>definedTags</code>
  3396. Use an array of `definedTags` strings to configure additional, allowed tags.
  3397. The format is as follows:
  3398. ```json
  3399. {
  3400. "definedTags": ["note", "record"]
  3401. }
  3402. ```
  3403. <a name="eslint-plugin-jsdoc-rules-check-tag-names-jsxtags"></a>
  3404. #### <code>jsxTags</code>
  3405. If this is set to `true`, all of the following tags used to control JSX output are allowed:
  3406. ```
  3407. jsx
  3408. jsxFrag
  3409. jsxImportSource
  3410. jsxRuntime
  3411. ```
  3412. For more information, see the [babel documentation](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx).
  3413. |||
  3414. |---|---|
  3415. |Context|everywhere|
  3416. |Tags|N/A|
  3417. |Recommended|true|
  3418. |Options|`definedTags`|
  3419. |Settings|`tagNamePreference`, `mode`|
  3420. The following patterns are considered problems:
  3421. ````js
  3422. /** @typoo {string} */
  3423. let a;
  3424. // Message: Invalid JSDoc tag name "typoo".
  3425. /** @typoo {string} */
  3426. let a;
  3427. // Settings: {"jsdoc":{"structuredTags":{"parameter":{"name":"namepath-referencing","required":["type","name"],"type":true}}}}
  3428. // Message: Invalid JSDoc tag name "typoo".
  3429. /**
  3430. * @Param
  3431. */
  3432. function quux () {
  3433. }
  3434. // Message: Invalid JSDoc tag name "Param".
  3435. /**
  3436. * @foo
  3437. */
  3438. function quux () {
  3439. }
  3440. // Message: Invalid JSDoc tag name "foo".
  3441. /**
  3442. * @arg foo
  3443. */
  3444. function quux (foo) {
  3445. }
  3446. // Message: Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "param".
  3447. /**
  3448. * @param foo
  3449. */
  3450. function quux (foo) {
  3451. }
  3452. // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
  3453. // Message: Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "arg".
  3454. /**
  3455. * @constructor foo
  3456. */
  3457. function quux (foo) {
  3458. }
  3459. // Settings: {"jsdoc":{"tagNamePreference":{"tag constructor":"cons"}}}
  3460. // Message: Invalid JSDoc tag (preference). Replace "constructor" JSDoc tag with "cons".
  3461. /**
  3462. * @arg foo
  3463. */
  3464. function quux (foo) {
  3465. }
  3466. // Settings: {"jsdoc":{"tagNamePreference":{"arg":"somethingDifferent"}}}
  3467. // Message: Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "somethingDifferent".
  3468. /**
  3469. * @param foo
  3470. */
  3471. function quux (foo) {
  3472. }
  3473. // Settings: {"jsdoc":{"tagNamePreference":{"param":"parameter"}}}
  3474. // Message: Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "parameter".
  3475. /**
  3476. * @bar foo
  3477. */
  3478. function quux (foo) {
  3479. }
  3480. // Message: Invalid JSDoc tag name "bar".
  3481. /**
  3482. * @baz @bar foo
  3483. */
  3484. function quux (foo) {
  3485. }
  3486. // "jsdoc/check-tag-names": ["error"|"warn", {"definedTags":["bar"]}]
  3487. // Message: Invalid JSDoc tag name "baz".
  3488. /**
  3489. * @bar
  3490. * @baz
  3491. */
  3492. function quux (foo) {
  3493. }
  3494. // "jsdoc/check-tag-names": ["error"|"warn", {"definedTags":["bar"]}]
  3495. // Message: Invalid JSDoc tag name "baz".
  3496. /**
  3497. * @todo
  3498. */
  3499. function quux () {
  3500. }
  3501. // Settings: {"jsdoc":{"tagNamePreference":{"todo":false}}}
  3502. // Message: Blacklisted tag found (`@todo`)
  3503. /**
  3504. * @todo
  3505. */
  3506. function quux () {
  3507. }
  3508. // Settings: {"jsdoc":{"tagNamePreference":{"todo":{"message":"Please resolve to-dos or add to the tracker"}}}}
  3509. // Message: Please resolve to-dos or add to the tracker
  3510. /**
  3511. * @todo
  3512. */
  3513. function quux () {
  3514. }
  3515. // Settings: {"jsdoc":{"tagNamePreference":{"todo":{"message":"Please use x-todo instead of todo","replacement":"x-todo"}}}}
  3516. // Message: Please use x-todo instead of todo
  3517. /**
  3518. * @todo
  3519. */
  3520. function quux () {
  3521. }
  3522. // Settings: {"jsdoc":{"tagNamePreference":{"todo":{"message":"Please use x-todo instead of todo","replacement":"x-todo"}}}}
  3523. // Message: Please use x-todo instead of todo
  3524. /**
  3525. * @todo
  3526. */
  3527. function quux () {
  3528. }
  3529. // Settings: {"jsdoc":{"tagNamePreference":{"todo":55}}}
  3530. // Message: Invalid `settings.jsdoc.tagNamePreference`. Values must be falsy, a string, or an object.
  3531. /**
  3532. * @property {object} a
  3533. * @prop {boolean} b
  3534. */
  3535. function quux () {
  3536. }
  3537. // Message: Invalid JSDoc tag (preference). Replace "prop" JSDoc tag with "property".
  3538. /**
  3539. * @abc foo
  3540. * @abcd bar
  3541. */
  3542. function quux () {
  3543. }
  3544. // Settings: {"jsdoc":{"tagNamePreference":{"abc":"abcd"}}}
  3545. // "jsdoc/check-tag-names": ["error"|"warn", {"definedTags":["abcd"]}]
  3546. // Message: Invalid JSDoc tag (preference). Replace "abc" JSDoc tag with "abcd".
  3547. /**
  3548. * @abc
  3549. * @abcd
  3550. */
  3551. function quux () {
  3552. }
  3553. // Settings: {"jsdoc":{"tagNamePreference":{"abc":"abcd"}}}
  3554. // Message: Invalid JSDoc tag (preference). Replace "abc" JSDoc tag with "abcd".
  3555. /**
  3556. * @returns
  3557. */
  3558. function quux (foo) {}
  3559. // Settings: {"jsdoc":{"mode":"closure"}}
  3560. // Message: Invalid JSDoc tag (preference). Replace "returns" JSDoc tag with "return".
  3561. /**
  3562. * @modifies
  3563. * @abstract
  3564. * @access
  3565. * @alias
  3566. * @async
  3567. * @augments
  3568. * @author
  3569. * @borrows
  3570. * @callback
  3571. * @class
  3572. * @classdesc
  3573. * @constant
  3574. * @constructs
  3575. * @copyright
  3576. * @default
  3577. * @deprecated
  3578. * @description
  3579. * @enum
  3580. * @event
  3581. * @example
  3582. * @exports
  3583. * @external
  3584. * @file
  3585. * @fires
  3586. * @function
  3587. * @generator
  3588. * @global
  3589. * @hideconstructor
  3590. * @ignore
  3591. * @implements
  3592. * @inheritdoc
  3593. * @inheritDoc
  3594. * @inner
  3595. * @instance
  3596. * @interface
  3597. * @kind
  3598. * @lends
  3599. * @license
  3600. * @listens
  3601. * @member
  3602. * @memberof
  3603. * @memberof!
  3604. * @mixes
  3605. * @mixin
  3606. * @module
  3607. * @name
  3608. * @namespace
  3609. * @override
  3610. * @package
  3611. * @param
  3612. * @private
  3613. * @property
  3614. * @protected
  3615. * @public
  3616. * @readonly
  3617. * @requires
  3618. * @returns
  3619. * @see
  3620. * @since
  3621. * @static
  3622. * @summary
  3623. * @this
  3624. * @throws
  3625. * @todo
  3626. * @tutorial
  3627. * @type
  3628. * @typedef
  3629. * @variation
  3630. * @version
  3631. * @yields
  3632. */
  3633. function quux (foo) {}
  3634. // Settings: {"jsdoc":{"mode":"badMode"}}
  3635. // Message: Unrecognized value `badMode` for `settings.jsdoc.mode`.
  3636. /**
  3637. * @modifies
  3638. * @abstract
  3639. * @access
  3640. * @alias
  3641. * @async
  3642. * @augments
  3643. * @author
  3644. * @borrows
  3645. * @callback
  3646. * @class
  3647. * @classdesc
  3648. * @constant
  3649. * @constructs
  3650. * @copyright
  3651. * @default
  3652. * @deprecated
  3653. * @description
  3654. * @enum
  3655. * @event
  3656. * @example
  3657. * @exports
  3658. * @external
  3659. * @file
  3660. * @fires
  3661. * @function
  3662. * @generator
  3663. * @global
  3664. * @hideconstructor
  3665. * @ignore
  3666. * @implements
  3667. * @inheritdoc
  3668. * @inheritDoc
  3669. * @inner
  3670. * @instance
  3671. * @interface
  3672. * @kind
  3673. * @lends
  3674. * @license
  3675. * @listens
  3676. * @member
  3677. * @memberof
  3678. * @memberof!
  3679. * @mixes
  3680. * @mixin
  3681. * @module
  3682. * @name
  3683. * @namespace
  3684. * @override
  3685. * @package
  3686. * @param
  3687. * @private
  3688. * @property
  3689. * @protected
  3690. * @public
  3691. * @readonly
  3692. * @requires
  3693. * @returns
  3694. * @see
  3695. * @since
  3696. * @static
  3697. * @summary
  3698. * @this
  3699. * @throws
  3700. * @todo
  3701. * @tutorial
  3702. * @type
  3703. * @typedef
  3704. * @variation
  3705. * @version
  3706. * @yields
  3707. * @template
  3708. */
  3709. function quux (foo) {}
  3710. // Message: Invalid JSDoc tag name "template".
  3711. /**
  3712. * @externs
  3713. */
  3714. function quux (foo) {}
  3715. // Message: Invalid JSDoc tag name "externs".
  3716. /** @jsx h */
  3717. /** @jsxFrag Fragment */
  3718. /** @jsxImportSource preact */
  3719. /** @jsxRuntime automatic */
  3720. // Message: Invalid JSDoc tag name "jsx".
  3721. ````
  3722. The following patterns are not considered problems:
  3723. ````js
  3724. /**
  3725. * @param foo
  3726. */
  3727. function quux (foo) {
  3728. }
  3729. /**
  3730. * @memberof! foo
  3731. */
  3732. function quux (foo) {
  3733. }
  3734. /**
  3735. * @arg foo
  3736. */
  3737. function quux (foo) {
  3738. }
  3739. // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
  3740. /**
  3741. * @parameter foo
  3742. */
  3743. function quux (foo) {
  3744. }
  3745. // Settings: {"jsdoc":{"structuredTags":{"parameter":{"name":"namepath-referencing","required":["type","name"],"type":true}}}}
  3746. /**
  3747. * @bar foo
  3748. */
  3749. function quux (foo) {
  3750. }
  3751. // "jsdoc/check-tag-names": ["error"|"warn", {"definedTags":["bar"]}]
  3752. /**
  3753. * @baz @bar foo
  3754. */
  3755. function quux (foo) {
  3756. }
  3757. // "jsdoc/check-tag-names": ["error"|"warn", {"definedTags":["baz","bar"]}]
  3758. /**
  3759. * @baz @bar foo
  3760. */
  3761. function quux (foo) {
  3762. }
  3763. // Settings: {"jsdoc":{"tagNamePreference":{"param":"baz","returns":{"message":"Prefer `bar`","replacement":"bar"},"todo":false}}}
  3764. /**
  3765. * @returns
  3766. */
  3767. function quux (foo) {}
  3768. /**
  3769. * @return
  3770. */
  3771. function quux (foo) {}
  3772. // Settings: {"jsdoc":{"mode":"closure"}}
  3773. /**
  3774. * @modifies
  3775. * @abstract
  3776. * @access
  3777. * @alias
  3778. * @async
  3779. * @augments
  3780. * @author
  3781. * @borrows
  3782. * @callback
  3783. * @class
  3784. * @classdesc
  3785. * @constant
  3786. * @constructs
  3787. * @copyright
  3788. * @default
  3789. * @deprecated
  3790. * @description
  3791. * @enum
  3792. * @event
  3793. * @example
  3794. * @exports
  3795. * @external
  3796. * @file
  3797. * @fires
  3798. * @function
  3799. * @generator
  3800. * @global
  3801. * @hideconstructor
  3802. * @ignore
  3803. * @implements
  3804. * @inheritdoc
  3805. * @inheritDoc
  3806. * @inner
  3807. * @instance
  3808. * @interface
  3809. * @kind
  3810. * @lends
  3811. * @license
  3812. * @listens
  3813. * @member
  3814. * @memberof
  3815. * @memberof!
  3816. * @mixes
  3817. * @mixin
  3818. * @module
  3819. * @name
  3820. * @namespace
  3821. * @override
  3822. * @package
  3823. * @param
  3824. * @private
  3825. * @property
  3826. * @protected
  3827. * @public
  3828. * @readonly
  3829. * @requires
  3830. * @returns
  3831. * @see
  3832. * @since
  3833. * @static
  3834. * @summary
  3835. * @this
  3836. * @throws
  3837. * @todo
  3838. * @tutorial
  3839. * @type
  3840. * @typedef
  3841. * @variation
  3842. * @version
  3843. * @yields
  3844. */
  3845. function quux (foo) {}
  3846. /**
  3847. * @modifies
  3848. * @abstract
  3849. * @access
  3850. * @alias
  3851. * @async
  3852. * @augments
  3853. * @author
  3854. * @borrows
  3855. * @callback
  3856. * @class
  3857. * @classdesc
  3858. * @constant
  3859. * @constructs
  3860. * @copyright
  3861. * @default
  3862. * @deprecated
  3863. * @description
  3864. * @enum
  3865. * @event
  3866. * @example
  3867. * @exports
  3868. * @external
  3869. * @file
  3870. * @fires
  3871. * @function
  3872. * @generator
  3873. * @global
  3874. * @hideconstructor
  3875. * @ignore
  3876. * @implements
  3877. * @inheritdoc
  3878. * @inheritDoc
  3879. * @inner
  3880. * @instance
  3881. * @interface
  3882. * @kind
  3883. * @lends
  3884. * @license
  3885. * @listens
  3886. * @member
  3887. * @memberof
  3888. * @memberof!
  3889. * @mixes
  3890. * @mixin
  3891. * @module
  3892. * @name
  3893. * @namespace
  3894. * @override
  3895. * @package
  3896. * @param
  3897. * @private
  3898. * @property
  3899. * @protected
  3900. * @public
  3901. * @readonly
  3902. * @requires
  3903. * @returns
  3904. * @see
  3905. * @since
  3906. * @static
  3907. * @summary
  3908. * @this
  3909. * @throws
  3910. * @todo
  3911. * @tutorial
  3912. * @type
  3913. * @typedef
  3914. * @variation
  3915. * @version
  3916. * @yields
  3917. * @template
  3918. */
  3919. function quux (foo) {}
  3920. // Settings: {"jsdoc":{"mode":"typescript"}}
  3921. /**
  3922. * @externs
  3923. */
  3924. function quux (foo) {}
  3925. // Settings: {"jsdoc":{"mode":"closure"}}
  3926. /**
  3927. *
  3928. */
  3929. function quux (foo) {
  3930. }
  3931. /**
  3932. * @todo
  3933. */
  3934. function quux () {
  3935. }
  3936. /**
  3937. * @extends Foo
  3938. */
  3939. function quux () {
  3940. }
  3941. // Settings: {"jsdoc":{"tagNamePreference":{"augments":{"message":"@extends is to be used over @augments.","replacement":"extends"}}}}
  3942. /**
  3943. * (Set tag name preference to itself to get aliases to
  3944. * work along with main tag name.)
  3945. * @augments Bar
  3946. * @extends Foo
  3947. */
  3948. function quux () {
  3949. }
  3950. // Settings: {"jsdoc":{"tagNamePreference":{"extends":"extends"}}}
  3951. /**
  3952. * Registers the `target` class as a transient dependency; each time the dependency is resolved a new instance will be created.
  3953. *
  3954. * @param target - The class / constructor function to register as transient.
  3955. *
  3956. * @example ```ts
  3957. @transient()
  3958. class Foo { }
  3959. ```
  3960. * @param Time for a new tag
  3961. */
  3962. export function transient<T>(target?: T): T {
  3963. // ...
  3964. }
  3965. /** @jsx h */
  3966. /** @jsxFrag Fragment */
  3967. /** @jsxImportSource preact */
  3968. /** @jsxRuntime automatic */
  3969. // "jsdoc/check-tag-names": ["error"|"warn", {"jsxTags":true}]
  3970. ````
  3971. <a name="eslint-plugin-jsdoc-rules-check-types"></a>
  3972. ### <code>check-types</code>
  3973. Reports invalid types.
  3974. By default, ensures that the casing of native types is the same as in this
  3975. list:
  3976. ```
  3977. undefined
  3978. null
  3979. boolean
  3980. number
  3981. bigint
  3982. string
  3983. symbol
  3984. object
  3985. Array
  3986. Function
  3987. Date
  3988. RegExp
  3989. ```
  3990. <a name="eslint-plugin-jsdoc-rules-check-types-options-7"></a>
  3991. #### Options
  3992. `check-types` allows one option:
  3993. - An option object:
  3994. - with the key `noDefaults` to insist that only the supplied option type
  3995. map is to be used, and that the default preferences (such as "string"
  3996. over "String") will not be enforced. The option's default is `false`.
  3997. - with the key `exemptTagContexts` which will avoid reporting when a
  3998. bad type is found on a specified tag. Set to an array of objects with
  3999. a key `tag` set to the tag to exempt, and a `types` key which can
  4000. either be `true` to indicate that any types on that tag will be allowed,
  4001. or to an array of strings which will only allow specific bad types.
  4002. If an array of strings is given, these must match the type exactly,
  4003. e.g., if you only allow `"object"`, it will not allow
  4004. `"object<string, string>"`. Note that this is different from the
  4005. behavior of `settings.jsdoc.preferredTypes`. This option is useful
  4006. for normally restricting generic types like `object` with
  4007. `preferredTypes`, but allowing `typedef` to indicate that its base
  4008. type is `object`.
  4009. - with the key `unifyParentAndChildTypeChecks` which will treat
  4010. `settings.jsdoc.preferredTypes` keys such as `SomeType` as matching
  4011. not only child types such as an unadorned `SomeType` but also
  4012. `SomeType<aChildType>`, `SomeType.<aChildType>`, or if `SomeType` is
  4013. `Array` (or `[]`), it will match `aChildType[]`. If this is `false` or
  4014. unset, the former format will only apply to types which are not parent
  4015. types/unions whereas the latter formats will only apply for parent
  4016. types/unions. The special types `[]`, `.<>` (or `.`), and `<>`
  4017. act only as parent types (and will not match a bare child type such as
  4018. `Array` even when unified, though, as mentioned, `Array` will match
  4019. say `string[]` or `Array.<string>` when unified). The special type
  4020. `*` is only a child type. Note that there is no detection of parent
  4021. and child type together, e.g., you cannot specify preferences for
  4022. `string[]` specifically as distinct from say `number[]`, but you can
  4023. target both with `[]` or the child types `number` or `string`.
  4024. If a value is present both as a key and as a value, neither the key nor the
  4025. value will be reported. Thus one can use this fact to allow both `object`
  4026. and `Object`, for example. Note that in "typescript" mode, this is the default
  4027. behavior.
  4028. See also the documentation on `settings.jsdoc.preferredTypes` which impacts
  4029. the behavior of `check-types`.
  4030. Note that if there is an error [parsing](https://github.com/jsdoctypeparser/jsdoctypeparser)
  4031. types for a tag, the function will silently ignore that tag, leaving it to
  4032. the `valid-types` rule to report parsing errors.
  4033. <a name="eslint-plugin-jsdoc-rules-check-types-why-not-capital-case-everything"></a>
  4034. #### Why not capital case everything?
  4035. Why are `boolean`, `number` and `string` exempt from starting with a capital
  4036. letter? Let's take `string` as an example. In Javascript, everything is an
  4037. object. The string Object has prototypes for string functions such as
  4038. `.toUpperCase()`.
  4039. Fortunately we don't have to write `new String()` everywhere in our code.
  4040. Javascript will automatically wrap string primitives into string Objects when
  4041. we're applying a string function to a string primitive. This way the memory
  4042. footprint is a tiny little bit smaller, and the
  4043. [GC](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) has
  4044. less work to do.
  4045. So in a sense, there are two types of strings in Javascript:
  4046. 1. `{string}` literals, also called primitives
  4047. 2. `{String}` Objects.
  4048. We use the primitives because it's easier to write and uses less memory.
  4049. `{String}` and `{string}` are technically both valid, but they are not the same.
  4050. ```js
  4051. new String('lard') // String {0: "l", 1: "a", 2: "r", 3: "d", length: 4}
  4052. 'lard' // "lard"
  4053. new String('lard') === 'lard' // false
  4054. ```
  4055. To make things more confusing, there are also object literals and object
  4056. Objects. But object literals are still static Objects and object Objects are
  4057. instantiated Objects. So an object primitive is still an object Object.
  4058. However, `Object.create(null)` objects are not `instanceof Object`, however, so
  4059. in the case of this Object we lower-case to indicate possible support for
  4060. these objects.
  4061. Basically, for primitives, we want to define the type as a primitive, because
  4062. that's what we use in 99.9% of cases. For everything else, we use the type
  4063. rather than the primitive. Otherwise it would all just be `{object}`.
  4064. In short: It's not about consistency, rather about the 99.9% use case. (And
  4065. some functions might not even support the objects if they are checking for
  4066. identity.)
  4067. type name | `typeof` | check-types | testcase
  4068. --|--|--|--
  4069. **Array** | object | **Array** | `([]) instanceof Array` -> `true`
  4070. **Function** | function | **Function** | `(function f () {}) instanceof Function` -> `true`
  4071. **Date** | object | **Date** | `(new Date()) instanceof Date` -> `true`
  4072. **RegExp** | object | **RegExp** | `(new RegExp(/.+/)) instanceof RegExp` -> `true`
  4073. Object | **object** | **object** | `({}) instanceof Object` -> `true` but `Object.create(null) instanceof Object` -> `false`
  4074. Boolean | **boolean** | **boolean** | `(true) instanceof Boolean` -> **`false`**
  4075. Number | **number** | **number** | `(41) instanceof Number` -> **`false`**
  4076. String | **string** | **string** | `("test") instanceof String` -> **`false`**
  4077. If you define your own tags and don't wish their bracketed portions checked
  4078. for types, you can use `settings.jsdoc.structuredTags` with a tag `type` of
  4079. `false`. If you set their `type` to an array, only those values will be
  4080. permitted.
  4081. |||
  4082. |---|---|
  4083. |Context|everywhere|
  4084. |Tags|`augments`, `class`, `constant`, `enum`, `implements`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`, `yields`|
  4085. |Aliases|`constructor`, `const`, `extends`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
  4086. |Closure-only|`package`, `private`, `protected`, `public`, `static`|
  4087. |Recommended|true|
  4088. |Options|`noDefaults`, `exemptTagContexts`, `unifyParentAndChildTypeChecks`|
  4089. |Settings|`preferredTypes`, `mode`, `structuredTags`|
  4090. The following patterns are considered problems:
  4091. ````js
  4092. /**
  4093. * @param {abc} foo
  4094. */
  4095. function quux (foo) {
  4096. }
  4097. // Settings: {"jsdoc":{"preferredTypes":{"abc":100}}}
  4098. // Message: Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.
  4099. /**
  4100. * @param {Number} foo
  4101. */
  4102. function quux (foo) {
  4103. }
  4104. // Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".
  4105. /**
  4106. * @arg {Number} foo
  4107. */
  4108. function quux (foo) {
  4109. }
  4110. // Message: Invalid JSDoc @arg "foo" type "Number"; prefer: "number".
  4111. /**
  4112. * @returns {Number} foo
  4113. * @throws {Number} foo
  4114. */
  4115. function quux () {
  4116. }
  4117. // Message: Invalid JSDoc @returns type "Number"; prefer: "number".
  4118. /**
  4119. * @param {(Number | string | Boolean)=} foo
  4120. */
  4121. function quux (foo, bar, baz) {
  4122. }
  4123. // Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".
  4124. /**
  4125. * @param {Array.<Number | String>} foo
  4126. */
  4127. function quux (foo, bar, baz) {
  4128. }
  4129. // Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".
  4130. /**
  4131. * @param {(Number | String)[]} foo
  4132. */
  4133. function quux (foo, bar, baz) {
  4134. }
  4135. // Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".
  4136. /**
  4137. * @param {abc} foo
  4138. */
  4139. function qux(foo) {
  4140. }
  4141. // Settings: {"jsdoc":{"preferredTypes":{"abc":"Abc","string":"Str"}}}
  4142. // Message: Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".
  4143. /**
  4144. * @param {abc} foo
  4145. */
  4146. function qux(foo) {
  4147. }
  4148. // Settings: {"jsdoc":{"preferredTypes":{"abc":{"replacement":"Abc"},"string":"Str"}}}
  4149. // Message: Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".
  4150. /**
  4151. * @param {abc} foo
  4152. */
  4153. function qux(foo) {
  4154. }
  4155. // Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\"; prefer: \"Abc\".","replacement":"Abc"},"string":"Str"}}}
  4156. // Message: Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".
  4157. /**
  4158. * @param {abc} foo
  4159. * @param {cde} bar
  4160. * @param {object} baz
  4161. */
  4162. function qux(foo, bar, baz) {
  4163. }
  4164. // Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\"; prefer: \"Abc\".","replacement":"Abc"},"cde":{"message":"More messed up JSDoc @{{tagName}}{{tagValue}} type \"cde\"; prefer: \"Cde\".","replacement":"Cde"},"object":"Object"}}}
  4165. // Message: Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".
  4166. /**
  4167. * @param {abc} foo
  4168. */
  4169. function qux(foo) {
  4170. }
  4171. // Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\".","replacement":false},"string":"Str"}}}
  4172. // Message: Messed up JSDoc @param "foo" type "abc".
  4173. /**
  4174. * @param {abc} foo
  4175. */
  4176. function qux(foo) {
  4177. }
  4178. // Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\"."},"string":"Str"}}}
  4179. // Message: Messed up JSDoc @param "foo" type "abc".
  4180. /**
  4181. * @param {abc} foo
  4182. * @param {Number} bar
  4183. */
  4184. function qux(foo, bar) {
  4185. }
  4186. // Settings: {"jsdoc":{"preferredTypes":{"abc":"Abc","string":"Str"}}}
  4187. // "jsdoc/check-types": ["error"|"warn", {"noDefaults":true}]
  4188. // Message: Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".
  4189. /**
  4190. * @param {abc} foo
  4191. * @param {Number} bar
  4192. */
  4193. function qux(foo, bar) {
  4194. }
  4195. // Settings: {"jsdoc":{"preferredTypes":{"abc":"Abc","string":"Str"}}}
  4196. // Message: Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".
  4197. /**
  4198. * @param {abc} foo
  4199. */
  4200. function qux(foo) {
  4201. }
  4202. // Settings: {"jsdoc":{"preferredTypes":{"abc":false,"string":"Str"}}}
  4203. // Message: Invalid JSDoc @param "foo" type "abc".
  4204. /**
  4205. * @param {abc} foo
  4206. */
  4207. function qux(foo) {
  4208. }
  4209. // Settings: {"jsdoc":{"preferredTypes":{"abc":false}}}
  4210. // Message: Invalid JSDoc @param "foo" type "abc".
  4211. /**
  4212. * @param {*} baz
  4213. */
  4214. function qux(baz) {
  4215. }
  4216. // Settings: {"jsdoc":{"preferredTypes":{"*":false,"abc":"Abc","string":"Str"}}}
  4217. // Message: Invalid JSDoc @param "baz" type "*".
  4218. /**
  4219. * @param {*} baz
  4220. */
  4221. function qux(baz) {
  4222. }
  4223. // Settings: {"jsdoc":{"preferredTypes":{"*":"aaa","abc":"Abc","string":"Str"}}}
  4224. // Message: Invalid JSDoc @param "baz" type "*"; prefer: "aaa".
  4225. /**
  4226. * @param {abc} foo
  4227. * @param {Number} bar
  4228. */
  4229. function qux(foo, bar) {
  4230. }
  4231. // Settings: {"jsdoc":{"preferredTypes":{"abc":"Abc","string":"Str"}}}
  4232. // Message: Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".
  4233. /**
  4234. * @param {Array} foo
  4235. */
  4236. function quux (foo) {
  4237. }
  4238. // Settings: {"jsdoc":{"preferredTypes":{"Array":"GenericArray"}}}
  4239. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".
  4240. /**
  4241. * @param {Array} foo
  4242. */
  4243. function quux (foo) {
  4244. }
  4245. // Settings: {"jsdoc":{"preferredTypes":{"Array":"GenericArray","Array.<>":"GenericArray"}}}
  4246. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".
  4247. /**
  4248. * @param {Array.<string>} foo
  4249. */
  4250. function quux (foo) {
  4251. }
  4252. // Settings: {"jsdoc":{"preferredTypes":{"Array.<>":"GenericArray"}}}
  4253. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".
  4254. /**
  4255. * @param {Array<string>} foo
  4256. */
  4257. function quux (foo) {
  4258. }
  4259. // Settings: {"jsdoc":{"preferredTypes":{"Array<>":"GenericArray"}}}
  4260. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".
  4261. /**
  4262. * @param {string[]} foo
  4263. */
  4264. function quux (foo) {
  4265. }
  4266. // Settings: {"jsdoc":{"preferredTypes":{"[]":"SpecialTypeArray"}}}
  4267. // Message: Invalid JSDoc @param "foo" type "[]"; prefer: "SpecialTypeArray".
  4268. /**
  4269. * @param {string[]} foo
  4270. */
  4271. function quux (foo) {
  4272. }
  4273. // Settings: {"jsdoc":{"preferredTypes":{"[]":"SpecialTypeArray"}}}
  4274. // "jsdoc/check-types": ["error"|"warn", {"unifyParentAndChildTypeChecks":true}]
  4275. // Message: Invalid JSDoc @param "foo" type "[]"; prefer: "SpecialTypeArray".
  4276. /**
  4277. * @param {string[]} foo
  4278. */
  4279. function quux (foo) {
  4280. }
  4281. // Settings: {"jsdoc":{"preferredTypes":{"Array":"SpecialTypeArray"}}}
  4282. // "jsdoc/check-types": ["error"|"warn", {"unifyParentAndChildTypeChecks":true}]
  4283. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "SpecialTypeArray".
  4284. /**
  4285. * @param {object} foo
  4286. */
  4287. function quux (foo) {
  4288. }
  4289. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
  4290. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4291. /**
  4292. * @param {object} foo
  4293. */
  4294. function quux (foo) {
  4295. }
  4296. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject","object.<>":"GenericObject"}}}
  4297. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4298. /**
  4299. * @param {object} foo
  4300. */
  4301. function quux (foo) {
  4302. }
  4303. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject","object<>":"GenericObject"}}}
  4304. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4305. /**
  4306. * @param {object.<string>} foo
  4307. */
  4308. function quux (foo) {
  4309. }
  4310. // Settings: {"jsdoc":{"preferredTypes":{"object.<>":"GenericObject"}}}
  4311. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4312. /**
  4313. * @param {object<string>} foo
  4314. */
  4315. function quux (foo) {
  4316. }
  4317. // Settings: {"jsdoc":{"preferredTypes":{"object<>":"GenericObject"}}}
  4318. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4319. /**
  4320. * @param {object.<string, number>} foo
  4321. */
  4322. function quux (foo) {
  4323. }
  4324. // Settings: {"jsdoc":{"preferredTypes":{"object.<>":"GenericObject"}}}
  4325. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4326. /**
  4327. * @param {object<string, number>} foo
  4328. */
  4329. function quux (foo) {
  4330. }
  4331. // Settings: {"jsdoc":{"preferredTypes":{"object<>":"GenericObject"}}}
  4332. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4333. /**
  4334. * @param {object.<string>} foo
  4335. */
  4336. function quux (foo) {
  4337. }
  4338. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
  4339. // "jsdoc/check-types": ["error"|"warn", {"unifyParentAndChildTypeChecks":true}]
  4340. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4341. /**
  4342. * @param {object<string>} foo
  4343. */
  4344. function quux (foo) {
  4345. }
  4346. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
  4347. // "jsdoc/check-types": ["error"|"warn", {"unifyParentAndChildTypeChecks":true}]
  4348. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4349. /**
  4350. * @param {object} foo
  4351. */
  4352. function quux (foo) {
  4353. }
  4354. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
  4355. // "jsdoc/check-types": ["error"|"warn", {"unifyParentAndChildTypeChecks":true}]
  4356. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4357. /**
  4358. * @param {object} foo
  4359. */
  4360. function quux (foo) {
  4361. }
  4362. // Settings: {"jsdoc":{"preferredTypes":{"object":false}}}
  4363. // "jsdoc/check-types": ["error"|"warn", {"unifyParentAndChildTypeChecks":true}]
  4364. // Message: Invalid JSDoc @param "foo" type "object".
  4365. /**
  4366. * @param {object} foo
  4367. */
  4368. function quux (foo) {
  4369. }
  4370. // Settings: {"jsdoc":{"preferredTypes":{"object":false}}}
  4371. // Message: Invalid JSDoc @param "foo" type "object".
  4372. /**
  4373. * @param {object.<string, number>} foo
  4374. */
  4375. function quux (foo) {
  4376. }
  4377. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
  4378. // "jsdoc/check-types": ["error"|"warn", {"unifyParentAndChildTypeChecks":true}]
  4379. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4380. /**
  4381. * @param {object<string, number>} foo
  4382. */
  4383. function quux (foo) {
  4384. }
  4385. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
  4386. // "jsdoc/check-types": ["error"|"warn", {"unifyParentAndChildTypeChecks":true}]
  4387. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
  4388. /**
  4389. *
  4390. * @param {string[][]} foo
  4391. */
  4392. function quux (foo) {
  4393. }
  4394. // Settings: {"jsdoc":{"preferredTypes":{"[]":"Array."}}}
  4395. // Message: Invalid JSDoc @param "foo" type "[]"; prefer: "Array.".
  4396. /**
  4397. *
  4398. * @param {string[][]} foo
  4399. */
  4400. function quux (foo) {
  4401. }
  4402. // Settings: {"jsdoc":{"preferredTypes":{"[]":"Array.<>"}}}
  4403. // Message: Invalid JSDoc @param "foo" type "[]"; prefer: "Array.<>".
  4404. /**
  4405. *
  4406. * @param {string[][]} foo
  4407. */
  4408. function quux (foo) {
  4409. }
  4410. // Settings: {"jsdoc":{"preferredTypes":{"[]":"Array<>"}}}
  4411. // Message: Invalid JSDoc @param "foo" type "[]"; prefer: "Array<>".
  4412. /**
  4413. *
  4414. * @param {object.<string, object.<string, string>>} foo
  4415. */
  4416. function quux (foo) {
  4417. }
  4418. // Settings: {"jsdoc":{"preferredTypes":{"object.":"Object"}}}
  4419. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "Object".
  4420. /**
  4421. *
  4422. * @param {object.<string, object.<string, string>>} foo
  4423. */
  4424. function quux (foo) {
  4425. }
  4426. // Settings: {"jsdoc":{"preferredTypes":{"object.":"Object<>"}}}
  4427. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "Object<>".
  4428. /**
  4429. *
  4430. * @param {object<string, object<string, string>>} foo
  4431. */
  4432. function quux (foo) {
  4433. }
  4434. // Settings: {"jsdoc":{"preferredTypes":{"object<>":"Object."}}}
  4435. // Message: Invalid JSDoc @param "foo" type "object"; prefer: "Object.".
  4436. /**
  4437. *
  4438. * @param {Array.<Array.<string>>} foo
  4439. */
  4440. function quux (foo) {
  4441. }
  4442. // Settings: {"jsdoc":{"preferredTypes":{"Array.":"[]"}}}
  4443. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "[]".
  4444. /**
  4445. *
  4446. * @param {Array.<Array.<string>>} foo
  4447. */
  4448. function quux (foo) {
  4449. }
  4450. // Settings: {"jsdoc":{"preferredTypes":{"Array.":"Array<>"}}}
  4451. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "Array<>".
  4452. /**
  4453. *
  4454. * @param {Array.<Array.<string>>} foo
  4455. */
  4456. function quux (foo) {
  4457. }
  4458. // Settings: {"jsdoc":{"preferredTypes":{"Array.":"<>"}}}
  4459. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "<>".
  4460. /**
  4461. *
  4462. * @param {Array.<MyArray.<string>>} foo
  4463. */
  4464. function quux (foo) {
  4465. }
  4466. // Settings: {"jsdoc":{"preferredTypes":{"Array.":"<>"}}}
  4467. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "<>".
  4468. /**
  4469. *
  4470. * @param {Array.<MyArray.<string>>} foo
  4471. */
  4472. function quux (foo) {
  4473. }
  4474. // Settings: {"jsdoc":{"preferredTypes":{"MyArray.":"<>"}}}
  4475. // Message: Invalid JSDoc @param "foo" type "MyArray"; prefer: "<>".
  4476. /**
  4477. *
  4478. * @param {Array<Array<string>>} foo
  4479. */
  4480. function quux (foo) {
  4481. }
  4482. // Settings: {"jsdoc":{"preferredTypes":{"<>":"Array."}}}
  4483. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".
  4484. /**
  4485. *
  4486. * @param {Array<Array<string>>} foo
  4487. */
  4488. function quux (foo) {
  4489. }
  4490. // Settings: {"jsdoc":{"preferredTypes":{"Array":"Array."}}}
  4491. // "jsdoc/check-types": ["error"|"warn", {"unifyParentAndChildTypeChecks":true}]
  4492. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".
  4493. /**
  4494. *
  4495. * @param {Array<Array<string>>} foo
  4496. */
  4497. function quux (foo) {
  4498. }
  4499. // Settings: {"jsdoc":{"preferredTypes":{"<>":"[]"}}}
  4500. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "[]".
  4501. /** @typedef {String} foo */
  4502. // Message: Invalid JSDoc @typedef "foo" type "String"; prefer: "string".
  4503. /**
  4504. * @this {array}
  4505. */
  4506. function quux () {}
  4507. // Settings: {"jsdoc":{"mode":"closure"}}
  4508. // Message: Invalid JSDoc @this type "array"; prefer: "Array".
  4509. /**
  4510. * @export {array}
  4511. */
  4512. function quux () {}
  4513. // Settings: {"jsdoc":{"mode":"closure"}}
  4514. // Message: Invalid JSDoc @export type "array"; prefer: "Array".
  4515. /**
  4516. * @typedef {object} foo
  4517. * @property {object} bar
  4518. */
  4519. // Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
  4520. // "jsdoc/check-types": ["error"|"warn", {"exemptTagContexts":[{"tag":"typedef","types":true}]}]
  4521. // Message: Invalid JSDoc @property "bar" type "object"; prefer: "Object".
  4522. /** @typedef {object} foo */
  4523. // Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
  4524. // "jsdoc/check-types": ["error"|"warn", {"exemptTagContexts":[{"tag":"typedef","types":["array"]}]}]
  4525. // Message: Invalid JSDoc @typedef "foo" type "object"; prefer: "Object".
  4526. /**
  4527. * @typedef {object} foo
  4528. * @property {object} bar
  4529. */
  4530. // Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
  4531. // "jsdoc/check-types": ["error"|"warn", {"exemptTagContexts":[{"tag":"typedef","types":["object"]}]}]
  4532. // Message: Invalid JSDoc @property "bar" type "object"; prefer: "Object".
  4533. /** @typedef {object<string, string>} foo */
  4534. // Settings: {"jsdoc":{"preferredTypes":{"object<>":"Object<>"}}}
  4535. // "jsdoc/check-types": ["error"|"warn", {"exemptTagContexts":[{"tag":"typedef","types":["object"]}]}]
  4536. // Message: Invalid JSDoc @typedef "foo" type "object"; prefer: "Object<>".
  4537. /**
  4538. * @param {Array<number | undefined>} foo
  4539. */
  4540. function quux (foo) {
  4541. }
  4542. // Settings: {"jsdoc":{"preferredTypes":{"Array.<>":"[]","Array<>":"[]"}}}
  4543. // Message: Invalid JSDoc @param "foo" type "Array"; prefer: "[]".
  4544. /**
  4545. * @typedef {object} foo
  4546. */
  4547. function a () {}
  4548. /**
  4549. * @typedef {Object} foo
  4550. */
  4551. function b () {}
  4552. // Settings: {"jsdoc":{"mode":"typescript","preferredTypes":{"object":"Object"}}}
  4553. // Message: Invalid JSDoc @typedef "foo" type "object"; prefer: "Object".
  4554. /**
  4555. * @aCustomTag {Number} foo
  4556. */
  4557. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":true}}}}
  4558. // Message: Invalid JSDoc @aCustomTag "foo" type "Number"; prefer: "number".
  4559. /**
  4560. * @aCustomTag {Number} foo
  4561. */
  4562. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":["otherType","anotherType"]}}}}
  4563. // Message: Invalid JSDoc @aCustomTag "foo" type "Number"; prefer: ["otherType","anotherType"].
  4564. ````
  4565. The following patterns are not considered problems:
  4566. ````js
  4567. /**
  4568. * @param {number} foo
  4569. * @param {Bar} bar
  4570. * @param {*} baz
  4571. */
  4572. function quux (foo, bar, baz) {
  4573. }
  4574. /**
  4575. * @arg {number} foo
  4576. * @arg {Bar} bar
  4577. * @arg {*} baz
  4578. */
  4579. function quux (foo, bar, baz) {
  4580. }
  4581. /**
  4582. * @param {(number | string | boolean)=} foo
  4583. */
  4584. function quux (foo, bar, baz) {
  4585. }
  4586. /**
  4587. * @param {typeof bar} foo
  4588. */
  4589. function qux(foo) {
  4590. }
  4591. /**
  4592. * @param {import('./foo').bar.baz} foo
  4593. */
  4594. function qux(foo) {
  4595. }
  4596. /**
  4597. * @param {(x: number, y: string) => string} foo
  4598. */
  4599. function qux(foo) {
  4600. }
  4601. /**
  4602. * @param {() => string} foo
  4603. */
  4604. function qux(foo) {
  4605. }
  4606. /**
  4607. * @returns {Number} foo
  4608. * @throws {Number} foo
  4609. */
  4610. function quux () {
  4611. }
  4612. // "jsdoc/check-types": ["error"|"warn", {"noDefaults":true}]
  4613. /**
  4614. * @param {Object} foo
  4615. */
  4616. function quux (foo) {
  4617. }
  4618. // Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
  4619. /**
  4620. * @param {Array} foo
  4621. */
  4622. function quux (foo) {
  4623. }
  4624. /**
  4625. * @param {Array.<string>} foo
  4626. */
  4627. function quux (foo) {
  4628. }
  4629. // Settings: {"jsdoc":{"preferredTypes":{"Array":"GenericArray"}}}
  4630. /**
  4631. * @param {Array<string>} foo
  4632. */
  4633. function quux (foo) {
  4634. }
  4635. // Settings: {"jsdoc":{"preferredTypes":{"Array":"GenericArray"}}}
  4636. /**
  4637. * @param {string[]} foo
  4638. */
  4639. function quux (foo) {
  4640. }
  4641. // Settings: {"jsdoc":{"preferredTypes":{"Array":"SpecialTypeArray","Array.<>":"SpecialTypeArray","Array<>":"SpecialTypeArray"}}}
  4642. /**
  4643. * @param {string[]} foo
  4644. */
  4645. function quux (foo) {
  4646. }
  4647. // Settings: {"jsdoc":{"preferredTypes":{"Array.<>":"SpecialTypeArray","Array<>":"SpecialTypeArray"}}}
  4648. // "jsdoc/check-types": ["error"|"warn", {"unifyParentAndChildTypeChecks":true}]
  4649. /**
  4650. * @param {Array} foo
  4651. */
  4652. function quux (foo) {
  4653. }
  4654. // Settings: {"jsdoc":{"preferredTypes":{"[]":"SpecialTypeArray"}}}
  4655. /**
  4656. * @param {Array} foo
  4657. */
  4658. function quux (foo) {
  4659. }
  4660. // Settings: {"jsdoc":{"preferredTypes":{"[]":"SpecialTypeArray"}}}
  4661. // "jsdoc/check-types": ["error"|"warn", {"unifyParentAndChildTypeChecks":true}]
  4662. /**
  4663. * @param {Array} foo
  4664. */
  4665. function quux (foo) {
  4666. }
  4667. // Settings: {"jsdoc":{"preferredTypes":{"Array.<>":"GenericArray"}}}
  4668. /**
  4669. * @param {Array} foo
  4670. */
  4671. function quux (foo) {
  4672. }
  4673. // Settings: {"jsdoc":{"preferredTypes":{"Array<>":"GenericArray"}}}
  4674. /**
  4675. * @param {object} foo
  4676. */
  4677. function quux (foo) {
  4678. }
  4679. /**
  4680. * @param {object.<string>} foo
  4681. */
  4682. function quux (foo) {
  4683. }
  4684. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
  4685. /**
  4686. * @param {object<string>} foo
  4687. */
  4688. function quux (foo) {
  4689. }
  4690. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
  4691. /**
  4692. * @param {object.<string, number>} foo
  4693. */
  4694. function quux (foo) {
  4695. }
  4696. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
  4697. /**
  4698. * @param {object<string, number>} foo
  4699. */
  4700. function quux (foo) {
  4701. }
  4702. // Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
  4703. /**
  4704. * @param {object} foo
  4705. */
  4706. function quux (foo) {
  4707. }
  4708. // Settings: {"jsdoc":{"preferredTypes":{"object.<>":"GenericObject"}}}
  4709. /**
  4710. * @param {object} foo
  4711. */
  4712. function quux (foo) {
  4713. }
  4714. // Settings: {"jsdoc":{"preferredTypes":{"object<>":"GenericObject"}}}
  4715. /**
  4716. * @param {Number<} Ignore the error as not a validating rule
  4717. */
  4718. function quux (foo) {
  4719. }
  4720. /** @param {function(...)} callback The function to invoke. */
  4721. var subscribe = function(callback) {};
  4722. /**
  4723. * @this {Array}
  4724. */
  4725. function quux () {}
  4726. // Settings: {"jsdoc":{"mode":"closure"}}
  4727. /**
  4728. * @export {Array}
  4729. */
  4730. function quux () {}
  4731. // Settings: {"jsdoc":{"mode":"closure"}}
  4732. /** @type {new() => EntityBase} */
  4733. /** @typedef {object} foo */
  4734. // Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
  4735. // "jsdoc/check-types": ["error"|"warn", {"exemptTagContexts":[{"tag":"typedef","types":true}]}]
  4736. /** @typedef {object<string, string>} foo */
  4737. // Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
  4738. /** @typedef {object<string, string>} foo */
  4739. // Settings: {"jsdoc":{"preferredTypes":{"object<>":"Object<>"}}}
  4740. // "jsdoc/check-types": ["error"|"warn", {"exemptTagContexts":[{"tag":"typedef","types":["object<string, string>"]}]}]
  4741. /**
  4742. * @typedef {object} foo
  4743. */
  4744. /**
  4745. * @typedef {Object} foo
  4746. */
  4747. // Settings: {"jsdoc":{"preferredTypes":{"object":"Object","Object":"object"}}}
  4748. /**
  4749. * @typedef {object} foo
  4750. */
  4751. function a () {}
  4752. /**
  4753. * @typedef {Object} foo
  4754. */
  4755. function b () {}
  4756. // Settings: {"jsdoc":{"preferredTypes":{"object":"Object","Object":"object"}}}
  4757. /**
  4758. * @typedef {object} foo
  4759. */
  4760. function a () {}
  4761. /**
  4762. * @typedef {Object} foo
  4763. */
  4764. function b () {}
  4765. // Settings: {"jsdoc":{"mode":"typescript"}}
  4766. /**
  4767. * @aCustomTag {Number} foo
  4768. */
  4769. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":false}}}}
  4770. /**
  4771. * @aCustomTag {otherType} foo
  4772. */
  4773. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":["otherType","anotherType"]}}}}
  4774. /**
  4775. * @aCustomTag {anotherType|otherType} foo
  4776. */
  4777. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":["otherType","anotherType"]}}}}
  4778. /**
  4779. * Bad types handled by `valid-types` instead.
  4780. * @param {str(} foo
  4781. */
  4782. function quux (foo) {
  4783. }
  4784. ````
  4785. <a name="eslint-plugin-jsdoc-rules-check-values"></a>
  4786. ### <code>check-values</code>
  4787. This rule checks the values for a handful of tags:
  4788. 1. `@version` - Checks that there is a present and valid
  4789. [semver](https://semver.org/) version value.
  4790. 2. `@since` - As with `@version`
  4791. 3. `@license` - Checks that there is a present and valid SPDX identifier
  4792. or is present within an `allowedLicenses` option.
  4793. 4. `@author` - Checks that there is a value present, and if the option
  4794. `allowedAuthors` is present, ensure that the author value is one
  4795. of these array items.
  4796. 5. `@variation` - If `numericOnlyVariation` is set, will checks that there
  4797. is a value present, and that it is an integer (otherwise, jsdoc allows any
  4798. value).
  4799. <a name="eslint-plugin-jsdoc-rules-check-values-options-8"></a>
  4800. #### Options
  4801. <a name="eslint-plugin-jsdoc-rules-check-values-options-8-allowedauthors"></a>
  4802. ##### <code>allowedAuthors</code>
  4803. An array of allowable author values. If absent, only non-whitespace will
  4804. be checked for.
  4805. <a name="eslint-plugin-jsdoc-rules-check-values-options-8-allowedlicenses"></a>
  4806. ##### <code>allowedLicenses</code>
  4807. An array of allowable license values or `true` to allow any license text.
  4808. If present as an array, will be used in place of SPDX identifiers.
  4809. <a name="eslint-plugin-jsdoc-rules-check-values-options-8-licensepattern"></a>
  4810. ##### <code>licensePattern</code>
  4811. A string to be converted into a `RegExp` (with `u` flag) and whose first
  4812. parenthetical grouping, if present, will match the portion of the license
  4813. description to check (if no grouping is present, then the whole portion
  4814. matched will be used). Defaults to `/([^\n\r]*)/gu`, i.e., the SPDX expression
  4815. is expected before any line breaks.
  4816. Note that the `/` delimiters are optional, but necessary to add flags.
  4817. Defaults to using the `u` flag, so to add your own flags, encapsulate
  4818. your expression as a string, but like a literal, e.g., `/^mit$/ui`.
  4819. <a name="eslint-plugin-jsdoc-rules-check-values-options-8-numericonlyvariation"></a>
  4820. ##### <code>numericOnlyVariation</code>
  4821. Whether to enable validation that `@variation` must be a number. Defaults to
  4822. `false`.
  4823. |||
  4824. |---|---|
  4825. |Context|everywhere|
  4826. |Tags|`@version`, `@since`, `@license`, `@author`, `@variation`|
  4827. |Recommended|true|
  4828. |Options|`allowedAuthors`, `allowedLicenses`, `licensePattern`|
  4829. |Settings|`tagNamePreference`|
  4830. The following patterns are considered problems:
  4831. ````js
  4832. /**
  4833. * @version
  4834. */
  4835. function quux (foo) {
  4836. }
  4837. // Message: Missing JSDoc @version value.
  4838. /**
  4839. * @version 3.1
  4840. */
  4841. function quux (foo) {
  4842. }
  4843. // Message: Invalid JSDoc @version: "3.1".
  4844. /**
  4845. * @variation -3
  4846. */
  4847. function quux (foo) {
  4848. }
  4849. // "jsdoc/check-values": ["error"|"warn", {"numericOnlyVariation":true}]
  4850. // Message: Invalid JSDoc @variation: "-3".
  4851. /**
  4852. * @since
  4853. */
  4854. function quux (foo) {
  4855. }
  4856. // Message: Missing JSDoc @since value.
  4857. /**
  4858. * @since 3.1
  4859. */
  4860. function quux (foo) {
  4861. }
  4862. // Message: Invalid JSDoc @since: "3.1".
  4863. /**
  4864. * @license
  4865. */
  4866. function quux (foo) {
  4867. }
  4868. // Message: Missing JSDoc @license value.
  4869. /**
  4870. * @license FOO
  4871. */
  4872. function quux (foo) {
  4873. }
  4874. // Message: Invalid JSDoc @license: "FOO"; expected SPDX expression: https://spdx.org/licenses/.
  4875. /**
  4876. * @license FOO
  4877. */
  4878. function quux (foo) {
  4879. }
  4880. // "jsdoc/check-values": ["error"|"warn", {"allowedLicenses":["BAR","BAX"]}]
  4881. // Message: Invalid JSDoc @license: "FOO"; expected one of BAR, BAX.
  4882. /**
  4883. * @license MIT-7
  4884. * Some extra text...
  4885. */
  4886. function quux (foo) {
  4887. }
  4888. // Message: Invalid JSDoc @license: "MIT-7"; expected SPDX expression: https://spdx.org/licenses/.
  4889. /**
  4890. * @license (MIT OR GPL-2.5)
  4891. */
  4892. function quux (foo) {
  4893. }
  4894. // Message: Invalid JSDoc @license: "(MIT OR GPL-2.5)"; expected SPDX expression: https://spdx.org/licenses/.
  4895. /**
  4896. * @license MIT
  4897. * Some extra text
  4898. */
  4899. function quux (foo) {
  4900. }
  4901. // "jsdoc/check-values": ["error"|"warn", {"licensePattern":"[\\s\\S]*"}]
  4902. // Message: Invalid JSDoc @license: "MIT
  4903. Some extra text"; expected SPDX expression: https://spdx.org/licenses/.
  4904. /**
  4905. * @author
  4906. */
  4907. function quux (foo) {
  4908. }
  4909. // Message: Missing JSDoc @author value.
  4910. /**
  4911. * @author Brett Zamir
  4912. */
  4913. function quux (foo) {
  4914. }
  4915. // "jsdoc/check-values": ["error"|"warn", {"allowedAuthors":["Gajus Kuizinas","golopot"]}]
  4916. // Message: Invalid JSDoc @author: "Brett Zamir"; expected one of Gajus Kuizinas, golopot.
  4917. /**
  4918. * @variation
  4919. */
  4920. function quux (foo) {
  4921. }
  4922. // "jsdoc/check-values": ["error"|"warn", {"numericOnlyVariation":true}]
  4923. // Message: Missing JSDoc @variation value.
  4924. /**
  4925. * @variation 5.2
  4926. */
  4927. function quux (foo) {
  4928. }
  4929. // "jsdoc/check-values": ["error"|"warn", {"numericOnlyVariation":true}]
  4930. // Message: Invalid JSDoc @variation: "5.2".
  4931. ````
  4932. The following patterns are not considered problems:
  4933. ````js
  4934. /**
  4935. * @version 3.4.1
  4936. */
  4937. function quux (foo) {
  4938. }
  4939. /**
  4940. * @version 3.4.1
  4941. */
  4942. function quux (foo) {
  4943. }
  4944. /**
  4945. * @since 3.4.1
  4946. */
  4947. function quux (foo) {
  4948. }
  4949. /**
  4950. * @since 3.4.1
  4951. */
  4952. function quux (foo) {
  4953. }
  4954. /**
  4955. * @license MIT
  4956. */
  4957. function quux (foo) {
  4958. }
  4959. /**
  4960. * @license MIT
  4961. * Some extra text...
  4962. */
  4963. function quux (foo) {
  4964. }
  4965. /**
  4966. * @license (MIT OR GPL-2.0)
  4967. */
  4968. function quux (foo) {
  4969. }
  4970. /**
  4971. * @license FOO
  4972. */
  4973. function quux (foo) {
  4974. }
  4975. // "jsdoc/check-values": ["error"|"warn", {"allowedLicenses":["FOO","BAR","BAX"]}]
  4976. /**
  4977. * @license FOO
  4978. */
  4979. function quux (foo) {
  4980. }
  4981. // "jsdoc/check-values": ["error"|"warn", {"allowedLicenses":true}]
  4982. /**
  4983. * @license MIT
  4984. * Some extra text
  4985. */
  4986. function quux (foo) {
  4987. }
  4988. // "jsdoc/check-values": ["error"|"warn", {"licensePattern":"[^\n]*"}]
  4989. /**
  4990. * @author Gajus Kuizinas
  4991. */
  4992. function quux (foo) {
  4993. }
  4994. /**
  4995. * @author Brett Zamir
  4996. */
  4997. function quux (foo) {
  4998. }
  4999. // "jsdoc/check-values": ["error"|"warn", {"allowedAuthors":["Gajus Kuizinas","golopot","Brett Zamir"]}]
  5000. /**
  5001. * @variation 3
  5002. */
  5003. function quux (foo) {
  5004. }
  5005. // "jsdoc/check-values": ["error"|"warn", {"numericOnlyVariation":true}]
  5006. /**
  5007. * @variation abc
  5008. */
  5009. function quux (foo) {
  5010. }
  5011. /**
  5012. * @module test
  5013. * @license MIT
  5014. */
  5015. 'use strict';
  5016. ````
  5017. <a name="eslint-plugin-jsdoc-rules-empty-tags"></a>
  5018. ### <code>empty-tags</code>
  5019. Expects the following tags to be empty of any content:
  5020. - `@abstract`
  5021. - `@async`
  5022. - `@generator`
  5023. - `@global`
  5024. - `@hideconstructor`
  5025. - `@ignore`
  5026. - `@inheritdoc`
  5027. - `@inner`
  5028. - `@instance`
  5029. - `@internal` (used by TypeScript)
  5030. - `@override`
  5031. - `@readonly`
  5032. The following will also be expected to be empty unless `settings.jsdoc.mode`
  5033. is set to "closure" (which allows types).
  5034. - `@package`
  5035. - `@private`
  5036. - `@protected`
  5037. - `@public`
  5038. - `@static`
  5039. Note that `@private` will still be checked for content by this rule even with
  5040. `settings.jsdoc.ignorePrivate` set to `true` (a setting which normally
  5041. causes rules not to take effect).
  5042. Similarly, `@internal` will still be checked for content by this rule even with
  5043. `settings.jsdoc.ignoreInternal` set to `true`.
  5044. <a name="eslint-plugin-jsdoc-rules-empty-tags-options-9"></a>
  5045. #### Options
  5046. <a name="eslint-plugin-jsdoc-rules-empty-tags-options-9-tags-1"></a>
  5047. ##### <code>tags</code>
  5048. If you want additional tags to be checked for their descriptions, you may
  5049. add them within this option.
  5050. ```js
  5051. {
  5052. 'jsdoc/empty-tags': ['error', {tags: ['event']}]
  5053. }
  5054. ```
  5055. |||
  5056. |---|---|
  5057. |Context|everywhere|
  5058. |Tags| `abstract`, `async`, `generator`, `global`, `hideconstructor`, `ignore`, `inheritdoc`, `inner`, `instance`, `internal`, `override`, `readonly`, `package`, `private`, `protected`, `public`, `static` and others added by `tags`|
  5059. |Recommended|true|
  5060. |Options|`tags`|
  5061. The following patterns are considered problems:
  5062. ````js
  5063. /**
  5064. * @abstract extra text
  5065. */
  5066. function quux () {
  5067. }
  5068. // Message: @abstract should be empty.
  5069. class Test {
  5070. /**
  5071. * @abstract extra text
  5072. */
  5073. quux () {
  5074. }
  5075. }
  5076. // Message: @abstract should be empty.
  5077. /**
  5078. * @abstract extra text
  5079. * @inheritdoc
  5080. * @async out of place
  5081. */
  5082. function quux () {
  5083. }
  5084. // Message: @abstract should be empty.
  5085. /**
  5086. * @event anEvent
  5087. */
  5088. function quux () {
  5089. }
  5090. // "jsdoc/empty-tags": ["error"|"warn", {"tags":["event"]}]
  5091. // Message: @event should be empty.
  5092. /**
  5093. * @private {someType}
  5094. */
  5095. function quux () {
  5096. }
  5097. // Message: @private should be empty.
  5098. /**
  5099. * @internal {someType}
  5100. */
  5101. function quux () {
  5102. }
  5103. // Message: @internal should be empty.
  5104. /**
  5105. * @private {someType}
  5106. */
  5107. function quux () {
  5108. }
  5109. // Settings: {"jsdoc":{"ignorePrivate":true}}
  5110. // Message: @private should be empty.
  5111. ````
  5112. The following patterns are not considered problems:
  5113. ````js
  5114. /**
  5115. * @abstract
  5116. */
  5117. function quux () {
  5118. }
  5119. /**
  5120. *
  5121. */
  5122. function quux () {
  5123. }
  5124. /**
  5125. * @param aName
  5126. */
  5127. function quux () {
  5128. }
  5129. /**
  5130. * @abstract
  5131. * @inheritdoc
  5132. * @async
  5133. */
  5134. function quux () {
  5135. }
  5136. /**
  5137. * @private {someType}
  5138. */
  5139. function quux () {
  5140. }
  5141. // Settings: {"jsdoc":{"mode":"closure"}}
  5142. /**
  5143. * @private
  5144. */
  5145. function quux () {
  5146. }
  5147. /**
  5148. * @internal
  5149. */
  5150. function quux () {
  5151. }
  5152. /**
  5153. * Create an array.
  5154. *
  5155. * @private
  5156. *
  5157. * @param {string[]} [elem] - Elements to make an array of.
  5158. * @param {boolean} [clone] - Optionally clone nodes.
  5159. * @returns {string[]} The array of nodes.
  5160. */
  5161. function quux () {}
  5162. ````
  5163. <a name="eslint-plugin-jsdoc-rules-implements-on-classes"></a>
  5164. ### <code>implements-on-classes</code>
  5165. Reports an issue with any non-constructor function using `@implements`.
  5166. Constructor functions, whether marked with `@class`, `@constructs`, or being
  5167. an ES6 class constructor, will not be flagged.
  5168. To indicate that a function follows another function's signature, one might
  5169. instead use `@type` to indicate the `@function` or `@callback` to which the
  5170. function is adhering.
  5171. <a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-10"></a>
  5172. #### Options
  5173. <a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-10-contexts"></a>
  5174. ##### <code>contexts</code>
  5175. Set this to an array of strings representing the AST context (or an object with
  5176. `context` and `comment` properties) where you wish the rule to be applied.
  5177. Overrides the default contexts (see below). Set to `"any"` if you want
  5178. the rule to apply to any jsdoc block throughout your files (as is necessary
  5179. for finding function blocks not attached to a function declaration or
  5180. expression, i.e., `@callback` or `@function` (or its aliases `@func` or
  5181. `@method`) (including those associated with an `@interface`).
  5182. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  5183. section of our README for more on the expected format.
  5184. |||
  5185. |---|---|
  5186. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
  5187. |Tags|`implements` (prevented)|
  5188. |Recommended|true|
  5189. |Options|`contexts`|
  5190. The following patterns are considered problems:
  5191. ````js
  5192. /**
  5193. * @implements {SomeClass}
  5194. */
  5195. function quux () {
  5196. }
  5197. // Message: @implements used on a non-constructor function
  5198. /**
  5199. * @implements {SomeClass}
  5200. */
  5201. function quux () {
  5202. }
  5203. // "jsdoc/implements-on-classes": ["error"|"warn", {"contexts":["any"]}]
  5204. // Message: @implements used on a non-constructor function
  5205. /**
  5206. * @function
  5207. * @implements {SomeClass}
  5208. */
  5209. function quux () {
  5210. }
  5211. // "jsdoc/implements-on-classes": ["error"|"warn", {"contexts":["any"]}]
  5212. // Message: @implements used on a non-constructor function
  5213. /**
  5214. * @callback
  5215. * @implements {SomeClass}
  5216. */
  5217. // "jsdoc/implements-on-classes": ["error"|"warn", {"contexts":["any"]}]
  5218. // Message: @implements used on a non-constructor function
  5219. /**
  5220. * @implements {SomeClass}
  5221. */
  5222. function quux () {
  5223. }
  5224. // Settings: {"jsdoc":{"tagNamePreference":{"implements":false}}}
  5225. // Message: Unexpected tag `@implements`
  5226. class Foo {
  5227. /**
  5228. * @implements {SomeClass}
  5229. */
  5230. constructor() {}
  5231. /**
  5232. * @implements {SomeClass}
  5233. */
  5234. bar() {}
  5235. }
  5236. // "jsdoc/implements-on-classes": ["error"|"warn", {"contexts":["MethodDefinition"]}]
  5237. // Message: @implements used on a non-constructor function
  5238. class Foo {
  5239. /**
  5240. * @implements {SomeClass}
  5241. */
  5242. constructor() {}
  5243. /**
  5244. * @implements {SomeClass}
  5245. */
  5246. bar() {}
  5247. }
  5248. // "jsdoc/implements-on-classes": ["error"|"warn", {"contexts":["any"]}]
  5249. // Message: @implements used on a non-constructor function
  5250. ````
  5251. The following patterns are not considered problems:
  5252. ````js
  5253. /**
  5254. * @implements {SomeClass}
  5255. * @class
  5256. */
  5257. function quux () {
  5258. }
  5259. /**
  5260. * @implements {SomeClass}
  5261. * @class
  5262. */
  5263. function quux () {
  5264. }
  5265. // "jsdoc/implements-on-classes": ["error"|"warn", {"contexts":["any"]}]
  5266. /**
  5267. * @implements {SomeClass}
  5268. */
  5269. // "jsdoc/implements-on-classes": ["error"|"warn", {"contexts":["any"]}]
  5270. /**
  5271. * @implements {SomeClass}
  5272. * @constructor
  5273. */
  5274. function quux () {
  5275. }
  5276. /**
  5277. *
  5278. */
  5279. class quux {
  5280. /**
  5281. * @implements {SomeClass}
  5282. */
  5283. constructor () {
  5284. }
  5285. }
  5286. /**
  5287. *
  5288. */
  5289. const quux = class {
  5290. /**
  5291. * @implements {SomeClass}
  5292. */
  5293. constructor () {
  5294. }
  5295. }
  5296. /**
  5297. *
  5298. */
  5299. function quux () {
  5300. }
  5301. /**
  5302. *
  5303. */
  5304. function quux () {
  5305. }
  5306. // Settings: {"jsdoc":{"tagNamePreference":{"implements":false}}}
  5307. /**
  5308. * @function
  5309. * @implements {SomeClass}
  5310. */
  5311. /**
  5312. * @callback
  5313. * @implements {SomeClass}
  5314. */
  5315. ````
  5316. <a name="eslint-plugin-jsdoc-rules-match-description"></a>
  5317. ### <code>match-description</code>
  5318. Enforces a regular expression pattern on descriptions.
  5319. The default is this basic expression to match English sentences (Support
  5320. for Unicode upper case may be added in a future version when it can be handled
  5321. by our supported Node versions):
  5322. ``^([A-Z]|[`\\d_])[\\s\\S]*[.?!`]$``
  5323. Applies to the jsdoc block description and `@description` (or `@desc`)
  5324. by default but the `tags` option (see below) may be used to match other tags.
  5325. The default (and all regex options) defaults to using (only) the `u` flag, so
  5326. to add your own flags, encapsulate your expression as a string, but like a
  5327. literal, e.g., `/[A-Z].*\\./ui`.
  5328. Note that `/` delimiters are optional, but necessary to add flags (besides
  5329. `u`).
  5330. Also note that the default or optional regular expressions is *not*
  5331. case-insensitive unless one opts in to add the `i` flag.
  5332. You can add the `s` flag if you want `.` to match newlines. Note, however,
  5333. that the trailing newlines of a description will not be matched.
  5334. <a name="eslint-plugin-jsdoc-rules-match-description-options-11"></a>
  5335. #### Options
  5336. <a name="eslint-plugin-jsdoc-rules-match-description-options-11-matchdescription"></a>
  5337. ##### <code>matchDescription</code>
  5338. You can supply your own expression to override the default, passing a
  5339. `matchDescription` string on the options object.
  5340. ```js
  5341. {
  5342. 'jsdoc/match-description': ['error', {matchDescription: '[A-Z].*\\.'}]
  5343. }
  5344. ```
  5345. <a name="eslint-plugin-jsdoc-rules-match-description-options-11-message"></a>
  5346. ##### <code>message</code>
  5347. You may provide a custom default message by using the following format:
  5348. ```js
  5349. {
  5350. 'jsdoc/match-description': ['error', {
  5351. message: 'The default dscription should begin with a capital letter.'
  5352. }]
  5353. }
  5354. ```
  5355. This can be overridden per tag or for the main block description by setting
  5356. `message` within `tags` or `mainDescription`, respectively.
  5357. <a name="eslint-plugin-jsdoc-rules-match-description-options-11-tags-2"></a>
  5358. ##### <code>tags</code>
  5359. If you want different regular expressions to apply to tags, you may use
  5360. the `tags` option object:
  5361. ```js
  5362. {
  5363. 'jsdoc/match-description': ['error', {tags: {
  5364. param: '\\- [A-Z].*\\.',
  5365. returns: '[A-Z].*\\.'
  5366. }}]
  5367. }
  5368. ```
  5369. In place of a string, you can also add `true` to indicate that a particular
  5370. tag should be linted with the `matchDescription` value (or the default).
  5371. ```js
  5372. {
  5373. 'jsdoc/match-description': ['error', {tags: {
  5374. param: true,
  5375. returns: true
  5376. }}]
  5377. }
  5378. ```
  5379. Alternatively, you may supply an object with a `message` property to indicate
  5380. the error message for that tag.
  5381. ```js
  5382. {
  5383. 'jsdoc/match-description': ['error', {tags: {
  5384. param: {message: 'Begin with a hyphen', match: '\\- [A-Z].*\\.'},
  5385. returns: {message: 'Capitalize for returns (the default)', match: true}
  5386. }}]
  5387. }
  5388. ```
  5389. The tags `@param`/`@arg`/`@argument` and `@property`/`@prop` will be properly
  5390. parsed to ensure that the matched "description" text includes only the text
  5391. after the name.
  5392. All other tags will treat the text following the tag name, a space, and
  5393. an optional curly-bracketed type expression (and another space) as part of
  5394. its "description" (e.g., for `@returns {someType} some description`, the
  5395. description is `some description` while for `@some-tag xyz`, the description
  5396. is `xyz`).
  5397. <a name="eslint-plugin-jsdoc-rules-match-description-options-11-maindescription"></a>
  5398. ##### <code>mainDescription</code>
  5399. If you wish to override the main block description without changing the
  5400. default `match-description` (which can cascade to the `tags` with `true`),
  5401. you may use `mainDescription`:
  5402. ```js
  5403. {
  5404. 'jsdoc/match-description': ['error', {
  5405. mainDescription: '[A-Z].*\\.',
  5406. tags: {
  5407. param: true,
  5408. returns: true
  5409. }
  5410. }]
  5411. }
  5412. ```
  5413. There is no need to add `mainDescription: true`, as by default, the main
  5414. block description (and only the main block description) is linted, though you
  5415. may disable checking it by setting it to `false`.
  5416. You may also provide an object with `message`:
  5417. ```js
  5418. {
  5419. 'jsdoc/match-description': ['error', {
  5420. mainDescription: {
  5421. message: 'Capitalize first word of JSDoc block descriptions',
  5422. match: '[A-Z].*\\.'
  5423. },
  5424. tags: {
  5425. param: true,
  5426. returns: true
  5427. }
  5428. }]
  5429. }
  5430. ```
  5431. <a name="eslint-plugin-jsdoc-rules-match-description-options-11-contexts-1"></a>
  5432. ##### <code>contexts</code>
  5433. Set this to an array of strings representing the AST context (or an object with
  5434. `context` and `comment` properties) where you wish the rule to be applied.
  5435. (e.g., `ClassDeclaration` for ES6
  5436. classes). Overrides the default contexts (see below). Set to `"any"` if you
  5437. want the rule to apply to any jsdoc block throughout your files.
  5438. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  5439. section of our README for more on the expected format.
  5440. |||
  5441. |---|---|
  5442. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
  5443. |Tags|docblock and `@description` by default but more with `tags`|
  5444. |Aliases|`@desc`|
  5445. |Recommended|false|
  5446. |Settings||
  5447. |Options|`contexts`, `tags` (accepts tags with names and optional type such as 'param', 'arg', 'argument', 'property', and 'prop', and accepts arbitrary list of other tags with an optional type (but without names), e.g., 'returns', 'return'), `mainDescription`, `matchDescription`|
  5448. The following patterns are considered problems:
  5449. ````js
  5450. /**
  5451. * foo.
  5452. */
  5453. const q = class {
  5454. }
  5455. // "jsdoc/match-description": ["error"|"warn", {"contexts":["ClassExpression"]}]
  5456. // Message: JSDoc description does not satisfy the regex pattern.
  5457. /**
  5458. * foo.
  5459. */
  5460. const q = class {
  5461. }
  5462. // "jsdoc/match-description": ["error"|"warn", {"contexts":["ClassExpression"],"message":"Needs to begin with a capital letter and end with an end mark."}]
  5463. // Message: Needs to begin with a capital letter and end with an end mark.
  5464. /**
  5465. * foo.
  5466. */
  5467. // "jsdoc/match-description": ["error"|"warn", {"contexts":["any"]}]
  5468. // Message: JSDoc description does not satisfy the regex pattern.
  5469. /**
  5470. * foo.
  5471. */
  5472. // "jsdoc/match-description": ["error"|"warn", {"contexts":["any"]}]
  5473. // Message: JSDoc description does not satisfy the regex pattern.
  5474. /**
  5475. * foo.
  5476. */
  5477. const q = {
  5478. };
  5479. // "jsdoc/match-description": ["error"|"warn", {"contexts":["ObjectExpression"]}]
  5480. // Message: JSDoc description does not satisfy the regex pattern.
  5481. /**
  5482. * foo.
  5483. */
  5484. function quux () {
  5485. }
  5486. // Message: JSDoc description does not satisfy the regex pattern.
  5487. /**
  5488. * Foo)
  5489. */
  5490. function quux () {
  5491. }
  5492. // Message: JSDoc description does not satisfy the regex pattern.
  5493. /**
  5494. * тест.
  5495. */
  5496. function quux () {
  5497. }
  5498. // "jsdoc/match-description": ["error"|"warn", {"matchDescription":"[А-Я][А-я]+\\."}]
  5499. // Message: JSDoc description does not satisfy the regex pattern.
  5500. /**
  5501. * тест.
  5502. */
  5503. function quux () {
  5504. }
  5505. // "jsdoc/match-description": ["error"|"warn", {"matchDescription":"[А-Я][А-я]+\\.","message":"Needs to begin with a capital letter and end with an end mark."}]
  5506. // Message: Needs to begin with a capital letter and end with an end mark.
  5507. /**
  5508. * Abc.
  5509. */
  5510. function quux () {
  5511. }
  5512. // "jsdoc/match-description": ["error"|"warn", {"mainDescription":"[А-Я][А-я]+\\.","tags":{"param":true}}]
  5513. // Message: JSDoc description does not satisfy the regex pattern.
  5514. /**
  5515. * Abc.
  5516. */
  5517. function quux () {
  5518. }
  5519. // "jsdoc/match-description": ["error"|"warn", {"mainDescription":{"match":"[А-Я][А-я]+\\.","message":"Needs to begin with a Cyrillic capital letter and end with a period."},"tags":{"param":true}}]
  5520. // Message: Needs to begin with a Cyrillic capital letter and end with a period.
  5521. /**
  5522. * Foo
  5523. */
  5524. function quux () {
  5525. }
  5526. // Message: JSDoc description does not satisfy the regex pattern.
  5527. /**
  5528. * Foo.
  5529. *
  5530. * @param foo foo.
  5531. */
  5532. function quux (foo) {
  5533. }
  5534. // "jsdoc/match-description": ["error"|"warn", {"tags":{"param":true}}]
  5535. // Message: JSDoc description does not satisfy the regex pattern.
  5536. /**
  5537. * Foo.
  5538. *
  5539. * @template Abc, Def foo.
  5540. */
  5541. function quux (foo) {
  5542. }
  5543. // "jsdoc/match-description": ["error"|"warn", {"tags":{"template":true}}]
  5544. // Message: JSDoc description does not satisfy the regex pattern.
  5545. /**
  5546. * Foo.
  5547. *
  5548. * @prop foo foo.
  5549. */
  5550. function quux (foo) {
  5551. }
  5552. // "jsdoc/match-description": ["error"|"warn", {"tags":{"prop":true}}]
  5553. // Message: JSDoc description does not satisfy the regex pattern.
  5554. /**
  5555. * Foo.
  5556. *
  5557. * @summary foo.
  5558. */
  5559. function quux () {
  5560. }
  5561. // "jsdoc/match-description": ["error"|"warn", {"tags":{"summary":true}}]
  5562. // Message: JSDoc description does not satisfy the regex pattern.
  5563. /**
  5564. * Foo.
  5565. *
  5566. * @author
  5567. */
  5568. function quux () {
  5569. }
  5570. // "jsdoc/match-description": ["error"|"warn", {"tags":{"author":".+"}}]
  5571. // Message: JSDoc description does not satisfy the regex pattern.
  5572. /**
  5573. * Foo.
  5574. *
  5575. * @x-tag
  5576. */
  5577. function quux () {
  5578. }
  5579. // "jsdoc/match-description": ["error"|"warn", {"tags":{"x-tag":".+"}}]
  5580. // Message: JSDoc description does not satisfy the regex pattern.
  5581. /**
  5582. * Foo.
  5583. *
  5584. * @description foo foo.
  5585. */
  5586. function quux (foo) {
  5587. }
  5588. // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
  5589. // Message: JSDoc description does not satisfy the regex pattern.
  5590. /**
  5591. * Foo
  5592. *
  5593. * @param foo foo.
  5594. */
  5595. function quux (foo) {
  5596. }
  5597. // "jsdoc/match-description": ["error"|"warn", {"mainDescription":"^[a-zA-Z]*$","tags":{"param":true}}]
  5598. // Message: JSDoc description does not satisfy the regex pattern.
  5599. /**
  5600. * Foo
  5601. *
  5602. * @param foo foo.
  5603. */
  5604. function quux (foo) {
  5605. }
  5606. // "jsdoc/match-description": ["error"|"warn", {"mainDescription":{"match":"^[a-zA-Z]*$","message":"Letters only"},"tags":{"param":{"match":true,"message":"Needs to begin with a capital letter and end with a period."}}}]
  5607. // Message: Needs to begin with a capital letter and end with a period.
  5608. /**
  5609. * Foo
  5610. *
  5611. * @param foo foo.
  5612. */
  5613. function quux (foo) {
  5614. }
  5615. // "jsdoc/match-description": ["error"|"warn", {"mainDescription":false,"tags":{"param":true}}]
  5616. // Message: JSDoc description does not satisfy the regex pattern.
  5617. /**
  5618. * Foo.
  5619. *
  5620. * @param foo bar
  5621. */
  5622. function quux (foo) {
  5623. }
  5624. // "jsdoc/match-description": ["error"|"warn", {"tags":{"param":true}}]
  5625. // Message: JSDoc description does not satisfy the regex pattern.
  5626. /**
  5627. * {@see Foo.bar} buz
  5628. */
  5629. function quux (foo) {
  5630. }
  5631. // Message: JSDoc description does not satisfy the regex pattern.
  5632. /**
  5633. * Foo.
  5634. *
  5635. * @returns {number} foo
  5636. */
  5637. function quux (foo) {
  5638. }
  5639. // "jsdoc/match-description": ["error"|"warn", {"tags":{"returns":true}}]
  5640. // Message: JSDoc description does not satisfy the regex pattern.
  5641. /**
  5642. * Foo.
  5643. *
  5644. * @returns foo.
  5645. */
  5646. function quux (foo) {
  5647. }
  5648. // "jsdoc/match-description": ["error"|"warn", {"tags":{"returns":true}}]
  5649. // Message: JSDoc description does not satisfy the regex pattern.
  5650. /**
  5651. * lorem ipsum dolor sit amet, consectetur adipiscing elit. pellentesque elit diam,
  5652. * iaculis eu dignissim sed, ultrices sed nisi. nulla at ligula auctor, consectetur neque sed,
  5653. * tincidunt nibh. vivamus sit amet vulputate ligula. vivamus interdum elementum nisl,
  5654. * vitae rutrum tortor semper ut. morbi porta ante vitae dictum fermentum.
  5655. * proin ut nulla at quam convallis gravida in id elit. sed dolor mauris, blandit quis ante at,
  5656. * consequat auctor magna. duis pharetra purus in porttitor mollis.
  5657. */
  5658. function longDescription (foo) {
  5659. }
  5660. // Message: JSDoc description does not satisfy the regex pattern.
  5661. /**
  5662. * @arg {number} foo - Foo
  5663. */
  5664. function quux (foo) {
  5665. }
  5666. // "jsdoc/match-description": ["error"|"warn", {"tags":{"arg":true}}]
  5667. // Message: JSDoc description does not satisfy the regex pattern.
  5668. /**
  5669. * @argument {number} foo - Foo
  5670. */
  5671. function quux (foo) {
  5672. }
  5673. // "jsdoc/match-description": ["error"|"warn", {"tags":{"argument":true}}]
  5674. // Message: JSDoc description does not satisfy the regex pattern.
  5675. /**
  5676. * @return {number} foo
  5677. */
  5678. function quux (foo) {
  5679. }
  5680. // "jsdoc/match-description": ["error"|"warn", {"tags":{"return":true}}]
  5681. // Message: JSDoc description does not satisfy the regex pattern.
  5682. /**
  5683. * Returns bar.
  5684. *
  5685. * @return {number} bar
  5686. */
  5687. function quux (foo) {
  5688. }
  5689. // "jsdoc/match-description": ["error"|"warn", {"tags":{"return":true}}]
  5690. // Message: JSDoc description does not satisfy the regex pattern.
  5691. /**
  5692. * @param notRet
  5693. * @returns Тест.
  5694. */
  5695. function quux () {
  5696. }
  5697. // "jsdoc/match-description": ["error"|"warn", {"tags":{"param":"[А-Я][А-я]+\\."}}]
  5698. // Message: JSDoc description does not satisfy the regex pattern.
  5699. /**
  5700. * @description notRet
  5701. * @returns Тест.
  5702. */
  5703. function quux () {
  5704. }
  5705. // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":"[А-Я][А-я]+\\."}}]
  5706. // Message: JSDoc description does not satisfy the regex pattern.
  5707. /**
  5708. * foo.
  5709. */
  5710. class quux {
  5711. }
  5712. // "jsdoc/match-description": ["error"|"warn", {"contexts":["ClassDeclaration"]}]
  5713. // Message: JSDoc description does not satisfy the regex pattern.
  5714. class MyClass {
  5715. /**
  5716. * Abc
  5717. */
  5718. myClassField = 1
  5719. }
  5720. // "jsdoc/match-description": ["error"|"warn", {"contexts":["ClassProperty"]}]
  5721. // Message: JSDoc description does not satisfy the regex pattern.
  5722. /**
  5723. * foo.
  5724. */
  5725. interface quux {
  5726. }
  5727. // "jsdoc/match-description": ["error"|"warn", {"contexts":["TSInterfaceDeclaration"]}]
  5728. // Message: JSDoc description does not satisfy the regex pattern.
  5729. const myObject = {
  5730. /**
  5731. * Bad description
  5732. */
  5733. myProp: true
  5734. };
  5735. // "jsdoc/match-description": ["error"|"warn", {"contexts":["Property"]}]
  5736. // Message: JSDoc description does not satisfy the regex pattern.
  5737. /**
  5738. * @param foo Foo bar
  5739. */
  5740. function quux (foo) {
  5741. }
  5742. // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
  5743. // "jsdoc/match-description": ["error"|"warn", {"tags":{"param":true}}]
  5744. // Message: JSDoc description does not satisfy the regex pattern.
  5745. /**
  5746. * Foo bar
  5747. */
  5748. function quux (foo) {
  5749. }
  5750. // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
  5751. // Message: JSDoc description does not satisfy the regex pattern.
  5752. ````
  5753. The following patterns are not considered problems:
  5754. ````js
  5755. /**
  5756. *
  5757. */
  5758. /**
  5759. *
  5760. */
  5761. function quux () {
  5762. }
  5763. /**
  5764. * @param foo - Foo.
  5765. */
  5766. function quux () {
  5767. }
  5768. // "jsdoc/match-description": ["error"|"warn", {"tags":{"param":true}}]
  5769. /**
  5770. * Foo.
  5771. */
  5772. function quux () {
  5773. }
  5774. /**
  5775. * Foo.
  5776. * Bar.
  5777. */
  5778. function quux () {
  5779. }
  5780. /**
  5781. * Foo.
  5782. *
  5783. * Bar.
  5784. */
  5785. function quux () {
  5786. }
  5787. /**
  5788. * Foo.
  5789. *
  5790. * Bar.
  5791. */
  5792. function quux () {
  5793. }
  5794. // "jsdoc/match-description": ["error"|"warn", {"message":"This won't be shown"}]
  5795. /**
  5796. * Тест.
  5797. */
  5798. function quux () {
  5799. }
  5800. // "jsdoc/match-description": ["error"|"warn", {"matchDescription":"[А-Я][А-я]+\\."}]
  5801. /**
  5802. * @param notRet
  5803. * @returns Тест.
  5804. */
  5805. function quux () {
  5806. }
  5807. // "jsdoc/match-description": ["error"|"warn", {"tags":{"returns":"[А-Я][А-я]+\\."}}]
  5808. /**
  5809. * @param notRet
  5810. * @description Тест.
  5811. */
  5812. function quux () {
  5813. }
  5814. // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":"[А-Я][А-я]+\\."}}]
  5815. /**
  5816. * Foo
  5817. * bar.
  5818. */
  5819. function quux () {
  5820. }
  5821. /**
  5822. * @returns Foo bar.
  5823. */
  5824. function quux () {
  5825. }
  5826. // "jsdoc/match-description": ["error"|"warn", {"tags":{"returns":true}}]
  5827. /**
  5828. * @returns {type1} Foo bar.
  5829. */
  5830. function quux () {
  5831. }
  5832. // "jsdoc/match-description": ["error"|"warn", {"tags":{"returns":true}}]
  5833. /**
  5834. * @description Foo bar.
  5835. */
  5836. function quux () {
  5837. }
  5838. // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
  5839. /**
  5840. * @description Foo
  5841. * bar.
  5842. * @param
  5843. */
  5844. function quux () {
  5845. }
  5846. // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
  5847. /** @description Foo bar. */
  5848. function quux () {
  5849. }
  5850. // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
  5851. /**
  5852. * @description Foo
  5853. * bar.
  5854. */
  5855. function quux () {
  5856. }
  5857. // "jsdoc/match-description": ["error"|"warn", {"tags":{"description":true}}]
  5858. /**
  5859. * Foo. {@see Math.sin}.
  5860. */
  5861. function quux () {
  5862. }
  5863. /**
  5864. * Foo {@see Math.sin} bar.
  5865. */
  5866. function quux () {
  5867. }
  5868. /**
  5869. * Foo?
  5870. *
  5871. * Bar!
  5872. *
  5873. * Baz:
  5874. * 1. Foo.
  5875. * 2. Bar.
  5876. */
  5877. function quux () {
  5878. }
  5879. /**
  5880. * Hello:
  5881. * World.
  5882. */
  5883. function quux () {
  5884. }
  5885. /**
  5886. * Hello: world.
  5887. */
  5888. function quux () {
  5889. }
  5890. /**
  5891. * Foo
  5892. * Bar.
  5893. */
  5894. function quux () {
  5895. }
  5896. /**
  5897. * Foo.
  5898. *
  5899. * foo.
  5900. */
  5901. function quux () {
  5902. }
  5903. /**
  5904. * foo.
  5905. */
  5906. function quux () {
  5907. }
  5908. // "jsdoc/match-description": ["error"|"warn", {"mainDescription":false}]
  5909. /**
  5910. * foo.
  5911. */
  5912. class quux {
  5913. }
  5914. /**
  5915. * foo.
  5916. */
  5917. class quux {
  5918. }
  5919. // "jsdoc/match-description": ["error"|"warn", {"mainDescription":true}]
  5920. class MyClass {
  5921. /**
  5922. * Abc.
  5923. */
  5924. myClassField = 1
  5925. }
  5926. // "jsdoc/match-description": ["error"|"warn", {"contexts":["ClassProperty"]}]
  5927. /**
  5928. * Foo.
  5929. */
  5930. interface quux {
  5931. }
  5932. // "jsdoc/match-description": ["error"|"warn", {"contexts":["TSInterfaceDeclaration"]}]
  5933. const myObject = {
  5934. /**
  5935. * Bad description
  5936. */
  5937. myProp: true
  5938. };
  5939. // "jsdoc/match-description": ["error"|"warn", {"contexts":[]}]
  5940. /**
  5941. * foo.
  5942. */
  5943. const q = class {
  5944. }
  5945. // "jsdoc/match-description": ["error"|"warn", {"contexts":[]}]
  5946. /**
  5947. * foo.
  5948. */
  5949. const q = {
  5950. };
  5951. // "jsdoc/match-description": ["error"|"warn", {"contexts":[]}]
  5952. /**
  5953. * @description foo.
  5954. */
  5955. function quux () {
  5956. }
  5957. // "jsdoc/match-description": ["error"|"warn", {"tags":{"param":true}}]
  5958. /**
  5959. * Foo.
  5960. *
  5961. * @summary Foo.
  5962. */
  5963. function quux () {
  5964. }
  5965. // "jsdoc/match-description": ["error"|"warn", {"tags":{"summary":true}}]
  5966. /**
  5967. * Foo.
  5968. *
  5969. * @author Somebody
  5970. */
  5971. function quux () {
  5972. }
  5973. // "jsdoc/match-description": ["error"|"warn", {"tags":{"author":".+"}}]
  5974. /**
  5975. * Foo.
  5976. *
  5977. * @x-tag something
  5978. */
  5979. function quux () {
  5980. }
  5981. // "jsdoc/match-description": ["error"|"warn", {"tags":{"x-tag":".+"}}]
  5982. /**
  5983. * Foo.
  5984. *
  5985. * @prop foo Foo.
  5986. */
  5987. function quux (foo) {
  5988. }
  5989. // "jsdoc/match-description": ["error"|"warn", {"tags":{"prop":true}}]
  5990. /**
  5991. * @param foo Foo bar.
  5992. */
  5993. function quux (foo) {
  5994. }
  5995. // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
  5996. /**
  5997. *
  5998. */
  5999. function quux () {
  6000. }
  6001. // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
  6002. /**
  6003. * Foo.
  6004. *
  6005. * @template Abc, Def Foo.
  6006. */
  6007. function quux (foo) {
  6008. }
  6009. // "jsdoc/match-description": ["error"|"warn", {"tags":{"template":true}}]
  6010. /**
  6011. * Enable or disable plugin.
  6012. *
  6013. * When enabling with this function, the script will be attached to the `document` if:.
  6014. * - the script runs in browser context.
  6015. * - the `document` doesn't have the script already attached.
  6016. * - the `loadScript` option is set to `true`.
  6017. * @param enabled `true` to enable, `false` to disable. Default: `true`.
  6018. */
  6019. // "jsdoc/match-description": ["error"|"warn", {"contexts":["any"],"mainDescription":"/^[A-Z`-].*\\.$/us","matchDescription":"^([A-Z`-].*(\\.|:)|-\\s.*)$","tags":{"param":true,"returns":true}}]
  6020. ````
  6021. <a name="eslint-plugin-jsdoc-rules-match-name"></a>
  6022. ### <code>match-name</code>
  6023. Reports the name portion of a JSDoc tag if matching or not matching
  6024. a given regular expression.
  6025. Note that some tags do not possess names and anything appearing to be a
  6026. name will actually be part of the description (e.g., for
  6027. `@returns {type} notAName`). If you are defining your own tags, see the
  6028. `structuredTags` setting (if `name: false`, this rule will not apply to
  6029. that tag).
  6030. <a name="eslint-plugin-jsdoc-rules-match-name-options-12"></a>
  6031. #### Options
  6032. A single options object with the following properties:
  6033. <a name="eslint-plugin-jsdoc-rules-match-name-options-12-match"></a>
  6034. ##### <code>match</code>
  6035. `match` is a required option containing an array of objects which determine
  6036. the conditions whereby a name is reported as being problematic.
  6037. These objects can have any combination of the following groups of optional
  6038. properties, all of which act to confine one another:
  6039. - `tags` - This array should include tag names or `*` to indicate the
  6040. match will apply for all tags (except as confined by any context
  6041. properties). If `*` is not used, then these rules will only apply to
  6042. the specified tags. If `tags` is omitted, then `*` is assumed.
  6043. - `allowName` - Indicates which names are allowed for the given tag (or `*`).
  6044. Accepts a string regular expression (optionally wrapped between two
  6045. `/` delimiters followed by optional flags) used to match the name.
  6046. - `disallowName` - As with `allowName` but indicates names that are not
  6047. allowed.
  6048. - `replacement` - If `disallowName` is supplied and this value is present, it
  6049. will replace the matched `disallowName` text.
  6050. - `context` - AST to confine the allowing or disallowing to jsdoc blocks
  6051. associated with a particular context. See the
  6052. ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  6053. section of our README for more on the expected format.
  6054. - `comment` - As with `context` but AST for the JSDoc block comment and types
  6055. - `message` - An optional custom message to use when there is a match.
  6056. Note that `comment`, even if targeting a specific tag, is used to match the
  6057. whole block. So if a `comment` finds its specific tag, it may still apply
  6058. fixes found by the likes of `disallowName` even when a different tag has the
  6059. disallowed name. An alternative is to ensure that `comment` finds the specific
  6060. tag of the desired tag and/or name and no `disallowName` (or `allowName`) is
  6061. supplied. In such a case, only one error will be reported, but no fixer will
  6062. be applied, however.
  6063. |||
  6064. |---|---|
  6065. |Context|everywhere|
  6066. |Tags|(The tags specifie by `tags`, including any tag if `*` is set)|
  6067. |Recommended|false|
  6068. |Settings|`structuredTags`|
  6069. |Options|`match`|
  6070. The following patterns are considered problems:
  6071. ````js
  6072. /**
  6073. * @param opt_a
  6074. * @param opt_b
  6075. */
  6076. // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^opt_/i"}]}]
  6077. // Message: Only allowing names not matching `/^opt_/i` but found "opt_a".
  6078. /**
  6079. * @param opt_a
  6080. * @param opt_b
  6081. */
  6082. // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^opt_/i","replacement":""}]}]
  6083. // Message: Only allowing names not matching `/^opt_/i` but found "opt_a".
  6084. /**
  6085. * @param a
  6086. * @param opt_b
  6087. */
  6088. // "jsdoc/match-name": ["error"|"warn", {"match":[{"allowName":"/^[a-z]+$/i"}]}]
  6089. // Message: Only allowing names matching `/^[a-z]+$/i` but found "opt_b".
  6090. /**
  6091. * @param arg
  6092. * @param opt_b
  6093. */
  6094. // "jsdoc/match-name": ["error"|"warn", {"match":[{"allowName":"/^[a-z]+$/i","disallowName":"/^arg/i"}]}]
  6095. // Message: Only allowing names not matching `/^arg/i` but found "arg".
  6096. /**
  6097. * @param opt_a
  6098. * @param arg
  6099. */
  6100. // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^arg$/i"},{"disallowName":"/^opt_/i"}]}]
  6101. // Message: Only allowing names not matching `/^opt_/i` but found "opt_a".
  6102. /**
  6103. * @property opt_a
  6104. * @param opt_b
  6105. */
  6106. // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^opt_/i","tags":["param"]}]}]
  6107. // Message: Only allowing names not matching `/^opt_/i` but found "opt_b".
  6108. /**
  6109. * @someTag opt_a
  6110. * @param opt_b
  6111. */
  6112. // Settings: {"jsdoc":{"structuredTags":{"someTag":{"name":"namepath-defining"}}}}
  6113. // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^opt_/i","tags":["param"]}]}]
  6114. // Message: Only allowing names not matching `/^opt_/i` but found "opt_b".
  6115. /**
  6116. * @property opt_a
  6117. * @param opt_b
  6118. */
  6119. // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^opt_/i","tags":["*"]}]}]
  6120. // Message: Only allowing names not matching `/^opt_/i` but found "opt_a".
  6121. /**
  6122. * @param opt_a
  6123. * @param opt_b
  6124. */
  6125. function quux () {
  6126. }
  6127. // "jsdoc/match-name": ["error"|"warn", {"match":[{"context":"FunctionDeclaration","disallowName":"/^opt_/i"}]}]
  6128. // Message: Only allowing names not matching `/^opt_/i` but found "opt_a".
  6129. /**
  6130. * @property opt_a
  6131. * @param {Bar|Foo} opt_b
  6132. */
  6133. // "jsdoc/match-name": ["error"|"warn", {"match":[{"comment":"JSDocBlock:has(JSDocTag[tag=\"param\"][name=/opt_/] > JSDocTypeUnion:has(JsdocTypeName[value=\"Bar\"]:nth-child(1)))"}]}]
  6134. // Message: Prohibited context for "opt_a".
  6135. /**
  6136. * @property opt_a
  6137. * @param {Bar|Foo} opt_b
  6138. */
  6139. // "jsdoc/match-name": ["error"|"warn", {"match":[{"comment":"JSDocBlock:has(JSDocTag[tag=\"param\"][name=/opt_/] > JSDocTypeUnion:has(JsdocTypeName[value=\"Bar\"]:nth-child(1)))","message":"Don't use `opt_` prefixes with Bar|..."}]}]
  6140. // Message: Don't use `opt_` prefixes with Bar|...
  6141. /**
  6142. * @param opt_a
  6143. * @param opt_b
  6144. */
  6145. function quux () {}
  6146. // "jsdoc/match-name": ["error"|"warn", ]
  6147. // Message: Rule `no-restricted-syntax` is missing a `match` option.
  6148. ````
  6149. The following patterns are not considered problems:
  6150. ````js
  6151. /**
  6152. * @param opt_a
  6153. * @param opt_b
  6154. */
  6155. // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^arg/i"}]}]
  6156. /**
  6157. * @param a
  6158. * @param opt_b
  6159. */
  6160. // "jsdoc/match-name": ["error"|"warn", {"match":[{"allowName":"/^[a-z_]+$/i"}]}]
  6161. /**
  6162. * @param someArg
  6163. * @param anotherArg
  6164. */
  6165. // "jsdoc/match-name": ["error"|"warn", {"match":[{"allowName":"/^[a-z]+$/i","disallowName":"/^arg/i"}]}]
  6166. /**
  6167. * @param elem1
  6168. * @param elem2
  6169. */
  6170. // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^arg$/i"},{"disallowName":"/^opt_/i"}]}]
  6171. /**
  6172. * @someTag opt_a
  6173. * @param opt_b
  6174. */
  6175. // Settings: {"jsdoc":{"structuredTags":{"someTag":{"name":"namepath-defining"}}}}
  6176. // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^opt_/i","tags":["property"]}]}]
  6177. /**
  6178. * @property opt_a
  6179. * @param opt_b
  6180. */
  6181. // "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^arg/i","tags":["*"]}]}]
  6182. /**
  6183. * @param opt_a
  6184. * @param opt_b
  6185. */
  6186. class A {
  6187. }
  6188. // "jsdoc/match-name": ["error"|"warn", {"match":[{"context":"FunctionDeclaration","disallowName":"/^opt_/i"}]}]
  6189. /**
  6190. * @property opt_a
  6191. * @param {Foo|Bar} opt_b
  6192. */
  6193. // "jsdoc/match-name": ["error"|"warn", {"match":[{"comment":"JSDocBlock > JSDocTag[tag=\"param\"] > JSDocTypeUnion[left.name=\"Bar\"]","disallowName":"/^opt_/i"}]}]
  6194. ````
  6195. <a name="eslint-plugin-jsdoc-rules-multiline-blocks"></a>
  6196. ### <code>multiline-blocks</code>
  6197. Controls how and whether jsdoc blocks can be expressed as single or multiple
  6198. line blocks.
  6199. Note that if you set `noSingleLineBlocks` and `noMultilineBlocks` to `true`
  6200. and configure them in a certain manner, you might effectively be prohibiting
  6201. all jsdoc blocks!
  6202. Also allows for preventing text at the very beginning or very end of blocks.
  6203. <a name="eslint-plugin-jsdoc-rules-multiline-blocks-options-13"></a>
  6204. #### Options
  6205. A single options object with the following properties.
  6206. <a name="eslint-plugin-jsdoc-rules-multiline-blocks-options-13-nozerolinetext-defaults-to-true"></a>
  6207. ##### <code>noZeroLineText</code> (defaults to <code>true</code>)
  6208. For multiline blocks, any non-whitespace text immediately after the `/**` and
  6209. space will be reported. (Text after a newline is not reported.)
  6210. `noMultilineBlocks` will have priority over this rule if it applies.
  6211. <a name="eslint-plugin-jsdoc-rules-multiline-blocks-options-13-nofinallinetext-defaults-to-true"></a>
  6212. ##### <code>noFinalLineText</code> (defaults to <code>true</code>)
  6213. For multiline blocks, any non-whitespace text preceding the `*/` on the final
  6214. line will be reported. (Text preceding a newline is not reported.)
  6215. `noMultilineBlocks` will have priority over this rule if it applies.
  6216. <a name="eslint-plugin-jsdoc-rules-multiline-blocks-options-13-nosinglelineblocks-defaults-to-false"></a>
  6217. ##### <code>noSingleLineBlocks</code> (defaults to <code>false</code>)
  6218. If this is `true`, any single line blocks will be reported, except those which
  6219. are whitelisted in `singleLineTags`.
  6220. <a name="eslint-plugin-jsdoc-rules-multiline-blocks-options-13-singlelinetags-defaults-to-lends-type"></a>
  6221. ##### <code>singleLineTags</code> (defaults to <code>[&#39;lends&#39;, &#39;type&#39;]</code>)
  6222. An array of tags which can nevertheless be allowed as single line blocks when
  6223. `noSingleLineBlocks` is set. You may set this to a empty array to
  6224. cause all single line blocks to be reported. If `'*'` is present, then
  6225. the presence of a tag will allow single line blocks (but not if a tag is
  6226. missing).
  6227. <a name="eslint-plugin-jsdoc-rules-multiline-blocks-options-13-nomultilineblocks-defaults-to-false"></a>
  6228. ##### <code>noMultilineBlocks</code> (defaults to <code>false</code>)
  6229. Requires that jsdoc blocks are restricted to single lines only unless impacted
  6230. by the options `minimumLengthForMultiline`, `multilineTags`, or
  6231. `allowMultipleTags`.
  6232. <a name="eslint-plugin-jsdoc-rules-multiline-blocks-options-13-minimumlengthformultiline-defaults-to-not-being-in-effect"></a>
  6233. ##### <code>minimumLengthForMultiline</code> (defaults to not being in effect)
  6234. If `noMultilineBlocks` is set with this numeric option, multiline blocks will
  6235. be permitted if containing at least the given amount of text.
  6236. If not set, multiline blocks will not be permitted regardless of length unless
  6237. a relevant tag is present and `multilineTags` is set.
  6238. <a name="eslint-plugin-jsdoc-rules-multiline-blocks-options-13-multilinetags-defaults-to"></a>
  6239. ##### <code>multilineTags</code> (defaults to <code>[&#39;*&#39;]</code>)
  6240. If `noMultilineBlocks` is set with this option, multiline blocks may be allowed
  6241. regardless of length as long as a tag or a tag of a certain type is present.
  6242. If `*` is included in the array, the presence of a tags will allow for
  6243. multiline blocks (but not when without any tags unless the amount of text is
  6244. over an amount specified by `minimumLengthForMultiline`).
  6245. If the array does not include `*` but lists certain tags, the presence of
  6246. such a tag will cause multiline blocks to be allowed.
  6247. You may set this to an empty array to prevent any tag from permitting multiple
  6248. lines.
  6249. <a name="eslint-plugin-jsdoc-rules-multiline-blocks-options-13-allowmultipletags-defaults-to-true"></a>
  6250. ##### <code>allowMultipleTags</code> (defaults to <code>true</code>)
  6251. If `noMultilineBlocks` is set to `true` with this option and multiple tags are
  6252. found in a block, an error will not be reported.
  6253. Since multiple-tagged lines cannot be collapsed into a single line, this option
  6254. prevents them from being reported. Set to `false` if you really want to report
  6255. any blocks.
  6256. This option will also be applied when there is a block description and a single
  6257. tag (since a description cannot precede a tag on a single line, and also
  6258. cannot be reliably added after the tag either).
  6259. |||
  6260. |---|---|
  6261. |Context|everywhere|
  6262. |Tags|Any (though `singleLineTags` and `multilineTags` control the application)|
  6263. |Recommended|true|
  6264. |Settings||
  6265. |Options|`noZeroLineText`, `noSingleLineBlocks`, `singleLineTags`, `noMultilineBlocks`, `minimumLengthForMultiline`, `multilineTags`, `allowMultipleTags`, `noFinalLineText`|
  6266. The following patterns are considered problems:
  6267. ````js
  6268. /** Reported up here
  6269. * because the rest is multiline
  6270. */
  6271. // Message: Should have no text on the "0th" line (after the `/**`).
  6272. /** Reported up here
  6273. * because the rest is multiline
  6274. */
  6275. // "jsdoc/multiline-blocks": ["error"|"warn", {"noZeroLineText":true}]
  6276. // Message: Should have no text on the "0th" line (after the `/**`).
  6277. /** @abc {aType} aName Reported up here
  6278. * because the rest is multiline
  6279. */
  6280. // "jsdoc/multiline-blocks": ["error"|"warn", {"noZeroLineText":true}]
  6281. // Message: Should have no text on the "0th" line (after the `/**`).
  6282. /** @tag */
  6283. // "jsdoc/multiline-blocks": ["error"|"warn", {"noSingleLineBlocks":true}]
  6284. // Message: Single line blocks are not permitted by your configuration.
  6285. /** @tag {someType} */
  6286. // "jsdoc/multiline-blocks": ["error"|"warn", {"noSingleLineBlocks":true}]
  6287. // Message: Single line blocks are not permitted by your configuration.
  6288. /** @tag {someType} aName */
  6289. // "jsdoc/multiline-blocks": ["error"|"warn", {"noSingleLineBlocks":true}]
  6290. // Message: Single line blocks are not permitted by your configuration.
  6291. /** @tag */
  6292. // "jsdoc/multiline-blocks": ["error"|"warn", {"noSingleLineBlocks":true,"singleLineTags":["someOtherTag"]}]
  6293. // Message: Single line blocks are not permitted by your configuration.
  6294. /** desc */
  6295. // "jsdoc/multiline-blocks": ["error"|"warn", {"noSingleLineBlocks":true,"singleLineTags":["*"]}]
  6296. // Message: Single line blocks are not permitted by your configuration.
  6297. /**
  6298. * Desc.
  6299. */
  6300. // "jsdoc/multiline-blocks": ["error"|"warn", {"noMultilineBlocks":true}]
  6301. // Message: Multiline jsdoc blocks are prohibited by your configuration.
  6302. /** desc
  6303. *
  6304. */
  6305. // "jsdoc/multiline-blocks": ["error"|"warn", {"noMultilineBlocks":true}]
  6306. // Message: Multiline jsdoc blocks are prohibited by your configuration.
  6307. /** desc
  6308. *
  6309. */
  6310. // "jsdoc/multiline-blocks": ["error"|"warn", {"noMultilineBlocks":true,"noSingleLineBlocks":true}]
  6311. // Message: Multiline jsdoc blocks are prohibited by your configuration but fixing would result in a single line block which you have prohibited with `noSingleLineBlocks`.
  6312. /**
  6313. *
  6314. */
  6315. // "jsdoc/multiline-blocks": ["error"|"warn", {"noMultilineBlocks":true}]
  6316. // Message: Multiline jsdoc blocks are prohibited by your configuration.
  6317. /**
  6318. * This is not long enough to be permitted.
  6319. */
  6320. // "jsdoc/multiline-blocks": ["error"|"warn", {"minimumLengthForMultiline":100,"noMultilineBlocks":true}]
  6321. // Message: Multiline jsdoc blocks are prohibited by your configuration.
  6322. /**
  6323. * This is not long enough to be permitted.
  6324. */
  6325. // "jsdoc/multiline-blocks": ["error"|"warn", {"allowMultipleTags":true,"minimumLengthForMultiline":100,"noMultilineBlocks":true}]
  6326. // Message: Multiline jsdoc blocks are prohibited by your configuration.
  6327. /**
  6328. * This has the wrong tags so is not permitted.
  6329. * @notTheRightTag
  6330. */
  6331. // "jsdoc/multiline-blocks": ["error"|"warn", {"allowMultipleTags":false,"multilineTags":["onlyThisIsExempted"],"noMultilineBlocks":true}]
  6332. // Message: Multiline jsdoc blocks are prohibited by your configuration but the block has a description with a tag.
  6333. /**
  6334. * This has too many tags so cannot be fixed ot a single line.
  6335. * @oneTag
  6336. * @anotherTag
  6337. */
  6338. // "jsdoc/multiline-blocks": ["error"|"warn", {"allowMultipleTags":false,"multilineTags":[],"noMultilineBlocks":true}]
  6339. // Message: Multiline jsdoc blocks are prohibited by your configuration but the block has multiple tags.
  6340. /**
  6341. * This has a tag and description so cannot be fixed ot a single line.
  6342. * @oneTag
  6343. */
  6344. // "jsdoc/multiline-blocks": ["error"|"warn", {"allowMultipleTags":false,"multilineTags":[],"noMultilineBlocks":true}]
  6345. // Message: Multiline jsdoc blocks are prohibited by your configuration but the block has a description with a tag.
  6346. /**
  6347. * This has no tags so is not permitted.
  6348. */
  6349. // "jsdoc/multiline-blocks": ["error"|"warn", {"multilineTags":["*"],"noMultilineBlocks":true}]
  6350. // Message: Multiline jsdoc blocks are prohibited by your configuration.
  6351. /**
  6352. * This has the wrong tags so is not permitted.
  6353. * @notTheRightTag
  6354. */
  6355. // "jsdoc/multiline-blocks": ["error"|"warn", {"allowMultipleTags":false,"minimumLengthForMultiline":500,"multilineTags":["onlyThisIsExempted"],"noMultilineBlocks":true}]
  6356. // Message: Multiline jsdoc blocks are prohibited by your configuration but the block has a description with a tag.
  6357. /**
  6358. * @lends This can be safely fixed to a single line.
  6359. */
  6360. // "jsdoc/multiline-blocks": ["error"|"warn", {"multilineTags":[],"noMultilineBlocks":true,"noSingleLineBlocks":true}]
  6361. // Message: Multiline jsdoc blocks are prohibited by your configuration.
  6362. /**
  6363. * @type {aType} This can be safely fixed to a single line.
  6364. */
  6365. // "jsdoc/multiline-blocks": ["error"|"warn", {"multilineTags":[],"noMultilineBlocks":true,"noSingleLineBlocks":true}]
  6366. // Message: Multiline jsdoc blocks are prohibited by your configuration.
  6367. /**
  6368. * @aTag
  6369. */
  6370. // "jsdoc/multiline-blocks": ["error"|"warn", {"multilineTags":[],"noMultilineBlocks":true}]
  6371. // Message: Multiline jsdoc blocks are prohibited by your configuration.
  6372. /**
  6373. * This is a problem when single and multiline are blocked.
  6374. */
  6375. // "jsdoc/multiline-blocks": ["error"|"warn", {"noMultilineBlocks":true,"noSingleLineBlocks":true}]
  6376. // Message: Multiline jsdoc blocks are prohibited by your configuration but fixing would result in a single line block which you have prohibited with `noSingleLineBlocks`.
  6377. /** This comment is bad
  6378. * It should not have text on line zero
  6379. */
  6380. // "jsdoc/multiline-blocks": ["error"|"warn", {"minimumLengthForMultiline":50,"noMultilineBlocks":true,"noZeroLineText":true}]
  6381. // Message: Should have no text on the "0th" line (after the `/**`).
  6382. /**
  6383. * @lends This can be safely fixed
  6384. * to a single
  6385. * line. */
  6386. // "jsdoc/multiline-blocks": ["error"|"warn", {"multilineTags":[],"noMultilineBlocks":true}]
  6387. // Message: Multiline jsdoc blocks are prohibited by your configuration.
  6388. /**
  6389. * @someTag {aType} with Description */
  6390. // "jsdoc/multiline-blocks": ["error"|"warn", {"noFinalLineBlocks":true}]
  6391. // Message: Should have no text on the final line (before the `*/`).
  6392. /**
  6393. * Description */
  6394. // "jsdoc/multiline-blocks": ["error"|"warn", {"noFinalLineBlocks":true}]
  6395. // Message: Should have no text on the final line (before the `*/`).
  6396. ````
  6397. The following patterns are not considered problems:
  6398. ````js
  6399. /** Not reported */
  6400. /**
  6401. * Not reported
  6402. */
  6403. /** Reported up here
  6404. * because the rest is multiline
  6405. */
  6406. // "jsdoc/multiline-blocks": ["error"|"warn", {"noZeroLineText":false}]
  6407. /** @tag */
  6408. /** @lends */
  6409. // "jsdoc/multiline-blocks": ["error"|"warn", {"noSingleLineBlocks":true}]
  6410. /** @tag */
  6411. // "jsdoc/multiline-blocks": ["error"|"warn", {"noSingleLineBlocks":true,"singleLineTags":["tag"]}]
  6412. /** @tag */
  6413. // "jsdoc/multiline-blocks": ["error"|"warn", {"noSingleLineBlocks":true,"singleLineTags":["*"]}]
  6414. /**
  6415. *
  6416. */
  6417. /**
  6418. *
  6419. */
  6420. // "jsdoc/multiline-blocks": ["error"|"warn", {"noMultilineBlocks":false}]
  6421. /** Test */
  6422. // "jsdoc/multiline-blocks": ["error"|"warn", {"noMultilineBlocks":true}]
  6423. /**
  6424. * This is long enough to be permitted by our config.
  6425. */
  6426. // "jsdoc/multiline-blocks": ["error"|"warn", {"minimumLengthForMultiline":25,"noMultilineBlocks":true}]
  6427. /**
  6428. * This is long enough to be permitted by our config.
  6429. */
  6430. // "jsdoc/multiline-blocks": ["error"|"warn", {"minimumLengthForMultiline":50,"noMultilineBlocks":true}]
  6431. /**
  6432. * This has the right tag so is permitted.
  6433. * @theRightTag
  6434. */
  6435. // "jsdoc/multiline-blocks": ["error"|"warn", {"multilineTags":["theRightTag"],"noMultilineBlocks":true}]
  6436. /** This has no tags but is single line so is not permitted. */
  6437. // "jsdoc/multiline-blocks": ["error"|"warn", {"multilineTags":["*"],"noMultilineBlocks":true}]
  6438. /**
  6439. * This has the wrong tags so is not permitted.
  6440. * @notTheRightTag
  6441. */
  6442. // "jsdoc/multiline-blocks": ["error"|"warn", {"minimumLengthForMultiline":10,"multilineTags":["onlyThisIsExempted"],"noMultilineBlocks":true}]
  6443. /**
  6444. * This has the wrong tags so is not permitted.
  6445. * @theRightTag
  6446. */
  6447. // "jsdoc/multiline-blocks": ["error"|"warn", {"minimumLengthForMultiline":500,"multilineTags":["theRightTag"],"noMultilineBlocks":true}]
  6448. /** tag */
  6449. /**
  6450. * @lends This is ok per multiline
  6451. */
  6452. // "jsdoc/multiline-blocks": ["error"|"warn", {"noMultilineBlocks":true,"noSingleLineBlocks":true}]
  6453. /**
  6454. * This has too many tags so cannot be fixed ot a single line.
  6455. * @oneTag
  6456. * @anotherTag
  6457. */
  6458. // "jsdoc/multiline-blocks": ["error"|"warn", {"multilineTags":[],"noMultilineBlocks":true}]
  6459. /**
  6460. * This has too many tags so cannot be fixed ot a single line.
  6461. * @oneTag
  6462. * @anotherTag
  6463. */
  6464. // "jsdoc/multiline-blocks": ["error"|"warn", {"allowMultipleTags":true,"multilineTags":[],"noMultilineBlocks":true}]
  6465. /**
  6466. * This has a tag and description so cannot be fixed ot a single line.
  6467. * @oneTag
  6468. */
  6469. // "jsdoc/multiline-blocks": ["error"|"warn", {"allowMultipleTags":true,"multilineTags":[],"noMultilineBlocks":true}]
  6470. /**
  6471. * This has a tag and description so cannot be fixed ot a single line.
  6472. * @oneTag
  6473. */
  6474. // "jsdoc/multiline-blocks": ["error"|"warn", {"allowMultipleTags":false,"multilineTags":["oneTag"],"noMultilineBlocks":true}]
  6475. /** @someTag with Description */
  6476. // "jsdoc/multiline-blocks": ["error"|"warn", {"noFinalLineBlocks":true}]
  6477. ````
  6478. <a name="eslint-plugin-jsdoc-rules-newline-after-description"></a>
  6479. ### <code>newline-after-description</code>
  6480. Enforces a consistent padding of the block description.
  6481. <a name="eslint-plugin-jsdoc-rules-newline-after-description-options-14"></a>
  6482. #### Options
  6483. This rule allows one optional string argument. If it is `"always"` then a
  6484. problem is raised when there is no newline after the description. If it is
  6485. `"never"` then a problem is raised when there is a newline after the
  6486. description. The default value is `"always"`.
  6487. |||
  6488. |---|---|
  6489. |Context|everywhere|
  6490. |Tags|N/A (doc block)|
  6491. |Options|(a string matching `"always" or "never"`)|
  6492. |Recommended|true|
  6493. The following patterns are considered problems:
  6494. ````js
  6495. /**
  6496. * Foo.
  6497. *
  6498. * Foo.
  6499. * @foo
  6500. */
  6501. function quux () {
  6502. }
  6503. // "jsdoc/newline-after-description": ["error"|"warn", "always"]
  6504. // Message: There must be a newline after the description of the JSDoc block.
  6505. /**
  6506. * Foo.
  6507. * @foo
  6508. *
  6509. * Foo.
  6510. */
  6511. function quux () {
  6512. }
  6513. // "jsdoc/newline-after-description": ["error"|"warn", "always"]
  6514. // Message: There must be a newline after the description of the JSDoc block.
  6515. /**
  6516. * Foo.
  6517. *
  6518. * Foo.
  6519. * @foo
  6520. */
  6521. function quux () {
  6522. }
  6523. // Message: There must be a newline after the description of the JSDoc block.
  6524. /**
  6525. * Bar.
  6526. *
  6527. * Bar.
  6528. *
  6529. * @bar
  6530. */
  6531. function quux () {
  6532. }
  6533. // "jsdoc/newline-after-description": ["error"|"warn", "never"]
  6534. // Message: There must be no newline after the description of the JSDoc block.
  6535. /**
  6536. * Bar.
  6537. *
  6538. * @bar
  6539. *
  6540. * Bar.
  6541. */
  6542. function quux () {
  6543. }
  6544. // "jsdoc/newline-after-description": ["error"|"warn", "never"]
  6545. // Message: There must be no newline after the description of the JSDoc block.
  6546. /**
  6547. * Bar.
  6548. *
  6549. * Bar.
  6550. *
  6551. * @bar
  6552. */
  6553. function quux () {
  6554. }
  6555. // "jsdoc/newline-after-description": ["error"|"warn", "never"]
  6556. // Message: There must be no newline after the description of the JSDoc block.
  6557. /**
  6558. * A.
  6559. *
  6560. * @typedef {object} A
  6561. * @prop {boolean} a A.
  6562. */
  6563. // "jsdoc/newline-after-description": ["error"|"warn", "never"]
  6564. // Message: There must be no newline after the description of the JSDoc block.
  6565. /**
  6566. * A.
  6567. * @typedef {object} A
  6568. * @prop {boolean} a A.
  6569. */
  6570. // "jsdoc/newline-after-description": ["error"|"warn", "always"]
  6571. // Message: There must be a newline after the description of the JSDoc block.
  6572. /**
  6573. * Service for fetching symbols.
  6574. * @param {object} $http - Injected http helper.
  6575. * @param {object} $q - Injected Promise api helper.
  6576. * @param {object} $location - Injected window location object.
  6577. * @param {object} REPORT_DIALOG_CONSTANTS - Injected handle.
  6578. */
  6579. // Message: There must be a newline after the description of the JSDoc block.
  6580. /** An example function.
  6581. *
  6582. * @returns {number} An example number.
  6583. */
  6584. function example() {
  6585. return 42;
  6586. }
  6587. // "jsdoc/newline-after-description": ["error"|"warn", "never"]
  6588. // Message: There must be no newline after the description of the JSDoc block.
  6589. /** An example function.
  6590. * @returns {number} An example number.
  6591. */
  6592. function example() {
  6593. return 42;
  6594. }
  6595. // "jsdoc/newline-after-description": ["error"|"warn", "always"]
  6596. // Message: There must be a newline after the description of the JSDoc block.
  6597. ````
  6598. The following patterns are not considered problems:
  6599. ````js
  6600. /**
  6601. * Foo.
  6602. */
  6603. function quux () {
  6604. }
  6605. // "jsdoc/newline-after-description": ["error"|"warn", "always"]
  6606. /**
  6607. * Bar.
  6608. */
  6609. function quux () {
  6610. }
  6611. // "jsdoc/newline-after-description": ["error"|"warn", "never"]
  6612. /**
  6613. * Foo.
  6614. *
  6615. * @foo
  6616. */
  6617. function quux () {
  6618. }
  6619. // "jsdoc/newline-after-description": ["error"|"warn", "always"]
  6620. /**
  6621. * Bar.
  6622. * @bar
  6623. */
  6624. function quux () {
  6625. }
  6626. // "jsdoc/newline-after-description": ["error"|"warn", "never"]
  6627. /**
  6628. * @foo
  6629. * Test 
  6630. * abc 
  6631. * @bar 
  6632. */
  6633. /**
  6634. *
  6635. * @foo
  6636. * Test 
  6637. * abc 
  6638. * @bar 
  6639. */
  6640. /***
  6641. *
  6642. */
  6643. function quux () {
  6644. }
  6645. // "jsdoc/newline-after-description": ["error"|"warn", "always"]
  6646. /**
  6647. * Parses query string to object containing URL parameters
  6648. *
  6649. * @param queryString
  6650. * Input string
  6651. *
  6652. * @returns
  6653. * Object containing URL parameters
  6654. */
  6655. export function parseQueryString(queryString: string): { [key: string]: string } { // <-- Line 10 that fails
  6656. }
  6657. /** An example function.
  6658. *
  6659. * @returns {number} An example number.
  6660. */
  6661. function example() {
  6662. return 42;
  6663. }
  6664. /** An example function.
  6665. * @returns {number} An example number.
  6666. */
  6667. function example() {
  6668. return 42;
  6669. }
  6670. // "jsdoc/newline-after-description": ["error"|"warn", "never"]
  6671. ````
  6672. <a name="eslint-plugin-jsdoc-rules-no-bad-blocks"></a>
  6673. ### <code>no-bad-blocks</code>
  6674. This rule checks for multi-line-style comments which fail to meet the
  6675. criteria of a jsdoc block, namely that it should begin with two and only two
  6676. asterisks, but which appear to be intended as jsdoc blocks due to the presence
  6677. of whitespace followed by whitespace or asterisks, and
  6678. an at-sign (`@`) and some non-whitespace (as with a jsdoc block tag).
  6679. <a name="eslint-plugin-jsdoc-rules-no-bad-blocks-options-15"></a>
  6680. #### Options
  6681. Takes an optional options object with the following.
  6682. <a name="eslint-plugin-jsdoc-rules-no-bad-blocks-options-15-ignore"></a>
  6683. ##### <code>ignore</code>
  6684. An array of directives that will not be reported if present at the beginning of
  6685. a multi-comment block and at-sign `/* @`.
  6686. Defaults to `['ts-check', 'ts-expect-error', 'ts-ignore', 'ts-nocheck']`
  6687. (some directives [used by TypeScript](https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html#ts-check)).
  6688. <a name="eslint-plugin-jsdoc-rules-no-bad-blocks-options-15-preventallmultiasteriskblocks"></a>
  6689. ##### <code>preventAllMultiAsteriskBlocks</code>
  6690. A boolean (defaulting to `false`) which if `true` will prevent all
  6691. multi-asterisked blocks even those without apparent tag content.
  6692. |||
  6693. |---|---|
  6694. |Context|Everywhere|
  6695. |Tags|N/A|
  6696. |Recommended|false|
  6697. |Options|`ignore`, `preventAllMultiAsteriskBlocks`|
  6698. The following patterns are considered problems:
  6699. ````js
  6700. /*
  6701. * @param foo
  6702. */
  6703. function quux (foo) {
  6704. }
  6705. // Message: Expected JSDoc-like comment to begin with two asterisks.
  6706. /*
  6707. * @property foo
  6708. */
  6709. // Message: Expected JSDoc-like comment to begin with two asterisks.
  6710. function quux() {
  6711. }
  6712. // Settings: {"jsdoc":{"structuredTags":{"see":{"name":false,"required":["name"]}}}}
  6713. // Message: Cannot add "name" to `require` with the tag's `name` set to `false`
  6714. /* @ts-ignore */
  6715. // "jsdoc/no-bad-blocks": ["error"|"warn", {"ignore":[]}]
  6716. // Message: Expected JSDoc-like comment to begin with two asterisks.
  6717. /*
  6718. * Some description.
  6719. *
  6720. * @returns {string} Some string
  6721. */
  6722. function echo() {
  6723. return 'Something';
  6724. }
  6725. // Message: Expected JSDoc-like comment to begin with two asterisks.
  6726. /***
  6727. * @param foo
  6728. */
  6729. function quux (foo) {
  6730. }
  6731. // Message: Expected JSDoc-like comment to begin with two asterisks.
  6732. /***
  6733. *
  6734. */
  6735. function quux (foo) {
  6736. }
  6737. // "jsdoc/no-bad-blocks": ["error"|"warn", {"preventAllMultiAsteriskBlocks":true}]
  6738. // Message: Expected JSDoc-like comment to begin with two asterisks.
  6739. ````
  6740. The following patterns are not considered problems:
  6741. ````js
  6742. /**
  6743. * @property foo
  6744. */
  6745. /**
  6746. * @param foo
  6747. */
  6748. function quux () {
  6749. }
  6750. function quux () {
  6751. }
  6752. /* This could just be intended as a regular multiline comment,
  6753. so don't report this */
  6754. function quux () {
  6755. }
  6756. /* Just a regular multiline comment with an `@` but not appearing
  6757. like a tag in a jsdoc-block, so don't report */
  6758. function quux () {
  6759. }
  6760. /* @ts-check */
  6761. /* @ts-expect-error */
  6762. /* @ts-ignore */
  6763. /* @ts-nocheck */
  6764. /* */
  6765. /* @custom */
  6766. // "jsdoc/no-bad-blocks": ["error"|"warn", {"ignore":["custom"]}]
  6767. /***
  6768. * This is not JSDoc because of the 3 asterisks, but
  6769. * is allowed without `preventAllMultiAsteriskBlocks`, as
  6770. * some might wish normal multiline comments.
  6771. */
  6772. function quux (foo) {
  6773. }
  6774. ````
  6775. <a name="eslint-plugin-jsdoc-rules-no-defaults"></a>
  6776. ### <code>no-defaults</code>
  6777. This rule reports defaults being used on the relevant portion of `@param`
  6778. or `@default`. It also optionally reports the presence of the
  6779. square-bracketed optional arguments at all.
  6780. The rule is intended to prevent the indication of defaults on tags where
  6781. this would be redundant with ES6 default parameters (or for `@default`,
  6782. where it would be redundant with the context to which the `@default`
  6783. tag is attached).
  6784. Unless your `@default` is on a function, you will need to set `contexts`
  6785. to an appropriate context, including, if you wish, "any".
  6786. <a name="eslint-plugin-jsdoc-rules-no-defaults-options-16"></a>
  6787. #### Options
  6788. <a name="eslint-plugin-jsdoc-rules-no-defaults-options-16-nooptionalparamnames"></a>
  6789. ##### <code>noOptionalParamNames</code>
  6790. Set this to `true` to report the presence of optional parameters. May be
  6791. used if the project is insisting on optionality being indicated by
  6792. the presence of ES6 default parameters (bearing in mind that such
  6793. "defaults" are only applied when the supplied value is missing or
  6794. `undefined` but not for `null` or other "falsey" values).
  6795. <a name="eslint-plugin-jsdoc-rules-no-defaults-options-16-contexts-2"></a>
  6796. ##### <code>contexts</code>
  6797. Set this to an array of strings representing the AST context (or an object with
  6798. `context` and `comment` properties) where you wish the rule to be applied.
  6799. Overrides the default contexts (see below). Set to `"any"` if you want
  6800. the rule to apply to any jsdoc block throughout your files (as is necessary
  6801. for finding function blocks not attached to a function declaration or
  6802. expression, i.e., `@callback` or `@function` (or its aliases `@func` or
  6803. `@method`) (including those associated with an `@interface`).
  6804. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  6805. section of our README for more on the expected format.
  6806. |||
  6807. |---|---|
  6808. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
  6809. |Tags|`param`, `default`|
  6810. |Aliases|`arg`, `argument`, `defaultvalue`|
  6811. |Recommended|false|
  6812. |Options|`contexts`, `noOptionalParamNames`|
  6813. The following patterns are considered problems:
  6814. ````js
  6815. /**
  6816. * @param {number} [foo="7"]
  6817. */
  6818. function quux (foo) {
  6819. }
  6820. // Message: Defaults are not permitted on @param.
  6821. class Test {
  6822. /**
  6823. * @param {number} [foo="7"]
  6824. */
  6825. quux (foo) {
  6826. }
  6827. }
  6828. // Message: Defaults are not permitted on @param.
  6829. /**
  6830. * @param {number} [foo="7"]
  6831. */
  6832. function quux (foo) {
  6833. }
  6834. // "jsdoc/no-defaults": ["error"|"warn", {"noOptionalParamNames":true}]
  6835. // Message: Optional param names are not permitted on @param.
  6836. /**
  6837. * @arg {number} [foo="7"]
  6838. */
  6839. function quux (foo) {
  6840. }
  6841. // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
  6842. // Message: Defaults are not permitted on @arg.
  6843. /**
  6844. * @param {number} [foo="7"]
  6845. */
  6846. function quux (foo) {
  6847. }
  6848. // "jsdoc/no-defaults": ["error"|"warn", {"contexts":["any"]}]
  6849. // Message: Defaults are not permitted on @param.
  6850. /**
  6851. * @function
  6852. * @param {number} [foo="7"]
  6853. */
  6854. // "jsdoc/no-defaults": ["error"|"warn", {"contexts":["any"]}]
  6855. // Message: Defaults are not permitted on @param.
  6856. /**
  6857. * @callback
  6858. * @param {number} [foo="7"]
  6859. */
  6860. // "jsdoc/no-defaults": ["error"|"warn", {"contexts":["any"]}]
  6861. // Message: Defaults are not permitted on @param.
  6862. /**
  6863. * @default {}
  6864. */
  6865. const a = {};
  6866. // "jsdoc/no-defaults": ["error"|"warn", {"contexts":["any"]}]
  6867. // Message: Default values are not permitted on @default.
  6868. /**
  6869. * @defaultvalue {}
  6870. */
  6871. const a = {};
  6872. // Settings: {"jsdoc":{"tagNamePreference":{"default":"defaultvalue"}}}
  6873. // "jsdoc/no-defaults": ["error"|"warn", {"contexts":["any"]}]
  6874. // Message: Default values are not permitted on @defaultvalue.
  6875. ````
  6876. The following patterns are not considered problems:
  6877. ````js
  6878. /**
  6879. * @param foo
  6880. */
  6881. function quux (foo) {
  6882. }
  6883. /**
  6884. * @param {number} foo
  6885. */
  6886. function quux (foo) {
  6887. }
  6888. /**
  6889. * @param foo
  6890. */
  6891. // "jsdoc/no-defaults": ["error"|"warn", {"contexts":["any"]}]
  6892. /**
  6893. * @function
  6894. * @param {number} foo
  6895. */
  6896. /**
  6897. * @callback
  6898. * @param {number} foo
  6899. */
  6900. /**
  6901. * @param {number} foo
  6902. */
  6903. function quux (foo) {
  6904. }
  6905. // "jsdoc/no-defaults": ["error"|"warn", {"noOptionalParamNames":true}]
  6906. /**
  6907. * @default
  6908. */
  6909. const a = {};
  6910. // "jsdoc/no-defaults": ["error"|"warn", {"contexts":["any"]}]
  6911. ````
  6912. <a name="eslint-plugin-jsdoc-rules-no-missing-syntax"></a>
  6913. ### <code>no-missing-syntax</code>
  6914. This rule lets you report if certain always expected comment structures are
  6915. missing.
  6916. This (along with `no-restricted-syntax`) is a bit similar to Schematron for
  6917. XML or jsontron for JSON--you can validate expectations of there being
  6918. arbitrary structures.
  6919. This differs from the rule of the same name in
  6920. [`eslint-plugin-query`](https://github.com/brettz9/eslint-plugin-query)
  6921. in that this rule always looks for a comment above a structure (whether or not
  6922. you have a `comment` condition).
  6923. This rule might be especially useful with [`overrides`](https://eslint.org/docs/user-guide/configuring/configuration-files#how-do-overrides-work)
  6924. where you need only require tags and/or types within specific directories
  6925. (e.g., to enforce that a plugins or locale directory always has a certain form
  6926. of export and comment therefor).
  6927. In addition to being generally useful for precision in requiring contexts,
  6928. it is hoped that the ability to specify required tags on structures can
  6929. be used for requiring `@type` or other types for a minimalist yet adequate
  6930. specification of types which can be used to compile JavaScript+JSDoc (JJ)
  6931. to WebAssembly (e.g., by converting it to TypeSscript and then using
  6932. AssemblyScript to convert to WebAssembly). (It may be possible that one
  6933. will need to require types with certain structures beyond function
  6934. declarations and the like, as well as optionally requiring specification
  6935. of number types.)
  6936. Note that you can use selectors which make use of negators like `:not()`
  6937. including with asterisk, e.g., `*:not(FunctionDeclaration)` to indicate types
  6938. which are not adequate to satisfy a condition, e.g.,
  6939. `FunctionDeclaration:not(FunctionDeclaration[id.name="ignoreMe"])` would
  6940. not report if there were only a function declaration of the name "ignoreMe"
  6941. (though it would report by function declarations of other names).
  6942. <a name="eslint-plugin-jsdoc-rules-no-missing-syntax-options-17"></a>
  6943. #### Options
  6944. <a name="eslint-plugin-jsdoc-rules-no-missing-syntax-options-17-contexts-3"></a>
  6945. ##### <code>contexts</code>
  6946. Set this to an array of strings representing the AST context (or an object with
  6947. `context` and `comment` properties) where you wish the rule to be applied.
  6948. Use the `minimum` property (defaults to 1) to indicate how many are required
  6949. for the rule to be reported.
  6950. Use the `message` property to indicate the specific error to be shown when an
  6951. error is reported for that context being found missing. You may use
  6952. `{{context}}` and `{{comment}}` with such messages.
  6953. Set to `"any"` if you want the rule to apply to any jsdoc block throughout
  6954. your files (as is necessary for finding function blocks not attached to a
  6955. function declaration or expression, i.e., `@callback` or `@function` (or its
  6956. aliases `@func` or `@method`) (including those associated with an `@interface`).
  6957. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  6958. section of our README for more on the expected format.
  6959. |||
  6960. |---|---|
  6961. |Context|None except those indicated by `contexts`|
  6962. |Tags|Any if indicated by AST|
  6963. |Recommended|false|
  6964. |Options|`contexts`|
  6965. The following patterns are considered problems:
  6966. ````js
  6967. /**
  6968. * @implements {Bar|Foo}
  6969. */
  6970. function quux () {
  6971. }
  6972. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration"}]}]
  6973. // Message: Syntax is required: FunctionDeclaration with JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Foo"]:nth-child(1))
  6974. /**
  6975. * @implements {Bar|Foo}
  6976. */
  6977. function quux () {
  6978. }
  6979. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration","message":"Problematically missing function syntax: `{{context}}` with `{{comment}}`."}]}]
  6980. // Message: Problematically missing function syntax: `FunctionDeclaration` with `JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Foo"]:nth-child(1))`.
  6981. /**
  6982. * @implements {Bar|Foo}
  6983. */
  6984. function quux () {
  6985. }
  6986. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":["FunctionDeclaration"]}]
  6987. // Message: Syntax is required: FunctionDeclaration
  6988. /**
  6989. * @implements {Bar|Foo}
  6990. */
  6991. function quux () {
  6992. }
  6993. // Message: Rule `no-missing-syntax` is missing a `context` option.
  6994. /**
  6995. * @implements {Bar|Foo}
  6996. */
  6997. function quux () {
  6998. }
  6999. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"FunctionDeclaration","minimum":2}]}]
  7000. // Message: Syntax is required: FunctionDeclaration with JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Bar"]:nth-child(1))
  7001. /**
  7002. * @param ab
  7003. * @param cd
  7004. */
  7005. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Require names matching `/^opt_/i`."}]}]
  7006. // Message: Require names matching `/^opt_/i`.
  7007. /**
  7008. * @param ab
  7009. * @param cd
  7010. */
  7011. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","message":"Require names matching `/^opt_/i`."}]}]
  7012. // Message: Require names matching `/^opt_/i`.
  7013. /**
  7014. * @param ab
  7015. * @param cd
  7016. */
  7017. function quux () {}
  7018. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Require names matching `/^opt_/i`."}]}]
  7019. // Message: Require names matching `/^opt_/i`.
  7020. ````
  7021. The following patterns are not considered problems:
  7022. ````js
  7023. /**
  7024. * @implements {Bar|Foo}
  7025. */
  7026. function quux () {
  7027. }
  7028. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"FunctionDeclaration"}]}]
  7029. /**
  7030. * @implements {Bar|Foo}
  7031. */
  7032. function quux () {
  7033. }
  7034. /**
  7035. * @implements {Bar|Foo}
  7036. */
  7037. function bar () {
  7038. }
  7039. /**
  7040. * @implements {Bar|Foo}
  7041. */
  7042. function baz () {
  7043. }
  7044. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"FunctionDeclaration","minimum":2}]}]
  7045. /**
  7046. * @param opt_a
  7047. * @param opt_b
  7048. */
  7049. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Require names matching `/^opt_/i`."}]}]
  7050. /**
  7051. * @param opt_a
  7052. * @param opt_b
  7053. */
  7054. function quux () {}
  7055. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Require names matching `/^opt_/i`."}]}]
  7056. /**
  7057. * @param opt_a
  7058. * @param opt_b
  7059. */
  7060. function quux () {}
  7061. // "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","message":"Require names matching `/^opt_/i`."}]}]
  7062. ````
  7063. <a name="eslint-plugin-jsdoc-rules-no-multi-asterisks"></a>
  7064. ### <code>no-multi-asterisks</code>
  7065. Prevents use of multiple asterisks at the beginning of lines.
  7066. Note that if you wish to prevent multiple asterisks at the very beginning of
  7067. the jsdoc block, you should use `no-bad-blocks` (as that is not proper jsdoc
  7068. and that rule is for catching blocks which only seem like jsdoc).
  7069. <a name="eslint-plugin-jsdoc-rules-no-multi-asterisks-options-18"></a>
  7070. #### Options
  7071. <a name="eslint-plugin-jsdoc-rules-no-multi-asterisks-options-18-preventatmiddlelines-defaults-to-true"></a>
  7072. ##### <code>preventAtMiddleLines</code> (defaults to <code>true</code>)
  7073. Prevent the likes of this:
  7074. ```js
  7075. /**
  7076. *
  7077. **
  7078. */
  7079. ```
  7080. <a name="eslint-plugin-jsdoc-rules-no-multi-asterisks-options-18-preventatend-defaults-to-true"></a>
  7081. ##### <code>preventAtEnd</code> (defaults to <code>true</code>)
  7082. Prevent the likes of this:
  7083. ```js
  7084. /**
  7085. *
  7086. *
  7087. **/
  7088. ```
  7089. |||
  7090. |---|---|
  7091. |Context|everywhere|
  7092. |Tags|(any)|
  7093. |Recommended|true|
  7094. |Settings||
  7095. |Options|`preventAtEnd`, `preventAtMiddleLines`|
  7096. The following patterns are considered problems:
  7097. ````js
  7098. /**
  7099. *
  7100. **
  7101. */
  7102. // Message: Should be no multiple asterisks on middle lines.
  7103. /**
  7104. *
  7105. **
  7106. */
  7107. // "jsdoc/no-multi-asterisks": ["error"|"warn", {"preventAtMiddleLines":true}]
  7108. // Message: Should be no multiple asterisks on middle lines.
  7109. /**
  7110. *
  7111. **
  7112. */
  7113. // "jsdoc/no-multi-asterisks": ["error"|"warn", {"preventAtEnd":false}]
  7114. // Message: Should be no multiple asterisks on middle lines.
  7115. /**
  7116. * With a description
  7117. * @tag {SomeType} and a tag with details
  7118. **
  7119. */
  7120. // Message: Should be no multiple asterisks on middle lines.
  7121. /**
  7122. **
  7123. *
  7124. */
  7125. // Message: Should be no multiple asterisks on middle lines.
  7126. /**
  7127. * Desc.
  7128. *
  7129. **/
  7130. // Message: Should be no multiple asterisks on end lines.
  7131. /**
  7132. * Desc.
  7133. *
  7134. **/
  7135. // "jsdoc/no-multi-asterisks": ["error"|"warn", {"preventAtEnd":true}]
  7136. // Message: Should be no multiple asterisks on end lines.
  7137. /**
  7138. * Desc.
  7139. *
  7140. abc * **/
  7141. // "jsdoc/no-multi-asterisks": ["error"|"warn", {"preventAtEnd":true}]
  7142. // Message: Should be no multiple asterisks on end lines.
  7143. /**
  7144. * Desc.
  7145. *
  7146. **/
  7147. // "jsdoc/no-multi-asterisks": ["error"|"warn", {"preventAtMiddleLines":false}]
  7148. // Message: Should be no multiple asterisks on end lines.
  7149. /** Desc. **/
  7150. // Message: Should be no multiple asterisks on end lines.
  7151. /** @someTag name desc. **/
  7152. // Message: Should be no multiple asterisks on end lines.
  7153. /** abc * */
  7154. // Message: Should be no multiple asterisks on end lines.
  7155. /**
  7156. * Preserve user's whitespace when fixing (though one may also
  7157. * use an align rule)
  7158. *
  7159. * */
  7160. // "jsdoc/no-multi-asterisks": ["error"|"warn", {"preventAtEnd":true}]
  7161. // Message: Should be no multiple asterisks on end lines.
  7162. ````
  7163. The following patterns are not considered problems:
  7164. ````js
  7165. /**
  7166. *
  7167. * Desc. ***
  7168. */
  7169. /**
  7170. * Desc. ***
  7171. *
  7172. */
  7173. /**
  7174. * Desc.
  7175. *
  7176. * sth */
  7177. /**
  7178. **
  7179. *
  7180. */
  7181. // "jsdoc/no-multi-asterisks": ["error"|"warn", {"preventAtMiddleLines":false}]
  7182. /**
  7183. *
  7184. *
  7185. **/
  7186. // "jsdoc/no-multi-asterisks": ["error"|"warn", {"preventAtEnd":false}]
  7187. /**
  7188. * With a desc.
  7189. * and ***
  7190. */
  7191. /**
  7192. * and ***
  7193. * With a desc.
  7194. */
  7195. /**
  7196. * With a desc.
  7197. * With a desc.
  7198. * Desc. */
  7199. /**
  7200. * With a description
  7201. * @tag {SomeType} and a tag with details
  7202. *
  7203. */
  7204. /** abc */
  7205. function foo() {
  7206. //
  7207. }
  7208. /** foo */
  7209. function foo(): void {
  7210. //
  7211. }
  7212. /** @aTag abc */
  7213. function foo() {
  7214. //
  7215. }
  7216. ````
  7217. <a name="eslint-plugin-jsdoc-rules-no-restricted-syntax"></a>
  7218. ### <code>no-restricted-syntax</code>
  7219. Reports when certain comment structures are present.
  7220. Note that this rule differs from ESLint's [no-restricted-syntax](https://eslint.org/docs/rules/no-restricted-syntax)
  7221. rule in expecting values within a single options object's
  7222. `contexts` property, and with the property `context` being used in place of
  7223. `selector` (as well as allowing for `comment`). The format also differs from
  7224. the format expected by [`eslint-plugin-query`](https://github.com/brettz9/eslint-plugin-query).
  7225. Unlike those rules, this is specific to finding comments attached to
  7226. structures, (whether or not you add a specific `comment` condition).
  7227. Note that if your parser supports comment AST (as [jsdoc-eslint-parser/](https://github.com/brettz9/jsdoc-eslint-parser/) is designed to do), you can just use ESLint's
  7228. rule.
  7229. <a name="eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19"></a>
  7230. #### Options
  7231. <a name="eslint-plugin-jsdoc-rules-no-restricted-syntax-options-19-contexts-4"></a>
  7232. ##### <code>contexts</code>
  7233. Set this to an array of strings representing the AST context (or an object with
  7234. `context` and `comment` properties) where you wish the rule to be applied.
  7235. Use the `message` property to indicate the specific error to be shown when an
  7236. error is reported for that context being found.
  7237. Set to `"any"` if you want the rule to apply to any jsdoc block throughout
  7238. your files (as is necessary for finding function blocks not attached to a
  7239. function declaration or expression, i.e., `@callback` or `@function` (or its
  7240. aliases `@func` or `@method`) (including those associated with an `@interface`).
  7241. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  7242. section of our README for more on the expected format.
  7243. |||
  7244. |---|---|
  7245. |Context|None except those indicated by `contexts`|
  7246. |Tags|Any if indicated by AST|
  7247. |Recommended|false|
  7248. |Options|`contexts`|
  7249. The following patterns are considered problems:
  7250. ````js
  7251. /**
  7252. *
  7253. */
  7254. function quux () {
  7255. }
  7256. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":["FunctionDeclaration"]}]
  7257. // Message: Syntax is restricted: FunctionDeclaration.
  7258. /**
  7259. *
  7260. */
  7261. function quux () {
  7262. }
  7263. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"context":"FunctionDeclaration","message":"Oops: `{{context}}`."}]}]
  7264. // Message: Oops: `FunctionDeclaration`.
  7265. /**
  7266. * @implements {Bar|Foo}
  7267. */
  7268. function quux () {
  7269. }
  7270. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"FunctionDeclaration"}]}]
  7271. // Message: Syntax is restricted: FunctionDeclaration.
  7272. /**
  7273. * @implements {Bar|Foo}
  7274. */
  7275. function quux () {
  7276. }
  7277. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration","message":"The foo one: {{context}}."},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"FunctionDeclaration","message":"The bar one: {{context}}."}]}]
  7278. // Message: The bar one: FunctionDeclaration.
  7279. /**
  7280. * @implements {Bar|Foo}
  7281. */
  7282. function quux () {
  7283. }
  7284. // Message: Rule `no-restricted-syntax` is missing a `context` option.
  7285. /**
  7286. * @param opt_a
  7287. * @param opt_b
  7288. */
  7289. function a () {}
  7290. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"FunctionDeclaration","message":"Only allowing names not matching `/^opt_/i`."}]}]
  7291. // Message: Only allowing names not matching `/^opt_/i`.
  7292. /**
  7293. * @param opt_a
  7294. * @param opt_b
  7295. */
  7296. function a () {}
  7297. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Only allowing names not matching `/^opt_/i`."}]}]
  7298. // Message: Only allowing names not matching `/^opt_/i`.
  7299. /**
  7300. * @param opt_a
  7301. * @param opt_b
  7302. */
  7303. function a () {}
  7304. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","message":"Only allowing names not matching `/^opt_/i`."}]}]
  7305. // Message: Only allowing names not matching `/^opt_/i`.
  7306. /**
  7307. * @param opt_a
  7308. * @param opt_b
  7309. */
  7310. function a () {}
  7311. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/not-this/])","context":"any","message":"Only allowing names not matching `/^not-this/i`."},{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Only allowing names not matching `/^opt_/i`."}]}]
  7312. // Message: Only allowing names not matching `/^opt_/i`.
  7313. /**
  7314. * @param opt_a
  7315. * @param opt_b
  7316. */
  7317. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Only allowing names not matching `/^opt_/i`."}]}]
  7318. // Message: Only allowing names not matching `/^opt_/i`.
  7319. ````
  7320. The following patterns are not considered problems:
  7321. ````js
  7322. /**
  7323. *
  7324. */
  7325. function quux () {
  7326. }
  7327. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":["FunctionExpression"]}]
  7328. /**
  7329. * @implements {Bar|Foo}
  7330. */
  7331. function quux () {
  7332. }
  7333. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration"}]}]
  7334. /**
  7335. * @param ab
  7336. * @param cd
  7337. */
  7338. function a () {}
  7339. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Only allowing names not matching `/^opt_/i`."}]}]
  7340. /**
  7341. * @param ab
  7342. * @param cd
  7343. */
  7344. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Only allowing names not matching `/^opt_/i`."}]}]
  7345. /**
  7346. * @param ab
  7347. * @param cd
  7348. */
  7349. // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","message":"Only allowing names not matching `/^opt_/i`."}]}]
  7350. ````
  7351. <a name="eslint-plugin-jsdoc-rules-no-types"></a>
  7352. ### <code>no-types</code>
  7353. This rule reports types being used on `@param` or `@returns`.
  7354. The rule is intended to prevent the indication of types on tags where
  7355. the type information would be redundant with TypeScript.
  7356. <a name="eslint-plugin-jsdoc-rules-no-types-options-20"></a>
  7357. #### Options
  7358. <a name="eslint-plugin-jsdoc-rules-no-types-options-20-contexts-5"></a>
  7359. ##### <code>contexts</code>
  7360. Set this to an array of strings representing the AST context (or an object with
  7361. `context` and `comment` properties) where you wish the rule to be applied.
  7362. Overrides the default contexts (see below). Set to `"any"` if you want
  7363. the rule to apply to any jsdoc block throughout your files (as is necessary
  7364. for finding function blocks not attached to a function declaration or
  7365. expression, i.e., `@callback` or `@function` (or its aliases `@func` or
  7366. `@method`) (including those associated with an `@interface`).
  7367. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  7368. section of our README for more on the expected format.
  7369. |||
  7370. |---|---|
  7371. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
  7372. |Tags|`param`, `returns`|
  7373. |Aliases|`arg`, `argument`, `return`|
  7374. |Recommended|false|
  7375. |Options|`contexts`|
  7376. The following patterns are considered problems:
  7377. ````js
  7378. /**
  7379. * @param {number} foo
  7380. */
  7381. function quux (foo) {
  7382. }
  7383. // Message: Types are not permitted on @param.
  7384. class quux {
  7385. /**
  7386. * @param {number} foo
  7387. */
  7388. bar (foo) {
  7389. }
  7390. }
  7391. // Message: Types are not permitted on @param.
  7392. /**
  7393. * @param {number} foo
  7394. */
  7395. function quux (foo) {
  7396. }
  7397. // "jsdoc/no-types": ["error"|"warn", {"contexts":["any"]}]
  7398. // Message: Types are not permitted on @param.
  7399. class quux {
  7400. /**
  7401. * @param {number} foo
  7402. */
  7403. quux (foo) {
  7404. }
  7405. }
  7406. // "jsdoc/no-types": ["error"|"warn", {"contexts":["any"]}]
  7407. // Message: Types are not permitted on @param.
  7408. /**
  7409. * @function
  7410. * @param {number} foo
  7411. */
  7412. // "jsdoc/no-types": ["error"|"warn", {"contexts":["any"]}]
  7413. // Message: Types are not permitted on @param.
  7414. /**
  7415. * @callback
  7416. * @param {number} foo
  7417. */
  7418. // "jsdoc/no-types": ["error"|"warn", {"contexts":["any"]}]
  7419. // Message: Types are not permitted on @param.
  7420. /**
  7421. * @returns {number}
  7422. */
  7423. function quux () {
  7424. }
  7425. // Message: Types are not permitted on @returns.
  7426. /**
  7427. * Beep
  7428. * Boop
  7429. *
  7430. * @returns {number}
  7431. */
  7432. function quux () {
  7433. }
  7434. // Message: Types are not permitted on @returns.
  7435. ````
  7436. The following patterns are not considered problems:
  7437. ````js
  7438. /**
  7439. * @param foo
  7440. */
  7441. function quux (foo) {
  7442. }
  7443. /**
  7444. * @param foo
  7445. */
  7446. // "jsdoc/no-types": ["error"|"warn", {"contexts":["any"]}]
  7447. /**
  7448. * @function
  7449. * @param {number} foo
  7450. */
  7451. /**
  7452. * @callback
  7453. * @param {number} foo
  7454. */
  7455. ````
  7456. <a name="eslint-plugin-jsdoc-rules-no-undefined-types"></a>
  7457. ### <code>no-undefined-types</code>
  7458. Checks that types in jsdoc comments are defined. This can be used to check
  7459. unimported types.
  7460. When enabling this rule, types in jsdoc comments will resolve as used
  7461. variables, i.e. will not be marked as unused by `no-unused-vars`.
  7462. In addition to considering globals found in code (or in ESLint-indicated
  7463. `globals`) as defined, the following tags will also be checked for
  7464. name(path) definitions to also serve as a potential "type" for checking
  7465. the tag types in the table below:
  7466. `@callback`, `@class` (or `@constructor`), `@constant` (or `@const`),
  7467. `@event`, `@external` (or `@host`), `@function` (or `@func` or `@method`),
  7468. `@interface`, `@member` (or `@var`), `@mixin`, `@name`, `@namespace`,
  7469. `@template` (for "closure" or "typescript" `settings.jsdoc.mode` only),
  7470. `@typedef`.
  7471. The following tags will also be checked but only when the mode is `closure`:
  7472. `@package`, `@private`, `@protected`, `@public`, `@static`
  7473. The following types are always considered defined.
  7474. - `null`, `undefined`, `void`, `string`, `boolean`, `object`,
  7475. `function`, `symbol`
  7476. - `number`, `bigint`, `NaN`, `Infinity`
  7477. - `any`, `*`
  7478. - `this`, `true`, `false`
  7479. - `Array`, `Object`, `RegExp`, `Date`, `Function`
  7480. Note that preferred types indicated within `settings.jsdoc.preferredTypes` will
  7481. also be assumed to be defined.
  7482. Also note that if there is an error [parsing](https://github.com/jsdoctypeparser/jsdoctypeparser)
  7483. types for a tag, the function will silently ignore that tag, leaving it to
  7484. the `valid-types` rule to report parsing errors.
  7485. If you define your own tags, you can use `settings.jsdoc.structuredTags`
  7486. to indicate that a tag's `name` is "namepath-defining" (and should prevent
  7487. reporting on use of that namepath elsewhere) and/or that a tag's `type` is
  7488. `false` (and should not be checked for types). If the `type` is an array, that
  7489. array's items will be considered as defined for the purposes of that tag.
  7490. <a name="eslint-plugin-jsdoc-rules-no-undefined-types-options-21"></a>
  7491. #### Options
  7492. An option object may have the following key:
  7493. - `definedTypes` - This array can be populated to indicate other types which
  7494. are automatically considered as defined (in addition to globals, etc.).
  7495. Defaults to an empty array.
  7496. |||
  7497. |---|---|
  7498. |Context|everywhere|
  7499. |Tags|`augments`, `class`, `constant`, `enum`, `implements`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`, `yields`|
  7500. |Aliases|`constructor`, `const`, `extends`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
  7501. |Closure-only|`package`, `private`, `protected`, `public`, `static`|
  7502. |Recommended|true|
  7503. |Options|`definedTypes`|
  7504. |Settings|`preferredTypes`, `mode`, `structuredTags`|
  7505. The following patterns are considered problems:
  7506. ````js
  7507. /**
  7508. * @param {HerType} baz - Foo.
  7509. */
  7510. function quux(foo, bar, baz) {
  7511. }
  7512. // Settings: {"jsdoc":{"preferredTypes":{"HerType":1000}}}
  7513. // Message: Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.
  7514. /**
  7515. * @param {HerType} baz - Foo.
  7516. */
  7517. function quux(foo, bar, baz) {
  7518. }
  7519. // Settings: {"jsdoc":{"preferredTypes":{"HerType":false}}}
  7520. // Message: The type 'HerType' is undefined.
  7521. /**
  7522. * @param {strnig} foo - Bar.
  7523. */
  7524. function quux(foo) {
  7525. }
  7526. // Message: The type 'strnig' is undefined.
  7527. /**
  7528. * @param {MyType} foo - Bar.
  7529. * @param {HisType} bar - Foo.
  7530. */
  7531. function quux(foo, bar) {
  7532. }
  7533. // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
  7534. // Message: The type 'HisType' is undefined.
  7535. /**
  7536. * @param {MyType} foo - Bar.
  7537. * @param {HisType} bar - Foo.
  7538. * @param {HerType} baz - Foo.
  7539. */
  7540. function quux(foo, bar, baz) {
  7541. }
  7542. // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"}}}}
  7543. // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
  7544. // Message: The type 'HisType' is undefined.
  7545. /**
  7546. * @param {MyType} foo - Bar.
  7547. * @param {HisType} bar - Foo.
  7548. * @param {HerType} baz - Foo.
  7549. */
  7550. function quux(foo, bar, baz) {
  7551. }
  7552. // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":false},"histype":"HisType"}}}
  7553. // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
  7554. // Message: The type 'HerType' is undefined.
  7555. /**
  7556. * @template TEMPLATE_TYPE
  7557. * @param {WRONG_TEMPLATE_TYPE} bar
  7558. */
  7559. function foo (bar) {
  7560. };
  7561. // Settings: {"jsdoc":{"mode":"closure"}}
  7562. // Message: The type 'WRONG_TEMPLATE_TYPE' is undefined.
  7563. class Foo {
  7564. /**
  7565. * @return {TEMPLATE_TYPE}
  7566. */
  7567. bar () {
  7568. }
  7569. }
  7570. // Message: The type 'TEMPLATE_TYPE' is undefined.
  7571. class Foo {
  7572. /**
  7573. * @return {TEMPLATE_TYPE}
  7574. */
  7575. invalidTemplateReference () {
  7576. }
  7577. }
  7578. /**
  7579. * @template TEMPLATE_TYPE
  7580. */
  7581. class Bar {
  7582. /**
  7583. * @return {TEMPLATE_TYPE}
  7584. */
  7585. validTemplateReference () {
  7586. }
  7587. }
  7588. // Settings: {"jsdoc":{"mode":"typescript"}}
  7589. // Message: The type 'TEMPLATE_TYPE' is undefined.
  7590. /**
  7591. * @type {strnig}
  7592. */
  7593. var quux = {
  7594. };
  7595. // Message: The type 'strnig' is undefined.
  7596. /**
  7597. * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
  7598. */
  7599. class Foo {
  7600. /**
  7601. * @param {TEMPLATE_TYPE_A} baz
  7602. * @return {TEMPLATE_TYPE_B}
  7603. */
  7604. bar (baz) {
  7605. }
  7606. }
  7607. // Message: The type 'TEMPLATE_TYPE_A' is undefined.
  7608. /**
  7609. * @param {...VAR_TYPE} varargs
  7610. */
  7611. function quux (varargs) {
  7612. }
  7613. // Message: The type 'VAR_TYPE' is undefined.
  7614. /**
  7615. * @this {Navigator}
  7616. */
  7617. function quux () {}
  7618. // Settings: {"jsdoc":{"mode":"closure"}}
  7619. // Message: The type 'Navigator' is undefined.
  7620. /**
  7621. * @export {SomeType}
  7622. */
  7623. function quux () {}
  7624. // Settings: {"jsdoc":{"mode":"closure"}}
  7625. // Message: The type 'SomeType' is undefined.
  7626. /**
  7627. * @aCustomTag {SomeType}
  7628. */
  7629. function quux () {}
  7630. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":true}}}}
  7631. // Message: The type 'SomeType' is undefined.
  7632. /**
  7633. * @aCustomTag {SomeType}
  7634. */
  7635. function quux () {}
  7636. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":["aType","anotherType"]}}}}
  7637. // Message: The type 'SomeType' is undefined.
  7638. /**
  7639. * @namepathDefiner SomeType
  7640. */
  7641. /**
  7642. * @type {SomeType}
  7643. */
  7644. // Settings: {"jsdoc":{"structuredTags":{"namepathDefiner":{"name":"namepath-referencing"}}}}
  7645. // Message: The type 'SomeType' is undefined.
  7646. /**
  7647. * @namepathDefiner SomeType
  7648. */
  7649. /**
  7650. * @type {SomeType}
  7651. */
  7652. // Message: The type 'SomeType' is undefined.
  7653. /**
  7654. * @template abc TEMPLATE_TYPE
  7655. * @param {TEMPLATE_TYPE} bar
  7656. */
  7657. function foo (bar) {
  7658. };
  7659. // Settings: {"jsdoc":{"mode":"closure"}}
  7660. // Message: The type 'TEMPLATE_TYPE' is undefined.
  7661. ````
  7662. The following patterns are not considered problems:
  7663. ````js
  7664. /**
  7665. * @param {string} foo - Bar.
  7666. */
  7667. function quux(foo) {
  7668. }
  7669. /**
  7670. * @param {Promise} foo - Bar.
  7671. */
  7672. function quux(foo) {
  7673. }
  7674. class MyClass {}
  7675. /**
  7676. * @param {MyClass} foo - Bar.
  7677. */
  7678. function quux(foo) {
  7679. console.log(foo);
  7680. }
  7681. quux(0);
  7682. const MyType = require('my-library').MyType;
  7683. /**
  7684. * @param {MyType} foo - Bar.
  7685. */
  7686. function quux(foo) {
  7687. }
  7688. const MyType = require('my-library').MyType;
  7689. /**
  7690. * @param {MyType} foo - Bar.
  7691. */
  7692. function quux(foo) {
  7693. }
  7694. const MyType = require('my-library').MyType;
  7695. /**
  7696. * @param {MyType} foo - Bar.
  7697. */
  7698. function quux(foo) {
  7699. }
  7700. import {MyType} from 'my-library';
  7701. /**
  7702. * @param {MyType} foo - Bar.
  7703. * @param {object<string, number>} foo
  7704. * @param {Array<string>} baz
  7705. */
  7706. function quux(foo, bar, baz) {
  7707. }
  7708. /*globals MyType*/
  7709. /**
  7710. * @param {MyType} foo - Bar.
  7711. * @param {HisType} bar - Foo.
  7712. */
  7713. function quux(foo, bar) {
  7714. }
  7715. /**
  7716. * @typedef {object} hello
  7717. * @property {string} a - a.
  7718. */
  7719. /**
  7720. * @param {hello} foo
  7721. */
  7722. function quux(foo) {
  7723. }
  7724. /**
  7725. * @param {Array<syntaxError} foo
  7726. */
  7727. function quux(foo) {
  7728. }
  7729. /**
  7730. * Callback test.
  7731. *
  7732. * @callback addStuffCallback
  7733. * @param {String} sum - An test integer.
  7734. */
  7735. /**
  7736. * Test Eslint.
  7737. *
  7738. * @param {addStuffCallback} callback - A callback to run.
  7739. */
  7740. function testFunction(callback) {
  7741. callback();
  7742. }
  7743. /**
  7744. *
  7745. *
  7746. */
  7747. function foo () {
  7748. }
  7749. /**
  7750. *
  7751. *
  7752. */
  7753. function foo () {
  7754. }
  7755. /**
  7756. * @param {MyType} foo - Bar.
  7757. * @param {HisType} bar - Foo.
  7758. */
  7759. function quux(foo, bar) {
  7760. }
  7761. // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType","HisType"]}]
  7762. /**
  7763. * @param {MyType} foo - Bar.
  7764. * @param {HisType} bar - Foo.
  7765. * @param {HerType} baz - Foo.
  7766. */
  7767. function quux(foo, bar, baz) {
  7768. }
  7769. // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"},"histype":"HisType"}}}
  7770. // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
  7771. /**
  7772. * @param {MyType} foo - Bar.
  7773. * @param {HisType} bar - Foo.
  7774. * @param {HerType} baz - Foo.
  7775. */
  7776. function quux(foo, bar, baz) {
  7777. }
  7778. // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType<>"},"histype":"HisType.<>"}}}
  7779. // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
  7780. /**
  7781. * @template TEMPLATE_TYPE
  7782. * @param {TEMPLATE_TYPE} bar
  7783. * @return {TEMPLATE_TYPE}
  7784. */
  7785. function foo (bar) {
  7786. };
  7787. // Settings: {"jsdoc":{"mode":"closure"}}
  7788. /**
  7789. * @template TEMPLATE_TYPE
  7790. */
  7791. class Foo {
  7792. /**
  7793. * @return {TEMPLATE_TYPE}
  7794. */
  7795. bar () {
  7796. }
  7797. }
  7798. // Settings: {"jsdoc":{"mode":"closure"}}
  7799. /**
  7800. * @template TEMPLATE_TYPE
  7801. */
  7802. class Foo {
  7803. /**
  7804. * @return {TEMPLATE_TYPE}
  7805. */
  7806. bar () {}
  7807. /**
  7808. * @return {TEMPLATE_TYPE}
  7809. */
  7810. baz () {}
  7811. }
  7812. // Settings: {"jsdoc":{"mode":"closure"}}
  7813. /**
  7814. * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
  7815. */
  7816. class Foo {
  7817. /**
  7818. * @param {TEMPLATE_TYPE_A} baz
  7819. * @return {TEMPLATE_TYPE_B}
  7820. */
  7821. bar (baz) {
  7822. }
  7823. }
  7824. // Settings: {"jsdoc":{"mode":"closure"}}
  7825. /**
  7826. * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B - Some description
  7827. */
  7828. class Foo {
  7829. /**
  7830. * @param {TEMPLATE_TYPE_A} baz
  7831. * @return {TEMPLATE_TYPE_B}
  7832. */
  7833. bar (baz) {
  7834. }
  7835. }
  7836. // Settings: {"jsdoc":{"mode":"closure"}}
  7837. /****/
  7838. /**
  7839. *
  7840. */
  7841. function quux () {
  7842. }
  7843. /**
  7844. * @typedef {object} BaseObject
  7845. */
  7846. /**
  7847. * Run callback when hooked method is called.
  7848. *
  7849. * @template {BaseObject} T
  7850. * @param {T} obj - object whose method should be hooked.
  7851. * @param {string} method - method which should be hooked.
  7852. * @param {(sender: T) => void} callback - callback which should
  7853. * be called when the hooked method was invoked.
  7854. */
  7855. function registerEvent(obj, method, callback) {
  7856. }
  7857. // Settings: {"jsdoc":{"mode":"typescript"}}
  7858. /**
  7859. * @param {...} varargs
  7860. */
  7861. function quux (varargs) {
  7862. }
  7863. /**
  7864. * @param {...number} varargs
  7865. */
  7866. function quux (varargs) {
  7867. }
  7868. class Navigator {}
  7869. /**
  7870. * @this {Navigator}
  7871. */
  7872. function quux () {}
  7873. // Settings: {"jsdoc":{"mode":"closure"}}
  7874. class SomeType {}
  7875. /**
  7876. * @export {SomeType}
  7877. */
  7878. function quux () {}
  7879. // Settings: {"jsdoc":{"mode":"closure"}}
  7880. /**
  7881. * @template T
  7882. * @param {T} arg
  7883. */
  7884. function example(arg) {
  7885. /** @param {T} */
  7886. function inner(x) {
  7887. }
  7888. }
  7889. // Settings: {"jsdoc":{"mode":"closure"}}
  7890. const init = () => {
  7891. /**
  7892. * Makes request
  7893. * @returns {Promise}
  7894. */
  7895. function request() {
  7896. return Promise.resolve('success');
  7897. }
  7898. };
  7899. /** Gets a Promise resolved with a given value.
  7900. *
  7901. * @template ValueType
  7902. * @param {ValueType} value Value to resolve.
  7903. * @returns {Promise<ValueType>} Promise resolved with value.
  7904. */
  7905. exports.resolve1 = function resolve1(value) {
  7906. return Promise.resolve(value);
  7907. };
  7908. // Settings: {"jsdoc":{"mode":"typescript"}}
  7909. /**
  7910. * A function returning the same type as its argument.
  7911. *
  7912. * @template ValueType
  7913. * @typedef {ValueType} ValueFunc
  7914. */
  7915. // Settings: {"jsdoc":{"mode":"typescript"}}
  7916. /**
  7917. * @aCustomTag {SomeType}
  7918. */
  7919. function quux () {}
  7920. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":false}}}}
  7921. /**
  7922. * @aCustomTag {SomeType}
  7923. */
  7924. function quux () {}
  7925. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":["aType","SomeType"]}}}}
  7926. /**
  7927. * @namepathDefiner SomeType
  7928. */
  7929. /**
  7930. * @type {SomeType}
  7931. */
  7932. // Settings: {"jsdoc":{"structuredTags":{"namepathDefiner":{"name":"namepath-defining"}}}}
  7933. class Test {
  7934. /**
  7935. * Method.
  7936. *
  7937. * @returns {this} Return description.
  7938. */
  7939. method (): this {
  7940. return this;
  7941. }
  7942. }
  7943. /**
  7944. * Bad types ignored here and handled instead by `valid-types`.
  7945. * @param {string(} foo - Bar.
  7946. */
  7947. function quux(foo) {
  7948. }
  7949. ````
  7950. <a name="eslint-plugin-jsdoc-rules-require-asterisk-prefix"></a>
  7951. ### <code>require-asterisk-prefix</code>
  7952. Requires that each JSDoc line starts with an `*`.
  7953. <a name="eslint-plugin-jsdoc-rules-require-asterisk-prefix-options-22"></a>
  7954. #### Options
  7955. This rule allows an optional string argument. If it is `"always"` then a
  7956. problem is raised when there is no asterisk prefix on a given jsdoc line. If
  7957. it is `"never"` then a problem is raised when there is an asterisk present.
  7958. The default value is `"always"`. You may also set the default to `"any"`
  7959. and use the `tags` option to apply to specific tags only.
  7960. After the string option, one may add an object with the following.
  7961. <a name="eslint-plugin-jsdoc-rules-require-asterisk-prefix-options-22-tags-3"></a>
  7962. ##### <code>tags</code>
  7963. If you want different values to apply to specific tags, you may use
  7964. the `tags` option object. The keys are `always`, `never`, or `any` and
  7965. the values are arrays of tag names or the special value `*description`
  7966. which applies to the main jsdoc block description.
  7967. ```js
  7968. {
  7969. 'jsdoc/require-asterisk-prefix': ['error', 'always', {
  7970. tags: {
  7971. always: ['*description'],
  7972. any: ['example', 'license'],
  7973. never: ['copyright']
  7974. }
  7975. }]
  7976. }
  7977. ```
  7978. |||
  7979. |---|---|
  7980. |Context|everywhere|
  7981. |Tags|All or as limited by the `tags` option|
  7982. |Options|(a string matching `"always"|"never"` and optional object with `tags`)|
  7983. The following patterns are considered problems:
  7984. ````js
  7985. /**
  7986. @param {Number} foo
  7987. */
  7988. function quux (foo) {
  7989. // with spaces
  7990. }
  7991. // Message: Expected JSDoc line to have the prefix.
  7992. /**
  7993. @param {Number} foo
  7994. */
  7995. function quux (foo) {
  7996. // with spaces
  7997. }
  7998. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "any",{"tags":{"always":["param"]}}]
  7999. // Message: Expected JSDoc line to have the prefix.
  8000. /**
  8001. * Desc
  8002. */
  8003. function quux (foo) {
  8004. // with spaces
  8005. }
  8006. // Message: Expected JSDoc line to have the prefix.
  8007. /**
  8008. *
  8009. Desc
  8010. */
  8011. function quux (foo) {
  8012. // with spaces
  8013. }
  8014. // Message: Expected JSDoc line to have the prefix.
  8015. /**
  8016. * Desc
  8017. *
  8018. */
  8019. function quux (foo) {
  8020. // with spaces
  8021. }
  8022. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "never"]
  8023. // Message: Expected JSDoc line to have no prefix.
  8024. /**
  8025. @param {Number} foo
  8026. */
  8027. function quux (foo) {
  8028. // with spaces
  8029. }
  8030. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "always",{"tags":{"any":["someOtherTag"]}}]
  8031. // Message: Expected JSDoc line to have the prefix.
  8032. /**
  8033. * @param {Number} foo
  8034. */
  8035. function quux (foo) {
  8036. // with spaces
  8037. }
  8038. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "never",{"tags":{"always":["someOtherTag"]}}]
  8039. // Message: Expected JSDoc line to have no prefix.
  8040. /**
  8041. * @param {Number} foo
  8042. */
  8043. function quux (foo) {
  8044. // with spaces
  8045. }
  8046. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "always",{"tags":{"never":["param"]}}]
  8047. // Message: Expected JSDoc line to have no prefix.
  8048. /**
  8049. @param {Number} foo
  8050. */
  8051. function quux (foo) {
  8052. // with spaces
  8053. }
  8054. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "never",{"tags":{"always":["param"]}}]
  8055. // Message: Expected JSDoc line to have the prefix.
  8056. /**
  8057. @param {Number} foo
  8058. */function quux (foo) {
  8059. // with spaces
  8060. }
  8061. // Message: Expected JSDoc line to have the prefix.
  8062. /**
  8063. * @param {Number} foo
  8064. */
  8065. function quux (foo) {
  8066. // with spaces
  8067. }
  8068. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "never"]
  8069. // Message: Expected JSDoc line to have no prefix.
  8070. /**
  8071. *@param {Number} foo
  8072. */function quux (foo) {
  8073. // with spaces
  8074. }
  8075. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "never"]
  8076. // Message: Expected JSDoc line to have no prefix.
  8077. ````
  8078. The following patterns are not considered problems:
  8079. ````js
  8080. /**
  8081. * Desc
  8082. *
  8083. * @param {Number} foo
  8084. * This is more comment.
  8085. */
  8086. function quux (foo) {
  8087. }
  8088. /**
  8089. * Desc
  8090. *
  8091. * @param {{
  8092. * foo: Bar,
  8093. * bar: Baz
  8094. * }} foo
  8095. *
  8096. */
  8097. function quux (foo) {
  8098. }
  8099. /* <- JSDoc must start with 2 stars.
  8100. So this is unchecked.
  8101. */
  8102. function quux (foo) {}
  8103. /** @param {Number} foo */
  8104. function quux (foo) {
  8105. // with spaces
  8106. }
  8107. /**
  8108. @param {Number} foo
  8109. */
  8110. function quux (foo) {
  8111. // with spaces
  8112. }
  8113. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "always",{"tags":{"any":["param"]}}]
  8114. /**
  8115. * @param {Number} foo
  8116. */
  8117. function quux (foo) {
  8118. // with spaces
  8119. }
  8120. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "never",{"tags":{"always":["param"]}}]
  8121. /**
  8122. * @param {Number} foo
  8123. */
  8124. function quux (foo) {
  8125. // with spaces
  8126. }
  8127. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "always",{"tags":{"never":["someOtherTag"]}}]
  8128. /**
  8129. @param {Number} foo
  8130. */
  8131. function quux (foo) {
  8132. // with spaces
  8133. }
  8134. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "always",{"tags":{"never":["param"]}}]
  8135. /**
  8136. @param {Number} foo
  8137. */
  8138. function quux (foo) {
  8139. // with spaces
  8140. }
  8141. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "never",{"tags":{"always":["someOtherTag"]}}]
  8142. /**
  8143. * Desc
  8144. *
  8145. */
  8146. function quux (foo) {
  8147. // with spaces
  8148. }
  8149. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "never",{"tags":{"any":["*description"]}}]
  8150. /**
  8151. * Desc
  8152. */
  8153. function quux (foo) {
  8154. // with spaces
  8155. }
  8156. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "always",{"tags":{"any":["*description"]}}]
  8157. /**
  8158. @param {Number} foo
  8159. */
  8160. function quux (foo) {
  8161. // with spaces
  8162. }
  8163. // "jsdoc/require-asterisk-prefix": ["error"|"warn", "any",{"tags":{"always":["someOtherTag"]}}]
  8164. ````
  8165. <a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence"></a>
  8166. ### <code>require-description-complete-sentence</code>
  8167. Requires that block description, explicit `@description`, and
  8168. `@param`/`@returns` tag descriptions are written in complete sentences, i.e.,
  8169. * Description must start with an uppercase alphabetical character.
  8170. * Paragraphs must start with an uppercase alphabetical character.
  8171. * Sentences must end with a period.
  8172. * Every line in a paragraph (except the first) which starts with an uppercase
  8173. character must be preceded by a line ending with a period.
  8174. * A colon or semi-colon followed by two line breaks is still part of the
  8175. containing paragraph (unlike normal dual line breaks).
  8176. * Text within inline tags `{...}` are not checked for sentence divisions.
  8177. * Periods after items within the `abbreviations` option array are not treated
  8178. as sentence endings.
  8179. <a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-23"></a>
  8180. #### Options
  8181. <a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-23-tags-4"></a>
  8182. ##### <code>tags</code>
  8183. If you want additional tags to be checked for their descriptions, you may
  8184. add them within this option.
  8185. ```js
  8186. {
  8187. 'jsdoc/require-description-complete-sentence': ['error', {
  8188. tags: ['see', 'copyright']
  8189. }]
  8190. }
  8191. ```
  8192. The tags `@param`/`@arg`/`@argument` and `@property`/`@prop` will be properly
  8193. parsed to ensure that the checked "description" text includes only the text
  8194. after the name.
  8195. All other tags will treat the text following the tag name, a space, and
  8196. an optional curly-bracketed type expression (and another space) as part of
  8197. its "description" (e.g., for `@returns {someType} some description`, the
  8198. description is `some description` while for `@some-tag xyz`, the description
  8199. is `xyz`).
  8200. <a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-23-abbreviations"></a>
  8201. ##### <code>abbreviations</code>
  8202. You can provide an `abbreviations` options array to avoid such strings of text
  8203. being treated as sentence endings when followed by dots. The `.` is not
  8204. necessary at the end of the array items.
  8205. <a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-23-newlinebeforecapsassumesbadsentenceend"></a>
  8206. ##### <code>newlineBeforeCapsAssumesBadSentenceEnd</code>
  8207. When `false` (the new default), we will not assume capital letters after
  8208. newlines are an incorrect way to end the sentence (they may be proper
  8209. nouns, for example).
  8210. |||
  8211. |---|---|
  8212. |Context|everywhere|
  8213. |Tags|doc block, `param`, `returns`, `description`, `property`, `summary`, `file`, `classdesc`, `todo`, `deprecated`, `throws`, 'yields' and others added by `tags`|
  8214. |Aliases|`arg`, `argument`, `return`, `desc`, `prop`, `fileoverview`, `overview`, `exception`, `yield`|
  8215. |Recommended|false|
  8216. |Options|`tags`, `abbreviations`, `newlineBeforeCapsAssumesBadSentenceEnd`|
  8217. The following patterns are considered problems:
  8218. ````js
  8219. /**
  8220. * foo.
  8221. */
  8222. function quux () {
  8223. }
  8224. // Message: Sentence should start with an uppercase character.
  8225. /**
  8226. * foo?
  8227. */
  8228. function quux () {
  8229. }
  8230. // Message: Sentence should start with an uppercase character.
  8231. /**
  8232. * @description foo.
  8233. */
  8234. function quux () {
  8235. }
  8236. // Message: Sentence should start with an uppercase character.
  8237. /**
  8238. * Foo)
  8239. */
  8240. function quux () {
  8241. }
  8242. // Message: Sentence must end with a period.
  8243. /**
  8244. * `foo` is a variable
  8245. */
  8246. function quux () {
  8247. }
  8248. // Message: Sentence must end with a period.
  8249. /**
  8250. * Foo.
  8251. *
  8252. * foo.
  8253. */
  8254. function quux () {
  8255. }
  8256. // Message: Sentence should start with an uppercase character.
  8257. /**
  8258. * тест.
  8259. */
  8260. function quux () {
  8261. }
  8262. // Message: Sentence should start with an uppercase character.
  8263. /**
  8264. * Foo
  8265. */
  8266. function quux () {
  8267. }
  8268. // Message: Sentence must end with a period.
  8269. /**
  8270. * Foo
  8271. * Bar.
  8272. */
  8273. function quux () {
  8274. }
  8275. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"newlineBeforeCapsAssumesBadSentenceEnd":true}]
  8276. // Message: A line of text is started with an uppercase character, but preceding line does not end the sentence.
  8277. /**
  8278. * Foo.
  8279. *
  8280. * @param foo foo.
  8281. */
  8282. function quux (foo) {
  8283. }
  8284. // Message: Sentence should start with an uppercase character.
  8285. /**
  8286. * Foo.
  8287. *
  8288. * @param foo bar
  8289. */
  8290. function quux (foo) {
  8291. }
  8292. // Message: Sentence should start with an uppercase character.
  8293. /**
  8294. * {@see Foo.bar} buz
  8295. */
  8296. function quux (foo) {
  8297. }
  8298. // Message: Sentence should start with an uppercase character.
  8299. /**
  8300. * Foo.
  8301. *
  8302. * @returns {number} foo
  8303. */
  8304. function quux (foo) {
  8305. }
  8306. // Message: Sentence should start with an uppercase character.
  8307. /**
  8308. * Foo.
  8309. *
  8310. * @returns foo.
  8311. */
  8312. function quux (foo) {
  8313. }
  8314. // Message: Sentence should start with an uppercase character.
  8315. /**
  8316. * lorem ipsum dolor sit amet, consectetur adipiscing elit. pellentesque elit diam,
  8317. * iaculis eu dignissim sed, ultrices sed nisi. nulla at ligula auctor, consectetur neque sed,
  8318. * tincidunt nibh. vivamus sit amet vulputate ligula. vivamus interdum elementum nisl,
  8319. * vitae rutrum tortor semper ut. morbi porta ante vitae dictum fermentum.
  8320. * proin ut nulla at quam convallis gravida in id elit. sed dolor mauris, blandit quis ante at,
  8321. * consequat auctor magna. duis pharetra purus in porttitor mollis.
  8322. */
  8323. function longDescription (foo) {
  8324. }
  8325. // Message: Sentence should start with an uppercase character.
  8326. /**
  8327. * @arg {number} foo - Foo
  8328. */
  8329. function quux (foo) {
  8330. }
  8331. // Message: Sentence must end with a period.
  8332. /**
  8333. * @argument {number} foo - Foo
  8334. */
  8335. function quux (foo) {
  8336. }
  8337. // Message: Sentence must end with a period.
  8338. /**
  8339. * @return {number} foo
  8340. */
  8341. function quux (foo) {
  8342. }
  8343. // Message: Sentence should start with an uppercase character.
  8344. /**
  8345. * Returns bar.
  8346. *
  8347. * @return {number} bar
  8348. */
  8349. function quux (foo) {
  8350. }
  8351. // Message: Sentence should start with an uppercase character.
  8352. /**
  8353. * @throws {object} Hello World
  8354. * hello world
  8355. */
  8356. // Message: Sentence must end with a period.
  8357. /**
  8358. * @summary Foo
  8359. */
  8360. function quux () {
  8361. }
  8362. // Message: Sentence must end with a period.
  8363. /**
  8364. * @throws {SomeType} Foo
  8365. */
  8366. function quux () {
  8367. }
  8368. // Message: Sentence must end with a period.
  8369. /**
  8370. * @see Foo
  8371. */
  8372. function quux () {
  8373. }
  8374. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["see"]}]
  8375. // Message: Sentence must end with a period.
  8376. /**
  8377. * @param foo Foo bar
  8378. */
  8379. function quux (foo) {
  8380. }
  8381. // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
  8382. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["param"]}]
  8383. // Message: Sentence must end with a period.
  8384. /**
  8385. * Sorry, but this isn't a complete sentence, Mr.
  8386. */
  8387. function quux () {
  8388. }
  8389. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
  8390. // Message: Sentence must end with a period.
  8391. /**
  8392. * Sorry, but this isn't a complete sentence Mr.
  8393. */
  8394. function quux () {
  8395. }
  8396. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr."]}]
  8397. // Message: Sentence must end with a period.
  8398. /**
  8399. * Sorry, but this isn't a complete sentence Mr.
  8400. */
  8401. function quux () {
  8402. }
  8403. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
  8404. // Message: Sentence must end with a period.
  8405. /**
  8406. * Sorry, but this isn't a complete sentence Mr. and Mrs.
  8407. */
  8408. function quux () {
  8409. }
  8410. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr","Mrs"]}]
  8411. // Message: Sentence must end with a period.
  8412. /**
  8413. * This is a complete sentence. But this isn't, Mr.
  8414. */
  8415. function quux () {
  8416. }
  8417. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
  8418. // Message: Sentence must end with a period.
  8419. /**
  8420. * This is a complete Mr. sentence. But this isn't, Mr.
  8421. */
  8422. function quux () {
  8423. }
  8424. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
  8425. // Message: Sentence must end with a period.
  8426. /**
  8427. * This is a complete Mr. sentence.
  8428. */
  8429. function quux () {
  8430. }
  8431. // Message: Sentence should start with an uppercase character.
  8432. /**
  8433. * This is fun, i.e. enjoyable, but not superlatively so, e.g. not
  8434. * super, wonderful, etc..
  8435. */
  8436. function quux () {
  8437. }
  8438. // Message: Sentence should start with an uppercase character.
  8439. /**
  8440. * Do not have dynamic content; e.g. homepage. Here a simple unique id
  8441. * suffices.
  8442. */
  8443. function quux () {
  8444. }
  8445. // Message: Sentence should start with an uppercase character.
  8446. /**
  8447. * Implements support for the
  8448. * Swahili voice synthesizer.
  8449. */
  8450. function speak() {
  8451. }
  8452. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"newlineBeforeCapsAssumesBadSentenceEnd":true}]
  8453. // Message: A line of text is started with an uppercase character, but preceding line does not end the sentence.
  8454. /**
  8455. * Foo.
  8456. *
  8457. * @template TempA, TempB foo.
  8458. */
  8459. function quux (foo) {
  8460. }
  8461. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["template"]}]
  8462. // Message: Sentence should start with an uppercase character.
  8463. ````
  8464. The following patterns are not considered problems:
  8465. ````js
  8466. /**
  8467. * @param foo - Foo.
  8468. */
  8469. function quux () {
  8470. }
  8471. /**
  8472. * Foo.
  8473. */
  8474. function quux () {
  8475. }
  8476. /**
  8477. * Foo.
  8478. * Bar.
  8479. */
  8480. function quux () {
  8481. }
  8482. /**
  8483. * Foo.
  8484. *
  8485. * Bar.
  8486. */
  8487. function quux () {
  8488. }
  8489. /**
  8490. * Тест.
  8491. */
  8492. function quux () {
  8493. }
  8494. /**
  8495. * Foo
  8496. * bar.
  8497. */
  8498. function quux () {
  8499. }
  8500. /**
  8501. * @returns Foo bar.
  8502. */
  8503. function quux () {
  8504. }
  8505. /**
  8506. * Foo. {@see Math.sin}.
  8507. */
  8508. function quux () {
  8509. }
  8510. /**
  8511. * Foo {@see Math.sin} bar.
  8512. */
  8513. function quux () {
  8514. }
  8515. /**
  8516. * Foo?
  8517. *
  8518. * Bar!
  8519. *
  8520. * Baz:
  8521. * 1. Foo.
  8522. * 2. Bar.
  8523. */
  8524. function quux () {
  8525. }
  8526. /**
  8527. * Hello:
  8528. * World.
  8529. */
  8530. function quux () {
  8531. }
  8532. /**
  8533. * Hello: world.
  8534. */
  8535. function quux () {
  8536. }
  8537. /**
  8538. *
  8539. */
  8540. function quux () {
  8541. }
  8542. /**
  8543. * @description Foo.
  8544. */
  8545. function quux () {
  8546. }
  8547. /**
  8548. * `foo` is a variable.
  8549. */
  8550. function quux () {
  8551. }
  8552. /**
  8553. * Foo.
  8554. *
  8555. * `foo`.
  8556. */
  8557. function quux () {
  8558. }
  8559. /**
  8560. * @param foo - `bar`.
  8561. */
  8562. function quux () {
  8563. }
  8564. /**
  8565. * @returns {number} `foo`.
  8566. */
  8567. function quux () {
  8568. }
  8569. /**
  8570. * Foo
  8571. * `bar`.
  8572. */
  8573. function quux () {
  8574. }
  8575. /**
  8576. * @example Foo
  8577. */
  8578. function quux () {
  8579. }
  8580. /**
  8581. * @see Foo
  8582. */
  8583. function quux () {
  8584. }
  8585. /**
  8586. * Foo.
  8587. *
  8588. * @param foo Foo.
  8589. */
  8590. function quux (foo) {
  8591. }
  8592. /**
  8593. * Foo.
  8594. *
  8595. * @param foo Foo.
  8596. */
  8597. function quux (foo) {
  8598. }
  8599. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["param"]}]
  8600. /**
  8601. * @param foo Foo bar.
  8602. */
  8603. function quux (foo) {
  8604. }
  8605. // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
  8606. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["param"]}]
  8607. /**
  8608. *
  8609. */
  8610. function quux (foo) {
  8611. }
  8612. // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
  8613. /**
  8614. * We stop loading Items when we have loaded:
  8615. *
  8616. * 1) The main Item;
  8617. * 2) All its variants.
  8618. */
  8619. /**
  8620. * This method is working on 2 steps.
  8621. *
  8622. * | Step | Comment |
  8623. * |------|-------------|
  8624. * | 1 | do it |
  8625. * | 2 | do it again |
  8626. */
  8627. /**
  8628. * This is something that
  8629. * I want to test.
  8630. */
  8631. function quux () {
  8632. }
  8633. /**
  8634. * When making HTTP requests, the
  8635. * URL is super important.
  8636. */
  8637. function quux () {
  8638. }
  8639. /**
  8640. * Sorry, but this isn't a complete sentence, Mr.
  8641. */
  8642. function quux () {
  8643. }
  8644. /**
  8645. * Sorry, but this isn't a complete sentence Mr..
  8646. */
  8647. function quux () {
  8648. }
  8649. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr."]}]
  8650. /**
  8651. * Sorry, but this isn't a complete sentence Mr.
  8652. */
  8653. function quux () {
  8654. }
  8655. /**
  8656. * Sorry, but this isn't a complete sentence Mr. and Mrs..
  8657. */
  8658. function quux () {
  8659. }
  8660. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr","Mrs"]}]
  8661. /**
  8662. * This is a complete sentence aMr.
  8663. */
  8664. function quux () {
  8665. }
  8666. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
  8667. /**
  8668. * This is a complete sentence. But this isn't, Mr.
  8669. */
  8670. function quux () {
  8671. }
  8672. /**
  8673. * This is a complete Mr. Sentence. But this isn't, Mr.
  8674. */
  8675. function quux () {
  8676. }
  8677. /**
  8678. * This is a complete Mr. sentence.
  8679. */
  8680. function quux () {
  8681. }
  8682. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
  8683. /**
  8684. * This is fun, i.e. enjoyable, but not superlatively so, e.g. not
  8685. * super, wonderful, etc..
  8686. */
  8687. function quux () {
  8688. }
  8689. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["etc","e.g.","i.e."]}]
  8690. **
  8691. * Do not have dynamic content; e.g. homepage. Here a simple unique id
  8692. * suffices.
  8693. */
  8694. function quux () {
  8695. }
  8696. // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["etc","e.g.","i.e."]}]
  8697. /**
  8698. * Implements support for the
  8699. * Swahili voice synthesizer.
  8700. */
  8701. function speak() {
  8702. }
  8703. /**
  8704. * @param foo
  8705. *
  8706. * @returns {void}
  8707. */
  8708. export default (foo) => {
  8709. foo()
  8710. }
  8711. ````
  8712. <a name="eslint-plugin-jsdoc-rules-require-description"></a>
  8713. ### <code>require-description</code>
  8714. Requires that all functions have a description.
  8715. * All functions must have an implicit description (e.g., text above tags) or
  8716. have the option `descriptionStyle` set to `tag` (requiring `@description`
  8717. (or `@desc` if that is set as your preferred tag name)).
  8718. * Every jsdoc block description (or `@description` tag if `descriptionStyle`
  8719. is `"tag"`) must have a non-empty description that explains the purpose of
  8720. the method.
  8721. <a name="eslint-plugin-jsdoc-rules-require-description-options-24"></a>
  8722. #### Options
  8723. An options object may have any of the following properties:
  8724. - `contexts` - Set to an array of strings representing the AST context
  8725. where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6
  8726. classes). Overrides the default contexts (see below). Set to `"any"` if
  8727. you want the rule to apply to any jsdoc block throughout your files.
  8728. - `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the
  8729. document block avoids the need for a `@description`. Defaults to an
  8730. array with `inheritdoc`. If you set this array, it will overwrite the
  8731. default, so be sure to add back `inheritdoc` if you wish its presence
  8732. to cause exemption of the rule.
  8733. - `descriptionStyle` - Whether to accept implicit descriptions (`"body"`) or
  8734. `@description` tags (`"tag"`) as satisfying the rule. Set to `"any"` to
  8735. accept either style. Defaults to `"body"`.
  8736. - `checkConstructors` - A value indicating whether `constructor`s should be
  8737. checked. Defaults to `true`.
  8738. - `checkGetters` - A value indicating whether getters should be checked.
  8739. Defaults to `true`.
  8740. - `checkSetters` - A value indicating whether setters should be checked.
  8741. Defaults to `true`.
  8742. | | |
  8743. | -------- | ------------------------------------------------------------------------------------------------------------- |
  8744. | Context | `ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled |
  8745. | Tags | `description` or jsdoc block |
  8746. | Aliases | `desc` |
  8747. | Recommended | false |
  8748. | Options | `contexts`, `exemptedBy`, `descriptionStyle`, `checkConstructors`, `checkGetters`, `checkSetters` |
  8749. | Settings | `ignoreReplacesDocs`, `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` |
  8750. The following patterns are considered problems:
  8751. ````js
  8752. /**
  8753. *
  8754. */
  8755. function quux () {
  8756. }
  8757. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  8758. // Message: Missing JSDoc @description declaration.
  8759. /**
  8760. *
  8761. */
  8762. function quux () {
  8763. }
  8764. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"any"}]
  8765. // Message: Missing JSDoc block description or @description declaration.
  8766. /**
  8767. *
  8768. */
  8769. function quux () {
  8770. }
  8771. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"body"}]
  8772. // Message: Missing JSDoc block description.
  8773. /**
  8774. * @desc Not a blank description
  8775. */
  8776. function quux () {
  8777. }
  8778. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"body"}]
  8779. // Message: Remove the @desc tag to leave a plain block description or add additional description text above the @desc line.
  8780. /**
  8781. * @description Not a blank description
  8782. */
  8783. function quux () {
  8784. }
  8785. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"body"}]
  8786. // Message: Remove the @description tag to leave a plain block description or add additional description text above the @description line.
  8787. /**
  8788. *
  8789. */
  8790. class quux {
  8791. }
  8792. // "jsdoc/require-description": ["error"|"warn", {"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
  8793. // Message: Missing JSDoc @description declaration.
  8794. /**
  8795. *
  8796. */
  8797. // "jsdoc/require-description": ["error"|"warn", {"contexts":["any"],"descriptionStyle":"tag"}]
  8798. // Message: Missing JSDoc @description declaration.
  8799. /**
  8800. *
  8801. */
  8802. class quux {
  8803. }
  8804. // "jsdoc/require-description": ["error"|"warn", {"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
  8805. // Message: Missing JSDoc @description declaration.
  8806. /**
  8807. *
  8808. */
  8809. class quux {
  8810. }
  8811. // "jsdoc/require-description": ["error"|"warn", {"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
  8812. // Message: Missing JSDoc @description declaration.
  8813. /**
  8814. * @description
  8815. */
  8816. function quux () {
  8817. }
  8818. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  8819. // Message: Missing JSDoc @description description.
  8820. /**
  8821. *
  8822. */
  8823. interface quux {
  8824. }
  8825. // "jsdoc/require-description": ["error"|"warn", {"contexts":["TSInterfaceDeclaration"],"descriptionStyle":"tag"}]
  8826. // Message: Missing JSDoc @description declaration.
  8827. /**
  8828. *
  8829. */
  8830. var quux = class {
  8831. };
  8832. // "jsdoc/require-description": ["error"|"warn", {"contexts":["ClassExpression"],"descriptionStyle":"tag"}]
  8833. // Message: Missing JSDoc @description declaration.
  8834. /**
  8835. *
  8836. */
  8837. var quux = {
  8838. };
  8839. // "jsdoc/require-description": ["error"|"warn", {"contexts":["ObjectExpression"],"descriptionStyle":"tag"}]
  8840. // Message: Missing JSDoc @description declaration.
  8841. /**
  8842. * @someDesc
  8843. */
  8844. function quux () {
  8845. }
  8846. // Settings: {"jsdoc":{"tagNamePreference":{"description":{"message":"Please avoid `{{tagName}}`; use `{{replacement}}` instead","replacement":"someDesc"}}}}
  8847. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  8848. // Message: Missing JSDoc @someDesc description.
  8849. /**
  8850. * @description
  8851. */
  8852. function quux () {
  8853. }
  8854. // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
  8855. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  8856. // Message: Unexpected tag `@description`
  8857. /**
  8858. * @description
  8859. */
  8860. function quux () {
  8861. }
  8862. // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
  8863. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"any"}]
  8864. // Message: Missing JSDoc block description or @description declaration.
  8865. /**
  8866. *
  8867. */
  8868. function quux () {
  8869. }
  8870. // "jsdoc/require-description": ["error"|"warn", {"exemptedBy":["notPresent"]}]
  8871. // Message: Missing JSDoc block description.
  8872. class TestClass {
  8873. /**
  8874. *
  8875. */
  8876. constructor() { }
  8877. }
  8878. // Message: Missing JSDoc block description.
  8879. class TestClass {
  8880. /**
  8881. *
  8882. */
  8883. constructor() { }
  8884. }
  8885. // "jsdoc/require-description": ["error"|"warn", {"checkConstructors":true}]
  8886. // Message: Missing JSDoc block description.
  8887. class TestClass {
  8888. /**
  8889. *
  8890. */
  8891. get Test() { }
  8892. }
  8893. // Message: Missing JSDoc block description.
  8894. class TestClass {
  8895. /**
  8896. *
  8897. */
  8898. get Test() { }
  8899. }
  8900. // "jsdoc/require-description": ["error"|"warn", {"checkGetters":true}]
  8901. // Message: Missing JSDoc block description.
  8902. class TestClass {
  8903. /**
  8904. *
  8905. */
  8906. set Test(value) { }
  8907. }
  8908. // Message: Missing JSDoc block description.
  8909. class TestClass {
  8910. /**
  8911. *
  8912. */
  8913. set Test(value) { }
  8914. }
  8915. // "jsdoc/require-description": ["error"|"warn", {"checkSetters":true}]
  8916. // Message: Missing JSDoc block description.
  8917. /**
  8918. *
  8919. */
  8920. class Foo {
  8921. /**
  8922. *
  8923. */
  8924. constructor() {}
  8925. /**
  8926. *
  8927. */
  8928. bar() {}
  8929. }
  8930. // "jsdoc/require-description": ["error"|"warn", {"checkConstructors":false,"contexts":["MethodDefinition"]}]
  8931. // Message: Missing JSDoc block description.
  8932. /**
  8933. * @implements {Bar}
  8934. */
  8935. class quux {
  8936. }
  8937. // Settings: {"jsdoc":{"implementsReplacesDocs":false}}
  8938. // "jsdoc/require-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[rawType=\"Bar\"])","context":"ClassDeclaration"}],"descriptionStyle":"tag"}]
  8939. // Message: Missing JSDoc @description declaration.
  8940. /**
  8941. * Has some
  8942. * description already.
  8943. * @implements {Bar}
  8944. */
  8945. class quux {
  8946. }
  8947. // Settings: {"jsdoc":{"implementsReplacesDocs":false}}
  8948. // "jsdoc/require-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[rawType=\"Bar\"])","context":"ClassDeclaration"}],"descriptionStyle":"tag"}]
  8949. // Message: Missing JSDoc @description declaration.
  8950. /**
  8951. * @implements {Bar
  8952. * | Foo}
  8953. */
  8954. class quux {
  8955. }
  8956. // Settings: {"jsdoc":{"implementsReplacesDocs":false}}
  8957. // "jsdoc/require-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"ClassDeclaration"}],"descriptionStyle":"tag"}]
  8958. // Message: Missing JSDoc @description declaration.
  8959. /**
  8960. * @implements {Bar}
  8961. */
  8962. class quux {
  8963. }
  8964. // Settings: {"jsdoc":{"implementsReplacesDocs":false}}
  8965. // "jsdoc/require-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[tag=\"implements\"])","context":"ClassDeclaration"}],"descriptionStyle":"tag"}]
  8966. // Message: Missing JSDoc @description declaration.
  8967. /**
  8968. * @implements {Bar}
  8969. */
  8970. class quux {
  8971. }
  8972. // Settings: {"jsdoc":{"implementsReplacesDocs":false}}
  8973. // "jsdoc/require-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[tag=\"implements\"])","context":"any"}],"descriptionStyle":"tag"}]
  8974. // Message: Missing JSDoc @description declaration.
  8975. ````
  8976. The following patterns are not considered problems:
  8977. ````js
  8978. /**
  8979. *
  8980. */
  8981. /**
  8982. * @description
  8983. * // arbitrary description content
  8984. */
  8985. function quux () {
  8986. }
  8987. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  8988. /**
  8989. * @description
  8990. * quux(); // does something useful
  8991. */
  8992. function quux () {
  8993. }
  8994. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  8995. /**
  8996. * @description <caption>Valid usage</caption>
  8997. * quux(); // does something useful
  8998. *
  8999. * @description <caption>Invalid usage</caption>
  9000. * quux('random unwanted arg'); // results in an error
  9001. */
  9002. function quux () {
  9003. }
  9004. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  9005. /**
  9006. *
  9007. */
  9008. class quux {
  9009. }
  9010. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  9011. /**
  9012. *
  9013. */
  9014. function quux () {
  9015. }
  9016. // "jsdoc/require-description": ["error"|"warn", {"contexts":["ClassDeclaration"]}]
  9017. /**
  9018. * @type {MyCallback}
  9019. */
  9020. function quux () {
  9021. }
  9022. // "jsdoc/require-description": ["error"|"warn", {"exemptedBy":["type"]}]
  9023. /**
  9024. *
  9025. */
  9026. interface quux {
  9027. }
  9028. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  9029. interface quux {
  9030. /**
  9031. * If the thing should be checked.
  9032. */
  9033. checked?: boolean
  9034. }
  9035. // "jsdoc/require-description": ["error"|"warn", {"contexts":["TSPropertySignature"]}]
  9036. /**
  9037. *
  9038. */
  9039. var quux = class {
  9040. };
  9041. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  9042. /**
  9043. *
  9044. */
  9045. var quux = {
  9046. };
  9047. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  9048. /**
  9049. * Has an implicit description
  9050. */
  9051. function quux () {
  9052. }
  9053. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"body"}]
  9054. /**
  9055. * Has an implicit description
  9056. */
  9057. function quux () {
  9058. }
  9059. /**
  9060. * Has an implicit description
  9061. */
  9062. function quux () {
  9063. }
  9064. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"any"}]
  9065. /**
  9066. * @description Has an explicit description
  9067. */
  9068. function quux () {
  9069. }
  9070. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"any"}]
  9071. /**
  9072. *
  9073. */
  9074. function quux () {
  9075. }
  9076. // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
  9077. class TestClass {
  9078. /**
  9079. * Test.
  9080. */
  9081. constructor() { }
  9082. }
  9083. class TestClass {
  9084. /**
  9085. *
  9086. */
  9087. constructor() { }
  9088. }
  9089. // "jsdoc/require-description": ["error"|"warn", {"checkConstructors":false}]
  9090. class TestClass {
  9091. /**
  9092. * Test.
  9093. */
  9094. get Test() { }
  9095. }
  9096. class TestClass {
  9097. /**
  9098. *
  9099. */
  9100. get Test() { }
  9101. }
  9102. // "jsdoc/require-description": ["error"|"warn", {"checkGetters":false}]
  9103. class TestClass {
  9104. /**
  9105. * Test.
  9106. */
  9107. set Test(value) { }
  9108. }
  9109. class TestClass {
  9110. /**
  9111. *
  9112. */
  9113. set Test(value) { }
  9114. }
  9115. // "jsdoc/require-description": ["error"|"warn", {"checkSetters":false}]
  9116. /**
  9117. * Multi
  9118. * line
  9119. */
  9120. function quux () {
  9121. }
  9122. /** Single line */
  9123. function quux () {
  9124. }
  9125. /** @description something */
  9126. function quux () {
  9127. }
  9128. // "jsdoc/require-description": ["error"|"warn", {"descriptionStyle":"tag"}]
  9129. /**
  9130. * @implements {Bar}
  9131. */
  9132. class quux {
  9133. }
  9134. // Settings: {"jsdoc":{"implementsReplacesDocs":false}}
  9135. // "jsdoc/require-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=/\\s{4}/]:has(JsdocTag[rawType=\"class\"])","context":"ClassDeclaration"}],"descriptionStyle":"tag"}]
  9136. /**
  9137. * Has some
  9138. * description already.
  9139. */
  9140. class quux {
  9141. }
  9142. // "jsdoc/require-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[rawType=\"{Bar}\"])","context":"ClassDeclaration"}],"descriptionStyle":"tag"}]
  9143. /**
  9144. * Has some
  9145. * description already.
  9146. */
  9147. class quux {
  9148. }
  9149. // "jsdoc/require-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[rawType=\"{Bar}\"])","context":"any"}],"descriptionStyle":"tag"}]
  9150. /**
  9151. * Has some
  9152. * description already.
  9153. */
  9154. // "jsdoc/require-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[rawType=\"{Bar}\"])","context":"any"}],"descriptionStyle":"tag"}]
  9155. ````
  9156. <a name="eslint-plugin-jsdoc-rules-require-example"></a>
  9157. ### <code>require-example</code>
  9158. Requires that all functions have examples.
  9159. * All functions must have one or more `@example` tags.
  9160. * Every example tag must have a non-empty description that explains the
  9161. method's usage.
  9162. <a name="eslint-plugin-jsdoc-rules-require-example-options-25"></a>
  9163. #### Options
  9164. This rule has an object option.
  9165. <a name="eslint-plugin-jsdoc-rules-require-example-options-25-exemptedby"></a>
  9166. ##### <code>exemptedBy</code>
  9167. Array of tags (e.g., `['type']`) whose presence on the document
  9168. block avoids the need for an `@example`. Defaults to an array with
  9169. `inheritdoc`. If you set this array, it will overwrite the default,
  9170. so be sure to add back `inheritdoc` if you wish its presence to cause
  9171. exemption of the rule.
  9172. <a name="eslint-plugin-jsdoc-rules-require-example-options-25-exemptnoarguments"></a>
  9173. ##### <code>exemptNoArguments</code>
  9174. Boolean to indicate that no-argument functions should not be reported for
  9175. missing `@example` declarations.
  9176. <a name="eslint-plugin-jsdoc-rules-require-example-options-25-contexts-6"></a>
  9177. ##### <code>contexts</code>
  9178. Set this to an array of strings representing the AST context (or an object with
  9179. `context` and `comment` properties) where you wish the rule to be applied.
  9180. (e.g., `ClassDeclaration` for ES6
  9181. classes). Overrides the default contexts (see below). Set to `"any"` if you
  9182. want the rule to apply to any jsdoc block throughout your files.
  9183. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  9184. section of our README for more on the expected format.
  9185. <a name="eslint-plugin-jsdoc-rules-require-example-options-25-checkconstructors"></a>
  9186. ##### <code>checkConstructors</code>
  9187. A value indicating whether `constructor`s should be checked.
  9188. Defaults to `true`.
  9189. <a name="eslint-plugin-jsdoc-rules-require-example-options-25-checkgetters"></a>
  9190. ##### <code>checkGetters</code>
  9191. A value indicating whether getters should be checked. Defaults to `false`.
  9192. <a name="eslint-plugin-jsdoc-rules-require-example-options-25-checksetters"></a>
  9193. ##### <code>checkSetters</code>
  9194. A value indicating whether setters should be checked. Defaults to `false`.
  9195. <a name="eslint-plugin-jsdoc-rules-require-example-fixer"></a>
  9196. #### Fixer
  9197. The fixer for `require-example` will add an empty `@example`, but it will still
  9198. report a missing example description after this is added.
  9199. |||
  9200. |---|---|
  9201. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
  9202. |Tags|`example`|
  9203. |Recommended|false|
  9204. |Options|`exemptedBy`, `exemptNoArguments`, `avoidExampleOnConstructors`, `contexts`|
  9205. |Settings|`ignoreReplacesDocs`, `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
  9206. The following patterns are considered problems:
  9207. ````js
  9208. /**
  9209. *
  9210. */
  9211. function quux () {
  9212. }
  9213. // Message: Missing JSDoc @example declaration.
  9214. /**
  9215. *
  9216. */
  9217. function quux (someParam) {
  9218. }
  9219. // "jsdoc/require-example": ["error"|"warn", {"exemptNoArguments":true}]
  9220. // Message: Missing JSDoc @example declaration.
  9221. /**
  9222. *
  9223. */
  9224. function quux () {
  9225. }
  9226. // Message: Missing JSDoc @example declaration.
  9227. /**
  9228. * @example
  9229. */
  9230. function quux () {
  9231. }
  9232. // Message: Missing JSDoc @example description.
  9233. /**
  9234. * @constructor
  9235. */
  9236. function quux () {
  9237. }
  9238. // Message: Missing JSDoc @example declaration.
  9239. /**
  9240. * @constructor
  9241. * @example
  9242. */
  9243. function quux () {
  9244. }
  9245. // Message: Missing JSDoc @example description.
  9246. /**
  9247. *
  9248. */
  9249. class quux {
  9250. }
  9251. // "jsdoc/require-example": ["error"|"warn", {"contexts":["ClassDeclaration"]}]
  9252. // Message: Missing JSDoc @example declaration.
  9253. /**
  9254. *
  9255. */
  9256. // "jsdoc/require-example": ["error"|"warn", {"contexts":["any"]}]
  9257. // Message: Missing JSDoc @example declaration.
  9258. /**
  9259. *
  9260. */
  9261. function quux () {
  9262. }
  9263. // "jsdoc/require-example": ["error"|"warn", {"exemptedBy":["notPresent"]}]
  9264. // Message: Missing JSDoc @example declaration.
  9265. class TestClass {
  9266. /**
  9267. *
  9268. */
  9269. get Test() { }
  9270. }
  9271. // "jsdoc/require-example": ["error"|"warn", {"checkGetters":true}]
  9272. // Message: Missing JSDoc @example declaration.
  9273. class TestClass {
  9274. /**
  9275. * @example
  9276. */
  9277. get Test() { }
  9278. }
  9279. // "jsdoc/require-example": ["error"|"warn", {"checkGetters":true}]
  9280. // Message: Missing JSDoc @example description.
  9281. class TestClass {
  9282. /**
  9283. *
  9284. */
  9285. set Test(value) { }
  9286. }
  9287. // "jsdoc/require-example": ["error"|"warn", {"checkSetters":true}]
  9288. // Message: Missing JSDoc @example declaration.
  9289. class TestClass {
  9290. /**
  9291. * @example
  9292. */
  9293. set Test(value) { }
  9294. }
  9295. // "jsdoc/require-example": ["error"|"warn", {"checkSetters":true}]
  9296. // Message: Missing JSDoc @example description.
  9297. ````
  9298. The following patterns are not considered problems:
  9299. ````js
  9300. /**
  9301. *
  9302. */
  9303. /**
  9304. * @example
  9305. * // arbitrary example content
  9306. */
  9307. function quux () {
  9308. }
  9309. /**
  9310. * @example
  9311. * quux(); // does something useful
  9312. */
  9313. function quux () {
  9314. }
  9315. /**
  9316. * @example <caption>Valid usage</caption>
  9317. * quux(); // does something useful
  9318. *
  9319. * @example <caption>Invalid usage</caption>
  9320. * quux('random unwanted arg'); // results in an error
  9321. */
  9322. function quux () {
  9323. }
  9324. /**
  9325. * @constructor
  9326. */
  9327. function quux () {
  9328. }
  9329. // "jsdoc/require-example": ["error"|"warn", {"checkConstructors":false}]
  9330. /**
  9331. * @constructor
  9332. * @example
  9333. */
  9334. function quux () {
  9335. }
  9336. // "jsdoc/require-example": ["error"|"warn", {"checkConstructors":false}]
  9337. class Foo {
  9338. /**
  9339. *
  9340. */
  9341. constructor () {
  9342. }
  9343. }
  9344. // "jsdoc/require-example": ["error"|"warn", {"checkConstructors":false}]
  9345. /**
  9346. * @inheritdoc
  9347. */
  9348. function quux () {
  9349. }
  9350. /**
  9351. * @type {MyCallback}
  9352. */
  9353. function quux () {
  9354. }
  9355. // "jsdoc/require-example": ["error"|"warn", {"exemptedBy":["type"]}]
  9356. /**
  9357. * @example Some example code
  9358. */
  9359. class quux {
  9360. }
  9361. // "jsdoc/require-example": ["error"|"warn", {"contexts":["ClassDeclaration"]}]
  9362. /**
  9363. *
  9364. */
  9365. function quux () {
  9366. }
  9367. // "jsdoc/require-example": ["error"|"warn", {"contexts":["ClassDeclaration"]}]
  9368. class TestClass {
  9369. /**
  9370. *
  9371. */
  9372. get Test() { }
  9373. }
  9374. class TestClass {
  9375. /**
  9376. * @example
  9377. */
  9378. get Test() { }
  9379. }
  9380. class TestClass {
  9381. /**
  9382. * @example Test
  9383. */
  9384. get Test() { }
  9385. }
  9386. // "jsdoc/require-example": ["error"|"warn", {"checkGetters":true}]
  9387. class TestClass {
  9388. /**
  9389. *
  9390. */
  9391. set Test(value) { }
  9392. }
  9393. class TestClass {
  9394. /**
  9395. * @example
  9396. */
  9397. set Test(value) { }
  9398. }
  9399. // "jsdoc/require-example": ["error"|"warn", {"checkSetters":false}]
  9400. class TestClass {
  9401. /**
  9402. * @example Test
  9403. */
  9404. set Test(value) { }
  9405. }
  9406. // "jsdoc/require-example": ["error"|"warn", {"checkSetters":true}]
  9407. /**
  9408. *
  9409. */
  9410. function quux () {
  9411. }
  9412. // "jsdoc/require-example": ["error"|"warn", {"exemptNoArguments":true}]
  9413. ````
  9414. <a name="eslint-plugin-jsdoc-rules-require-file-overview"></a>
  9415. ### <code>require-file-overview</code>
  9416. Checks that:
  9417. 1. All files have a `@file`, `@fileoverview`, or `@overview` tag.
  9418. 2. Duplicate file overview tags within a given file will be reported
  9419. 3. File overview tags will be reported which are not, as per
  9420. [the docs](https://jsdoc.app/tags-file.html), "at the beginning of
  9421. the file"–where beginning of the file is interpreted in this rule
  9422. as being when the overview tag is not preceded by anything other than
  9423. a comment.
  9424. <a name="eslint-plugin-jsdoc-rules-require-file-overview-options-26"></a>
  9425. #### Options
  9426. <a name="eslint-plugin-jsdoc-rules-require-file-overview-options-26-tags-5"></a>
  9427. ##### <code>tags</code>
  9428. The keys of this object are tag names, and the values are configuration
  9429. objects indicating what will be checked for these whole-file tags.
  9430. Each configuration object has the following boolean keys (which default
  9431. to `false` when this option is supplied): `mustExist`, `preventDuplicates`,
  9432. `initialCommentsOnly`. These correspond to the three items above.
  9433. When no `tags` is present, the default is:
  9434. ```json
  9435. {
  9436. "file": {
  9437. "initialCommentsOnly": true,
  9438. "mustExist": true,
  9439. "preventDuplicates": true,
  9440. }
  9441. }
  9442. ```
  9443. You can add additional tag names and/or override `file` if you supply this
  9444. option, e.g., in place of or in addition to `file`, giving other potential
  9445. file global tags like `@license`, `@copyright`, `@author`, `@module` or
  9446. `@exports`, optionally restricting them to a single use or preventing them
  9447. from being preceded by anything besides comments.
  9448. For example:
  9449. ```js
  9450. {
  9451. "license": {
  9452. "mustExist": true,
  9453. "preventDuplicates": true,
  9454. }
  9455. }
  9456. ```
  9457. This would require one and only one `@license` in the file, though because
  9458. `initialCommentsOnly` is absent and defaults to `false`, the `@license`
  9459. can be anywhere.
  9460. In the case of `@license`, you can use this rule along with the
  9461. `check-values` rule (with its `allowedLicenses` or `licensePattern` options),
  9462. to enforce a license whitelist be present on every JS file.
  9463. Note that if you choose to use `preventDuplicates` with `license`, you still
  9464. have a way to allow multiple licenses for the whole page by using the SPDX
  9465. "AND" expression, e.g., `@license (MIT AND GPL-3.0)`.
  9466. Note that the tag names are the main jsdoc tag name, so you should use `file`
  9467. in this configuration object regardless of whether you have configured
  9468. `fileoverview` instead of `file` on `tagNamePreference` (i.e., `fileoverview`
  9469. will be checked, but you must use `file` on the configuration object).
  9470. |||
  9471. |---|---|
  9472. |Context|Everywhere|
  9473. |Tags|`file`; others when `tags` set|
  9474. |Aliases|`fileoverview`, `overview`|
  9475. |Recommended|false|
  9476. |Options|`tags`|
  9477. The following patterns are considered problems:
  9478. ````js
  9479. // Message: Missing @file
  9480. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"file":{"initialCommentsOnly":true,"mustExist":true,"preventDuplicates":true}}}]
  9481. // Message: Missing @file
  9482. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"file":{"mustExist":true}}}]
  9483. // Message: Missing @file
  9484. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"author":{"initialCommentsOnly":false,"mustExist":true,"preventDuplicates":false}}}]
  9485. // Message: Missing @author
  9486. /**
  9487. *
  9488. */
  9489. // Message: Missing @file
  9490. /**
  9491. *
  9492. */
  9493. function quux () {}
  9494. // Message: Missing @file
  9495. /**
  9496. *
  9497. */
  9498. function quux () {}
  9499. // Settings: {"jsdoc":{"tagNamePreference":{"file":"fileoverview"}}}
  9500. // Message: Missing @fileoverview
  9501. /**
  9502. *
  9503. */
  9504. function quux () {}
  9505. // Settings: {"jsdoc":{"tagNamePreference":{"file":"overview"}}}
  9506. // Message: Missing @overview
  9507. /**
  9508. *
  9509. */
  9510. function quux () {}
  9511. // Settings: {"jsdoc":{"tagNamePreference":{"file":false}}}
  9512. // Message: `settings.jsdoc.tagNamePreference` cannot block @file for the `require-file-overview` rule
  9513. /**
  9514. *
  9515. */
  9516. function quux () {}
  9517. // Settings: {"jsdoc":{"tagNamePreference":{"file":false}}}
  9518. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"file":{"initialCommentsOnly":false,"mustExist":true,"preventDuplicates":false}}}]
  9519. // Message: `settings.jsdoc.tagNamePreference` cannot block @file for the `require-file-overview` rule
  9520. /**
  9521. *
  9522. */
  9523. function quux () {}
  9524. // Settings: {"jsdoc":{"tagNamePreference":{"file":{"message":"Don't use file"}}}}
  9525. // Message: `settings.jsdoc.tagNamePreference` cannot block @file for the `require-file-overview` rule
  9526. /**
  9527. * @param a
  9528. */
  9529. function quux (a) {}
  9530. // Message: Missing @file
  9531. /**
  9532. * @param a
  9533. */
  9534. function quux (a) {}
  9535. /**
  9536. * @param b
  9537. */
  9538. function bar (b) {}
  9539. // Message: Missing @file
  9540. /**
  9541. * @file
  9542. */
  9543. /**
  9544. * @file
  9545. */
  9546. // Message: Duplicate @file
  9547. /**
  9548. * @copyright
  9549. */
  9550. /**
  9551. * @copyright
  9552. */
  9553. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"copyright":{"initialCommentsOnly":false,"mustExist":false,"preventDuplicates":true}}}]
  9554. // Message: Duplicate @copyright
  9555. function quux () {
  9556. }
  9557. /**
  9558. * @file
  9559. */
  9560. // Message: @file should be at the beginning of the file
  9561. function quux () {
  9562. }
  9563. /**
  9564. * @license
  9565. */
  9566. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"license":{"initialCommentsOnly":true,"mustExist":false,"preventDuplicates":false}}}]
  9567. // Message: @license should be at the beginning of the file
  9568. function quux () {
  9569. }
  9570. /**
  9571. * @license
  9572. */
  9573. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"license":{"initialCommentsOnly":true}}}]
  9574. // Message: @license should be at the beginning of the file
  9575. /**
  9576. * @file
  9577. */
  9578. /**
  9579. * @file
  9580. */
  9581. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"file":{"initialCommentsOnly":true,"preventDuplicates":true}}}]
  9582. // Message: Duplicate @file
  9583. ````
  9584. The following patterns are not considered problems:
  9585. ````js
  9586. /**
  9587. * @file
  9588. */
  9589. /**
  9590. * @file
  9591. */
  9592. /**
  9593. * @file
  9594. */
  9595. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"license":{"initialCommentsOnly":true,"preventDuplicates":true}}}]
  9596. // Ok preceded by comment
  9597. /**
  9598. * @file
  9599. */
  9600. /**
  9601. * @fileoverview
  9602. */
  9603. // Settings: {"jsdoc":{"tagNamePreference":{"file":"fileoverview"}}}
  9604. /**
  9605. * @overview
  9606. */
  9607. // Settings: {"jsdoc":{"tagNamePreference":{"file":"overview"}}}
  9608. /**
  9609. * @file Description of file
  9610. */
  9611. /**
  9612. * @file Description of file
  9613. */
  9614. function quux () {
  9615. }
  9616. /**
  9617. *
  9618. */
  9619. function quux () {
  9620. }
  9621. /**
  9622. *
  9623. */
  9624. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"license":{"initialCommentsOnly":true,"mustExist":false,"preventDuplicates":false}}}]
  9625. function quux () {
  9626. }
  9627. /**
  9628. *
  9629. */
  9630. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"license":{"initialCommentsOnly":false,"mustExist":false,"preventDuplicates":false}}}]
  9631. function quux () {
  9632. }
  9633. /**
  9634. *
  9635. */
  9636. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"license":{"initialCommentsOnly":false,"mustExist":false,"preventDuplicates":true}}}]
  9637. /**
  9638. * @license MIT
  9639. */
  9640. var a
  9641. /**
  9642. * @type {Array}
  9643. */
  9644. // "jsdoc/require-file-overview": ["error"|"warn", {"tags":{"license":{"initialCommentsOnly":true,"mustExist":false,"preventDuplicates":false}}}]
  9645. ````
  9646. <a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description"></a>
  9647. ### <code>require-hyphen-before-param-description</code>
  9648. Requires (or disallows) a hyphen before the `@param` description.
  9649. <a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description-options-27"></a>
  9650. #### Options
  9651. This rule takes one optional string argument and an optional options object.
  9652. If the string is `"always"` then a problem is raised when there is no hyphen
  9653. before the description. If it is `"never"` then a problem is raised when there
  9654. is a hyphen before the description. The default value is `"always"`.
  9655. The options object may have the following properties to indicate behavior for
  9656. other tags besides the `@param` tag (or the `@arg` tag if so set):
  9657. - `tags` - Object whose keys indicate different tags to check for the
  9658. presence or absence of hyphens; the key value should be "always" or "never",
  9659. indicating how hyphens are to be applied, e.g., `{property: 'never'}`
  9660. to ensure `@property` never uses hyphens. A key can also be set as `*`, e.g.,
  9661. `'*': 'always'` to apply hyphen checking to any tag (besides the preferred
  9662. `@param` tag which follows the main string option setting and besides any
  9663. other `tags` entries).
  9664. |||
  9665. |---|---|
  9666. |Context|everywhere|
  9667. |Tags|`param` and optionally other tags within `tags`|
  9668. |Aliases|`arg`, `argument`; potentially `prop` or other aliases|
  9669. |Recommended|false|
  9670. |Options|a string matching `"always" or "never"` followed by an optional object with a `tags` property|
  9671. The following patterns are considered problems:
  9672. ````js
  9673. /**
  9674. * @param foo Foo.
  9675. */
  9676. function quux () {
  9677. }
  9678. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always"]
  9679. // Message: There must be a hyphen before @param description.
  9680. /**
  9681. * @param foo Foo.
  9682. */
  9683. function quux () {
  9684. }
  9685. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always",{"tags":{"*":"never"}}]
  9686. // Message: There must be a hyphen before @param description.
  9687. /**
  9688. * @param foo Foo.
  9689. * @returns {SomeType} - Hyphen here.
  9690. */
  9691. function quux () {
  9692. }
  9693. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always",{"tags":{"*":"never","returns":"always"}}]
  9694. // Message: There must be a hyphen before @param description.
  9695. /**
  9696. * @param foo Foo.
  9697. */
  9698. function quux () {
  9699. }
  9700. // Message: There must be a hyphen before @param description.
  9701. /**
  9702. * @param foo - Foo.
  9703. */
  9704. function quux () {
  9705. }
  9706. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "never"]
  9707. // Message: There must be no hyphen before @param description.
  9708. /**
  9709. * @param foo - Foo.
  9710. */
  9711. function quux () {
  9712. }
  9713. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "never"]
  9714. // Message: There must be no hyphen before @param description.
  9715. /**
  9716. * @param foo - foo
  9717. * @param foo foo
  9718. */
  9719. function quux () {
  9720. }
  9721. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always"]
  9722. // Message: There must be a hyphen before @param description.
  9723. /**
  9724. * @param foo foo
  9725. * bar
  9726. * @param bar - bar
  9727. */
  9728. function quux () {
  9729. }
  9730. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always"]
  9731. // Message: There must be a hyphen before @param description.
  9732. /**
  9733. * @param foo
  9734. */
  9735. function quux (foo) {
  9736. }
  9737. // Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
  9738. // Message: Unexpected tag `@param`
  9739. /**
  9740. * @typedef {SomeType} ATypeDefName
  9741. * @property foo Foo.
  9742. */
  9743. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always",{"tags":{"property":"always"}}]
  9744. // Message: There must be a hyphen before @property description.
  9745. /**
  9746. * @template TempA, TempB A desc.
  9747. */
  9748. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always",{"tags":{"template":"always"}}]
  9749. // Message: There must be a hyphen before @template description.
  9750. /**
  9751. * @typedef {SomeType} ATypeDefName
  9752. * @property foo - Foo.
  9753. */
  9754. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "never",{"tags":{"property":"never"}}]
  9755. // Message: There must be no hyphen before @property description.
  9756. /**
  9757. * @param foo Foo.
  9758. * @returns {SomeType} - A description.
  9759. */
  9760. function quux () {
  9761. }
  9762. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always",{"tags":{"returns":"never"}}]
  9763. // Message: There must be a hyphen before @param description.
  9764. ````
  9765. The following patterns are not considered problems:
  9766. ````js
  9767. /**
  9768. * @param foo - Foo.
  9769. */
  9770. function quux () {
  9771. }
  9772. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always"]
  9773. /**
  9774. * @param foo - Foo.
  9775. */
  9776. function quux () {
  9777. }
  9778. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always"]
  9779. /**
  9780. * @param foo - Foo.
  9781. * @returns {SomeType} A description.
  9782. */
  9783. function quux () {
  9784. }
  9785. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always",{"tags":{"returns":"never"}}]
  9786. /**
  9787. * @param foo Foo.
  9788. */
  9789. function quux () {
  9790. }
  9791. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "never"]
  9792. /**
  9793. * @param foo
  9794. */
  9795. function quux () {
  9796. }
  9797. /**
  9798. *
  9799. */
  9800. function quux () {
  9801. }
  9802. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always",{"tags":{"*":"always"}}]
  9803. /**
  9804. * @typedef {SomeType} ATypeDefName
  9805. * @property foo - Foo.
  9806. */
  9807. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "always",{"tags":{"property":"always"}}]
  9808. /**
  9809. * @typedef {SomeType} ATypeDefName
  9810. * @property foo Foo.
  9811. */
  9812. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "never",{"tags":{"property":"never"}}]
  9813. /**
  9814. * @typedef {SomeType} ATypeDefName
  9815. * @property foo - Foo.
  9816. */
  9817. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "never",{"tags":{"*":"always"}}]
  9818. /** Entry point for module.
  9819. *
  9820. * @param {!Array<string>} argv Command-line arguments.
  9821. */
  9822. function main(argv) {
  9823. };
  9824. // "jsdoc/require-hyphen-before-param-description": ["error"|"warn", "never"]
  9825. ````
  9826. <a name="eslint-plugin-jsdoc-rules-require-jsdoc"></a>
  9827. ### <code>require-jsdoc</code>
  9828. Checks for presence of jsdoc comments, on class declarations as well as
  9829. functions.
  9830. <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28"></a>
  9831. #### Options
  9832. Accepts one optional options object with the following optional keys.
  9833. <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-publiconly"></a>
  9834. ##### <code>publicOnly</code>
  9835. This option will insist that missing jsdoc blocks are only reported for
  9836. function bodies / class declarations that are exported from the module.
  9837. May be a boolean or object. If set to `true`, the defaults below will be
  9838. used. If unset, jsdoc block reporting will not be limited to exports.
  9839. This object supports the following optional boolean keys (`false` unless
  9840. otherwise noted):
  9841. - `ancestorsOnly` - Only check node ancestors to check if node is exported
  9842. - `esm` - ESM exports are checked for JSDoc comments (Defaults to `true`)
  9843. - `cjs` - CommonJS exports are checked for JSDoc comments (Defaults to `true`)
  9844. - `window` - Window global exports are checked for JSDoc comments
  9845. <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-require"></a>
  9846. ##### <code>require</code>
  9847. An object with the following optional boolean keys which all default to
  9848. `false` except as noted, indicating the contexts where the rule will apply:
  9849. - `ArrowFunctionExpression`
  9850. - `ClassDeclaration`
  9851. - `ClassExpression`
  9852. - `FunctionDeclaration` (defaults to `true`)
  9853. - `FunctionExpression`
  9854. - `MethodDefinition`
  9855. <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-contexts-7"></a>
  9856. ##### <code>contexts</code>
  9857. Set this to an array of strings or objects representing the additional AST
  9858. contexts where you wish the rule to be applied (e.g., `Property` for
  9859. properties). If specified as an object, it should have a `context` property
  9860. and can have an `inlineCommentBlock` property which, if set to `true`, will
  9861. add an inline `/** */` instead of the regular, multi-line, indented jsdoc
  9862. block which will otherwise be added. Defaults to an empty array.
  9863. Note that you may need to disable `require` items (e.g., `MethodDefinition`)
  9864. if you are specifying a more precise form in `contexts` (e.g., `MethodDefinition:not([accessibility="private"] > FunctionExpression`).
  9865. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  9866. section of our README for more on the expected format.
  9867. <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-exemptemptyconstructors"></a>
  9868. ##### <code>exemptEmptyConstructors</code>
  9869. Default: true
  9870. When `true`, the rule will not report missing jsdoc blocks above constructors
  9871. with no parameters or return values (this is enabled by default as the class
  9872. name or description should be seen as sufficient to convey intent).
  9873. <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-exemptemptyfunctions"></a>
  9874. ##### <code>exemptEmptyFunctions</code>
  9875. Default: false.
  9876. When `true`, the rule will not report missing jsdoc blocks above
  9877. functions/methods with no parameters or return values (intended where
  9878. function/method names are sufficient for themselves as documentation).
  9879. <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-checkconstructors-1"></a>
  9880. ##### <code>checkConstructors</code>
  9881. A value indicating whether `constructor`s should be checked. Defaults to
  9882. `true`. When `true`, `exemptEmptyConstructors` may still avoid reporting when
  9883. no parameters or return values are found.
  9884. <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-checkgetters-1"></a>
  9885. ##### <code>checkGetters</code>
  9886. A value indicating whether getters should be checked. Besides setting as a
  9887. boolean, this option can be set to the string `"no-setter"` to indicate that
  9888. getters should be checked but only when there is no setter. This may be useful
  9889. if one only wishes documentation on one of the two accessors. Defaults to
  9890. `false`.
  9891. <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-checksetters-1"></a>
  9892. ##### <code>checkSetters</code>
  9893. A value indicating whether setters should be checked. Besides setting as a
  9894. boolean, this option can be set to the string `"no-getter"` to indicate that
  9895. setters should be checked but only when there is no getter. This may be useful
  9896. if one only wishes documentation on one of the two accessors. Defaults to
  9897. `false`.
  9898. <a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-28-enablefixer-2"></a>
  9899. ##### <code>enableFixer</code>
  9900. A boolean on whether to enable the fixer (which adds an empty jsdoc block).
  9901. Defaults to `true`.
  9902. |||
  9903. |---|---|
  9904. |Context|`ArrowFunctionExpression`, `ClassDeclaration`, `ClassExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
  9905. |Tags|N/A|
  9906. |Recommended|true|
  9907. |Options|`publicOnly`, `require`, `contexts`, `exemptEmptyConstructors`, `exemptEmptyFunctions`, `enableFixer`|
  9908. The following patterns are considered problems:
  9909. ````js
  9910. /** This is comment */
  9911. export interface Foo {
  9912. /** This is comment x2 */
  9913. tom: string;
  9914. catchJerry(): boolean;
  9915. }
  9916. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration","TSMethodSignature","TSPropertySignature"],"publicOnly":{"ancestorsOnly":true},"require":{"ClassDeclaration":true,"ClassExpression":true,"MethodDefinition":true}}]
  9917. // Message: Missing JSDoc comment.
  9918. /** This is comment */
  9919. export interface Foo {
  9920. /** This is comment x2 */
  9921. tom: string;
  9922. jerry: number;
  9923. }
  9924. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration","TSMethodSignature","TSPropertySignature"],"publicOnly":{"ancestorsOnly":true},"require":{"ClassDeclaration":true,"ClassExpression":true,"MethodDefinition":true}}]
  9925. // Message: Missing JSDoc comment.
  9926. /** This is comment */
  9927. export interface Foo {
  9928. bar(): string;
  9929. }
  9930. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration","TSMethodSignature","TSPropertySignature"],"publicOnly":{"ancestorsOnly":true}}]
  9931. // Message: Missing JSDoc comment.
  9932. /** This is comment */
  9933. export interface Foo {
  9934. bar: string;
  9935. }
  9936. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration","TSMethodSignature","TSPropertySignature"],"publicOnly":{"ancestorsOnly":true,"esm":true}}]
  9937. // Message: Missing JSDoc comment.
  9938. /**
  9939. * Foo interface documentation.
  9940. */
  9941. export interface Foo extends Bar {
  9942. /**
  9943. * baz method documentation.
  9944. */
  9945. baz(): void;
  9946. meow(): void;
  9947. }
  9948. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSMethodSignature"],"publicOnly":{"ancestorsOnly":true}}]
  9949. // Message: Missing JSDoc comment.
  9950. function quux (foo) {
  9951. }
  9952. // Message: Missing JSDoc comment.
  9953. /**
  9954. * @func myFunction
  9955. */
  9956. function myFunction() {
  9957. }
  9958. // Settings: {"jsdoc":{"maxLines":3,"minLines":2}}
  9959. // Message: Missing JSDoc comment.
  9960. /**
  9961. * @func myFunction
  9962. */
  9963. function myFunction() {
  9964. }
  9965. // Settings: {"jsdoc":{"maxLines":2}}
  9966. // Message: Missing JSDoc comment.
  9967. /** @func myFunction */ function myFunction() {
  9968. }
  9969. // Settings: {"jsdoc":{"minLines":1}}
  9970. // Message: Missing JSDoc comment.
  9971. function myFunction() {
  9972. }
  9973. // "jsdoc/require-jsdoc": ["error"|"warn", {"enableFixer":false}]
  9974. // Message: Missing JSDoc comment.
  9975. export var test = function () {
  9976. };
  9977. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  9978. // Message: Missing JSDoc comment.
  9979. function test () {
  9980. }
  9981. export var test2 = test;
  9982. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionDeclaration":true}}]
  9983. // Message: Missing JSDoc comment.
  9984. export const test = () => {
  9985. };
  9986. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
  9987. // Message: Missing JSDoc comment.
  9988. export const test = () => {
  9989. };
  9990. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["ArrowFunctionExpression"],"publicOnly":true}]
  9991. // Message: Missing JSDoc comment.
  9992. export const test = () => {
  9993. };
  9994. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":[{"context":"ArrowFunctionExpression"}],"publicOnly":true}]
  9995. // Message: Missing JSDoc comment.
  9996. export let test = class {
  9997. };
  9998. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"ClassExpression":true}}]
  9999. // Message: Missing JSDoc comment.
  10000. export default function () {}
  10001. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
  10002. // Message: Missing JSDoc comment.
  10003. export default () => {}
  10004. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"ArrowFunctionExpression":true}}]
  10005. // Message: Missing JSDoc comment.
  10006. export default (function () {})
  10007. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
  10008. // Message: Missing JSDoc comment.
  10009. export default class {}
  10010. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"ClassDeclaration":true}}]
  10011. // Message: Missing JSDoc comment.
  10012. function quux (foo) {
  10013. }
  10014. // Message: Missing JSDoc comment.
  10015. function quux (foo) {
  10016. }
  10017. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyFunctions":true}]
  10018. // Message: Missing JSDoc comment.
  10019. function quux (foo) {
  10020. }
  10021. // Settings: {"jsdoc":{"minLines":2}}
  10022. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyFunctions":true}]
  10023. // Message: Missing JSDoc comment.
  10024. function myFunction() {}
  10025. // Message: Missing JSDoc comment.
  10026. /**
  10027. * Description for A.
  10028. */
  10029. class A {
  10030. constructor(xs) {
  10031. this.a = xs;
  10032. }
  10033. }
  10034. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
  10035. // Message: Missing JSDoc comment.
  10036. class A {
  10037. /**
  10038. * Description for constructor.
  10039. * @param {object[]} xs - xs
  10040. */
  10041. constructor(xs) {
  10042. this.a = xs;
  10043. }
  10044. }
  10045. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
  10046. // Message: Missing JSDoc comment.
  10047. class A extends B {
  10048. /**
  10049. * Description for constructor.
  10050. * @param {object[]} xs - xs
  10051. */
  10052. constructor(xs) {
  10053. this.a = xs;
  10054. }
  10055. }
  10056. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
  10057. // Message: Missing JSDoc comment.
  10058. export class A extends B {
  10059. /**
  10060. * Description for constructor.
  10061. * @param {object[]} xs - xs
  10062. */
  10063. constructor(xs) {
  10064. this.a = xs;
  10065. }
  10066. }
  10067. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
  10068. // Message: Missing JSDoc comment.
  10069. export default class A extends B {
  10070. /**
  10071. * Description for constructor.
  10072. * @param {object[]} xs - xs
  10073. */
  10074. constructor(xs) {
  10075. this.a = xs;
  10076. }
  10077. }
  10078. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
  10079. // Message: Missing JSDoc comment.
  10080. var myFunction = () => {}
  10081. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":true}}]
  10082. // Message: Missing JSDoc comment.
  10083. var myFunction = () => () => {}
  10084. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":true}}]
  10085. // Message: Missing JSDoc comment.
  10086. var foo = function() {}
  10087. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"FunctionExpression":true}}]
  10088. // Message: Missing JSDoc comment.
  10089. const foo = {bar() {}}
  10090. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"FunctionExpression":true}}]
  10091. // Message: Missing JSDoc comment.
  10092. var foo = {bar: function() {}}
  10093. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"FunctionExpression":true}}]
  10094. // Message: Missing JSDoc comment.
  10095. function foo (abc) {}
  10096. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyFunctions":false}]
  10097. // Message: Missing JSDoc comment.
  10098. function foo () {
  10099. return true;
  10100. }
  10101. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyFunctions":false}]
  10102. // Message: Missing JSDoc comment.
  10103. module.exports = function quux () {
  10104. }
  10105. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10106. // Message: Missing JSDoc comment.
  10107. module.exports = function quux () {
  10108. }
  10109. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
  10110. // Message: Missing JSDoc comment.
  10111. module.exports = {
  10112. method: function() {
  10113. }
  10114. }
  10115. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10116. // Message: Missing JSDoc comment.
  10117. module.exports = {
  10118. test: {
  10119. test2: function() {
  10120. }
  10121. }
  10122. }
  10123. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10124. // Message: Missing JSDoc comment.
  10125. module.exports = {
  10126. test: {
  10127. test2: function() {
  10128. }
  10129. }
  10130. }
  10131. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
  10132. // Message: Missing JSDoc comment.
  10133. const test = module.exports = function () {
  10134. }
  10135. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10136. // Message: Missing JSDoc comment.
  10137. /**
  10138. *
  10139. */
  10140. const test = module.exports = function () {
  10141. }
  10142. test.prototype.method = function() {}
  10143. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10144. // Message: Missing JSDoc comment.
  10145. const test = function () {
  10146. }
  10147. module.exports = {
  10148. test: test
  10149. }
  10150. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10151. // Message: Missing JSDoc comment.
  10152. const test = () => {
  10153. }
  10154. module.exports = {
  10155. test: test
  10156. }
  10157. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
  10158. // Message: Missing JSDoc comment.
  10159. class Test {
  10160. method() {
  10161. }
  10162. }
  10163. module.exports = Test;
  10164. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"MethodDefinition":true}}]
  10165. // Message: Missing JSDoc comment.
  10166. export default function quux () {
  10167. }
  10168. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10169. // Message: Missing JSDoc comment.
  10170. export default function quux () {
  10171. }
  10172. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
  10173. // Message: Missing JSDoc comment.
  10174. function quux () {
  10175. }
  10176. export default quux;
  10177. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10178. // Message: Missing JSDoc comment.
  10179. export function test() {
  10180. }
  10181. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10182. // Message: Missing JSDoc comment.
  10183. export function test() {
  10184. }
  10185. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
  10186. // Message: Missing JSDoc comment.
  10187. var test = function () {
  10188. }
  10189. var test2 = 2;
  10190. export { test, test2 }
  10191. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10192. // Message: Missing JSDoc comment.
  10193. var test = function () {
  10194. }
  10195. export { test as test2 }
  10196. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10197. // Message: Missing JSDoc comment.
  10198. export default class A {
  10199. }
  10200. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"ClassDeclaration":true}}]
  10201. // Message: Missing JSDoc comment.
  10202. export default class A {
  10203. }
  10204. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"ancestorsOnly":true},"require":{"ClassDeclaration":true}}]
  10205. // Message: Missing JSDoc comment.
  10206. var test = function () {
  10207. }
  10208. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
  10209. // Message: Missing JSDoc comment.
  10210. window.test = function () {
  10211. }
  10212. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
  10213. // Message: Missing JSDoc comment.
  10214. function test () {
  10215. }
  10216. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"window":true}}]
  10217. // Message: Missing JSDoc comment.
  10218. module.exports = function() {
  10219. }
  10220. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionExpression":true}}]
  10221. // Message: Missing JSDoc comment.
  10222. export function someMethod() {
  10223. }
  10224. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
  10225. // Message: Missing JSDoc comment.
  10226. export function someMethod() {
  10227. }
  10228. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
  10229. // Message: Missing JSDoc comment.
  10230. const myObject = {
  10231. myProp: true
  10232. };
  10233. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["Property"]}]
  10234. // Message: Missing JSDoc comment.
  10235. /**
  10236. * Foo interface documentation.
  10237. */
  10238. export interface Foo extends Bar {
  10239. /**
  10240. * baz method documentation.
  10241. */
  10242. baz(): void;
  10243. meow(): void;
  10244. }
  10245. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSMethodSignature"]}]
  10246. // Message: Missing JSDoc comment.
  10247. class MyClass {
  10248. someProperty: boolean; // Flow type annotation.
  10249. }
  10250. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyFunctions":true,"require":{"ClassDeclaration":true}}]
  10251. // Message: Missing JSDoc comment.
  10252. export default class Test {
  10253. constructor(a) {
  10254. this.a = a;
  10255. }
  10256. }
  10257. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"ArrowFunctionExpression":false,"ClassDeclaration":false,"ClassExpression":false,"FunctionDeclaration":false,"FunctionExpression":false,"MethodDefinition":true}}]
  10258. // Message: Missing JSDoc comment.
  10259. export default class Test {
  10260. constructor(a) {
  10261. this.a = a;
  10262. }
  10263. private abc(a) {
  10264. this.a = a;
  10265. }
  10266. }
  10267. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["MethodDefinition:not([accessibility=\"private\"]) > FunctionExpression"],"publicOnly":true,"require":{"ArrowFunctionExpression":false,"ClassDeclaration":false,"ClassExpression":false,"FunctionDeclaration":false,"FunctionExpression":false,"MethodDefinition":false}}]
  10268. // Message: Missing JSDoc comment.
  10269. e = function () {
  10270. };
  10271. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"FunctionDeclaration":false,"FunctionExpression":true}}]
  10272. // Message: Missing JSDoc comment.
  10273. /**
  10274. *
  10275. */
  10276. export class Class {
  10277. test = 1;
  10278. foo() {
  10279. this.test = 2;
  10280. }
  10281. }
  10282. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"FunctionDeclaration":false,"MethodDefinition":true}}]
  10283. // Message: Missing JSDoc comment.
  10284. class Dog {
  10285. eat() {
  10286. }
  10287. }
  10288. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"FunctionDeclaration":false,"MethodDefinition":true}}]
  10289. // Message: Missing JSDoc comment.
  10290. const hello = name => {
  10291. document.body.textContent = "Hello, " + name + "!";
  10292. };
  10293. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":true,"FunctionDeclaration":false}}]
  10294. // Message: Missing JSDoc comment.
  10295. export const loginSuccessAction = (): BaseActionPayload => ({ type: LOGIN_SUCCESSFUL });
  10296. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":true,"FunctionDeclaration":false}}]
  10297. // Message: Missing JSDoc comment.
  10298. export type Container = {
  10299. constants?: ObjByString;
  10300. enums?: { [key in string]: TypescriptEnum };
  10301. helpers?: { [key in string]: AnyFunction };
  10302. };
  10303. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSTypeAliasDeclaration",{"context":"TSPropertySignature","inlineCommentBlock":true}]}]
  10304. // Message: Missing JSDoc comment.
  10305. class Foo {
  10306. constructor() {}
  10307. bar() {}
  10308. }
  10309. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["MethodDefinition[key.name!=\"constructor\"]"],"require":{"ClassDeclaration":true}}]
  10310. // Message: Missing JSDoc comment.
  10311. class Example extends React.PureComponent {
  10312. componentDidMount() {}
  10313. render() {}
  10314. someOtherMethod () {}
  10315. }
  10316. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["MethodDefinition:not([key.name=\"componentDidMount\"]):not([key.name=\"render\"])"],"require":{"ClassDeclaration":true}}]
  10317. // Message: Missing JSDoc comment.
  10318. function foo(arg: boolean): boolean {
  10319. return arg;
  10320. }
  10321. function bar(arg: true): true;
  10322. function bar(arg: false): false;
  10323. function bar(arg: boolean): boolean {
  10324. return arg;
  10325. }
  10326. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSDeclareFunction:not(TSDeclareFunction + TSDeclareFunction)","FunctionDeclaration:not(TSDeclareFunction + FunctionDeclaration)"],"require":{"FunctionDeclaration":false}}]
  10327. // Message: Missing JSDoc comment.
  10328. export function foo(arg: boolean): boolean {
  10329. return arg;
  10330. }
  10331. export function bar(arg: true): true;
  10332. export function bar(arg: false): false;
  10333. export function bar(arg: boolean): boolean {
  10334. return arg;
  10335. }
  10336. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["ExportNamedDeclaration[declaration.type=\"TSDeclareFunction\"]:not(ExportNamedDeclaration[declaration.type=\"TSDeclareFunction\"] + ExportNamedDeclaration[declaration.type=\"TSDeclareFunction\"])","ExportNamedDeclaration[declaration.type=\"FunctionDeclaration\"]:not(ExportNamedDeclaration[declaration.type=\"TSDeclareFunction\"] + ExportNamedDeclaration[declaration.type=\"FunctionDeclaration\"])"],"require":{"FunctionDeclaration":false}}]
  10337. // Message: Missing JSDoc comment.
  10338. module.exports.foo = (bar) => {
  10339. return bar + "biz"
  10340. }
  10341. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":false,"require":{"ArrowFunctionExpression":true,"FunctionDeclaration":true,"FunctionExpression":true,"MethodDefinition":true}}]
  10342. // Message: Missing JSDoc comment.
  10343. class Animal {
  10344. #name: string;
  10345. private species: string;
  10346. public color: string;
  10347. @SomeAnnotation('optionalParameter')
  10348. tail: boolean;
  10349. }
  10350. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["ClassProperty"]}]
  10351. // Message: Missing JSDoc comment.
  10352. @Entity('users')
  10353. export class User {}
  10354. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true}}]
  10355. // Message: Missing JSDoc comment.
  10356. /**
  10357. *
  10358. */
  10359. class Foo {
  10360. constructor() {}
  10361. }
  10362. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyConstructors":false,"require":{"MethodDefinition":true}}]
  10363. // Message: Missing JSDoc comment.
  10364. /**
  10365. *
  10366. */
  10367. class Foo {
  10368. constructor(notEmpty) {}
  10369. }
  10370. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyConstructors":true,"require":{"MethodDefinition":true}}]
  10371. // Message: Missing JSDoc comment.
  10372. /**
  10373. *
  10374. */
  10375. class Foo {
  10376. constructor() {
  10377. const notEmpty = true;
  10378. return notEmpty;
  10379. }
  10380. }
  10381. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyConstructors":true,"require":{"MethodDefinition":true}}]
  10382. // Message: Missing JSDoc comment.
  10383. /**
  10384. *
  10385. */
  10386. function quux() {
  10387. }
  10388. // Settings: {"jsdoc":{"structuredTags":{"see":{"name":false,"required":["name"]}}}}
  10389. // Message: Cannot add "name" to `require` with the tag's `name` set to `false`
  10390. class Test {
  10391. aFunc() {}
  10392. }
  10393. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkConstructors":false,"require":{"ArrowFunctionExpression":true,"ClassDeclaration":false,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":true,"MethodDefinition":true}}]
  10394. // Message: Missing JSDoc comment.
  10395. class Test {
  10396. aFunc = () => {}
  10397. anotherFunc() {}
  10398. }
  10399. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":true,"ClassDeclaration":false,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":true,"MethodDefinition":true}}]
  10400. // Message: Missing JSDoc comment.
  10401. export enum testEnum {
  10402. A, B
  10403. }
  10404. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSEnumDeclaration"],"publicOnly":true}]
  10405. // Message: Missing JSDoc comment.
  10406. export interface Test {
  10407. aFunc: () => void;
  10408. aVar: string;
  10409. }
  10410. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration"],"publicOnly":true}]
  10411. // Message: Missing JSDoc comment.
  10412. export type testType = string | number;
  10413. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSTypeAliasDeclaration"],"publicOnly":true}]
  10414. // Message: Missing JSDoc comment.
  10415. export interface Foo {
  10416. bar: number;
  10417. baz: string;
  10418. quux(): void;
  10419. }
  10420. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSPropertySignature","TSMethodSignature"],"publicOnly":true}]
  10421. // Message: Missing JSDoc comment.
  10422. export class MyComponentComponent {
  10423. @Output()
  10424. public changed = new EventEmitter();
  10425. public test = 'test';
  10426. @Input()
  10427. public value = new EventEmitter();
  10428. }
  10429. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["ClassProperty:has(Decorator[expression.callee.name=\"Input\"])"]}]
  10430. // Message: Missing JSDoc comment.
  10431. requestAnimationFrame(draw)
  10432. function bench() {
  10433. }
  10434. // Message: Missing JSDoc comment.
  10435. class Foo {
  10436. set aName (val) {}
  10437. }
  10438. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkSetters":"no-getter","contexts":["MethodDefinition > FunctionExpression"]}]
  10439. // Message: Missing JSDoc comment.
  10440. class Foo {
  10441. get aName () {}
  10442. }
  10443. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkGetters":"no-setter","contexts":["MethodDefinition > FunctionExpression"]}]
  10444. // Message: Missing JSDoc comment.
  10445. const obj = {
  10446. get aName () {},
  10447. }
  10448. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkGetters":"no-setter","contexts":["Property > FunctionExpression"]}]
  10449. // Message: Missing JSDoc comment.
  10450. function comment () {
  10451. return "comment";
  10452. }
  10453. // "jsdoc/require-jsdoc": ["error"|"warn", {"enableFixer":true,"fixerMessage":" TODO: add comment"}]
  10454. // Message: Missing JSDoc comment.
  10455. function comment () {
  10456. return "comment";
  10457. }
  10458. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["any",{"context":"FunctionDeclaration","inlineCommentBlock":true}],"fixerMessage":"TODO: add comment "}]
  10459. // Message: Missing JSDoc comment.
  10460. function comment () {
  10461. return "comment";
  10462. }
  10463. // "jsdoc/require-jsdoc": ["error"|"warn", {"enableFixer":false,"fixerMessage":" TODO: add comment"}]
  10464. // Message: Missing JSDoc comment.
  10465. ````
  10466. The following patterns are not considered problems:
  10467. ````js
  10468. interface FooBar {
  10469. fooBar: string;
  10470. }
  10471. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration","TSMethodSignature","TSPropertySignature"],"publicOnly":{"ancestorsOnly":true}}]
  10472. /** This is comment */
  10473. interface FooBar {
  10474. fooBar: string;
  10475. }
  10476. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration","TSMethodSignature","TSPropertySignature"],"publicOnly":{"ancestorsOnly":true}}]
  10477. /** This is comment */
  10478. export class Foo {
  10479. someMethod() {
  10480. interface FooBar {
  10481. fooBar: string;
  10482. }
  10483. }
  10484. }
  10485. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration","TSMethodSignature","TSPropertySignature"],"publicOnly":{"ancestorsOnly":true}}]
  10486. /** This is comment */
  10487. function someFunciton() {
  10488. interface FooBar {
  10489. fooBar: string;
  10490. }
  10491. }
  10492. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration","TSMethodSignature","TSPropertySignature"],"publicOnly":{"ancestorsOnly":true}}]
  10493. /** This is comment */
  10494. export function foo() {
  10495. interface bar {
  10496. fooBar: string;
  10497. }
  10498. }
  10499. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration","TSMethodSignature","TSPropertySignature"],"publicOnly":{"ancestorsOnly":true}}]
  10500. /**
  10501. *
  10502. */
  10503. var array = [1,2,3];
  10504. array.forEach(function() {});
  10505. /**
  10506. * @class MyClass
  10507. **/
  10508. function MyClass() {}
  10509. /**
  10510. Function doing something
  10511. */
  10512. function myFunction() {}
  10513. /**
  10514. Function doing something
  10515. */
  10516. var myFunction = function() {};
  10517. /**
  10518. Function doing something
  10519. */
  10520. Object.myFunction = function () {};
  10521. var obj = {
  10522. /**
  10523. * Function doing something
  10524. **/
  10525. myFunction: function () {} };
  10526. /**
  10527. @func myFunction
  10528. */
  10529. function myFunction() {}
  10530. /**
  10531. @method myFunction
  10532. */
  10533. function myFunction() {}
  10534. /**
  10535. @function myFunction
  10536. */
  10537. function myFunction() {}
  10538. /**
  10539. @func myFunction
  10540. */
  10541. var myFunction = function () {}
  10542. /**
  10543. @method myFunction
  10544. */
  10545. var myFunction = function () {}
  10546. /**
  10547. @function myFunction
  10548. */
  10549. var myFunction = function () {}
  10550. /**
  10551. @func myFunction
  10552. */
  10553. Object.myFunction = function() {}
  10554. /**
  10555. @method myFunction
  10556. */
  10557. Object.myFunction = function() {}
  10558. /**
  10559. @function myFunction
  10560. */
  10561. Object.myFunction = function() {}
  10562. (function(){})();
  10563. var object = {
  10564. /**
  10565. * @func myFunction - Some function
  10566. */
  10567. myFunction: function() {} }
  10568. var object = {
  10569. /**
  10570. * @method myFunction - Some function
  10571. */
  10572. myFunction: function() {} }
  10573. var object = {
  10574. /**
  10575. * @function myFunction - Some function
  10576. */
  10577. myFunction: function() {} }
  10578. var array = [1,2,3];
  10579. array.filter(function() {});
  10580. Object.keys(this.options.rules || {}).forEach(function(name) {}.bind(this));
  10581. var object = { name: 'key'};
  10582. Object.keys(object).forEach(function() {})
  10583. /**
  10584. * @func myFunction
  10585. */
  10586. function myFunction() {
  10587. }
  10588. // Settings: {"jsdoc":{"maxLines":2,"minLines":0}}
  10589. /**
  10590. * @func myFunction
  10591. */
  10592. function myFunction() {
  10593. }
  10594. // Settings: {"jsdoc":{"maxLines":3,"minLines":0}}
  10595. /** @func myFunction */ function myFunction() {
  10596. }
  10597. // Settings: {"jsdoc":{"maxLines":0,"minLines":0}}
  10598. /**
  10599. * @func myFunction
  10600. */
  10601. function myFunction() {
  10602. }
  10603. // Settings: {"jsdoc":{"maxLines":3,"minLines":2}}
  10604. function myFunction() {}
  10605. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true,"FunctionDeclaration":false,"MethodDefinition":true}}]
  10606. var myFunction = function() {}
  10607. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true,"FunctionDeclaration":false,"MethodDefinition":true}}]
  10608. /**
  10609. * Description for A.
  10610. */
  10611. class A {
  10612. /**
  10613. * Description for constructor.
  10614. * @param {object[]} xs - xs
  10615. */
  10616. constructor(xs) {
  10617. this.a = xs;
  10618. }
  10619. }
  10620. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
  10621. /**
  10622. * Description for A.
  10623. */
  10624. class App extends Component {
  10625. /**
  10626. * Description for constructor.
  10627. * @param {object[]} xs - xs
  10628. */
  10629. constructor(xs) {
  10630. this.a = xs;
  10631. }
  10632. }
  10633. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
  10634. /**
  10635. * Description for A.
  10636. */
  10637. export default class App extends Component {
  10638. /**
  10639. * Description for constructor.
  10640. * @param {object[]} xs - xs
  10641. */
  10642. constructor(xs) {
  10643. this.a = xs;
  10644. }
  10645. }
  10646. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
  10647. /**
  10648. * Description for A.
  10649. */
  10650. export class App extends Component {
  10651. /**
  10652. * Description for constructor.
  10653. * @param {object[]} xs - xs
  10654. */
  10655. constructor(xs) {
  10656. this.a = xs;
  10657. }
  10658. }
  10659. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
  10660. class A {
  10661. constructor(xs) {
  10662. this.a = xs;
  10663. }
  10664. }
  10665. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":false,"MethodDefinition":false}}]
  10666. /**
  10667. * Function doing something
  10668. */
  10669. var myFunction = () => {}
  10670. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":true}}]
  10671. /**
  10672. * Function doing something
  10673. */
  10674. var myFunction = function () {}
  10675. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":true}}]
  10676. /**
  10677. * Function doing something
  10678. */
  10679. var myFunction = () => {}
  10680. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":false}}]
  10681. /**
  10682. Function doing something
  10683. */
  10684. var myFunction = () => () => {}
  10685. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":true}}]
  10686. setTimeout(() => {}, 10);
  10687. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":true}}]
  10688. /**
  10689. JSDoc Block
  10690. */
  10691. var foo = function() {}
  10692. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"FunctionExpression":true}}]
  10693. const foo = {/**
  10694. JSDoc Block
  10695. */
  10696. bar() {}}
  10697. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"FunctionExpression":true}}]
  10698. var foo = {/**
  10699. JSDoc Block
  10700. */
  10701. bar: function() {}}
  10702. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"FunctionExpression":true}}]
  10703. var foo = { [function() {}]: 1 };
  10704. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"FunctionExpression":true}}]
  10705. function foo () {}
  10706. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyFunctions":true}]
  10707. function foo () {
  10708. return;
  10709. }
  10710. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyFunctions":true}]
  10711. const test = {};
  10712. /**
  10713. * test
  10714. */
  10715. test.method = function () {
  10716. }
  10717. module.exports = {
  10718. prop: { prop2: test.method }
  10719. }
  10720. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10721. /**
  10722. *
  10723. */
  10724. function test() {
  10725. }
  10726. module.exports = {
  10727. prop: { prop2: test }
  10728. }
  10729. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10730. /**
  10731. *
  10732. */
  10733. test = function() {
  10734. }
  10735. module.exports = {
  10736. prop: { prop2: test }
  10737. }
  10738. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionExpression":true}}]
  10739. /**
  10740. *
  10741. */
  10742. test = function() {
  10743. }
  10744. exports.someMethod = {
  10745. prop: { prop2: test }
  10746. }
  10747. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
  10748. /**
  10749. *
  10750. */
  10751. const test = () => {
  10752. }
  10753. module.exports = {
  10754. prop: { prop2: test }
  10755. }
  10756. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
  10757. const test = () => {
  10758. }
  10759. module.exports = {
  10760. prop: { prop2: test }
  10761. }
  10762. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"ancestorsOnly":true},"require":{"ArrowFunctionExpression":true}}]
  10763. /**
  10764. *
  10765. */
  10766. window.test = function() {
  10767. }
  10768. module.exports = {
  10769. prop: window
  10770. }
  10771. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10772. test = function() {
  10773. }
  10774. /**
  10775. *
  10776. */
  10777. test = function() {
  10778. }
  10779. module.exports = {
  10780. prop: { prop2: test }
  10781. }
  10782. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10783. test = function() {
  10784. }
  10785. test = 2;
  10786. module.exports = {
  10787. prop: { prop2: test }
  10788. }
  10789. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10790. /**
  10791. *
  10792. */
  10793. function test() {
  10794. }
  10795. /**
  10796. *
  10797. */
  10798. test.prototype.method = function() {
  10799. }
  10800. module.exports = {
  10801. prop: { prop2: test }
  10802. }
  10803. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10804. class Test {
  10805. /**
  10806. * Test
  10807. */
  10808. method() {
  10809. }
  10810. }
  10811. module.exports = Test;
  10812. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"MethodDefinition":true}}]
  10813. /**
  10814. *
  10815. */
  10816. export default function quux () {
  10817. }
  10818. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10819. /**
  10820. *
  10821. */
  10822. export default function quux () {
  10823. }
  10824. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
  10825. /**
  10826. *
  10827. */
  10828. function quux () {
  10829. }
  10830. export default quux;
  10831. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10832. function quux () {
  10833. }
  10834. export default quux;
  10835. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
  10836. /**
  10837. *
  10838. */
  10839. export function test() {
  10840. }
  10841. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10842. /**
  10843. *
  10844. */
  10845. export function test() {
  10846. }
  10847. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
  10848. /**
  10849. *
  10850. */
  10851. var test = function () {
  10852. }
  10853. var test2 = 2;
  10854. export { test, test2 }
  10855. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10856. /**
  10857. *
  10858. */
  10859. var test = function () {
  10860. }
  10861. export { test as test2 }
  10862. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10863. /**
  10864. *
  10865. */
  10866. export default class A {
  10867. }
  10868. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"ancestorsOnly":true},"require":{"ClassDeclaration":true}}]
  10869. /**
  10870. *
  10871. */
  10872. var test = function () {
  10873. }
  10874. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
  10875. let test = function () {
  10876. }
  10877. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
  10878. let test = class {
  10879. }
  10880. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"ClassExpression":false}}]
  10881. /**
  10882. *
  10883. */
  10884. let test = class {
  10885. }
  10886. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"ClassExpression":true}}]
  10887. export function someMethod() {
  10888. }
  10889. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionDeclaration":true}}]
  10890. export function someMethod() {
  10891. }
  10892. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionDeclaration":true}}]
  10893. exports.someMethod = function() {
  10894. }
  10895. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
  10896. const myObject = {
  10897. myProp: true
  10898. };
  10899. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":[]}]
  10900. function bear() {}
  10901. /**
  10902. *
  10903. */
  10904. function quux () {
  10905. }
  10906. export default quux;
  10907. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true,"require":{"FunctionExpression":true}}]
  10908. /**
  10909. * This example interface is great!
  10910. */
  10911. export interface Example {
  10912. /**
  10913. * My super test string!
  10914. */
  10915. test: string
  10916. }
  10917. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration"]}]
  10918. /**
  10919. * This example interface is great!
  10920. */
  10921. interface Example {
  10922. /**
  10923. * My super test string!
  10924. */
  10925. test: string
  10926. }
  10927. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSInterfaceDeclaration"]}]
  10928. /**
  10929. * This example type is great!
  10930. */
  10931. export type Example = {
  10932. /**
  10933. * My super test string!
  10934. */
  10935. test: string
  10936. };
  10937. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSTypeAliasDeclaration"]}]
  10938. /**
  10939. * This example type is great!
  10940. */
  10941. type Example = {
  10942. /**
  10943. * My super test string!
  10944. */
  10945. test: string
  10946. };
  10947. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSTypeAliasDeclaration"]}]
  10948. /**
  10949. * This example enum is great!
  10950. */
  10951. export enum Example {
  10952. /**
  10953. * My super test enum!
  10954. */
  10955. test = 123
  10956. }
  10957. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSEnumDeclaration"]}]
  10958. /**
  10959. * This example enum is great!
  10960. */
  10961. enum Example {
  10962. /**
  10963. * My super test enum!
  10964. */
  10965. test = 123
  10966. }
  10967. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSEnumDeclaration"]}]
  10968. const foo = {...{}};
  10969. function bar() {}
  10970. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyFunctions":false,"publicOnly":true,"require":{"ArrowFunctionExpression":true,"ClassDeclaration":true,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":false,"MethodDefinition":true}}]
  10971. /**
  10972. * Class documentation
  10973. */
  10974. @logged
  10975. export default class Foo {
  10976. // ....
  10977. }
  10978. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyFunctions":false,"require":{"ClassDeclaration":true}}]
  10979. const a = {};
  10980. const b = {
  10981. ...a
  10982. };
  10983. export default b;
  10984. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["ObjectExpression"],"exemptEmptyFunctions":false,"publicOnly":true}]
  10985. /**
  10986. * Foo interface documentation.
  10987. */
  10988. export interface Foo extends Bar {
  10989. /**
  10990. * baz method documentation.
  10991. */
  10992. baz(): void;
  10993. /**
  10994. * meow method documentation.
  10995. */
  10996. meow(): void;
  10997. }
  10998. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSMethodSignature"]}]
  10999. export default class Test {
  11000. private abc(a) {
  11001. this.a = a;
  11002. }
  11003. }
  11004. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["MethodDefinition:not([accessibility=\"private\"]) > FunctionExpression"],"publicOnly":true,"require":{"ArrowFunctionExpression":false,"ClassDeclaration":false,"ClassExpression":false,"FunctionDeclaration":false,"FunctionExpression":false,"MethodDefinition":false}}]
  11005. /**
  11006. * Basic application controller.
  11007. */
  11008. @Controller()
  11009. export class AppController {
  11010. /**
  11011. * Returns the application information.
  11012. *
  11013. * @returns ...
  11014. */
  11015. @Get('/info')
  11016. public getInfo(): string {
  11017. return 'OK';
  11018. }
  11019. }
  11020. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":false,"ClassDeclaration":true,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":false,"MethodDefinition":true}}]
  11021. /**
  11022. * Entity to represent a user in the system.
  11023. */
  11024. @Entity('users')
  11025. export class User {
  11026. }
  11027. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":false,"ClassDeclaration":true,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":false,"MethodDefinition":true}}]
  11028. /**
  11029. * Entity to represent a user in the system.
  11030. */
  11031. @Entity('users', getVal())
  11032. export class User {
  11033. }
  11034. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ArrowFunctionExpression":false,"ClassDeclaration":true,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":false,"MethodDefinition":true}}]
  11035. /**
  11036. *
  11037. */
  11038. class Foo {
  11039. constructor() {}
  11040. }
  11041. // "jsdoc/require-jsdoc": ["error"|"warn", {"exemptEmptyConstructors":true,"require":{"MethodDefinition":true}}]
  11042. /**
  11043. *
  11044. */
  11045. class Foo {
  11046. constructor() {}
  11047. }
  11048. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkConstructors":false,"require":{"MethodDefinition":true}}]
  11049. class Foo {
  11050. get aName () {}
  11051. set aName (val) {}
  11052. }
  11053. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkGetters":"no-setter","checkSetters":false,"contexts":["MethodDefinition > FunctionExpression"]}]
  11054. const obj = {
  11055. get aName () {},
  11056. set aName (val) {}
  11057. }
  11058. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkGetters":"no-setter","checkSetters":false,"contexts":["Property > FunctionExpression"]}]
  11059. class Foo {
  11060. set aName (val) {}
  11061. }
  11062. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkSetters":false,"contexts":["MethodDefinition > FunctionExpression"]}]
  11063. class Foo {
  11064. get aName () {}
  11065. }
  11066. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkGetters":false,"contexts":["MethodDefinition > FunctionExpression"]}]
  11067. class Foo {
  11068. /**
  11069. *
  11070. */
  11071. set aName (val) {}
  11072. }
  11073. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkSetters":"no-getter","contexts":["MethodDefinition > FunctionExpression"]}]
  11074. class Foo {
  11075. /**
  11076. *
  11077. */
  11078. get aName () {}
  11079. }
  11080. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkGetters":"no-setter","contexts":["MethodDefinition > FunctionExpression"]}]
  11081. class Foo {
  11082. get aName () {}
  11083. set aName (val) {}
  11084. }
  11085. // "jsdoc/require-jsdoc": ["error"|"warn", {"checkGetters":false,"checkSetters":"no-getter","contexts":["MethodDefinition > FunctionExpression"]}]
  11086. class Base {
  11087. constructor() {
  11088. }
  11089. }
  11090. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["MethodDefinition"],"exemptEmptyConstructors":true}]
  11091. /**
  11092. * This is a text.
  11093. */
  11094. export function a(); // Reports an error
  11095. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["TSDeclareFunction"],"require":{"FunctionDeclaration":true}}]
  11096. /**
  11097. * Foo
  11098. */
  11099. export function foo(): void {
  11100. function bar(): void {
  11101. console.log('bar');
  11102. }
  11103. console.log('foo');
  11104. }
  11105. // "jsdoc/require-jsdoc": ["error"|"warn", {"publicOnly":true}]
  11106. const foo = {
  11107. bar: () => {
  11108. // ...
  11109. }
  11110. }
  11111. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":[":not(Property) > ArrowFunctionExpression"],"require":{"ArrowFunctionExpression":false,"ClassDeclaration":true,"ClassExpression":true}}]
  11112. /** Defines the current user's settings. */
  11113. @Injectable({
  11114. providedIn: 'root',
  11115. })
  11116. @State<Partial<UserSettingsStateModel>>
  11117. ({
  11118. name: 'userSettings',
  11119. defaults: {
  11120. isDev: !environment.production,
  11121. },
  11122. })
  11123. export class UserSettingsState { }
  11124. // "jsdoc/require-jsdoc": ["error"|"warn", {"require":{"ClassDeclaration":true}}]
  11125. /**
  11126. * Entity to represent a user in the system.
  11127. */
  11128. @Entity('users')
  11129. export class User {
  11130. }
  11131. // "jsdoc/require-jsdoc": ["error"|"warn", {"contexts":["Decorator"],"require":{"FunctionDeclaration":false}}]
  11132. ````
  11133. <a name="eslint-plugin-jsdoc-rules-require-param-description"></a>
  11134. ### <code>require-param-description</code>
  11135. Requires that each `@param` tag has a `description` value.
  11136. <a name="eslint-plugin-jsdoc-rules-require-param-description-options-29"></a>
  11137. #### Options
  11138. <a name="eslint-plugin-jsdoc-rules-require-param-description-options-29-contexts-8"></a>
  11139. ##### <code>contexts</code>
  11140. Set this to an array of strings representing the AST context (or an object with
  11141. `context` and `comment` properties) where you wish the rule to be applied.
  11142. Overrides the default contexts (see below). Set to `"any"` if you want
  11143. the rule to apply to any jsdoc block throughout your files (as is necessary
  11144. for finding function blocks not attached to a function declaration or
  11145. expression, i.e., `@callback` or `@function` (or its aliases `@func` or
  11146. `@method`) (including those associated with an `@interface`).
  11147. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  11148. section of our README for more on the expected format.
  11149. |||
  11150. |---|---|
  11151. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
  11152. |Tags|`param`|
  11153. |Aliases|`arg`, `argument`|
  11154. |Recommended|true|
  11155. |Options|`contexts`|
  11156. The following patterns are considered problems:
  11157. ````js
  11158. /**
  11159. * @param foo
  11160. */
  11161. function quux (foo) {
  11162. }
  11163. // Message: Missing JSDoc @param "foo" description.
  11164. /**
  11165. * @param foo
  11166. */
  11167. function quux (foo) {
  11168. }
  11169. // "jsdoc/require-param-description": ["error"|"warn", {"contexts":["any"]}]
  11170. // Message: Missing JSDoc @param "foo" description.
  11171. /**
  11172. * @function
  11173. * @param foo
  11174. */
  11175. // "jsdoc/require-param-description": ["error"|"warn", {"contexts":["any"]}]
  11176. // Message: Missing JSDoc @param "foo" description.
  11177. /**
  11178. * @callback
  11179. * @param foo
  11180. */
  11181. // "jsdoc/require-param-description": ["error"|"warn", {"contexts":["any"]}]
  11182. // Message: Missing JSDoc @param "foo" description.
  11183. /**
  11184. * @arg foo
  11185. */
  11186. function quux (foo) {
  11187. }
  11188. // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
  11189. // Message: Missing JSDoc @arg "foo" description.
  11190. /**
  11191. * @param foo
  11192. */
  11193. function quux (foo) {
  11194. }
  11195. // Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
  11196. // Message: Unexpected tag `@param`
  11197. ````
  11198. The following patterns are not considered problems:
  11199. ````js
  11200. /**
  11201. *
  11202. */
  11203. function quux (foo) {
  11204. }
  11205. /**
  11206. * @param foo Foo.
  11207. */
  11208. function quux (foo) {
  11209. }
  11210. /**
  11211. * @param foo Foo.
  11212. */
  11213. function quux (foo) {
  11214. }
  11215. // "jsdoc/require-param-description": ["error"|"warn", {"contexts":["any"]}]
  11216. /**
  11217. * @function
  11218. * @param foo
  11219. */
  11220. /**
  11221. * @callback
  11222. * @param foo
  11223. */
  11224. ````
  11225. <a name="eslint-plugin-jsdoc-rules-require-param-name"></a>
  11226. ### <code>require-param-name</code>
  11227. Requires that all function parameters have names.
  11228. > The `@param` tag requires you to specify the name of the parameter you are documenting. You can also include the parameter's type, enclosed in curly brackets, and a description of the parameter.
  11229. >
  11230. > [JSDoc](https://jsdoc.app/tags-param.html#overview)
  11231. <a name="eslint-plugin-jsdoc-rules-require-param-name-options-30"></a>
  11232. #### Options
  11233. <a name="eslint-plugin-jsdoc-rules-require-param-name-options-30-contexts-9"></a>
  11234. ##### <code>contexts</code>
  11235. Set this to an array of strings representing the AST context (or an object with
  11236. `context` and `comment` properties) where you wish the rule to be applied.
  11237. Overrides the default contexts (see below). Set to `"any"` if you want
  11238. the rule to apply to any jsdoc block throughout your files (as is necessary
  11239. for finding function blocks not attached to a function declaration or
  11240. expression, i.e., `@callback` or `@function` (or its aliases `@func` or
  11241. `@method`) (including those associated with an `@interface`).
  11242. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  11243. section of our README for more on the expected format.
  11244. |||
  11245. |---|---|
  11246. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
  11247. |Tags|`param`|
  11248. |Aliases|`arg`, `argument`|
  11249. |Recommended|true|
  11250. |Options|`contexts`|
  11251. The following patterns are considered problems:
  11252. ````js
  11253. /**
  11254. * @param
  11255. */
  11256. function quux (foo) {
  11257. }
  11258. // Message: There must be an identifier after @param type.
  11259. /**
  11260. * @param {string}
  11261. */
  11262. function quux (foo) {
  11263. }
  11264. // Message: There must be an identifier after @param tag.
  11265. /**
  11266. * @param {string}
  11267. */
  11268. function quux (foo) {
  11269. }
  11270. // "jsdoc/require-param-name": ["error"|"warn", {"contexts":["any"]}]
  11271. // Message: There must be an identifier after @param tag.
  11272. /**
  11273. * @function
  11274. * @param {string}
  11275. */
  11276. // "jsdoc/require-param-name": ["error"|"warn", {"contexts":["any"]}]
  11277. // Message: There must be an identifier after @param tag.
  11278. /**
  11279. * @callback
  11280. * @param {string}
  11281. */
  11282. // "jsdoc/require-param-name": ["error"|"warn", {"contexts":["any"]}]
  11283. // Message: There must be an identifier after @param tag.
  11284. /**
  11285. * @param foo
  11286. */
  11287. function quux (foo) {
  11288. }
  11289. // Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
  11290. // Message: Unexpected tag `@param`
  11291. ````
  11292. The following patterns are not considered problems:
  11293. ````js
  11294. /**
  11295. * @param foo
  11296. */
  11297. function quux (foo) {
  11298. }
  11299. /**
  11300. * @param foo
  11301. */
  11302. function quux (foo) {
  11303. }
  11304. // "jsdoc/require-param-name": ["error"|"warn", {"contexts":["any"]}]
  11305. /**
  11306. * @param {string} foo
  11307. */
  11308. function quux (foo) {
  11309. }
  11310. /**
  11311. * @function
  11312. * @param
  11313. */
  11314. /**
  11315. * @callback
  11316. * @param
  11317. */
  11318. /**
  11319. * @param {Function} [processor=data => data] A function to run
  11320. */
  11321. function processData(processor) {
  11322. return processor(data)
  11323. }
  11324. /** Example with multi-line param type.
  11325. *
  11326. * @param {function(
  11327. * number
  11328. * )} cb Callback.
  11329. */
  11330. function example(cb) {
  11331. cb(42);
  11332. }
  11333. ````
  11334. <a name="eslint-plugin-jsdoc-rules-require-param-type"></a>
  11335. ### <code>require-param-type</code>
  11336. Requires that each `@param` tag has a `type` value.
  11337. <a name="eslint-plugin-jsdoc-rules-require-param-type-options-31"></a>
  11338. #### Options
  11339. <a name="eslint-plugin-jsdoc-rules-require-param-type-options-31-contexts-10"></a>
  11340. ##### <code>contexts</code>
  11341. Set this to an array of strings representing the AST context (or an object with
  11342. `context` and `comment` properties) where you wish the rule to be applied.
  11343. Overrides the default contexts (see below). Set to `"any"` if you want
  11344. the rule to apply to any jsdoc block throughout your files (as is necessary
  11345. for finding function blocks not attached to a function declaration or
  11346. expression, i.e., `@callback` or `@function` (or its aliases `@func` or
  11347. `@method`) (including those associated with an `@interface`).
  11348. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  11349. section of our README for more on the expected format.
  11350. |||
  11351. |---|---|
  11352. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
  11353. |Tags|`param`|
  11354. |Aliases|`arg`, `argument`|
  11355. |Recommended|true|
  11356. |Options|`contexts`|
  11357. The following patterns are considered problems:
  11358. ````js
  11359. /**
  11360. * @param foo
  11361. */
  11362. function quux (foo) {
  11363. }
  11364. // Message: Missing JSDoc @param "foo" type.
  11365. /**
  11366. * @param foo
  11367. */
  11368. function quux (foo) {
  11369. }
  11370. // "jsdoc/require-param-type": ["error"|"warn", {"contexts":["any"]}]
  11371. // Message: Missing JSDoc @param "foo" type.
  11372. /**
  11373. * @function
  11374. * @param foo
  11375. */
  11376. // "jsdoc/require-param-type": ["error"|"warn", {"contexts":["any"]}]
  11377. // Message: Missing JSDoc @param "foo" type.
  11378. /**
  11379. * @callback
  11380. * @param foo
  11381. */
  11382. // "jsdoc/require-param-type": ["error"|"warn", {"contexts":["any"]}]
  11383. // Message: Missing JSDoc @param "foo" type.
  11384. /**
  11385. * @arg foo
  11386. */
  11387. function quux (foo) {
  11388. }
  11389. // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
  11390. // Message: Missing JSDoc @arg "foo" type.
  11391. /**
  11392. * @param foo
  11393. */
  11394. function quux (foo) {
  11395. }
  11396. // Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
  11397. // Message: Unexpected tag `@param`
  11398. ````
  11399. The following patterns are not considered problems:
  11400. ````js
  11401. /**
  11402. *
  11403. */
  11404. function quux (foo) {
  11405. }
  11406. /**
  11407. * @param {number} foo
  11408. */
  11409. function quux (foo) {
  11410. }
  11411. /**
  11412. * @param {number} foo
  11413. */
  11414. function quux (foo) {
  11415. }
  11416. // "jsdoc/require-param-type": ["error"|"warn", {"contexts":["any"]}]
  11417. /**
  11418. * @function
  11419. * @param foo
  11420. */
  11421. /**
  11422. * @callback
  11423. * @param foo
  11424. */
  11425. ````
  11426. <a name="eslint-plugin-jsdoc-rules-require-param"></a>
  11427. ### <code>require-param</code>
  11428. Requires that all function parameters are documented.
  11429. <a name="eslint-plugin-jsdoc-rules-require-param-fixer-1"></a>
  11430. #### Fixer
  11431. Adds `@param <name>` for each tag present in the function signature but
  11432. missing in the jsdoc. Can be disabled by setting the `enableFixer`
  11433. option to `false`.
  11434. <a name="eslint-plugin-jsdoc-rules-require-param-fixer-1-destructured-object-and-array-naming"></a>
  11435. ##### Destructured object and array naming
  11436. When the fixer is applied to destructured objects, only the input name is
  11437. used.
  11438. So for:
  11439. ```js
  11440. /**
  11441. * @param cfg
  11442. */
  11443. function quux ({foo: bar, baz: bax = 5}) {
  11444. }
  11445. ```
  11446. ..the fixed jsdoc will be:
  11447. ```js
  11448. /**
  11449. * @param cfg
  11450. * @param cfg.foo
  11451. * @param cfg.baz
  11452. */
  11453. ```
  11454. This is because the input to the function is the relevant item for
  11455. understanding the function's input, not how the variable is renamed
  11456. for internal use (the signature itself documents that).
  11457. For destructured arrays, the input name is merely the array index.
  11458. So for:
  11459. ```js
  11460. /**
  11461. * @param cfg
  11462. */
  11463. function quux ([foo, bar]) {
  11464. }
  11465. ```
  11466. ..the fixed jsdoc will be:
  11467. ```js
  11468. /**
  11469. * @param cfg
  11470. * @param cfg."0"
  11471. * @param cfg."1"
  11472. */
  11473. ```
  11474. <a name="eslint-plugin-jsdoc-rules-require-param-fixer-1-missing-root-fixing"></a>
  11475. ##### Missing root fixing
  11476. Note that unless `enableRootFixer` (or `enableFixer`) is set to `false`,
  11477. missing roots will be added and auto-incremented. The default behavior
  11478. is for "root" to be auto-inserted for missing roots, followed by a
  11479. 0-based auto-incrementing number.
  11480. So for:
  11481. ```js
  11482. function quux ({foo}, {bar}, {baz}) {
  11483. }
  11484. ```
  11485. ...the default jsdoc that would be added if the fixer is enabled would be:
  11486. ```js
  11487. /**
  11488. * @param root0
  11489. * @param root0.foo
  11490. * @param root1
  11491. * @param root1.bar
  11492. * @param root2
  11493. * @param root2.baz
  11494. */
  11495. ```
  11496. The name of "root" can be configured with `unnamedRootBase` (which also allows
  11497. cycling through a list of multiple root names before there is need for any
  11498. numeric component).
  11499. And one can have the count begin at another number (e.g., `1`) by changing
  11500. `autoIncrementBase` from the default of `0`.
  11501. <a name="eslint-plugin-jsdoc-rules-require-param-fixer-1-rest-element-restelement-insertions"></a>
  11502. ##### Rest Element (<code>RestElement</code>) insertions
  11503. The fixer will automatically report/insert
  11504. [jsdoc repeatable parameters](https://jsdoc.app/tags-param.html#multiple-types-and-repeatable-parameters)
  11505. if missing.
  11506. ```js
  11507. /**
  11508. * @param {GenericArray} cfg
  11509. * @param {number} cfg."0"
  11510. */
  11511. function baar ([a, ...extra]) {
  11512. //
  11513. }
  11514. ```
  11515. ..becomes:
  11516. ```js
  11517. /**
  11518. * @param {GenericArray} cfg
  11519. * @param {number} cfg."0"
  11520. * @param {...any} cfg."1"
  11521. */
  11522. function baar ([a, ...extra]) {
  11523. //
  11524. }
  11525. ```
  11526. Note that the type `any` is included since we don't know of any specific
  11527. type to use.
  11528. To disable such rest element insertions, set `enableRestElementFixer` to
  11529. `false`.
  11530. Note too that the following will be reported even though there is an item
  11531. corresponding to `extra`:
  11532. ```js
  11533. /**
  11534. * @param {GenericArray} cfg
  11535. * @param {number} cfg."0"
  11536. * @param {any} cfg."1"
  11537. */
  11538. function baar ([a, ...extra]) {
  11539. //
  11540. }
  11541. ```
  11542. ...because it does not use the `...` syntax in the type.
  11543. <a name="eslint-plugin-jsdoc-rules-require-param-fixer-1-object-rest-property-insertions"></a>
  11544. ##### Object Rest Property insertions
  11545. If the `checkRestProperty` option is set to `true` (`false` by default),
  11546. missing rest properties will be reported with documentation auto-inserted:
  11547. ```js
  11548. /**
  11549. * @param cfg
  11550. * @param cfg.num
  11551. */
  11552. function quux ({num, ...extra}) {
  11553. }
  11554. ```
  11555. ...becomes:
  11556. ```js
  11557. /**
  11558. * @param cfg
  11559. * @param cfg.num
  11560. * @param cfg.extra
  11561. */
  11562. function quux ({num, ...extra}) {
  11563. }
  11564. ```
  11565. You may wish to manually note in your jsdoc for `extra` that this is a
  11566. rest property, however, as jsdoc
  11567. [does not appear](https://github.com/jsdoc/jsdoc/issues/1773)
  11568. to currently support syntax or output to distinguish rest properties from
  11569. other properties, so in looking at the docs alone without looking at the
  11570. function signature, it may appear that there is an actual property named
  11571. `extra`.
  11572. <a name="eslint-plugin-jsdoc-rules-require-param-options-32"></a>
  11573. #### Options
  11574. An options object accepts the following optional properties:
  11575. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-enablefixer-3"></a>
  11576. ##### <code>enableFixer</code>
  11577. Whether to enable the fixer. Defaults to `true`.
  11578. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-enablerootfixer"></a>
  11579. ##### <code>enableRootFixer</code>
  11580. Whether to enable the auto-adding of incrementing roots (see the "Fixer"
  11581. section). Defaults to `true`. Has no effect if `enableFixer` is set to
  11582. `false`.
  11583. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-enablerestelementfixer"></a>
  11584. ##### <code>enableRestElementFixer</code>
  11585. Whether to enable the rest element fixer (see
  11586. "Rest Element (`RestElement`) insertions"). Defaults to `true`.
  11587. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-checkrestproperty-1"></a>
  11588. ##### <code>checkRestProperty</code>
  11589. If set to `true`, will report (and add fixer insertions) for missing rest
  11590. properties. Defaults to `false`.
  11591. If set to `true`, note that you can still document the subproperties of the
  11592. rest property using other jsdoc features, e.g., `@typedef`:
  11593. ```js
  11594. /**
  11595. * @typedef ExtraOptions
  11596. * @property innerProp1
  11597. * @property innerProp2
  11598. */
  11599. /**
  11600. * @param cfg
  11601. * @param cfg.num
  11602. * @param {ExtraOptions} extra
  11603. */
  11604. function quux ({num, ...extra}) {
  11605. }
  11606. ```
  11607. Setting this option to `false` (the default) may be useful in cases where
  11608. you already have separate `@param` definitions for each of the properties
  11609. within the rest property.
  11610. For example, with the option disabled, this will not give an error despite
  11611. `extra` not having any definition:
  11612. ```js
  11613. /**
  11614. * @param cfg
  11615. * @param cfg.num
  11616. */
  11617. function quux ({num, ...extra}) {
  11618. }
  11619. ```
  11620. Nor will this:
  11621. ```js
  11622. /**
  11623. * @param cfg
  11624. * @param cfg.num
  11625. * @param cfg.innerProp1
  11626. * @param cfg.innerProp2
  11627. */
  11628. function quux ({num, ...extra}) {
  11629. }
  11630. ```
  11631. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-autoincrementbase"></a>
  11632. ##### <code>autoIncrementBase</code>
  11633. Numeric to indicate the number at which to begin auto-incrementing roots.
  11634. Defaults to `0`.
  11635. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-unnamedrootbase"></a>
  11636. ##### <code>unnamedRootBase</code>
  11637. An array of root names to use in the fixer when roots are missing. Defaults
  11638. to `['root']`. Note that only when all items in the array besides the last
  11639. are exhausted will auto-incrementing occur. So, with
  11640. `unnamedRootBase: ['arg', 'config']`, the following:
  11641. ```js
  11642. function quux ({foo}, [bar], {baz}) {
  11643. }
  11644. ```
  11645. ...will get the following jsdoc block added:
  11646. ```js
  11647. /**
  11648. * @param arg
  11649. * @param arg.foo
  11650. * @param config0
  11651. * @param config0."0" (`bar`)
  11652. * @param config1
  11653. * @param config1.baz
  11654. */
  11655. ```
  11656. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-exemptedby-1"></a>
  11657. ##### <code>exemptedBy</code>
  11658. Array of tags (e.g., `['type']`) whose presence on the document block
  11659. avoids the need for a `@param`. Defaults to an array with
  11660. `inheritdoc`. If you set this array, it will overwrite the default,
  11661. so be sure to add back `inheritdoc` if you wish its presence to cause
  11662. exemption of the rule.
  11663. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-checktypespattern-1"></a>
  11664. ##### <code>checkTypesPattern</code>
  11665. When one specifies a type, unless it is of a generic type, like `object`
  11666. or `array`, it may be considered unnecessary to have that object's
  11667. destructured components required, especially where generated docs will
  11668. link back to the specified type. For example:
  11669. ```js
  11670. /**
  11671. * @param {SVGRect} bbox - a SVGRect
  11672. */
  11673. export const bboxToObj = function ({x, y, width, height}) {
  11674. return {x, y, width, height};
  11675. };
  11676. ```
  11677. By default `checkTypesPattern` is set to
  11678. `/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/u`,
  11679. meaning that destructuring will be required only if the type of the `@param`
  11680. (the text between curly brackets) is a match for "Object" or "Array" (with or
  11681. without initial caps), "PlainObject", or "GenericObject", "GenericArray" (or
  11682. if no type is present). So in the above example, the lack of a match will
  11683. mean that no complaint will be given about the undocumented destructured
  11684. parameters.
  11685. Note that the `/` delimiters are optional, but necessary to add flags.
  11686. Defaults to using (only) the `u` flag, so to add your own flags, encapsulate
  11687. your expression as a string, but like a literal, e.g., `/^object$/ui`.
  11688. You could set this regular expression to a more expansive list, or you
  11689. could restrict it such that even types matching those strings would not
  11690. need destructuring.
  11691. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-contexts-11"></a>
  11692. ##### <code>contexts</code>
  11693. Set this to an array of strings representing the AST context (or an object with
  11694. `context` and `comment` properties) where you wish the rule to be applied.
  11695. Overrides the default contexts (see below). May be useful for adding such as
  11696. `TSMethodSignature` in TypeScript or restricting the contexts
  11697. which are checked.
  11698. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  11699. section of our README for more on the expected format.
  11700. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-checkconstructors-2"></a>
  11701. ##### <code>checkConstructors</code>
  11702. A value indicating whether `constructor`s should be checked. Defaults to
  11703. `true`.
  11704. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-checkgetters-2"></a>
  11705. ##### <code>checkGetters</code>
  11706. A value indicating whether getters should be checked. Defaults to `false`.
  11707. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-checksetters-2"></a>
  11708. ##### <code>checkSetters</code>
  11709. A value indicating whether setters should be checked. Defaults to `false`.
  11710. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-checkdestructured-1"></a>
  11711. ##### <code>checkDestructured</code>
  11712. Whether to require destructured properties. Defaults to `true`.
  11713. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-checkdestructuredroots"></a>
  11714. ##### <code>checkDestructuredRoots</code>
  11715. Whether to check the existence of a corresponding `@param` for root objects
  11716. of destructured properties (e.g., that for `function ({a, b}) {}`, that there
  11717. is something like `@param myRootObj` defined that can correspond to
  11718. the `{a, b}` object parameter).
  11719. If `checkDestructuredRoots` is `false`, `checkDestructured` will also be
  11720. implied to be `false` (i.e., the inside of the roots will not be checked
  11721. either, e.g., it will also not complain if `a` or `b` do not have their own
  11722. documentation). Defaults to `true`.
  11723. <a name="eslint-plugin-jsdoc-rules-require-param-options-32-usedefaultobjectproperties-1"></a>
  11724. ##### <code>useDefaultObjectProperties</code>
  11725. Set to `true` if you wish to expect documentation of properties on objects
  11726. supplied as default values. Defaults to `false`.
  11727. | | |
  11728. | -------- | ----------------------------------------------------------------------------- |
  11729. | Context | `ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled |
  11730. | Tags | `param` |
  11731. | Aliases | `arg`, `argument` |
  11732. |Recommended | true|
  11733. | Options | `autoIncrementBase`, `checkDestructured`, `checkDestructuredRoots`, `contexts`, `enableFixer`, `enableRootFixer`, `enableRestElementFixer`, `checkRestProperty`, `exemptedBy`, `checkConstructors`, `checkGetters`, `checkSetters`, `checkTypesPattern`, `unnamedRootBase`, `useDefaultObjectProperties`|
  11734. | Settings | `ignoreReplacesDocs`, `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
  11735. The following patterns are considered problems:
  11736. ````js
  11737. /**
  11738. *
  11739. */
  11740. function quux (foo) {
  11741. }
  11742. // Message: Missing JSDoc @param "foo" declaration.
  11743. /**
  11744. *
  11745. */
  11746. function quux (foo) {
  11747. }
  11748. // "jsdoc/require-param": ["error"|"warn", {"contexts":["FunctionDeclaration"]}]
  11749. // Message: Missing JSDoc @param "foo" declaration.
  11750. /**
  11751. *
  11752. */
  11753. function quux ({foo}) {
  11754. }
  11755. // Message: Missing JSDoc @param "root0" declaration.
  11756. /**
  11757. * @param foo
  11758. */
  11759. function quux (foo, bar, {baz}) {
  11760. }
  11761. // "jsdoc/require-param": ["error"|"warn", {"checkDestructured":false}]
  11762. // Message: Missing JSDoc @param "bar" declaration.
  11763. /**
  11764. * @param foo
  11765. */
  11766. function quux (foo, bar, {baz}) {
  11767. }
  11768. // "jsdoc/require-param": ["error"|"warn", {"checkDestructuredRoots":false}]
  11769. // Message: Missing JSDoc @param "bar" declaration.
  11770. /**
  11771. *
  11772. */
  11773. function quux ({foo}) {
  11774. }
  11775. // "jsdoc/require-param": ["error"|"warn", {"enableFixer":false}]
  11776. // Message: Missing JSDoc @param "root0" declaration.
  11777. /**
  11778. *
  11779. */
  11780. function quux ({foo: bar = 5} = {}) {
  11781. }
  11782. // Message: Missing JSDoc @param "root0" declaration.
  11783. /**
  11784. * @param
  11785. */
  11786. function quux ({foo}) {
  11787. }
  11788. // Message: Missing JSDoc @param "root0" declaration.
  11789. /**
  11790. * @param
  11791. */
  11792. function quux ({foo}) {
  11793. }
  11794. // "jsdoc/require-param": ["error"|"warn", {"autoIncrementBase":1}]
  11795. // Message: Missing JSDoc @param "root1" declaration.
  11796. /**
  11797. * @param options
  11798. */
  11799. function quux ({foo}) {
  11800. }
  11801. // Message: Missing JSDoc @param "options.foo" declaration.
  11802. /**
  11803. * @param
  11804. */
  11805. function quux ({ foo, bar: { baz }}) {
  11806. }
  11807. // Message: Missing JSDoc @param "root0" declaration.
  11808. /**
  11809. *
  11810. */
  11811. function quux ({foo}, {bar}) {
  11812. }
  11813. // "jsdoc/require-param": ["error"|"warn", {"unnamedRootBase":["arg"]}]
  11814. // Message: Missing JSDoc @param "arg0" declaration.
  11815. /**
  11816. *
  11817. */
  11818. function quux ({foo}, {bar}) {
  11819. }
  11820. // "jsdoc/require-param": ["error"|"warn", {"unnamedRootBase":["arg","config"]}]
  11821. // Message: Missing JSDoc @param "arg" declaration.
  11822. /**
  11823. *
  11824. */
  11825. function quux ({foo}, {bar}) {
  11826. }
  11827. // "jsdoc/require-param": ["error"|"warn", {"enableRootFixer":false,"unnamedRootBase":["arg","config"]}]
  11828. // Message: Missing JSDoc @param "arg" declaration.
  11829. /**
  11830. *
  11831. */
  11832. function quux (foo, bar) {
  11833. }
  11834. // Message: Missing JSDoc @param "foo" declaration.
  11835. /**
  11836. * @param foo
  11837. */
  11838. function quux (foo, bar) {
  11839. }
  11840. // Message: Missing JSDoc @param "bar" declaration.
  11841. /**
  11842. * @param bar
  11843. */
  11844. function quux (foo, bar, baz) {
  11845. }
  11846. // Message: Missing JSDoc @param "foo" declaration.
  11847. /**
  11848. * @param foo
  11849. * @param bar
  11850. */
  11851. function quux (foo, bar, baz) {
  11852. }
  11853. // Message: Missing JSDoc @param "baz" declaration.
  11854. /**
  11855. * @param baz
  11856. */
  11857. function quux (foo, bar, baz) {
  11858. }
  11859. // Message: Missing JSDoc @param "foo" declaration.
  11860. /**
  11861. * @param
  11862. */
  11863. function quux (foo) {
  11864. }
  11865. // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
  11866. // Message: Missing JSDoc @arg "foo" declaration.
  11867. /**
  11868. * @param foo
  11869. */
  11870. function quux (foo, bar) {
  11871. }
  11872. // Message: Missing JSDoc @param "bar" declaration.
  11873. /**
  11874. * @override
  11875. */
  11876. function quux (foo) {
  11877. }
  11878. // Settings: {"jsdoc":{"overrideReplacesDocs":false}}
  11879. // Message: Missing JSDoc @param "foo" declaration.
  11880. /**
  11881. * @ignore
  11882. */
  11883. function quux (foo) {
  11884. }
  11885. // Settings: {"jsdoc":{"ignoreReplacesDocs":false}}
  11886. // Message: Missing JSDoc @param "foo" declaration.
  11887. /**
  11888. * @implements
  11889. */
  11890. function quux (foo) {
  11891. }
  11892. // Settings: {"jsdoc":{"implementsReplacesDocs":false}}
  11893. // Message: Missing JSDoc @param "foo" declaration.
  11894. /**
  11895. * @augments
  11896. */
  11897. function quux (foo) {
  11898. }
  11899. // Message: Missing JSDoc @param "foo" declaration.
  11900. /**
  11901. * @extends
  11902. */
  11903. function quux (foo) {
  11904. }
  11905. // Message: Missing JSDoc @param "foo" declaration.
  11906. /**
  11907. * @override
  11908. */
  11909. class A {
  11910. /**
  11911. *
  11912. */
  11913. quux (foo) {
  11914. }
  11915. }
  11916. // Settings: {"jsdoc":{"overrideReplacesDocs":false}}
  11917. // Message: Missing JSDoc @param "foo" declaration.
  11918. /**
  11919. * @ignore
  11920. */
  11921. class A {
  11922. /**
  11923. *
  11924. */
  11925. quux (foo) {
  11926. }
  11927. }
  11928. // Settings: {"jsdoc":{"ignoreReplacesDocs":false}}
  11929. // Message: Missing JSDoc @param "foo" declaration.
  11930. /**
  11931. * @implements
  11932. */
  11933. class A {
  11934. /**
  11935. *
  11936. */
  11937. quux (foo) {
  11938. }
  11939. }
  11940. // Settings: {"jsdoc":{"implementsReplacesDocs":false}}
  11941. // Message: Missing JSDoc @param "foo" declaration.
  11942. /**
  11943. * @augments
  11944. */
  11945. class A {
  11946. /**
  11947. *
  11948. */
  11949. quux (foo) {
  11950. }
  11951. }
  11952. // Message: Missing JSDoc @param "foo" declaration.
  11953. /**
  11954. * @extends
  11955. */
  11956. class A {
  11957. /**
  11958. *
  11959. */
  11960. quux (foo) {
  11961. }
  11962. }
  11963. // Message: Missing JSDoc @param "foo" declaration.
  11964. export class SomeClass {
  11965. /**
  11966. * @param property
  11967. */
  11968. constructor(private property: string, private foo: number) {}
  11969. }
  11970. // Message: Missing JSDoc @param "foo" declaration.
  11971. /**
  11972. * @param
  11973. */
  11974. function quux (foo) {
  11975. }
  11976. // Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
  11977. // Message: Unexpected tag `@param`
  11978. /**
  11979. *
  11980. */
  11981. function quux ({bar, baz}, foo) {
  11982. }
  11983. // Message: Missing JSDoc @param "root0" declaration.
  11984. /**
  11985. *
  11986. */
  11987. function quux (foo, {bar, baz}) {
  11988. }
  11989. // Message: Missing JSDoc @param "foo" declaration.
  11990. /**
  11991. *
  11992. */
  11993. function quux ([bar, baz], foo) {
  11994. }
  11995. // Message: Missing JSDoc @param "root0" declaration.
  11996. /**
  11997. *
  11998. */
  11999. function quux (foo) {
  12000. }
  12001. // "jsdoc/require-param": ["error"|"warn", {"exemptedBy":["notPresent"]}]
  12002. // Message: Missing JSDoc @param "foo" declaration.
  12003. /**
  12004. * @inheritdoc
  12005. */
  12006. function quux (foo) {
  12007. }
  12008. // "jsdoc/require-param": ["error"|"warn", {"exemptedBy":[]}]
  12009. // Message: Missing JSDoc @param "foo" declaration.
  12010. /**
  12011. * @inheritdoc
  12012. */
  12013. function quux (foo) {
  12014. }
  12015. // Settings: {"jsdoc":{"mode":"closure"}}
  12016. // Message: Missing JSDoc @param "foo" declaration.
  12017. /**
  12018. * Assign the project to a list of employees.
  12019. * @param {object[]} employees - The employees who are responsible for the project.
  12020. * @param {string} employees[].name - The name of an employee.
  12021. * @param {string} employees[].department - The employee's department.
  12022. */
  12023. function assign (employees, name) {
  12024. };
  12025. // Message: Missing JSDoc @param "name" declaration.
  12026. interface ITest {
  12027. /**
  12028. * Test description.
  12029. */
  12030. TestMethod(id: number): void;
  12031. }
  12032. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSMethodSignature"]}]
  12033. // Message: Missing JSDoc @param "id" declaration.
  12034. /**
  12035. * A test class.
  12036. */
  12037. abstract class TestClass
  12038. {
  12039. /**
  12040. * A test method.
  12041. */
  12042. abstract TestFunction(id);
  12043. }
  12044. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSEmptyBodyFunctionExpression"]}]
  12045. // Message: Missing JSDoc @param "id" declaration.
  12046. /**
  12047. * A test class.
  12048. */
  12049. declare class TestClass
  12050. {
  12051. /**
  12052. *
  12053. */
  12054. TestMethod(id);
  12055. }
  12056. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSEmptyBodyFunctionExpression"]}]
  12057. // Message: Missing JSDoc @param "id" declaration.
  12058. /**
  12059. * A test function.
  12060. */
  12061. declare let TestFunction: (id) => void;
  12062. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
  12063. // Message: Missing JSDoc @param "id" declaration.
  12064. /**
  12065. * A test function.
  12066. */
  12067. let TestFunction: (id) => void;
  12068. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
  12069. // Message: Missing JSDoc @param "id" declaration.
  12070. /**
  12071. * A test function.
  12072. */
  12073. function test(
  12074. processor: (id: number) => string
  12075. ) {
  12076. return processor(10);
  12077. }
  12078. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
  12079. // Message: Missing JSDoc @param "id" declaration.
  12080. /**
  12081. * A test function.
  12082. */
  12083. let test = (processor: (id: number) => string) =>
  12084. {
  12085. return processor(10);
  12086. }
  12087. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
  12088. // Message: Missing JSDoc @param "id" declaration.
  12089. class TestClass {
  12090. /**
  12091. * A class property.
  12092. */
  12093. public Test: (id: number) => string;
  12094. }
  12095. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
  12096. // Message: Missing JSDoc @param "id" declaration.
  12097. class TestClass {
  12098. /**
  12099. * A class method.
  12100. */
  12101. public TestMethod(): (id: number) => string
  12102. {
  12103. }
  12104. }
  12105. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
  12106. // Message: Missing JSDoc @param "id" declaration.
  12107. interface TestInterface {
  12108. /**
  12109. * An interface property.
  12110. */
  12111. public Test: (id: number) => string;
  12112. }
  12113. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
  12114. // Message: Missing JSDoc @param "id" declaration.
  12115. interface TestInterface {
  12116. /**
  12117. * An interface method.
  12118. */
  12119. public TestMethod(): (id: number) => string;
  12120. }
  12121. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
  12122. // Message: Missing JSDoc @param "id" declaration.
  12123. /**
  12124. * A function with return type
  12125. */
  12126. function test(): (id: number) => string;
  12127. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
  12128. // Message: Missing JSDoc @param "id" declaration.
  12129. /**
  12130. * A function with return type
  12131. */
  12132. let test = (): (id: number) => string =>
  12133. {
  12134. return (id) => `${id}`;
  12135. }
  12136. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
  12137. // Message: Missing JSDoc @param "id" declaration.
  12138. /**
  12139. * @param baz
  12140. * @param options
  12141. */
  12142. function quux (baz, {foo: bar}) {
  12143. }
  12144. // Message: Missing JSDoc @param "options.foo" declaration.
  12145. class Client {
  12146. /**
  12147. * Set collection data.
  12148. * @param {Object} data The collection data object.
  12149. * @param {number} data.last_modified
  12150. * @param {Object} options The options object.
  12151. * @param {Object} [options.headers] The headers object option.
  12152. * @param {Number} [options.retry=0] Number of retries to make
  12153. * when faced with transient errors.
  12154. * @param {Boolean} [options.safe] The safe option.
  12155. * @param {Boolean} [options.patch] The patch option.
  12156. * @param {Number} [options.last_modified] The last_modified option.
  12157. * @return {Promise<Object, Error>}
  12158. */
  12159. async setData(
  12160. data: { last_modified?: number },
  12161. options: {
  12162. headers?: Record<string, string>;
  12163. safe?: boolean;
  12164. retry?: number;
  12165. patch?: boolean;
  12166. last_modified?: number;
  12167. permissions?: [];
  12168. } = {}
  12169. ) {}
  12170. }
  12171. // Message: Missing JSDoc @param "options.permissions" declaration.
  12172. /**
  12173. *
  12174. */
  12175. function quux (foo) {
  12176. }
  12177. // "jsdoc/require-param": ["error"|"warn", {"enableFixer":false}]
  12178. // Message: Missing JSDoc @param "foo" declaration.
  12179. class Client {
  12180. /**
  12181. * Set collection data.
  12182. * @return {Promise<Object, Error>}
  12183. */
  12184. async setData(
  12185. data: { last_modified?: number }
  12186. ) {}
  12187. }
  12188. // Message: Missing JSDoc @param "data" declaration.
  12189. /**
  12190. * @param cfg
  12191. * @param cfg.num
  12192. */
  12193. function quux ({num, ...extra}) {
  12194. }
  12195. // "jsdoc/require-param": ["error"|"warn", {"checkRestProperty":true}]
  12196. // Message: Missing JSDoc @param "cfg.extra" declaration.
  12197. /**
  12198. * @param cfg
  12199. * @param cfg.opts
  12200. * @param cfg.opts.num
  12201. */
  12202. function quux ({opts: {num, ...extra}}) {
  12203. }
  12204. // "jsdoc/require-param": ["error"|"warn", {"checkRestProperty":true}]
  12205. // Message: Missing JSDoc @param "cfg.opts.extra" declaration.
  12206. /**
  12207. * @param {GenericArray} cfg
  12208. * @param {number} cfg."0"
  12209. */
  12210. function baar ([a, ...extra]) {
  12211. //
  12212. }
  12213. // Message: Missing JSDoc @param "cfg."1"" declaration.
  12214. /**
  12215. * @param a
  12216. */
  12217. function baar (a, ...extra) {
  12218. //
  12219. }
  12220. // Message: Missing JSDoc @param "extra" declaration.
  12221. /**
  12222. * Converts an SVGRect into an object.
  12223. * @param {SVGRect} bbox - a SVGRect
  12224. */
  12225. const bboxToObj = function ({x, y, width, height}) {
  12226. return {x, y, width, height};
  12227. };
  12228. // "jsdoc/require-param": ["error"|"warn", {"checkTypesPattern":"SVGRect"}]
  12229. // Message: Missing JSDoc @param "bbox.x" declaration.
  12230. /**
  12231. * Converts an SVGRect into an object.
  12232. * @param {object} bbox - a SVGRect
  12233. */
  12234. const bboxToObj = function ({x, y, width, height}) {
  12235. return {x, y, width, height};
  12236. };
  12237. // Message: Missing JSDoc @param "bbox.x" declaration.
  12238. module.exports = class GraphQL {
  12239. /**
  12240. * @param fetchOptions
  12241. * @param cacheKey
  12242. */
  12243. fetch = ({ url, ...options }, cacheKey) => {
  12244. }
  12245. };
  12246. // "jsdoc/require-param": ["error"|"warn", {"checkRestProperty":true}]
  12247. // Message: Missing JSDoc @param "fetchOptions.url" declaration.
  12248. (function() {
  12249. /**
  12250. * A function.
  12251. */
  12252. function f(param) {
  12253. return !param;
  12254. }
  12255. })();
  12256. // Message: Missing JSDoc @param "param" declaration.
  12257. /**
  12258. * Description.
  12259. * @param {Object} options
  12260. * @param {Object} options.foo
  12261. */
  12262. function quux ({ foo: { bar } }) {}
  12263. // Message: Missing JSDoc @param "options.foo.bar" declaration.
  12264. /**
  12265. * Description.
  12266. * @param {FooBar} options
  12267. * @param {FooBar} options.foo
  12268. */
  12269. function quux ({ foo: { bar } }) {}
  12270. // "jsdoc/require-param": ["error"|"warn", {"checkTypesPattern":"FooBar"}]
  12271. // Message: Missing JSDoc @param "options.foo.bar" declaration.
  12272. /**
  12273. * Description.
  12274. * @param {Object} options
  12275. * @param {FooBar} foo
  12276. */
  12277. function quux ({ foo: { bar } }) {}
  12278. // Message: Missing JSDoc @param "options.foo" declaration.
  12279. /**
  12280. * Description.
  12281. * @param {Object} options
  12282. * @param options.foo
  12283. */
  12284. function quux ({ foo: { bar } }) {}
  12285. // Message: Missing JSDoc @param "options.foo.bar" declaration.
  12286. /**
  12287. * Description.
  12288. * @param {object} options Options.
  12289. * @param {object} options.foo A description.
  12290. * @param {object} options.foo.bar
  12291. */
  12292. function foo({ foo: { bar: { baz } }}) {}
  12293. // Message: Missing JSDoc @param "options.foo.bar.baz" declaration.
  12294. /**
  12295. * Returns a number.
  12296. * @param {Object} props Props.
  12297. * @param {Object} props.prop Prop.
  12298. * @return {number} A number.
  12299. */
  12300. export function testFn1 ({ prop = { a: 1, b: 2 } }) {
  12301. }
  12302. // "jsdoc/require-param": ["error"|"warn", {"useDefaultObjectProperties":true}]
  12303. // Message: Missing JSDoc @param "props.prop.a" declaration.
  12304. /** Foo. */
  12305. function foo(a, b, c) {}
  12306. // Message: Missing JSDoc @param "a" declaration.
  12307. ````
  12308. The following patterns are not considered problems:
  12309. ````js
  12310. /**
  12311. * @param foo
  12312. */
  12313. function quux (foo) {
  12314. }
  12315. /**
  12316. * @param root0
  12317. * @param root0.foo
  12318. */
  12319. function quux ({foo}) {
  12320. }
  12321. /**
  12322. * @param root0
  12323. * @param root0.foo
  12324. * @param root1
  12325. * @param root1.bar
  12326. */
  12327. function quux ({foo}, {bar}) {
  12328. }
  12329. /**
  12330. * @param arg0
  12331. * @param arg0.foo
  12332. * @param arg1
  12333. * @param arg1.bar
  12334. */
  12335. function quux ({foo}, {bar}) {
  12336. }
  12337. // "jsdoc/require-param": ["error"|"warn", {"unnamedRootBase":["arg"]}]
  12338. /**
  12339. * @param arg
  12340. * @param arg.foo
  12341. * @param config0
  12342. * @param config0.bar
  12343. * @param config1
  12344. * @param config1.baz
  12345. */
  12346. function quux ({foo}, {bar}, {baz}) {
  12347. }
  12348. // "jsdoc/require-param": ["error"|"warn", {"unnamedRootBase":["arg","config"]}]
  12349. /**
  12350. * @inheritdoc
  12351. */
  12352. function quux (foo) {
  12353. }
  12354. /**
  12355. * @inheritDoc
  12356. */
  12357. function quux (foo) {
  12358. }
  12359. /**
  12360. * @arg foo
  12361. */
  12362. function quux (foo) {
  12363. }
  12364. // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
  12365. /**
  12366. * @override
  12367. * @param foo
  12368. */
  12369. function quux (foo) {
  12370. }
  12371. /**
  12372. * @override
  12373. */
  12374. function quux (foo) {
  12375. }
  12376. /**
  12377. * @override
  12378. */
  12379. class A {
  12380. /**
  12381. *
  12382. */
  12383. quux (foo) {
  12384. }
  12385. }
  12386. /**
  12387. * @override
  12388. */
  12389. function quux (foo) {
  12390. }
  12391. // Settings: {"jsdoc":{"overrideReplacesDocs":true}}
  12392. /**
  12393. * @ignore
  12394. */
  12395. function quux (foo) {
  12396. }
  12397. // Settings: {"jsdoc":{"ignoreReplacesDocs":true}}
  12398. /**
  12399. * @implements
  12400. */
  12401. class A {
  12402. /**
  12403. *
  12404. */
  12405. quux (foo) {
  12406. }
  12407. }
  12408. /**
  12409. * @implements
  12410. */
  12411. function quux (foo) {
  12412. }
  12413. /**
  12414. * @implements
  12415. */
  12416. function quux (foo) {
  12417. }
  12418. // Settings: {"jsdoc":{"implementsReplacesDocs":true}}
  12419. /**
  12420. * @implements
  12421. * @param foo
  12422. */
  12423. function quux (foo) {
  12424. }
  12425. /**
  12426. * @augments
  12427. */
  12428. function quux (foo) {
  12429. }
  12430. // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
  12431. /**
  12432. * @augments
  12433. * @param foo
  12434. */
  12435. function quux (foo) {
  12436. }
  12437. /**
  12438. * @extends
  12439. */
  12440. function quux (foo) {
  12441. }
  12442. // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
  12443. /**
  12444. * @extends
  12445. * @param foo
  12446. */
  12447. function quux (foo) {
  12448. }
  12449. /**
  12450. * @augments
  12451. */
  12452. function quux (foo) {
  12453. }
  12454. // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
  12455. /**
  12456. * @extends
  12457. */
  12458. function quux (foo) {
  12459. }
  12460. // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
  12461. /**
  12462. * @override
  12463. */
  12464. class A {
  12465. /**
  12466. * @param foo
  12467. */
  12468. quux (foo) {
  12469. }
  12470. }
  12471. /**
  12472. * @override
  12473. */
  12474. class A {
  12475. /**
  12476. *
  12477. */
  12478. quux (foo) {
  12479. }
  12480. }
  12481. // Settings: {"jsdoc":{"overrideReplacesDocs":true}}
  12482. /**
  12483. * @ignore
  12484. */
  12485. class A {
  12486. /**
  12487. *
  12488. */
  12489. quux (foo) {
  12490. }
  12491. }
  12492. // Settings: {"jsdoc":{"ignoreReplacesDocs":true}}
  12493. /**
  12494. * @implements
  12495. */
  12496. class A {
  12497. /**
  12498. *
  12499. */
  12500. quux (foo) {
  12501. }
  12502. }
  12503. // Settings: {"jsdoc":{"implementsReplacesDocs":true}}
  12504. /**
  12505. * @implements
  12506. */
  12507. class A {
  12508. /**
  12509. * @param foo
  12510. */
  12511. quux (foo) {
  12512. }
  12513. }
  12514. /**
  12515. * @augments
  12516. */
  12517. class A {
  12518. /**
  12519. *
  12520. */
  12521. quux (foo) {
  12522. }
  12523. }
  12524. // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
  12525. /**
  12526. * @augments
  12527. */
  12528. class A {
  12529. /**
  12530. * @param foo
  12531. */
  12532. quux (foo) {
  12533. }
  12534. }
  12535. /**
  12536. * @extends
  12537. */
  12538. class A {
  12539. /**
  12540. *
  12541. */
  12542. quux (foo) {
  12543. }
  12544. }
  12545. // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
  12546. /**
  12547. * @extends
  12548. */
  12549. class A {
  12550. /**
  12551. * @param foo
  12552. */
  12553. quux (foo) {
  12554. }
  12555. }
  12556. /**
  12557. * @augments
  12558. */
  12559. class A {
  12560. /**
  12561. *
  12562. */
  12563. quux (foo) {
  12564. }
  12565. }
  12566. // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
  12567. /**
  12568. * @extends
  12569. */
  12570. class A {
  12571. /**
  12572. *
  12573. */
  12574. quux (foo) {
  12575. }
  12576. }
  12577. // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
  12578. /**
  12579. * @internal
  12580. */
  12581. function quux (foo) {
  12582. }
  12583. // Settings: {"jsdoc":{"ignoreInternal":true}}
  12584. /**
  12585. * @private
  12586. */
  12587. function quux (foo) {
  12588. }
  12589. // Settings: {"jsdoc":{"ignorePrivate":true}}
  12590. /**
  12591. * @access private
  12592. */
  12593. function quux (foo) {
  12594. }
  12595. // Settings: {"jsdoc":{"ignorePrivate":true}}
  12596. // issue 182: optional chaining
  12597. /** @const {boolean} test */
  12598. const test = something?.find(_ => _)
  12599. /** @type {RequestHandler} */
  12600. function foo(req, res, next) {}
  12601. /**
  12602. * @type {MyCallback}
  12603. */
  12604. function quux () {
  12605. }
  12606. // "jsdoc/require-param": ["error"|"warn", {"exemptedBy":["type"]}]
  12607. /**
  12608. * @override
  12609. */
  12610. var A = class {
  12611. /**
  12612. *
  12613. */
  12614. quux (foo) {
  12615. }
  12616. }
  12617. export class SomeClass {
  12618. /**
  12619. * @param property
  12620. */
  12621. constructor(private property: string) {}
  12622. }
  12623. /**
  12624. * Assign the project to an employee.
  12625. *
  12626. * @param {object} employee - The employee who is responsible for the project.
  12627. * @param {string} employee.name - The name of the employee.
  12628. * @param {string} employee.department - The employee's department.
  12629. */
  12630. function assign({name, department}) {
  12631. // ...
  12632. }
  12633. export abstract class StephanPlugin<O, D> {
  12634. /**
  12635. * Called right after Stephan loads the plugin file.
  12636. *
  12637. * @example
  12638. *```typescript
  12639. * type Options = {
  12640. * verbose?: boolean;
  12641. * token?: string;
  12642. * }
  12643. * ```
  12644. *
  12645. * Note that your Options type should only have optional properties...
  12646. *
  12647. * @param args Arguments compiled and provided by StephanClient.
  12648. * @param args.options The options as provided by the user, or an empty object if not provided.
  12649. * @param args.client The options as provided by the user, or an empty object if not provided.
  12650. * @param defaultOptions The default options as provided by the plugin, or an empty object.
  12651. */
  12652. public constructor({options, client}: {
  12653. options: O;
  12654. client: unknown;
  12655. }, defaultOptions: D) {
  12656. }
  12657. }
  12658. /**
  12659. *
  12660. */
  12661. function quux (foo) {
  12662. }
  12663. // "jsdoc/require-param": ["error"|"warn", {"contexts":["ArrowFunctionExpression"]}]
  12664. /**
  12665. * A function with return type
  12666. *
  12667. * @param id
  12668. */
  12669. let test = (): (id: number) => string =>
  12670. {
  12671. return (id) => `${id}`;
  12672. }
  12673. // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
  12674. /** @abstract */
  12675. class base {
  12676. /** @param {boolean} arg0 */
  12677. constructor(arg0) {}
  12678. }
  12679. class foo extends base {
  12680. /** @inheritDoc */
  12681. constructor(arg0) {
  12682. super(arg0);
  12683. this.arg0 = arg0;
  12684. }
  12685. }
  12686. // Settings: {"jsdoc":{"mode":"closure"}}
  12687. export abstract class StephanPlugin<O, D> {
  12688. /**
  12689. * Called right after Stephan loads the plugin file.
  12690. *
  12691. * @example
  12692. *```typescript
  12693. * type Options = {
  12694. * verbose?: boolean;
  12695. * token?: string;
  12696. * }
  12697. * ```
  12698. *
  12699. * Note that your Options type should only have optional properties...
  12700. *
  12701. * @param args Arguments compiled and provided by StephanClient.
  12702. * @param args.options The options as provided by the user, or an empty object if not provided.
  12703. * @param args.client The options as provided by the user, or an empty object if not provided.
  12704. * @param args.client.name The name of the client.
  12705. * @param defaultOptions The default options as provided by the plugin, or an empty object.
  12706. */
  12707. public constructor({ options, client: { name } }: {
  12708. options: O;
  12709. client: { name: string };
  12710. }, defaultOptions: D) {
  12711. }
  12712. }
  12713. /**
  12714. * @param {string} cb
  12715. */
  12716. function createGetter (cb) {
  12717. return function (...args) {
  12718. cb();
  12719. };
  12720. }
  12721. /**
  12722. * @param cfg
  12723. * @param cfg.num
  12724. */
  12725. function quux ({num, ...extra}) {
  12726. }
  12727. /**
  12728. * @param {GenericArray} cfg
  12729. * @param {number} cfg."0"
  12730. */
  12731. function baar ([a, ...extra]) {
  12732. //
  12733. }
  12734. // "jsdoc/require-param": ["error"|"warn", {"enableRestElementFixer":false}]
  12735. /**
  12736. * @param a
  12737. */
  12738. function baar (a, ...extra) {
  12739. //
  12740. }
  12741. // "jsdoc/require-param": ["error"|"warn", {"enableRestElementFixer":false}]
  12742. /**
  12743. * Converts an SVGRect into an object.
  12744. * @param {SVGRect} bbox - a SVGRect
  12745. */
  12746. const bboxToObj = function ({x, y, width, height}) {
  12747. return {x, y, width, height};
  12748. };
  12749. /**
  12750. * Converts an SVGRect into an object.
  12751. * @param {object} bbox - a SVGRect
  12752. */
  12753. const bboxToObj = function ({x, y, width, height}) {
  12754. return {x, y, width, height};
  12755. };
  12756. // "jsdoc/require-param": ["error"|"warn", {"checkTypesPattern":"SVGRect"}]
  12757. class CSS {
  12758. /**
  12759. * Set one or more CSS properties for the set of matched elements.
  12760. *
  12761. * @param {Object} propertyObject - An object of property-value pairs to set.
  12762. */
  12763. setCssObject(propertyObject: {[key: string]: string | number}): void {
  12764. }
  12765. }
  12766. /**
  12767. * @param foo
  12768. * @param bar
  12769. * @param cfg
  12770. */
  12771. function quux (foo, bar, {baz}) {
  12772. }
  12773. // "jsdoc/require-param": ["error"|"warn", {"checkDestructured":false}]
  12774. /**
  12775. * @param foo
  12776. * @param bar
  12777. */
  12778. function quux (foo, bar, {baz}) {
  12779. }
  12780. // "jsdoc/require-param": ["error"|"warn", {"checkDestructuredRoots":false}]
  12781. /**
  12782. * @param root
  12783. * @param root.foo
  12784. */
  12785. function quux ({"foo": bar}) {
  12786. }
  12787. /**
  12788. * @param root
  12789. * @param root."foo"
  12790. */
  12791. function quux ({foo: bar}) {
  12792. }
  12793. /**
  12794. * Description.
  12795. * @param {string} b Description `/**`.
  12796. */
  12797. module.exports = function a(b) {
  12798. console.info(b);
  12799. };
  12800. /**
  12801. * Description.
  12802. * @param {Object} options Options.
  12803. * @param {FooBar} options.foo foo description.
  12804. */
  12805. function quux ({ foo: { bar } }) {}
  12806. /**
  12807. * Description.
  12808. * @param {FooBar} options
  12809. * @param {Object} options.foo
  12810. */
  12811. function quux ({ foo: { bar } }) {}
  12812. // "jsdoc/require-param": ["error"|"warn", {"checkTypesPattern":"FooBar"}]
  12813. /**
  12814. * @param obj
  12815. * @param obj.data
  12816. * @param obj.data."0"
  12817. * @param obj.data."1"
  12818. * @param obj.data."2"
  12819. * @param obj.defaulting
  12820. * @param obj.defaulting."0"
  12821. * @param obj.defaulting."1"
  12822. */
  12823. function Item({
  12824. data: [foo, bar, ...baz],
  12825. defaulting: [quux, xyz] = []
  12826. }) {
  12827. }
  12828. /**
  12829. * Returns a number.
  12830. * @param {Object} props Props.
  12831. * @param {Object} props.prop Prop.
  12832. * @return {number} A number.
  12833. */
  12834. export function testFn1 ({ prop = { a: 1, b: 2 } }) {
  12835. }
  12836. // "jsdoc/require-param": ["error"|"warn", {"useDefaultObjectProperties":false}]
  12837. ````
  12838. <a name="eslint-plugin-jsdoc-rules-require-property"></a>
  12839. ### <code>require-property</code>
  12840. Requires that all `@typedef` and `@namespace` tags have `@property`
  12841. when their type is a plain `object`, `Object`, or `PlainObject`.
  12842. Note that any other type, including a subtype of object such as
  12843. `object<string, string>`, will not be reported.
  12844. <a name="eslint-plugin-jsdoc-rules-require-property-fixer-2"></a>
  12845. #### Fixer
  12846. The fixer for `require-property` will add an empty `@property`.
  12847. |||
  12848. |---|---|
  12849. |Context|Everywhere|
  12850. |Tags|`typedef`, `namespace`|
  12851. |Recommended|true|
  12852. The following patterns are considered problems:
  12853. ````js
  12854. /**
  12855. * @typedef {object} SomeTypedef
  12856. */
  12857. // Message: Missing JSDoc @property.
  12858. class Test {
  12859. /**
  12860. * @typedef {object} SomeTypedef
  12861. */
  12862. quux () {}
  12863. }
  12864. // Message: Missing JSDoc @property.
  12865. /**
  12866. * @typedef {PlainObject} SomeTypedef
  12867. */
  12868. // Settings: {"jsdoc":{"tagNamePreference":{"property":"prop"}}}
  12869. // Message: Missing JSDoc @prop.
  12870. /**
  12871. * @namespace {Object} SomeName
  12872. */
  12873. // Message: Missing JSDoc @property.
  12874. ````
  12875. The following patterns are not considered problems:
  12876. ````js
  12877. /**
  12878. *
  12879. */
  12880. /**
  12881. * @property
  12882. */
  12883. /**
  12884. * @typedef {Object} SomeTypedef
  12885. * @property {SomeType} propName Prop description
  12886. */
  12887. /**
  12888. * @typedef {object} SomeTypedef
  12889. * @prop {SomeType} propName Prop description
  12890. */
  12891. // Settings: {"jsdoc":{"tagNamePreference":{"property":"prop"}}}
  12892. /**
  12893. * @typedef {object} SomeTypedef
  12894. * @property
  12895. * // arbitrary property content
  12896. */
  12897. /**
  12898. * @typedef {object<string, string>} SomeTypedef
  12899. */
  12900. /**
  12901. * @typedef {string} SomeTypedef
  12902. */
  12903. /**
  12904. * @namespace {object} SomeName
  12905. * @property {SomeType} propName Prop description
  12906. */
  12907. /**
  12908. * @namespace {object} SomeName
  12909. * @property
  12910. * // arbitrary property content
  12911. */
  12912. /**
  12913. * @typedef {object} SomeTypedef
  12914. * @property someProp
  12915. * @property anotherProp This with a description
  12916. * @property {anotherType} yetAnotherProp This with a type and desc.
  12917. */
  12918. function quux () {
  12919. }
  12920. ````
  12921. <a name="eslint-plugin-jsdoc-rules-require-property-description"></a>
  12922. ### <code>require-property-description</code>
  12923. Requires that each `@property` tag has a `description` value.
  12924. |||
  12925. |---|---|
  12926. |Context|everywhere|
  12927. |Tags|`property`|
  12928. |Aliases|`prop`|
  12929. |Recommended|true|
  12930. The following patterns are considered problems:
  12931. ````js
  12932. /**
  12933. * @typedef {SomeType} SomeTypedef
  12934. * @property foo
  12935. */
  12936. // Message: Missing JSDoc @property "foo" description.
  12937. /**
  12938. * @typedef {SomeType} SomeTypedef
  12939. * @prop foo
  12940. */
  12941. // Settings: {"jsdoc":{"tagNamePreference":{"property":"prop"}}}
  12942. // Message: Missing JSDoc @prop "foo" description.
  12943. /**
  12944. * @typedef {SomeType} SomeTypedef
  12945. * @property foo
  12946. */
  12947. // Settings: {"jsdoc":{"tagNamePreference":{"property":false}}}
  12948. // Message: Unexpected tag `@property`
  12949. ````
  12950. The following patterns are not considered problems:
  12951. ````js
  12952. /**
  12953. * @typedef {SomeType} SomeTypedef
  12954. */
  12955. /**
  12956. * @typedef {SomeType} SomeTypedef
  12957. * @property foo Foo.
  12958. */
  12959. /**
  12960. * @namespace {SomeType} SomeName
  12961. * @property foo Foo.
  12962. */
  12963. /**
  12964. * @class
  12965. * @property foo Foo.
  12966. */
  12967. /**
  12968. * Typedef with multi-line property type.
  12969. *
  12970. * @typedef {object} MyType
  12971. * @property {function(
  12972. * number
  12973. * )} numberEater Method which takes a number.
  12974. */
  12975. ````
  12976. <a name="eslint-plugin-jsdoc-rules-require-property-name"></a>
  12977. ### <code>require-property-name</code>
  12978. Requires that all function `@property` tags have names.
  12979. |||
  12980. |---|---|
  12981. |Context|everywhere|
  12982. |Tags|`property`|
  12983. |Aliases|`prop`|
  12984. |Recommended|true|
  12985. The following patterns are considered problems:
  12986. ````js
  12987. /**
  12988. * @typedef {SomeType} SomeTypedef
  12989. * @property
  12990. */
  12991. // Message: There must be an identifier after @property type.
  12992. /**
  12993. * @typedef {SomeType} SomeTypedef
  12994. * @property {string}
  12995. */
  12996. // Message: There must be an identifier after @property tag.
  12997. /**
  12998. * @typedef {SomeType} SomeTypedef
  12999. * @property foo
  13000. */
  13001. // Settings: {"jsdoc":{"tagNamePreference":{"property":false}}}
  13002. // Message: Unexpected tag `@property`
  13003. ````
  13004. The following patterns are not considered problems:
  13005. ````js
  13006. /**
  13007. * @typedef {SomeType} SomeTypedef
  13008. * @property foo
  13009. */
  13010. /**
  13011. * @typedef {SomeType} SomeTypedef
  13012. * @property {string} foo
  13013. */
  13014. /**
  13015. * @namespace {SomeType} SomeName
  13016. * @property {string} foo
  13017. */
  13018. /**
  13019. * @class
  13020. * @property {string} foo
  13021. */
  13022. ````
  13023. <a name="eslint-plugin-jsdoc-rules-require-property-type"></a>
  13024. ### <code>require-property-type</code>
  13025. Requires that each `@property` tag has a `type` value.
  13026. |||
  13027. |---|---|
  13028. |Context|everywhere|
  13029. |Tags|`property`|
  13030. |Aliases|`prop`|
  13031. |Recommended|true|
  13032. The following patterns are considered problems:
  13033. ````js
  13034. /**
  13035. * @typedef {SomeType} SomeTypedef
  13036. * @property foo
  13037. */
  13038. // Message: Missing JSDoc @property "foo" type.
  13039. /**
  13040. * @typedef {SomeType} SomeTypedef
  13041. * @prop foo
  13042. */
  13043. // Settings: {"jsdoc":{"tagNamePreference":{"property":"prop"}}}
  13044. // Message: Missing JSDoc @prop "foo" type.
  13045. /**
  13046. * @typedef {SomeType} SomeTypedef
  13047. * @property foo
  13048. */
  13049. // Settings: {"jsdoc":{"tagNamePreference":{"property":false}}}
  13050. // Message: Unexpected tag `@property`
  13051. ````
  13052. The following patterns are not considered problems:
  13053. ````js
  13054. /**
  13055. * @typedef {SomeType} SomeTypedef
  13056. */
  13057. /**
  13058. * @typedef {SomeType} SomeTypedef
  13059. * @property {number} foo
  13060. */
  13061. /**
  13062. * @namespace {SomeType} SomeName
  13063. * @property {number} foo
  13064. */
  13065. /**
  13066. * @class
  13067. * @property {number} foo
  13068. */
  13069. ````
  13070. <a name="eslint-plugin-jsdoc-rules-require-returns-check"></a>
  13071. ### <code>require-returns-check</code>
  13072. Requires a return statement (or non-`undefined` Promise resolve value) in
  13073. function bodies if a `@returns` tag (without a `void` or `undefined` type)
  13074. is specified in the function's jsdoc comment.
  13075. Will also report `@returns {void}` and `@returns {undefined}` if `exemptAsync`
  13076. is set to `false` no non-`undefined` returned or resolved value is found.
  13077. Will also report if multiple `@returns` tags are present.
  13078. <a name="eslint-plugin-jsdoc-rules-require-returns-check-options-33"></a>
  13079. #### Options
  13080. - `exemptGenerators`- Because a generator might be labeled as having a
  13081. `IterableIterator` `@returns` value (along with an iterator type
  13082. corresponding to the type of any `yield` statements), projects might wish to
  13083. leverage `@returns` in generators even without a` return` statement. This
  13084. option is therefore `true` by default in `typescript` mode (in "jsdoc" mode,
  13085. one might be more likely to take advantage of `@yields`). Set it to `false`
  13086. if you wish for a missing `return` to be flagged regardless.
  13087. - `exemptAsync` - By default, functions which return a `Promise` that are not
  13088. detected as resolving with a non-`undefined` value and `async` functions
  13089. (even ones that do not explicitly return a value, as these are returning a
  13090. `Promise` implicitly) will be exempted from reporting by this rule.
  13091. If you wish to insist that only `Promise`'s which resolve to
  13092. non-`undefined` values or `async` functions with explicit `return`'s will
  13093. be exempted from reporting (i.e., that `async` functions can be reported
  13094. if they lack an explicit (non-`undefined`) `return` when a `@returns` is
  13095. present), you can set `exemptAsync` to `false` on the options object.
  13096. - `reportMissingReturnForUndefinedTypes` - If `true` and no return or
  13097. resolve value is found, this setting will even insist that reporting occur
  13098. with `void` or `undefined` (including as an indicated `Promise` type).
  13099. Unlike `require-returns`, with this option in the rule, one can
  13100. *discourage* the labeling of `undefined` types. Defaults to `false`.
  13101. |||
  13102. |---|---|
  13103. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
  13104. |Tags|`returns`|
  13105. |Aliases|`return`|
  13106. |Options|`exemptAsync`, `reportMissingReturnForUndefinedTypes`|
  13107. |Recommended|true|
  13108. The following patterns are considered problems:
  13109. ````js
  13110. /**
  13111. * @returns
  13112. */
  13113. function quux (foo) {
  13114. }
  13115. // Message: JSDoc @returns declaration present but return expression not available in function.
  13116. /**
  13117. * @return
  13118. */
  13119. function quux (foo) {
  13120. }
  13121. // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
  13122. // Message: JSDoc @return declaration present but return expression not available in function.
  13123. /**
  13124. * @returns
  13125. */
  13126. const quux = () => {}
  13127. // Message: JSDoc @returns declaration present but return expression not available in function.
  13128. /**
  13129. * @returns {undefined} Foo.
  13130. * @returns {String} Foo.
  13131. */
  13132. function quux () {
  13133. return foo;
  13134. }
  13135. // Message: Found more than one @returns declaration.
  13136. const language = {
  13137. /**
  13138. * @param {string} name
  13139. * @returns {string}
  13140. */
  13141. get name() {
  13142. this._name = name;
  13143. }
  13144. }
  13145. // Message: JSDoc @returns declaration present but return expression not available in function.
  13146. class Foo {
  13147. /**
  13148. * @returns {string}
  13149. */
  13150. bar () {
  13151. }
  13152. }
  13153. // Message: JSDoc @returns declaration present but return expression not available in function.
  13154. /**
  13155. * @returns
  13156. */
  13157. function quux () {
  13158. }
  13159. // Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
  13160. // Message: Unexpected tag `@returns`
  13161. /**
  13162. * @returns {string}
  13163. */
  13164. function f () {
  13165. function g() {
  13166. return 'foo'
  13167. }
  13168. () => {
  13169. return 5
  13170. }
  13171. }
  13172. // Message: JSDoc @returns declaration present but return expression not available in function.
  13173. /**
  13174. * @returns {Promise<void>}
  13175. */
  13176. async function quux() {}
  13177. // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
  13178. // Message: JSDoc @returns declaration present but return expression not available in function.
  13179. /**
  13180. * @returns {IterableIterator<any>}
  13181. */
  13182. function * quux() {}
  13183. // Settings: {"jsdoc":{"mode":"jsdoc"}}
  13184. // Message: JSDoc @returns declaration present but return expression not available in function.
  13185. /**
  13186. * @returns {IterableIterator<any>}
  13187. */
  13188. function * quux() {}
  13189. // Settings: {"jsdoc":{"mode":"typescript"}}
  13190. // "jsdoc/require-returns-check": ["error"|"warn", {"exemptGenerators":false}]
  13191. // Message: JSDoc @returns declaration present but return expression not available in function.
  13192. /**
  13193. * @returns {Promise<void>}
  13194. */
  13195. function quux() {
  13196. return new Promise((resolve, reject) => {})
  13197. }
  13198. // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
  13199. // Message: JSDoc @returns declaration present but return expression not available in function.
  13200. /**
  13201. * @returns {Promise<void>}
  13202. */
  13203. function quux() {
  13204. return new Promise((resolve, reject) => {
  13205. setTimeout(() => {
  13206. resolve();
  13207. });
  13208. })
  13209. }
  13210. // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
  13211. // Message: JSDoc @returns declaration present but return expression not available in function.
  13212. /**
  13213. * Description.
  13214. * @returns {string}
  13215. */
  13216. async function foo() {
  13217. return new Promise(resolve => resolve());
  13218. }
  13219. // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
  13220. // Message: JSDoc @returns declaration present but return expression not available in function.
  13221. /**
  13222. * Description.
  13223. * @returns {void}
  13224. */
  13225. async function foo() {
  13226. return new Promise(resolve => resolve());
  13227. }
  13228. // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false,"reportMissingReturnForUndefinedTypes":true}]
  13229. // Message: JSDoc @returns declaration present but return expression not available in function.
  13230. /**
  13231. * @returns { void } Foo.
  13232. */
  13233. function quux () {}
  13234. // "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
  13235. // Message: JSDoc @returns declaration present but return expression not available in function.
  13236. ````
  13237. The following patterns are not considered problems:
  13238. ````js
  13239. /**
  13240. * @returns Foo.
  13241. */
  13242. function quux () {
  13243. return foo;
  13244. }
  13245. /**
  13246. * @returns {string} Foo.
  13247. */
  13248. function quux () {
  13249. return foo;
  13250. }
  13251. /**
  13252. * @returns {string} Foo.
  13253. */
  13254. function quux () {
  13255. return foo;
  13256. }
  13257. /**
  13258. *
  13259. */
  13260. function quux () {
  13261. }
  13262. /**
  13263. * @returns {*} Foo.
  13264. */
  13265. const quux = () => foo;
  13266. /**
  13267. * @returns {undefined} Foo.
  13268. */
  13269. function quux () {}
  13270. /**
  13271. * @returns { void } Foo.
  13272. */
  13273. function quux () {}
  13274. /**
  13275. * @returns {Promise<void>}
  13276. */
  13277. async function quux() {}
  13278. /**
  13279. * @returns {Promise<void>}
  13280. */
  13281. const quux = async function () {}
  13282. /**
  13283. * @returns {Promise<void>}
  13284. */
  13285. const quux = async () => {}
  13286. /**
  13287. * @returns Foo.
  13288. * @abstract
  13289. */
  13290. function quux () {
  13291. throw new Error('must be implemented by subclass!');
  13292. }
  13293. /**
  13294. * @returns Foo.
  13295. * @virtual
  13296. */
  13297. function quux () {
  13298. throw new Error('must be implemented by subclass!');
  13299. }
  13300. /**
  13301. * @returns Foo.
  13302. * @constructor
  13303. */
  13304. function quux () {
  13305. }
  13306. /**
  13307. * @interface
  13308. */
  13309. class Foo {
  13310. /**
  13311. * @returns {string}
  13312. */
  13313. bar () {
  13314. }
  13315. }
  13316. /**
  13317. * @record
  13318. */
  13319. class Foo {
  13320. /**
  13321. * @returns {string}
  13322. */
  13323. bar () {
  13324. }
  13325. }
  13326. // Settings: {"jsdoc":{"mode":"closure"}}
  13327. /**
  13328. * @returns {undefined} Foo.
  13329. */
  13330. function quux () {
  13331. }
  13332. /**
  13333. * @returns {void} Foo.
  13334. */
  13335. function quux () {
  13336. }
  13337. /**
  13338. * @returns {void} Foo.
  13339. */
  13340. function quux () {
  13341. return undefined;
  13342. }
  13343. /**
  13344. * @returns {void} Foo.
  13345. */
  13346. function quux () {
  13347. return;
  13348. }
  13349. /**
  13350. *
  13351. */
  13352. function quux () {
  13353. return undefined;
  13354. }
  13355. /**
  13356. *
  13357. */
  13358. function quux () {
  13359. return;
  13360. }
  13361. /**
  13362. * @returns {true}
  13363. */
  13364. function quux () {
  13365. try {
  13366. return true;
  13367. } catch (err) {
  13368. }
  13369. return;
  13370. }
  13371. /**
  13372. * @returns {true}
  13373. */
  13374. function quux () {
  13375. try {
  13376. } finally {
  13377. return true;
  13378. }
  13379. return;
  13380. }
  13381. /**
  13382. * @returns {true}
  13383. */
  13384. function quux () {
  13385. try {
  13386. return;
  13387. } catch (err) {
  13388. }
  13389. return true;
  13390. }
  13391. /**
  13392. * @returns {true}
  13393. */
  13394. function quux () {
  13395. try {
  13396. something();
  13397. } catch (err) {
  13398. return true;
  13399. }
  13400. return;
  13401. }
  13402. /**
  13403. * @returns {true}
  13404. */
  13405. function quux () {
  13406. switch (true) {
  13407. case 'abc':
  13408. return true;
  13409. }
  13410. return;
  13411. }
  13412. /**
  13413. * @returns {true}
  13414. */
  13415. function quux () {
  13416. switch (true) {
  13417. case 'abc':
  13418. return;
  13419. }
  13420. return true;
  13421. }
  13422. /**
  13423. * @returns {true}
  13424. */
  13425. function quux () {
  13426. for (const i of abc) {
  13427. return true;
  13428. }
  13429. return;
  13430. }
  13431. /**
  13432. * @returns {true}
  13433. */
  13434. function quux () {
  13435. for (const a in b) {
  13436. return true;
  13437. }
  13438. }
  13439. /**
  13440. * @returns {true}
  13441. */
  13442. function quux () {
  13443. for (let i=0; i<n; i+=1) {
  13444. return true;
  13445. }
  13446. }
  13447. /**
  13448. * @returns {true}
  13449. */
  13450. function quux () {
  13451. while(true) {
  13452. return true
  13453. }
  13454. }
  13455. /**
  13456. * @returns {true}
  13457. */
  13458. function quux () {
  13459. do {
  13460. return true
  13461. }
  13462. while(true)
  13463. }
  13464. /**
  13465. * @returns {true}
  13466. */
  13467. function quux () {
  13468. if (true) {
  13469. return;
  13470. }
  13471. return true;
  13472. }
  13473. /**
  13474. * @returns {true}
  13475. */
  13476. function quux () {
  13477. if (true) {
  13478. return true;
  13479. }
  13480. }
  13481. /**
  13482. * @returns {true}
  13483. */
  13484. function quux () {
  13485. var a = {};
  13486. with (a) {
  13487. return true;
  13488. }
  13489. }
  13490. /**
  13491. * @returns {true}
  13492. */
  13493. function quux () {
  13494. if (true) {
  13495. return;
  13496. } else {
  13497. return true;
  13498. }
  13499. return;
  13500. }
  13501. /**
  13502. * @returns {Promise<number>}
  13503. */
  13504. async function quux() {
  13505. return 5;
  13506. }
  13507. /**
  13508. * @returns {Promise<number>}
  13509. */
  13510. async function quux() {
  13511. return 5;
  13512. }
  13513. // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
  13514. /**
  13515. * @returns {Promise<void>}
  13516. */
  13517. function quux() {
  13518. return new Promise((resolve, reject) => {
  13519. setTimeout(() => {
  13520. resolve(true);
  13521. });
  13522. })
  13523. }
  13524. // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
  13525. /**
  13526. * Description.
  13527. * @returns {void}
  13528. */
  13529. async function foo() {
  13530. return new Promise(resolve => resolve());
  13531. }
  13532. // "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
  13533. /**
  13534. * @returns { void } Foo.
  13535. */
  13536. function quux () {
  13537. return undefined;
  13538. }
  13539. // "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
  13540. /**
  13541. * @returns { string } Foo.
  13542. */
  13543. function quux () {
  13544. return 'abc';
  13545. }
  13546. // "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
  13547. /**
  13548. * @returns {IterableIterator<any>}
  13549. */
  13550. function * quux() {}
  13551. // Settings: {"jsdoc":{"mode":"typescript"}}
  13552. /**
  13553. * @returns {IterableIterator<any>}
  13554. */
  13555. function * quux() {}
  13556. // Settings: {"jsdoc":{"mode":"jsdoc"}}
  13557. // "jsdoc/require-returns-check": ["error"|"warn", {"exemptGenerators":true}]
  13558. ````
  13559. <a name="eslint-plugin-jsdoc-rules-require-returns-description"></a>
  13560. ### <code>require-returns-description</code>
  13561. Requires that the `@returns` tag has a `description` value. The error
  13562. will not be reported if the return value is `void` or `undefined`
  13563. or if it is `Promise<void>` or `Promise<undefined>`.
  13564. <a name="eslint-plugin-jsdoc-rules-require-returns-description-options-34"></a>
  13565. #### Options
  13566. <a name="eslint-plugin-jsdoc-rules-require-returns-description-options-34-contexts-12"></a>
  13567. ##### <code>contexts</code>
  13568. Set this to an array of strings representing the AST context (or an object with
  13569. `context` and `comment` properties) where you wish the rule to be applied.
  13570. Overrides the default contexts (see below). Set to `"any"` if you want
  13571. the rule to apply to any jsdoc block throughout your files (as is necessary
  13572. for finding function blocks not attached to a function declaration or
  13573. expression, i.e., `@callback` or `@function` (or its aliases `@func` or
  13574. `@method`) (including those associated with an `@interface`).
  13575. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  13576. section of our README for more on the expected format.
  13577. |||
  13578. |---|---|
  13579. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
  13580. |Tags|`returns`|
  13581. |Aliases|`return`|
  13582. |Recommended|true|
  13583. |Options|`contexts`|
  13584. The following patterns are considered problems:
  13585. ````js
  13586. /**
  13587. * @returns
  13588. */
  13589. function quux (foo) {
  13590. }
  13591. // Message: Missing JSDoc @returns description.
  13592. /**
  13593. * @returns {string}
  13594. */
  13595. function quux (foo) {
  13596. }
  13597. // Message: Missing JSDoc @returns description.
  13598. /**
  13599. * @returns {string}
  13600. */
  13601. function quux (foo) {
  13602. }
  13603. // "jsdoc/require-returns-description": ["error"|"warn", {"contexts":["any"]}]
  13604. // Message: Missing JSDoc @returns description.
  13605. /**
  13606. * @function
  13607. * @returns {string}
  13608. */
  13609. // "jsdoc/require-returns-description": ["error"|"warn", {"contexts":["any"]}]
  13610. // Message: Missing JSDoc @returns description.
  13611. /**
  13612. * @callback
  13613. * @returns {string}
  13614. */
  13615. // "jsdoc/require-returns-description": ["error"|"warn", {"contexts":["any"]}]
  13616. // Message: Missing JSDoc @returns description.
  13617. /**
  13618. * @return
  13619. */
  13620. function quux (foo) {
  13621. }
  13622. // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
  13623. // Message: Missing JSDoc @return description.
  13624. /**
  13625. * @returns
  13626. */
  13627. function quux () {
  13628. }
  13629. // Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
  13630. // Message: Unexpected tag `@returns`
  13631. ````
  13632. The following patterns are not considered problems:
  13633. ````js
  13634. /**
  13635. *
  13636. */
  13637. function quux () {
  13638. }
  13639. /**
  13640. * @returns Foo.
  13641. */
  13642. function quux () {
  13643. }
  13644. /**
  13645. * @returns Foo.
  13646. */
  13647. function quux () {
  13648. }
  13649. // "jsdoc/require-returns-description": ["error"|"warn", {"contexts":["any"]}]
  13650. /**
  13651. * @returns {undefined}
  13652. */
  13653. function quux () {
  13654. }
  13655. /**
  13656. * @returns {void}
  13657. */
  13658. function quux () {
  13659. }
  13660. /**
  13661. * @returns {Promise<void>}
  13662. */
  13663. function quux () {
  13664. }
  13665. /**
  13666. * @returns {Promise<undefined>}
  13667. */
  13668. function quux () {
  13669. }
  13670. /**
  13671. * @function
  13672. * @returns
  13673. */
  13674. /**
  13675. * @callback
  13676. * @returns
  13677. */
  13678. ````
  13679. <a name="eslint-plugin-jsdoc-rules-require-returns-type"></a>
  13680. ### <code>require-returns-type</code>
  13681. Requires that `@returns` tag has `type` value.
  13682. <a name="eslint-plugin-jsdoc-rules-require-returns-type-options-35"></a>
  13683. #### Options
  13684. <a name="eslint-plugin-jsdoc-rules-require-returns-type-options-35-contexts-13"></a>
  13685. ##### <code>contexts</code>
  13686. Set this to an array of strings representing the AST context (or an object with
  13687. `context` and `comment` properties) where you wish the rule to be applied.
  13688. Overrides the default contexts (see below). Set to `"any"` if you want
  13689. the rule to apply to any jsdoc block throughout your files (as is necessary
  13690. for finding function blocks not attached to a function declaration or
  13691. expression, i.e., `@callback` or `@function` (or its aliases `@func` or
  13692. `@method`) (including those associated with an `@interface`).
  13693. See the ["AST and Selectors"](#eslint-plugin-jsdoc-advanced-ast-and-selectors)
  13694. section of our README for more on the expected format.
  13695. |||
  13696. |---|---|
  13697. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
  13698. |Tags|`returns`|
  13699. |Aliases|`return`|
  13700. |Recommended|true|
  13701. |Options|`contexts`|
  13702. The following patterns are considered problems:
  13703. ````js
  13704. /**
  13705. * @returns
  13706. */
  13707. function quux () {
  13708. }
  13709. // Message: Missing JSDoc @returns type.
  13710. /**
  13711. * @returns Foo.
  13712. */
  13713. function quux () {
  13714. }
  13715. // Message: Missing JSDoc @returns type.
  13716. /**
  13717. * @returns Foo.
  13718. */
  13719. function quux () {
  13720. }
  13721. // "jsdoc/require-returns-type": ["error"|"warn", {"contexts":["any"]}]
  13722. // Message: Missing JSDoc @returns type.
  13723. /**
  13724. * @function
  13725. * @returns Foo.
  13726. */
  13727. // "jsdoc/require-returns-type": ["error"|"warn", {"contexts":["any"]}]
  13728. // Message: Missing JSDoc @returns type.
  13729. /**
  13730. * @callback
  13731. * @returns Foo.
  13732. */
  13733. // "jsdoc/require-returns-type": ["error"|"warn", {"contexts":["any"]}]
  13734. // Message: Missing JSDoc @returns type.
  13735. /**
  13736. * @return Foo.
  13737. */
  13738. function quux () {
  13739. }
  13740. // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
  13741. // Message: Missing JSDoc @return type.
  13742. /**
  13743. * @returns
  13744. */
  13745. function quux () {
  13746. }
  13747. // Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
  13748. // Message: Unexpected tag `@returns`
  13749. ````
  13750. The following patterns are not considered problems:
  13751. ````js
  13752. /**
  13753. * @returns {number}
  13754. */
  13755. function quux () {
  13756. }
  13757. /**
  13758. * @returns {number}
  13759. */
  13760. function quux () {
  13761. }
  13762. // "jsdoc/require-returns-type": ["error"|"warn", {"contexts":["any"]}]
  13763. /**
  13764. * @function
  13765. * @returns Foo.
  13766. */
  13767. /**
  13768. * @callback
  13769. * @returns Foo.
  13770. */
  13771. ````
  13772. <a name="eslint-plugin-jsdoc-rules-require-returns"></a>
  13773. ### <code>require-returns</code>
  13774. Requires that returns are documented.
  13775. Will also report if multiple `@returns` tags are present.
  13776. <a name="eslint-plugin-jsdoc-rules-require-returns-options-36"></a>
  13777. #### Options
  13778. - `checkConstructors` - A value indicating whether `constructor`s should
  13779. be checked for `@returns` tags. Defaults to `false`.
  13780. - `checkGetters` - Boolean to determine whether getter methods should
  13781. be checked for `@returns` tags. Defaults to `true`.
  13782. - `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the
  13783. document block avoids the need for a `@returns`. Defaults to an array
  13784. with `inheritdoc`. If you set this array, it will overwrite the default,
  13785. so be sure to add back `inheritdoc` if you wish its presence to cause
  13786. exemption of the rule.
  13787. - `forceRequireReturn` - Set to `true` to always insist on
  13788. `@returns` documentation regardless of implicit or explicit `return`'s
  13789. in the function. May be desired to flag that a project is aware of an
  13790. `undefined`/`void` return. Defaults to `false`.
  13791. - `forceReturnsWithAsync` - By default `async` functions that do not explicitly
  13792. return a value pass this rule as an `async` function will always return a
  13793. `Promise`, even if the `Promise` resolves to void. You can force all
  13794. `async` functions (including ones with an explicit `Promise` but no
  13795. detected non-`undefined` `resolve` value) to require `@return`
  13796. documentation by setting `forceReturnsWithAsync` to `true` on the options
  13797. object. This may be useful for flagging that there has been consideration
  13798. of return type. Defaults to `false`.
  13799. - `contexts` - Set this to an array of strings representing the AST context
  13800. (or an object with `context` and `comment` properties) where you wish
  13801. the rule to be applied.
  13802. Overrides the default contexts (see below). Set to `"any"` if you want
  13803. the rule to apply to any jsdoc block throughout your files (as is necessary
  13804. for finding function blocks not attached to a function declaration or
  13805. expression, i.e., `@callback` or `@function` (or its aliases `@func` or
  13806. `@method`) (including those associated with an `@interface`). This
  13807. rule will only apply on non-default contexts when there is such a tag
  13808. present and the `forceRequireReturn` option is set or if the
  13809. `forceReturnsWithAsync` option is set with a present `@async` tag
  13810. (since we are not checking against the actual `return` values in these
  13811. cases).
  13812. | | |
  13813. | -------- | ------- |
  13814. | Context | `ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled |
  13815. | Tags | `returns` |
  13816. | Aliases | `return` |
  13817. |Recommended|true|
  13818. | Options | `checkConstructors`, `checkGetters`, `contexts`, `exemptedBy`, `forceRequireReturn`, `forceReturnsWithAsync` |
  13819. | Settings | `ignoreReplacesDocs`, `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` |
  13820. The following patterns are considered problems:
  13821. ````js
  13822. /**
  13823. *
  13824. */
  13825. function quux (foo) {
  13826. return foo;
  13827. }
  13828. // Message: Missing JSDoc @returns declaration.
  13829. /**
  13830. *
  13831. */
  13832. const foo = () => ({
  13833. bar: 'baz'
  13834. })
  13835. // Message: Missing JSDoc @returns declaration.
  13836. /**
  13837. *
  13838. */
  13839. const foo = bar=>({ bar })
  13840. // Message: Missing JSDoc @returns declaration.
  13841. /**
  13842. *
  13843. */
  13844. const foo = bar => bar.baz()
  13845. // Message: Missing JSDoc @returns declaration.
  13846. /**
  13847. *
  13848. */
  13849. function quux (foo) {
  13850. return foo;
  13851. }
  13852. // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
  13853. // Message: Missing JSDoc @return declaration.
  13854. /**
  13855. *
  13856. */
  13857. async function quux() {
  13858. }
  13859. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  13860. // Message: Missing JSDoc @returns declaration.
  13861. /**
  13862. *
  13863. */
  13864. const quux = async function () {}
  13865. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  13866. // Message: Missing JSDoc @returns declaration.
  13867. /**
  13868. *
  13869. */
  13870. const quux = async () => {}
  13871. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  13872. // Message: Missing JSDoc @returns declaration.
  13873. /**
  13874. *
  13875. */
  13876. async function quux () {}
  13877. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  13878. // Message: Missing JSDoc @returns declaration.
  13879. /**
  13880. *
  13881. */
  13882. function quux () {
  13883. }
  13884. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  13885. // Message: Missing JSDoc @returns declaration.
  13886. /**
  13887. *
  13888. */
  13889. function quux () {
  13890. }
  13891. // "jsdoc/require-returns": ["error"|"warn", {"contexts":["any"],"forceRequireReturn":true}]
  13892. // Message: Missing JSDoc @returns declaration.
  13893. /**
  13894. * @function
  13895. */
  13896. // "jsdoc/require-returns": ["error"|"warn", {"contexts":["any"],"forceRequireReturn":true}]
  13897. // Message: Missing JSDoc @returns declaration.
  13898. /**
  13899. * @callback
  13900. */
  13901. // "jsdoc/require-returns": ["error"|"warn", {"contexts":["any"],"forceRequireReturn":true}]
  13902. // Message: Missing JSDoc @returns declaration.
  13903. const language = {
  13904. /**
  13905. * @param {string} name
  13906. */
  13907. get name() {
  13908. return this._name;
  13909. }
  13910. }
  13911. // Message: Missing JSDoc @returns declaration.
  13912. /**
  13913. *
  13914. */
  13915. async function quux () {
  13916. }
  13917. // "jsdoc/require-returns": ["error"|"warn", {"forceReturnsWithAsync":true}]
  13918. // Message: Missing JSDoc @returns declaration.
  13919. /**
  13920. * @function
  13921. * @async
  13922. */
  13923. // "jsdoc/require-returns": ["error"|"warn", {"contexts":["any"],"forceReturnsWithAsync":true}]
  13924. // Message: Missing JSDoc @returns declaration.
  13925. /**
  13926. * @callback
  13927. * @async
  13928. */
  13929. // "jsdoc/require-returns": ["error"|"warn", {"contexts":["any"],"forceReturnsWithAsync":true}]
  13930. // Message: Missing JSDoc @returns declaration.
  13931. /**
  13932. * @returns {undefined}
  13933. * @returns {void}
  13934. */
  13935. function quux (foo) {
  13936. return foo;
  13937. }
  13938. // Message: Found more than one @returns declaration.
  13939. /**
  13940. * @returns
  13941. */
  13942. function quux () {
  13943. }
  13944. // Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
  13945. // Message: Unexpected tag `@returns`
  13946. /**
  13947. * @param foo
  13948. */
  13949. function quux (foo) {
  13950. return 'bar';
  13951. }
  13952. // "jsdoc/require-returns": ["error"|"warn", {"exemptedBy":["notPresent"]}]
  13953. // Message: Missing JSDoc @returns declaration.
  13954. /**
  13955. * @param {array} a
  13956. */
  13957. async function foo(a) {
  13958. return;
  13959. }
  13960. // "jsdoc/require-returns": ["error"|"warn", {"forceReturnsWithAsync":true}]
  13961. // Message: Missing JSDoc @returns declaration.
  13962. /**
  13963. * @param {array} a
  13964. */
  13965. async function foo(a) {
  13966. return Promise.all(a);
  13967. }
  13968. // "jsdoc/require-returns": ["error"|"warn", {"forceReturnsWithAsync":true}]
  13969. // Message: Missing JSDoc @returns declaration.
  13970. class foo {
  13971. /** gets bar */
  13972. get bar() {
  13973. return 0;
  13974. }
  13975. }
  13976. // "jsdoc/require-returns": ["error"|"warn", {"checkGetters":true}]
  13977. // Message: Missing JSDoc @returns declaration.
  13978. class TestClass {
  13979. /**
  13980. *
  13981. */
  13982. constructor() {
  13983. return new Map();
  13984. }
  13985. }
  13986. // "jsdoc/require-returns": ["error"|"warn", {"checkConstructors":true}]
  13987. // Message: Missing JSDoc @returns declaration.
  13988. class TestClass {
  13989. /**
  13990. *
  13991. */
  13992. get Test() {
  13993. return 0;
  13994. }
  13995. }
  13996. // "jsdoc/require-returns": ["error"|"warn", {"checkGetters":true}]
  13997. // Message: Missing JSDoc @returns declaration.
  13998. class quux {
  13999. /**
  14000. *
  14001. */
  14002. quux () {
  14003. }
  14004. }
  14005. // "jsdoc/require-returns": ["error"|"warn", {"contexts":["any"],"forceRequireReturn":true}]
  14006. // Message: Missing JSDoc @returns declaration.
  14007. /**
  14008. * @param {array} a
  14009. */
  14010. async function foo(a) {
  14011. return Promise.all(a);
  14012. }
  14013. // Message: Missing JSDoc @returns declaration.
  14014. /**
  14015. *
  14016. */
  14017. function quux (foo) {
  14018. return new Promise(function (resolve, reject) {
  14019. resolve(foo);
  14020. });
  14021. }
  14022. // Message: Missing JSDoc @returns declaration.
  14023. /**
  14024. *
  14025. */
  14026. function quux (foo) {
  14027. return new Promise(function (resolve, reject) {
  14028. setTimeout(() => {
  14029. resolve(true);
  14030. });
  14031. });
  14032. }
  14033. // Message: Missing JSDoc @returns declaration.
  14034. /**
  14035. *
  14036. */
  14037. function quux (foo) {
  14038. return new Promise(function (resolve, reject) {
  14039. foo(resolve);
  14040. });
  14041. }
  14042. // Message: Missing JSDoc @returns declaration.
  14043. /**
  14044. *
  14045. */
  14046. function quux () {
  14047. return new Promise((resolve, reject) => {
  14048. while(true) {
  14049. resolve(true);
  14050. }
  14051. });
  14052. }
  14053. // Message: Missing JSDoc @returns declaration.
  14054. /**
  14055. *
  14056. */
  14057. function quux () {
  14058. return new Promise((resolve, reject) => {
  14059. do {
  14060. resolve(true);
  14061. }
  14062. while(true)
  14063. });
  14064. }
  14065. // Message: Missing JSDoc @returns declaration.
  14066. /**
  14067. *
  14068. */
  14069. function quux () {
  14070. return new Promise((resolve, reject) => {
  14071. if (true) {
  14072. resolve(true);
  14073. }
  14074. return;
  14075. });
  14076. }
  14077. // Message: Missing JSDoc @returns declaration.
  14078. /**
  14079. *
  14080. */
  14081. function quux () {
  14082. return new Promise((resolve, reject) => {
  14083. if (true) {
  14084. resolve(true);
  14085. }
  14086. });
  14087. }
  14088. // Message: Missing JSDoc @returns declaration.
  14089. /**
  14090. *
  14091. */
  14092. function quux () {
  14093. var a = {};
  14094. return new Promise((resolve, reject) => {
  14095. with (a) {
  14096. resolve(true);
  14097. }
  14098. });
  14099. }
  14100. // Message: Missing JSDoc @returns declaration.
  14101. /**
  14102. *
  14103. */
  14104. function quux () {
  14105. var a = {};
  14106. return new Promise((resolve, reject) => {
  14107. try {
  14108. resolve(true);
  14109. } catch (err) {}
  14110. });
  14111. }
  14112. // Message: Missing JSDoc @returns declaration.
  14113. /**
  14114. *
  14115. */
  14116. function quux () {
  14117. var a = {};
  14118. return new Promise((resolve, reject) => {
  14119. try {
  14120. } catch (err) {
  14121. resolve(true);
  14122. }
  14123. });
  14124. }
  14125. // Message: Missing JSDoc @returns declaration.
  14126. /**
  14127. *
  14128. */
  14129. function quux () {
  14130. var a = {};
  14131. return new Promise((resolve, reject) => {
  14132. try {
  14133. } catch (err) {
  14134. } finally {
  14135. resolve(true);
  14136. }
  14137. });
  14138. }
  14139. // Message: Missing JSDoc @returns declaration.
  14140. /**
  14141. *
  14142. */
  14143. function quux () {
  14144. var a = {};
  14145. return new Promise((resolve, reject) => {
  14146. switch (a) {
  14147. case 'abc':
  14148. resolve(true);
  14149. }
  14150. });
  14151. }
  14152. // Message: Missing JSDoc @returns declaration.
  14153. /**
  14154. *
  14155. */
  14156. function quux () {
  14157. return new Promise((resolve, reject) => {
  14158. if (true) {
  14159. resolve();
  14160. } else {
  14161. resolve(true);
  14162. }
  14163. });
  14164. }
  14165. // Message: Missing JSDoc @returns declaration.
  14166. /**
  14167. *
  14168. */
  14169. function quux () {
  14170. return new Promise((resolve, reject) => {
  14171. for (let i = 0; i < 5 ; i++) {
  14172. resolve(true);
  14173. }
  14174. });
  14175. }
  14176. // Message: Missing JSDoc @returns declaration.
  14177. /**
  14178. *
  14179. */
  14180. function quux () {
  14181. return new Promise((resolve, reject) => {
  14182. for (const i of obj) {
  14183. resolve(true);
  14184. }
  14185. });
  14186. }
  14187. // Message: Missing JSDoc @returns declaration.
  14188. /**
  14189. *
  14190. */
  14191. function quux () {
  14192. return new Promise((resolve, reject) => {
  14193. for (const i in obj) {
  14194. resolve(true);
  14195. }
  14196. });
  14197. }
  14198. // Message: Missing JSDoc @returns declaration.
  14199. /**
  14200. *
  14201. */
  14202. function quux () {
  14203. return new Promise((resolve, reject) => {
  14204. if (true) {
  14205. return;
  14206. } else {
  14207. resolve(true);
  14208. }
  14209. });
  14210. }
  14211. // Message: Missing JSDoc @returns declaration.
  14212. /**
  14213. *
  14214. */
  14215. function quux () {
  14216. return new Promise((resolve, reject) => {
  14217. function a () {
  14218. resolve(true);
  14219. }
  14220. a();
  14221. });
  14222. }
  14223. // Message: Missing JSDoc @returns declaration.
  14224. /**
  14225. *
  14226. */
  14227. function quux () {
  14228. return new Promise();
  14229. }
  14230. // "jsdoc/require-returns": ["error"|"warn", {"forceReturnsWithAsync":true}]
  14231. // Message: Missing JSDoc @returns declaration.
  14232. /**
  14233. *
  14234. */
  14235. async function quux () {
  14236. return new Promise();
  14237. }
  14238. // "jsdoc/require-returns": ["error"|"warn", {"forceReturnsWithAsync":true}]
  14239. // Message: Missing JSDoc @returns declaration.
  14240. /**
  14241. *
  14242. */
  14243. async function quux () {
  14244. return new Promise((resolve, reject) => {});
  14245. }
  14246. // "jsdoc/require-returns": ["error"|"warn", {"forceReturnsWithAsync":true}]
  14247. // Message: Missing JSDoc @returns declaration.
  14248. export class A {
  14249. /**
  14250. * Description.
  14251. */
  14252. public f(): string {
  14253. return "";
  14254. }
  14255. }
  14256. export interface B {
  14257. /**
  14258. * Description.
  14259. */
  14260. f(): string;
  14261. /**
  14262. * Description.
  14263. */
  14264. g: () => string;
  14265. /**
  14266. * Description.
  14267. */
  14268. h(): void;
  14269. /**
  14270. * Description.
  14271. */
  14272. i: () => void;
  14273. }
  14274. /**
  14275. * Description.
  14276. */
  14277. export function f(): string {
  14278. return "";
  14279. }
  14280. // "jsdoc/require-returns": ["error"|"warn", {"contexts":[":not(BlockStatement) > FunctionDeclaration","MethodDefinition","TSMethodSignature","TSPropertySignature > TSTypeAnnotation > TSFunctionType"]}]
  14281. // Message: Missing JSDoc @returns declaration.
  14282. ````
  14283. The following patterns are not considered problems:
  14284. ````js
  14285. /**
  14286. * @returns Foo.
  14287. */
  14288. function quux () {
  14289. return foo;
  14290. }
  14291. /**
  14292. * @returns Foo.
  14293. */
  14294. function quux () {
  14295. return foo;
  14296. }
  14297. // "jsdoc/require-returns": ["error"|"warn", {"contexts":["any"]}]
  14298. /**
  14299. *
  14300. */
  14301. function quux () {
  14302. }
  14303. /**
  14304. *
  14305. */
  14306. function quux (bar) {
  14307. bar.filter(baz => {
  14308. return baz.corge();
  14309. })
  14310. }
  14311. /**
  14312. * @returns Array
  14313. */
  14314. function quux (bar) {
  14315. return bar.filter(baz => {
  14316. return baz.corge();
  14317. })
  14318. }
  14319. /**
  14320. * @returns Array
  14321. */
  14322. const quux = (bar) => bar.filter(({ corge }) => corge())
  14323. /**
  14324. * @inheritdoc
  14325. */
  14326. function quux (foo) {
  14327. }
  14328. /**
  14329. * @override
  14330. */
  14331. function quux (foo) {
  14332. }
  14333. /**
  14334. * @constructor
  14335. */
  14336. function quux (foo) {
  14337. return true;
  14338. }
  14339. /**
  14340. * @implements
  14341. */
  14342. function quux (foo) {
  14343. return true;
  14344. }
  14345. /**
  14346. * @override
  14347. */
  14348. function quux (foo) {
  14349. return foo;
  14350. }
  14351. /**
  14352. * @class
  14353. */
  14354. function quux (foo) {
  14355. return true;
  14356. }
  14357. /**
  14358. * @constructor
  14359. */
  14360. function quux (foo) {
  14361. }
  14362. /**
  14363. * @returns {object}
  14364. */
  14365. function quux () {
  14366. return {a: foo};
  14367. }
  14368. /**
  14369. * @returns {object}
  14370. */
  14371. const quux = () => ({a: foo});
  14372. /**
  14373. * @returns {object}
  14374. */
  14375. const quux = () => {
  14376. return {a: foo}
  14377. };
  14378. /**
  14379. * @returns {void}
  14380. */
  14381. function quux () {
  14382. }
  14383. /**
  14384. * @returns {void}
  14385. */
  14386. const quux = () => {
  14387. }
  14388. /**
  14389. * @returns {undefined}
  14390. */
  14391. function quux () {
  14392. }
  14393. /**
  14394. * @returns {undefined}
  14395. */
  14396. const quux = () => {
  14397. }
  14398. /**
  14399. *
  14400. */
  14401. function quux () {
  14402. }
  14403. /**
  14404. *
  14405. */
  14406. const quux = () => {
  14407. }
  14408. class Foo {
  14409. /**
  14410. *
  14411. */
  14412. constructor () {
  14413. }
  14414. }
  14415. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  14416. const language = {
  14417. /**
  14418. * @param {string} name
  14419. */
  14420. set name(name) {
  14421. this._name = name;
  14422. }
  14423. }
  14424. /**
  14425. * @returns {void}
  14426. */
  14427. function quux () {
  14428. }
  14429. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  14430. /**
  14431. * @returns {void}
  14432. */
  14433. function quux () {
  14434. return undefined;
  14435. }
  14436. /**
  14437. * @returns {void}
  14438. */
  14439. function quux () {
  14440. return undefined;
  14441. }
  14442. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  14443. /**
  14444. * @returns {void}
  14445. */
  14446. function quux () {
  14447. return;
  14448. }
  14449. /**
  14450. * @returns {void}
  14451. */
  14452. function quux () {
  14453. }
  14454. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  14455. /**
  14456. * @returns {void}
  14457. */
  14458. function quux () {
  14459. return;
  14460. }
  14461. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  14462. /** @type {RequestHandler} */
  14463. function quux (req, res , next) {
  14464. return;
  14465. }
  14466. /**
  14467. * @returns {Promise}
  14468. */
  14469. async function quux () {
  14470. }
  14471. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  14472. /**
  14473. * @returns {Promise}
  14474. */
  14475. async function quux () {
  14476. }
  14477. // "jsdoc/require-returns": ["error"|"warn", {"forceReturnsWithAsync":true}]
  14478. /**
  14479. *
  14480. */
  14481. async function quux () {}
  14482. /**
  14483. *
  14484. */
  14485. const quux = async function () {}
  14486. /**
  14487. *
  14488. */
  14489. const quux = async () => {}
  14490. /** foo class */
  14491. class foo {
  14492. /** foo constructor */
  14493. constructor () {
  14494. // =>
  14495. this.bar = true;
  14496. }
  14497. }
  14498. export default foo;
  14499. /**
  14500. *
  14501. */
  14502. function quux () {
  14503. }
  14504. // "jsdoc/require-returns": ["error"|"warn", {"forceReturnsWithAsync":true}]
  14505. /**
  14506. * @type {MyCallback}
  14507. */
  14508. function quux () {
  14509. }
  14510. // "jsdoc/require-returns": ["error"|"warn", {"exemptedBy":["type"]}]
  14511. /**
  14512. * @param {array} a
  14513. */
  14514. async function foo(a) {
  14515. return;
  14516. }
  14517. /**
  14518. *
  14519. */
  14520. // "jsdoc/require-returns": ["error"|"warn", {"contexts":["any"]}]
  14521. /**
  14522. * @async
  14523. */
  14524. // "jsdoc/require-returns": ["error"|"warn", {"contexts":["any"]}]
  14525. /**
  14526. * @function
  14527. */
  14528. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  14529. /**
  14530. * @callback
  14531. */
  14532. // "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
  14533. /**
  14534. * @function
  14535. * @async
  14536. */
  14537. // "jsdoc/require-returns": ["error"|"warn", {"forceReturnsWithAsync":true}]
  14538. /**
  14539. * @callback
  14540. * @async
  14541. */
  14542. // "jsdoc/require-returns": ["error"|"warn", {"forceReturnsWithAsync":true}]
  14543. /**
  14544. * @function
  14545. */
  14546. // "jsdoc/require-returns": ["error"|"warn", {"contexts":["any"],"forceReturnsWithAsync":true}]
  14547. /**
  14548. * @callback
  14549. */
  14550. // "jsdoc/require-returns": ["error"|"warn", {"contexts":["any"],"forceReturnsWithAsync":true}]
  14551. class foo {
  14552. get bar() {
  14553. return 0;
  14554. }
  14555. }
  14556. // "jsdoc/require-returns": ["error"|"warn", {"checkGetters":false}]
  14557. class foo {
  14558. /** @returns zero */
  14559. get bar() {
  14560. return 0;
  14561. }
  14562. }
  14563. // "jsdoc/require-returns": ["error"|"warn", {"checkGetters":true}]
  14564. class foo {
  14565. /** @returns zero */
  14566. get bar() {
  14567. return 0;
  14568. }
  14569. }
  14570. // "jsdoc/require-returns": ["error"|"warn", {"checkGetters":false}]
  14571. class TestClass {
  14572. /**
  14573. *
  14574. */
  14575. constructor() { }
  14576. }
  14577. class TestClass {
  14578. /**
  14579. * @returns A map.
  14580. */
  14581. constructor() {
  14582. return new Map();
  14583. }
  14584. }
  14585. class TestClass {
  14586. /**
  14587. *
  14588. */
  14589. constructor() { }
  14590. }
  14591. // "jsdoc/require-returns": ["error"|"warn", {"checkConstructors":false}]
  14592. class TestClass {
  14593. /**
  14594. *
  14595. */
  14596. get Test() { }
  14597. }
  14598. class TestClass {
  14599. /**
  14600. * @returns A number.
  14601. */
  14602. get Test() {
  14603. return 0;
  14604. }
  14605. }
  14606. class TestClass {
  14607. /**
  14608. *
  14609. */
  14610. get Test() {
  14611. return 0;
  14612. }
  14613. }
  14614. // "jsdoc/require-returns": ["error"|"warn", {"checkGetters":false}]
  14615. /**
  14616. *
  14617. */
  14618. function quux (foo) {
  14619. return new Promise(function (resolve, reject) {
  14620. resolve();
  14621. });
  14622. }
  14623. /**
  14624. *
  14625. */
  14626. function quux (foo) {
  14627. return new Promise(function (resolve, reject) {
  14628. setTimeout(() => {
  14629. resolve();
  14630. });
  14631. });
  14632. }
  14633. /**
  14634. *
  14635. */
  14636. function quux (foo) {
  14637. return new Promise(function (resolve, reject) {
  14638. foo();
  14639. });
  14640. }
  14641. /**
  14642. *
  14643. */
  14644. function quux (foo) {
  14645. return new Promise(function (resolve, reject) {
  14646. abc((resolve) => {
  14647. resolve(true);
  14648. });
  14649. });
  14650. }
  14651. /**
  14652. *
  14653. */
  14654. function quux (foo) {
  14655. return new Promise(function (resolve, reject) {
  14656. abc(function (resolve) {
  14657. resolve(true);
  14658. });
  14659. });
  14660. }
  14661. /**
  14662. *
  14663. */
  14664. function quux () {
  14665. return new Promise((resolve, reject) => {
  14666. if (true) {
  14667. resolve();
  14668. }
  14669. });
  14670. return;
  14671. }
  14672. /**
  14673. *
  14674. */
  14675. function quux () {
  14676. return new Promise();
  14677. }
  14678. /**
  14679. * Description.
  14680. */
  14681. async function foo() {
  14682. return new Promise(resolve => resolve());
  14683. }
  14684. ````
  14685. <a name="eslint-plugin-jsdoc-rules-require-throws"></a>
  14686. ### <code>require-throws</code>
  14687. Requires that throw statements are documented.
  14688. <a name="eslint-plugin-jsdoc-rules-require-throws-options-37"></a>
  14689. #### Options
  14690. - `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the
  14691. document block avoids the need for a `@throws`. Defaults to an array
  14692. with `inheritdoc`. If you set this array, it will overwrite the default,
  14693. so be sure to add back `inheritdoc` if you wish its presence to cause
  14694. exemption of the rule.
  14695. - `contexts` - Set this to an array of strings representing the AST context
  14696. (or an object with `context` and `comment` properties) where you wish
  14697. the rule to be applied.
  14698. Overrides the default contexts (see below). Set to `"any"` if you want
  14699. the rule to apply to any jsdoc block throughout your files (as is necessary
  14700. for finding function blocks not attached to a function declaration or
  14701. expression, i.e., `@callback` or `@function` (or its aliases `@func` or
  14702. `@method`) (including those associated with an `@interface`).
  14703. ```js
  14704. 'jsdoc/require-throws': 'error',
  14705. ```
  14706. | | |
  14707. | -------- | --- |
  14708. | Context | `ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled |
  14709. | Tags | `throws` |
  14710. | Aliases | `exception` |
  14711. |Recommended|true|
  14712. | Options | `contexts`, `exemptedBy` |
  14713. | Settings | `ignoreReplacesDocs`, `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` |
  14714. The following patterns are considered problems:
  14715. ````js
  14716. /**
  14717. *
  14718. */
  14719. function quux (foo) {
  14720. throw new Error('err')
  14721. }
  14722. // Message: Missing JSDoc @throws declaration.
  14723. /**
  14724. *
  14725. */
  14726. const quux = function (foo) {
  14727. throw new Error('err')
  14728. }
  14729. // Message: Missing JSDoc @throws declaration.
  14730. /**
  14731. *
  14732. */
  14733. const quux = (foo) => {
  14734. throw new Error('err')
  14735. }
  14736. // Message: Missing JSDoc @throws declaration.
  14737. /**
  14738. *
  14739. */
  14740. function quux (foo) {
  14741. while(true) {
  14742. throw new Error('err')
  14743. }
  14744. }
  14745. // Message: Missing JSDoc @throws declaration.
  14746. /**
  14747. *
  14748. */
  14749. function quux (foo) {
  14750. do {
  14751. throw new Error('err')
  14752. } while(true)
  14753. }
  14754. // Message: Missing JSDoc @throws declaration.
  14755. /**
  14756. *
  14757. */
  14758. function quux (foo) {
  14759. for(var i = 0; i <= 10; i++) {
  14760. throw new Error('err')
  14761. }
  14762. }
  14763. // Message: Missing JSDoc @throws declaration.
  14764. /**
  14765. *
  14766. */
  14767. function quux (foo) {
  14768. for(num in [1,2,3]) {
  14769. throw new Error('err')
  14770. }
  14771. }
  14772. // Message: Missing JSDoc @throws declaration.
  14773. /**
  14774. *
  14775. */
  14776. function quux (foo) {
  14777. for(const num of [1,2,3]) {
  14778. throw new Error('err')
  14779. }
  14780. }
  14781. // Message: Missing JSDoc @throws declaration.
  14782. /**
  14783. *
  14784. */
  14785. function quux (foo) {
  14786. for(const index in [1,2,3]) {
  14787. throw new Error('err')
  14788. }
  14789. }
  14790. // Message: Missing JSDoc @throws declaration.
  14791. /**
  14792. *
  14793. */
  14794. function quux (foo) {
  14795. with(foo) {
  14796. throw new Error('err')
  14797. }
  14798. }
  14799. // Message: Missing JSDoc @throws declaration.
  14800. /**
  14801. *
  14802. */
  14803. function quux (foo) {
  14804. if (true) {
  14805. throw new Error('err')
  14806. }
  14807. }
  14808. // Message: Missing JSDoc @throws declaration.
  14809. /**
  14810. *
  14811. */
  14812. function quux (foo) {
  14813. if (false) {
  14814. // do nothing
  14815. } else {
  14816. throw new Error('err')
  14817. }
  14818. }
  14819. // Message: Missing JSDoc @throws declaration.
  14820. /**
  14821. *
  14822. */
  14823. function quux (foo) {
  14824. try {
  14825. throw new Error('err')
  14826. } catch(e) {
  14827. throw new Error(e.message)
  14828. }
  14829. }
  14830. // Message: Missing JSDoc @throws declaration.
  14831. /**
  14832. *
  14833. */
  14834. function quux (foo) {
  14835. try {
  14836. // do nothing
  14837. } finally {
  14838. throw new Error(e.message)
  14839. }
  14840. }
  14841. // Message: Missing JSDoc @throws declaration.
  14842. /**
  14843. *
  14844. */
  14845. function quux (foo) {
  14846. const a = 'b'
  14847. switch(a) {
  14848. case 'b':
  14849. throw new Error('err')
  14850. }
  14851. }
  14852. // Message: Missing JSDoc @throws declaration.
  14853. /**
  14854. * @throws
  14855. */
  14856. function quux () {
  14857. }
  14858. // Settings: {"jsdoc":{"tagNamePreference":{"throws":false}}}
  14859. // Message: Unexpected tag `@throws`
  14860. /**
  14861. *
  14862. */
  14863. const directThrowAfterArrow = (b) => {
  14864. const a = () => {};
  14865. if (b) {
  14866. throw new Error('oops')
  14867. }
  14868. return a;
  14869. };
  14870. // Message: Missing JSDoc @throws declaration.
  14871. ````
  14872. The following patterns are not considered problems:
  14873. ````js
  14874. /**
  14875. * @throws An error.
  14876. */
  14877. function quux () {
  14878. throw new Error('err')
  14879. }
  14880. /**
  14881. *
  14882. */
  14883. function quux (foo) {
  14884. try {
  14885. throw new Error('err')
  14886. } catch(e) {}
  14887. }
  14888. /**
  14889. * @inheritdoc
  14890. */
  14891. function quux (foo) {
  14892. throw new Error('err')
  14893. }
  14894. /**
  14895. * @abstract
  14896. */
  14897. function quux (foo) {
  14898. throw new Error('err')
  14899. }
  14900. /**
  14901. *
  14902. */
  14903. function quux (foo) {
  14904. }
  14905. /**
  14906. * @type {MyCallback}
  14907. */
  14908. function quux () {
  14909. throw new Error('err')
  14910. }
  14911. // "jsdoc/require-throws": ["error"|"warn", {"exemptedBy":["type"]}]
  14912. /**
  14913. *
  14914. */
  14915. const itself = (n) => n;
  14916. /**
  14917. * Not tracking on nested function
  14918. */
  14919. const nested = () => () => {throw new Error('oops');};
  14920. /**
  14921. */
  14922. async function foo() {
  14923. throw Error("bar");
  14924. }
  14925. ````
  14926. <a name="eslint-plugin-jsdoc-rules-require-yields"></a>
  14927. ### <code>require-yields</code>
  14928. Requires that yields are documented.
  14929. Will also report if multiple `@yields` tags are present.
  14930. See the `next`, `forceRequireNext`, and `nextWithGeneratorTag` options for an
  14931. option to expect a non-standard `@next` tag.
  14932. <a name="eslint-plugin-jsdoc-rules-require-yields-options-38"></a>
  14933. #### Options
  14934. - `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the
  14935. document block avoids the need for a `@yields`. Defaults to an array
  14936. with `inheritdoc`. If you set this array, it will overwrite the default,
  14937. so be sure to add back `inheritdoc` if you wish its presence to cause
  14938. exemption of the rule.
  14939. - `forceRequireYields` - Set to `true` to always insist on
  14940. `@yields` documentation for generators even if there are only
  14941. expressionless `yield` statements in the function. May be desired to flag
  14942. that a project is aware of an `undefined`/`void` yield. Defaults to
  14943. `false`.
  14944. - `contexts` - Set this to an array of strings representing the AST context
  14945. (or an object with `context` and `comment` properties) where you wish
  14946. the rule to be applied.
  14947. Overrides the default contexts (see below). Set to `"any"` if you want
  14948. the rule to apply to any jsdoc block throughout your files (as is necessary
  14949. for finding function blocks not attached to a function declaration or
  14950. expression, i.e., `@callback` or `@function` (or its aliases `@func` or
  14951. `@method`) (including those associated with an `@interface`). This
  14952. rule will only apply on non-default contexts when there is such a tag
  14953. present and the `forceRequireYields` option is set or if the
  14954. `withGeneratorTag` option is set with a present `@generator` tag
  14955. (since we are not checking against the actual `yield` values in these
  14956. cases).
  14957. - `withGeneratorTag` - If a `@generator` tag is present on a block, require
  14958. `@yields`/`@yield`. Defaults to `true`. See `contexts` to `any` if you want
  14959. to catch `@generator` with `@callback` or such not attached to a function.
  14960. - `next` - If `true`, this option will insist that any use of a `yield` return
  14961. value (e.g., `const rv = yield;` or `const rv = yield value;`) has a
  14962. (non-standard) `@next` tag (in addition to any `@yields` tag) so as to be
  14963. able to document the type expected to be supplied into the iterator
  14964. (the `Generator` iterator that is returned by the call to the generator
  14965. function) to the iterator (e.g., `it.next(value)`). The tag will not be
  14966. expected if the generator function body merely has plain `yield;` or
  14967. `yield value;` statements without returning the values. Defaults to
  14968. `false`.
  14969. - `forceRequireNext` - Set to `true` to always insist on
  14970. `@next` documentation even if there are no `yield` statements in the
  14971. function or none return values. May be desired to flag that a project is
  14972. aware of the expected yield return being `undefined`. Defaults to `false`.
  14973. - `nextWithGeneratorTag` - If a `@generator` tag is present on a block, require
  14974. (non-standard ) `@next` (see `next` option). This will require using `void`
  14975. or `undefined` in cases where generators do not use the `next()`-supplied
  14976. incoming `yield`-returned value. Defaults to `false`. See `contexts` to
  14977. `any` if you want to catch `@generator` with `@callback` or such not
  14978. attached to a function.
  14979. |||
  14980. |---|---|
  14981. |Context|Generator functions (`FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled)|
  14982. |Tags|`yields`|
  14983. |Aliases|`yield`|
  14984. |Recommended|true|
  14985. | Options | `contexts`, `exemptedBy`, `withGeneratorTag`, `nextWithGeneratorTag`, `forceRequireYields`, `next` |
  14986. | Settings | `ignoreReplacesDocs`, `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` |
  14987. The following patterns are considered problems:
  14988. ````js
  14989. /**
  14990. *
  14991. */
  14992. function * quux (foo) {
  14993. yield foo;
  14994. }
  14995. // Message: Missing JSDoc @yields declaration.
  14996. /**
  14997. * @yields
  14998. */
  14999. function * quux (foo) {
  15000. const retVal = yield foo;
  15001. }
  15002. // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
  15003. // Message: Missing JSDoc @next declaration.
  15004. /**
  15005. * @yields
  15006. */
  15007. function * quux (foo) {
  15008. const retVal = yield;
  15009. }
  15010. // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
  15011. // Message: Missing JSDoc @next declaration.
  15012. /**
  15013. * @yields {void}
  15014. */
  15015. function * quux () {
  15016. }
  15017. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireNext":true}]
  15018. // Message: Missing JSDoc @next declaration.
  15019. /**
  15020. * @yields {void}
  15021. */
  15022. function * quux () {
  15023. yield;
  15024. }
  15025. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireNext":true}]
  15026. // Message: Missing JSDoc @next declaration.
  15027. /**
  15028. *
  15029. */
  15030. function * quux (foo) {
  15031. const a = yield foo;
  15032. }
  15033. // Message: Missing JSDoc @yields declaration.
  15034. /**
  15035. *
  15036. */
  15037. function * quux (foo) {
  15038. yield foo;
  15039. }
  15040. // Settings: {"jsdoc":{"tagNamePreference":{"yields":"yield"}}}
  15041. // Message: Missing JSDoc @yield declaration.
  15042. /**
  15043. * @yields
  15044. */
  15045. function * quux (foo) {
  15046. const val = yield foo;
  15047. }
  15048. // Settings: {"jsdoc":{"tagNamePreference":{"next":"yield-returns"}}}
  15049. // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
  15050. // Message: Missing JSDoc @yield-returns declaration.
  15051. /**
  15052. * @yields
  15053. * @next
  15054. */
  15055. function * quux () {
  15056. const ret = yield 5;
  15057. }
  15058. // Settings: {"jsdoc":{"tagNamePreference":{"next":false}}}
  15059. // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
  15060. // Message: Unexpected tag `@next`
  15061. /**
  15062. *
  15063. */
  15064. function * quux() {
  15065. yield 5;
  15066. }
  15067. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15068. // Message: Missing JSDoc @yields declaration.
  15069. /**
  15070. *
  15071. */
  15072. function * quux() {
  15073. yield;
  15074. }
  15075. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15076. // Message: Missing JSDoc @yields declaration.
  15077. /**
  15078. *
  15079. */
  15080. const quux = async function * () {
  15081. yield;
  15082. }
  15083. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15084. // Message: Missing JSDoc @yields declaration.
  15085. /**
  15086. *
  15087. */
  15088. async function * quux () {
  15089. yield;
  15090. }
  15091. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15092. // Message: Missing JSDoc @yields declaration.
  15093. /**
  15094. *
  15095. */
  15096. function * quux () {
  15097. yield;
  15098. }
  15099. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
  15100. // Message: Missing JSDoc @yields declaration.
  15101. /**
  15102. * @function
  15103. * @generator
  15104. */
  15105. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
  15106. // Message: Missing JSDoc @yields declaration.
  15107. /**
  15108. * @callback
  15109. * @generator
  15110. */
  15111. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
  15112. // Message: Missing JSDoc @yields declaration.
  15113. /**
  15114. * @yields {undefined}
  15115. * @yields {void}
  15116. */
  15117. function * quux (foo) {
  15118. return foo;
  15119. }
  15120. // Message: Found more than one @yields declaration.
  15121. /**
  15122. * @yields
  15123. */
  15124. function * quux () {
  15125. }
  15126. // Settings: {"jsdoc":{"tagNamePreference":{"yields":false}}}
  15127. // Message: Unexpected tag `@yields`
  15128. /**
  15129. * @param foo
  15130. */
  15131. function * quux (foo) {
  15132. yield 'bar';
  15133. }
  15134. // "jsdoc/require-yields": ["error"|"warn", {"exemptedBy":["notPresent"]}]
  15135. // Message: Missing JSDoc @yields declaration.
  15136. /**
  15137. * @param {array} a
  15138. */
  15139. async function * foo(a) {
  15140. return;
  15141. }
  15142. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15143. // Message: Missing JSDoc @yields declaration.
  15144. /**
  15145. * @param {array} a
  15146. */
  15147. async function * foo(a) {
  15148. yield Promise.all(a);
  15149. }
  15150. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15151. // Message: Missing JSDoc @yields declaration.
  15152. class quux {
  15153. /**
  15154. *
  15155. */
  15156. * quux () {
  15157. yield;
  15158. }
  15159. }
  15160. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
  15161. // Message: Missing JSDoc @yields declaration.
  15162. /**
  15163. * @param {array} a
  15164. */
  15165. async function * foo(a) {
  15166. yield Promise.all(a);
  15167. }
  15168. // Message: Missing JSDoc @yields declaration.
  15169. /**
  15170. * @generator
  15171. */
  15172. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"withGeneratorTag":true}]
  15173. // Message: Missing JSDoc @yields declaration.
  15174. /**
  15175. * @generator
  15176. * @yields
  15177. */
  15178. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"nextWithGeneratorTag":true}]
  15179. // Message: Missing JSDoc @next declaration.
  15180. /**
  15181. *
  15182. */
  15183. function * quux () {
  15184. if (true) {
  15185. yield;
  15186. }
  15187. yield true;
  15188. }
  15189. // Message: Missing JSDoc @yields declaration.
  15190. /**
  15191. *
  15192. */
  15193. function * quux () {
  15194. try {
  15195. yield true;
  15196. } catch (err) {
  15197. }
  15198. yield;
  15199. }
  15200. // Message: Missing JSDoc @yields declaration.
  15201. /**
  15202. *
  15203. */
  15204. function * quux () {
  15205. try {
  15206. } finally {
  15207. yield true;
  15208. }
  15209. yield;
  15210. }
  15211. // Message: Missing JSDoc @yields declaration.
  15212. /**
  15213. *
  15214. */
  15215. function * quux () {
  15216. try {
  15217. yield;
  15218. } catch (err) {
  15219. }
  15220. yield true;
  15221. }
  15222. // Message: Missing JSDoc @yields declaration.
  15223. /**
  15224. *
  15225. */
  15226. function * quux () {
  15227. try {
  15228. something();
  15229. } catch (err) {
  15230. yield true;
  15231. }
  15232. yield;
  15233. }
  15234. // Message: Missing JSDoc @yields declaration.
  15235. /**
  15236. *
  15237. */
  15238. function * quux () {
  15239. switch (true) {
  15240. case 'abc':
  15241. yield true;
  15242. }
  15243. yield;
  15244. }
  15245. // Message: Missing JSDoc @yields declaration.
  15246. /**
  15247. *
  15248. */
  15249. function * quux () {
  15250. switch (true) {
  15251. case 'abc':
  15252. yield;
  15253. }
  15254. yield true;
  15255. }
  15256. // Message: Missing JSDoc @yields declaration.
  15257. /**
  15258. *
  15259. */
  15260. function * quux () {
  15261. for (const i of abc) {
  15262. yield true;
  15263. }
  15264. yield;
  15265. }
  15266. // Message: Missing JSDoc @yields declaration.
  15267. /**
  15268. *
  15269. */
  15270. function * quux () {
  15271. for (const a in b) {
  15272. yield true;
  15273. }
  15274. }
  15275. // Message: Missing JSDoc @yields declaration.
  15276. /**
  15277. *
  15278. */
  15279. function * quux () {
  15280. for (let i=0; i<n; i+=1) {
  15281. yield true;
  15282. }
  15283. }
  15284. // Message: Missing JSDoc @yields declaration.
  15285. /**
  15286. *
  15287. */
  15288. function * quux () {
  15289. while(true) {
  15290. yield true
  15291. }
  15292. }
  15293. // Message: Missing JSDoc @yields declaration.
  15294. /**
  15295. *
  15296. */
  15297. function * quux () {
  15298. do {
  15299. yield true
  15300. }
  15301. while(true)
  15302. }
  15303. // Message: Missing JSDoc @yields declaration.
  15304. /**
  15305. *
  15306. */
  15307. function * quux () {
  15308. if (true) {
  15309. yield;
  15310. }
  15311. yield true;
  15312. }
  15313. // Message: Missing JSDoc @yields declaration.
  15314. /**
  15315. *
  15316. */
  15317. function * quux () {
  15318. if (true) {
  15319. yield true;
  15320. }
  15321. }
  15322. // Message: Missing JSDoc @yields declaration.
  15323. /**
  15324. *
  15325. */
  15326. function * quux () {
  15327. var a = {};
  15328. with (a) {
  15329. yield true;
  15330. }
  15331. }
  15332. // Message: Missing JSDoc @yields declaration.
  15333. /**
  15334. *
  15335. */
  15336. function * quux () {
  15337. if (true) {
  15338. yield;
  15339. } else {
  15340. yield true;
  15341. }
  15342. yield;
  15343. }
  15344. // Message: Missing JSDoc @yields declaration.
  15345. ````
  15346. The following patterns are not considered problems:
  15347. ````js
  15348. /**
  15349. * @yields Foo.
  15350. */
  15351. function * quux () {
  15352. yield foo;
  15353. }
  15354. /**
  15355. * @yields Foo.
  15356. */
  15357. function * quux () {
  15358. yield foo;
  15359. }
  15360. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"]}]
  15361. /**
  15362. *
  15363. */
  15364. function * quux () {
  15365. }
  15366. /**
  15367. *
  15368. */
  15369. function * quux () {
  15370. yield;
  15371. }
  15372. /**
  15373. *
  15374. */
  15375. function quux (bar) {
  15376. bar.doSomething(function * (baz) {
  15377. yield baz.corge();
  15378. })
  15379. }
  15380. /**
  15381. * @yields {Array}
  15382. */
  15383. function * quux (bar) {
  15384. yield bar.doSomething(function * (baz) {
  15385. yield baz.corge();
  15386. })
  15387. }
  15388. /**
  15389. * @inheritdoc
  15390. */
  15391. function * quux (foo) {
  15392. }
  15393. /**
  15394. * @override
  15395. */
  15396. function * quux (foo) {
  15397. }
  15398. /**
  15399. * @constructor
  15400. */
  15401. function * quux (foo) {
  15402. }
  15403. /**
  15404. * @implements
  15405. */
  15406. function * quux (foo) {
  15407. yield;
  15408. }
  15409. /**
  15410. * @override
  15411. */
  15412. function * quux (foo) {
  15413. yield foo;
  15414. }
  15415. /**
  15416. * @class
  15417. */
  15418. function * quux (foo) {
  15419. yield foo;
  15420. }
  15421. /**
  15422. * @constructor
  15423. */
  15424. function * quux (foo) {
  15425. }
  15426. /**
  15427. * @yields {object}
  15428. */
  15429. function * quux () {
  15430. yield {a: foo};
  15431. }
  15432. /**
  15433. * @yields {void}
  15434. */
  15435. function * quux () {
  15436. }
  15437. /**
  15438. * @yields {undefined}
  15439. */
  15440. function * quux () {
  15441. }
  15442. /**
  15443. *
  15444. */
  15445. function * quux () {
  15446. }
  15447. /**
  15448. * @yields {void}
  15449. */
  15450. function quux () {
  15451. }
  15452. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15453. /**
  15454. * @yields {void}
  15455. * @next {void}
  15456. */
  15457. function * quux () {
  15458. }
  15459. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireNext":true}]
  15460. /**
  15461. * @yields {void}
  15462. */
  15463. function * quux () {
  15464. yield undefined;
  15465. }
  15466. /**
  15467. * @yields {void}
  15468. */
  15469. function * quux () {
  15470. yield undefined;
  15471. }
  15472. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15473. /**
  15474. * @yields {void}
  15475. */
  15476. function * quux () {
  15477. yield;
  15478. }
  15479. /**
  15480. * @yields {void}
  15481. */
  15482. function * quux () {
  15483. }
  15484. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15485. /**
  15486. * @yields {void}
  15487. */
  15488. function * quux () {
  15489. yield;
  15490. }
  15491. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15492. /** @type {SpecialIterator} */
  15493. function * quux () {
  15494. yield 5;
  15495. }
  15496. /**
  15497. * @yields {Something}
  15498. */
  15499. async function * quux () {
  15500. }
  15501. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15502. /**
  15503. *
  15504. */
  15505. async function * quux () {}
  15506. /**
  15507. *
  15508. */
  15509. const quux = async function * () {}
  15510. /**
  15511. * @type {MyCallback}
  15512. */
  15513. function * quux () {
  15514. yield;
  15515. }
  15516. // "jsdoc/require-yields": ["error"|"warn", {"exemptedBy":["type"]}]
  15517. /**
  15518. * @param {array} a
  15519. */
  15520. async function * foo (a) {
  15521. yield;
  15522. }
  15523. /**
  15524. *
  15525. */
  15526. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"]}]
  15527. /**
  15528. * @function
  15529. */
  15530. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"]}]
  15531. /**
  15532. * @function
  15533. */
  15534. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15535. /**
  15536. * @callback
  15537. */
  15538. // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
  15539. /**
  15540. * @generator
  15541. */
  15542. // "jsdoc/require-yields": ["error"|"warn", {"withGeneratorTag":true}]
  15543. /**
  15544. * @generator
  15545. */
  15546. // "jsdoc/require-yields": ["error"|"warn", {"nextWithGeneratorTag":true}]
  15547. /**
  15548. * @generator
  15549. * @yields
  15550. */
  15551. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"withGeneratorTag":true}]
  15552. /**
  15553. * @generator
  15554. * @yields
  15555. * @next
  15556. */
  15557. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"nextWithGeneratorTag":true}]
  15558. /**
  15559. * @generator
  15560. */
  15561. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"withGeneratorTag":false}]
  15562. /**
  15563. * @generator
  15564. * @yields
  15565. */
  15566. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"nextWithGeneratorTag":false}]
  15567. /**
  15568. * @yields
  15569. */
  15570. function * quux (foo) {
  15571. const a = yield foo;
  15572. }
  15573. /**
  15574. * @yields
  15575. * @next
  15576. */
  15577. function * quux (foo) {
  15578. let a = yield;
  15579. }
  15580. // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
  15581. /**
  15582. * @yields
  15583. * @next
  15584. */
  15585. function * quux (foo) {
  15586. const a = yield foo;
  15587. }
  15588. // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
  15589. /**
  15590. *
  15591. */
  15592. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"nextWithGeneratorTag":true}]
  15593. /**
  15594. *
  15595. */
  15596. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"next":true}]
  15597. /**
  15598. *
  15599. */
  15600. function quux () {}
  15601. // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"next":true}]
  15602. /**
  15603. * @yields {void}
  15604. */
  15605. function * quux () {
  15606. yield;
  15607. }
  15608. // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
  15609. /**
  15610. *
  15611. */
  15612. function * quux (foo) {
  15613. const a = function * bar () {
  15614. yield foo;
  15615. }
  15616. }
  15617. ````
  15618. <a name="eslint-plugin-jsdoc-rules-require-yields-check"></a>
  15619. ### <code>require-yields-check</code>
  15620. Ensures that if a `@yields` is present that a `yield` (or `yield` with a
  15621. value) is present in the function body (or that if a `@next` is present that
  15622. there is a `yield` with a return value present).
  15623. Please also note that JavaScript does allow generators not to have `yield`
  15624. (e.g., with just a return or even no explicit return), but if you want to
  15625. enforce that all generators (except wholly empty ones) have a `yield` in the
  15626. function body, you can use the ESLint
  15627. [`require-yield`](https://eslint.org/docs/rules/require-yield) rule. In
  15628. conjunction with this, you can also use the `checkGeneratorsOnly` option
  15629. as an optimization so that this rule won't need to do its own checking within
  15630. function bodies.
  15631. Will also report if multiple `@yields` tags are present.
  15632. <a name="eslint-plugin-jsdoc-rules-require-yields-check-options-39"></a>
  15633. #### Options
  15634. - `checkGeneratorsOnly` - Avoids checking the function body and merely insists
  15635. that all generators have `@yields`. This can be an optimization with the
  15636. ESLint `require-yield` rule, as that rule already ensures a `yield` is
  15637. present in generators, albeit assuming the generator is not empty).
  15638. Defaults to `false`.
  15639. - `next` - If `true`, this option will insist that any use of a (non-standard)
  15640. `@next` tag (in addition to any `@yields` tag) will be matched by a `yield`
  15641. which uses a return value in the body of the generator (e.g.,
  15642. `const rv = yield;` or `const rv = yield value;`). This (non-standard)
  15643. tag is intended to be used to indicate a type and/or description of
  15644. the value expected to be supplied by the user when supplied to the iterator
  15645. by its `next` method, as with `it.next(value)` (with the iterator being
  15646. the `Generator` iterator that is returned by the call to the generator
  15647. function). This option will report an error if the generator function body
  15648. merely has plain `yield;` or `yield value;` statements without returning
  15649. the values. Defaults to `false`.
  15650. |||
  15651. |---|---|
  15652. |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
  15653. |Tags|`yields`|
  15654. |Aliases|`yield`|
  15655. |Recommended|true|
  15656. |Options|`checkGeneratorsOnly`|
  15657. The following patterns are considered problems:
  15658. ````js
  15659. /**
  15660. * @yields
  15661. */
  15662. function * quux (foo) {
  15663. }
  15664. // Message: JSDoc @yields declaration present but yield expression not available in function.
  15665. /**
  15666. * @yields
  15667. */
  15668. function quux (foo) {
  15669. }
  15670. // "jsdoc/require-yields-check": ["error"|"warn", {"checkGeneratorsOnly":true}]
  15671. // Message: JSDoc @yields declaration present but yield expression not available in function.
  15672. /**
  15673. * @next
  15674. */
  15675. function quux (foo) {
  15676. }
  15677. // "jsdoc/require-yields-check": ["error"|"warn", {"checkGeneratorsOnly":true,"next":true}]
  15678. // Message: JSDoc @next declaration present but yield expression with return value not available in function.
  15679. /**
  15680. * @next {SomeType}
  15681. */
  15682. function * quux (foo) {
  15683. }
  15684. // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
  15685. // Message: JSDoc @next declaration present but yield expression with return value not available in function.
  15686. /**
  15687. * @next {SomeType}
  15688. */
  15689. function * quux (foo) {
  15690. yield;
  15691. }
  15692. // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
  15693. // Message: JSDoc @next declaration present but yield expression with return value not available in function.
  15694. /**
  15695. * @next {SomeType}
  15696. */
  15697. function * quux (foo) {
  15698. yield 5;
  15699. }
  15700. // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
  15701. // Message: JSDoc @next declaration present but yield expression with return value not available in function.
  15702. /**
  15703. * @yield
  15704. */
  15705. function * quux (foo) {
  15706. }
  15707. // Settings: {"jsdoc":{"tagNamePreference":{"yields":"yield"}}}
  15708. // Message: JSDoc @yield declaration present but yield expression not available in function.
  15709. /**
  15710. * @yield-returns {Something}
  15711. */
  15712. function * quux (foo) {
  15713. yield;
  15714. }
  15715. // Settings: {"jsdoc":{"tagNamePreference":{"next":"yield-returns"}}}
  15716. // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
  15717. // Message: JSDoc @yield-returns declaration present but yield expression with return value not available in function.
  15718. /**
  15719. * @yields {undefined} Foo.
  15720. * @yields {String} Foo.
  15721. */
  15722. function * quux () {
  15723. yield foo;
  15724. }
  15725. // Message: Found more than one @yields declaration.
  15726. class Foo {
  15727. /**
  15728. * @yields {string}
  15729. */
  15730. * bar () {
  15731. }
  15732. }
  15733. // Message: JSDoc @yields declaration present but yield expression not available in function.
  15734. /**
  15735. * @yields
  15736. */
  15737. function * quux () {
  15738. }
  15739. // Settings: {"jsdoc":{"tagNamePreference":{"yields":false}}}
  15740. // Message: Unexpected tag `@yields`
  15741. /**
  15742. * @next
  15743. */
  15744. function * quux () {
  15745. }
  15746. // Settings: {"jsdoc":{"tagNamePreference":{"next":false}}}
  15747. // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
  15748. // Message: Unexpected tag `@next`
  15749. /**
  15750. * @yields {string}
  15751. */
  15752. function * f () {
  15753. function * g() {
  15754. yield 'foo'
  15755. }
  15756. }
  15757. // Message: JSDoc @yields declaration present but yield expression not available in function.
  15758. /**
  15759. * @yields {Promise<void>}
  15760. */
  15761. async function * quux() {}
  15762. // Message: JSDoc @yields declaration present but yield expression not available in function.
  15763. /**
  15764. * @yields {Promise<void>}
  15765. */
  15766. const quux = async function * () {}
  15767. // Message: JSDoc @yields declaration present but yield expression not available in function.
  15768. ````
  15769. The following patterns are not considered problems:
  15770. ````js
  15771. /**
  15772. * @yields Foo.
  15773. */
  15774. function * quux () {
  15775. yield foo;
  15776. }
  15777. /**
  15778. * @yields {string} Foo.
  15779. */
  15780. function * quux () {
  15781. yield foo;
  15782. }
  15783. /**
  15784. * @yields {string} Foo.
  15785. */
  15786. function * quux () {
  15787. yield foo;
  15788. }
  15789. /**
  15790. *
  15791. */
  15792. function * quux () {
  15793. }
  15794. /**
  15795. * @yields {undefined} Foo.
  15796. */
  15797. function * quux () {}
  15798. /**
  15799. * @yields { void } Foo.
  15800. */
  15801. function quux () {}
  15802. /**
  15803. * @yields Foo.
  15804. * @abstract
  15805. */
  15806. function * quux () {
  15807. throw new Error('must be implemented by subclass!');
  15808. }
  15809. /**
  15810. * @yields Foo.
  15811. * @virtual
  15812. */
  15813. function * quux () {
  15814. throw new Error('must be implemented by subclass!');
  15815. }
  15816. /**
  15817. * @yields Foo.
  15818. * @constructor
  15819. */
  15820. function * quux () {
  15821. }
  15822. /**
  15823. * @interface
  15824. */
  15825. class Foo {
  15826. /**
  15827. * @yields {string}
  15828. */
  15829. * bar () {
  15830. }
  15831. }
  15832. /**
  15833. * @record
  15834. */
  15835. class Foo {
  15836. /**
  15837. * @yields {string}
  15838. */
  15839. * bar () {
  15840. }
  15841. }
  15842. // Settings: {"jsdoc":{"mode":"closure"}}
  15843. /**
  15844. * @yields {undefined} Foo.
  15845. */
  15846. function * quux () {
  15847. }
  15848. /**
  15849. * @yields {void} Foo.
  15850. */
  15851. function * quux () {
  15852. }
  15853. /**
  15854. * @yields {void} Foo.
  15855. */
  15856. function * quux () {
  15857. yield undefined;
  15858. }
  15859. /**
  15860. * @yields {void} Foo.
  15861. */
  15862. function * quux () {
  15863. yield;
  15864. }
  15865. /**
  15866. *
  15867. */
  15868. function * quux () {
  15869. yield undefined;
  15870. }
  15871. /**
  15872. *
  15873. */
  15874. function * quux () {
  15875. yield;
  15876. }
  15877. /**
  15878. * @yields {true}
  15879. */
  15880. function * quux () {
  15881. try {
  15882. yield true;
  15883. } catch (err) {
  15884. }
  15885. yield;
  15886. }
  15887. /**
  15888. * @yields {true}
  15889. */
  15890. function * quux () {
  15891. try {
  15892. } finally {
  15893. yield true;
  15894. }
  15895. yield;
  15896. }
  15897. /**
  15898. * @yields {true}
  15899. */
  15900. function * quux () {
  15901. try {
  15902. yield;
  15903. } catch (err) {
  15904. }
  15905. yield true;
  15906. }
  15907. /**
  15908. * @yields {true}
  15909. */
  15910. function * quux () {
  15911. try {
  15912. something();
  15913. } catch (err) {
  15914. yield true;
  15915. }
  15916. yield;
  15917. }
  15918. /**
  15919. * @yields {true}
  15920. */
  15921. function * quux () {
  15922. switch (true) {
  15923. case 'abc':
  15924. yield true;
  15925. }
  15926. yield;
  15927. }
  15928. /**
  15929. * @yields {true}
  15930. */
  15931. function * quux () {
  15932. switch (true) {
  15933. case 'abc':
  15934. yield;
  15935. }
  15936. yield true;
  15937. }
  15938. /**
  15939. * @yields {true}
  15940. */
  15941. function * quux () {
  15942. for (const i of abc) {
  15943. yield true;
  15944. }
  15945. yield;
  15946. }
  15947. /**
  15948. * @yields {true}
  15949. */
  15950. function * quux () {
  15951. for (const a in b) {
  15952. yield true;
  15953. }
  15954. }
  15955. /**
  15956. * @yields {true}
  15957. */
  15958. function * quux () {
  15959. for (let i=0; i<n; i+=1) {
  15960. yield true;
  15961. }
  15962. }
  15963. /**
  15964. * @yields {true}
  15965. */
  15966. function * quux () {
  15967. while(true) {
  15968. yield true
  15969. }
  15970. }
  15971. /**
  15972. * @yields {true}
  15973. */
  15974. function * quux () {
  15975. do {
  15976. yield true
  15977. }
  15978. while(true)
  15979. }
  15980. /**
  15981. * @yields {true}
  15982. */
  15983. function * quux () {
  15984. if (true) {
  15985. yield;
  15986. }
  15987. yield true;
  15988. }
  15989. /**
  15990. * @yields {true}
  15991. */
  15992. function * quux () {
  15993. if (true) {
  15994. yield true;
  15995. }
  15996. }
  15997. /**
  15998. * @yields {true}
  15999. */
  16000. function * quux () {
  16001. var a = {};
  16002. with (a) {
  16003. yield true;
  16004. }
  16005. }
  16006. /**
  16007. * @yields {true}
  16008. */
  16009. function * quux () {
  16010. if (true) {
  16011. yield;
  16012. } else {
  16013. yield true;
  16014. }
  16015. yield;
  16016. }
  16017. /**
  16018. * @next {void}
  16019. */
  16020. function * quux (foo) {
  16021. }
  16022. // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
  16023. /**
  16024. * @next {SomeType}
  16025. */
  16026. function * quux (foo) {
  16027. const a = yield;
  16028. }
  16029. // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
  16030. /**
  16031. * @next {SomeType}
  16032. */
  16033. function * quux (foo) {
  16034. const a = yield 5;
  16035. }
  16036. // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
  16037. ````
  16038. <a name="eslint-plugin-jsdoc-rules-tag-lines"></a>
  16039. ### <code>tag-lines</code>
  16040. Enforces lines (or no lines) between tags.
  16041. <a name="eslint-plugin-jsdoc-rules-tag-lines-options-40"></a>
  16042. #### Options
  16043. The first option is a single string set to "always", "never", or "any"
  16044. (defaults to "never").
  16045. "any" is only useful with `tags` (allowing non-enforcement of lines except
  16046. for particular tags).
  16047. The second option is an object with the following optional properties.
  16048. <a name="eslint-plugin-jsdoc-rules-tag-lines-options-40-count-defaults-to-1"></a>
  16049. ##### <code>count</code> (defaults to 1)
  16050. Use with "always" to indicate the number of lines to require be present.
  16051. <a name="eslint-plugin-jsdoc-rules-tag-lines-options-40-noendlines-defaults-to-false"></a>
  16052. ##### <code>noEndLines</code> (defaults to <code>false</code>)
  16053. Use with "always" to indicate the normal lines to be added after tags should
  16054. not be added after the final tag.
  16055. <a name="eslint-plugin-jsdoc-rules-tag-lines-options-40-tags-default-to-empty-object"></a>
  16056. ##### <code>tags</code> (default to empty object)
  16057. Overrides the default behavior depending on specific tags.
  16058. An object whose keys are tag names and whose values are objects with the
  16059. following keys:
  16060. 1. `lines` - Set to `always`, `never`, or `any` to override.
  16061. 2. `count` - Overrides main `count` (for "always")
  16062. |||
  16063. |---|---|
  16064. |Context|everywhere|
  16065. |Tags|Any|
  16066. |Recommended|true|
  16067. |Settings|N/A|
  16068. |Options|(a string matching `"always" or "never"` and optional object with `count` and `noEndLines`)|
  16069. The following patterns are considered problems:
  16070. ````js
  16071. /**
  16072. * Some description
  16073. * @param {string} a
  16074. * @param {number} b
  16075. */
  16076. // "jsdoc/tag-lines": ["error"|"warn", "always"]
  16077. // Message: Expected 1 line between tags but found 0
  16078. /**
  16079. * Some description
  16080. * @param {string} a
  16081. * @param {number} b
  16082. */
  16083. // "jsdoc/tag-lines": ["error"|"warn", "always",{"count":2}]
  16084. // Message: Expected 2 lines between tags but found 0
  16085. /**
  16086. * Some description
  16087. * @param {string} a
  16088. *
  16089. * @param {number} b
  16090. */
  16091. // "jsdoc/tag-lines": ["error"|"warn", "always",{"count":2}]
  16092. // Message: Expected 2 lines between tags but found 1
  16093. /**
  16094. * Some description
  16095. * @param {string} a
  16096. * @param {number} b
  16097. */
  16098. // "jsdoc/tag-lines": ["error"|"warn", "always",{"noEndLines":true}]
  16099. // Message: Expected 1 line between tags but found 0
  16100. /**
  16101. * Some description
  16102. * @param {string} a
  16103. *
  16104. * @param {number} b
  16105. *
  16106. */
  16107. // "jsdoc/tag-lines": ["error"|"warn", "never"]
  16108. // Message: Expected no lines between tags
  16109. /**
  16110. * Some description
  16111. * @param {string} a
  16112. *
  16113. * @param {number} b
  16114. *
  16115. */
  16116. // Message: Expected no lines between tags
  16117. /**
  16118. * Some description
  16119. * @param {string} a
  16120. *
  16121. * @param {number} b
  16122. * @param {number} c
  16123. */
  16124. // "jsdoc/tag-lines": ["error"|"warn", "always"]
  16125. // Message: Expected 1 line between tags but found 0
  16126. /**
  16127. * Some description
  16128. * @param {string} a
  16129. * @param {number} b
  16130. */
  16131. // "jsdoc/tag-lines": ["error"|"warn", "never",{"tags":{"param":{"lines":"always"}}}]
  16132. // Message: Expected 1 line between tags but found 0
  16133. /**
  16134. * Some description
  16135. * @param {string} a
  16136. * @param {number} b
  16137. */
  16138. // "jsdoc/tag-lines": ["error"|"warn", "never",{"tags":{"param":{"lines":"always"}}}]
  16139. // Message: Expected 1 line between tags but found 0
  16140. /**
  16141. * Some description
  16142. * @param {string} a
  16143. * @param {number} b
  16144. *
  16145. */
  16146. // "jsdoc/tag-lines": ["error"|"warn", "always",{"tags":{"param":{"lines":"never"}}}]
  16147. // Message: Expected no lines between tags
  16148. /**
  16149. * Some description
  16150. * @param {string} a
  16151. *
  16152. * @param {number} b
  16153. */
  16154. // "jsdoc/tag-lines": ["error"|"warn", "never",{"count":2,"tags":{"param":{"lines":"always"}}}]
  16155. // Message: Expected 2 lines between tags but found 1
  16156. /**
  16157. * Some description
  16158. * @param {string} a
  16159. *
  16160. * @param {number} b
  16161. */
  16162. // "jsdoc/tag-lines": ["error"|"warn", "never",{"count":5,"tags":{"param":{"count":2,"lines":"always"}}}]
  16163. // Message: Expected 2 lines between tags but found 1
  16164. /**
  16165. * Some description
  16166. * @param {string} a
  16167. * @param {number} b
  16168. */
  16169. // "jsdoc/tag-lines": ["error"|"warn", "always",{"tags":{"anotherTag":{"lines":"never"}}}]
  16170. // Message: Expected 1 line between tags but found 0
  16171. /**
  16172. * Some description
  16173. * @param {string} A broken up
  16174. *
  16175. * tag description.
  16176. * @param {number} b
  16177. *
  16178. */
  16179. // "jsdoc/tag-lines": ["error"|"warn", "always"]
  16180. // Message: Expected 1 line between tags but found 0
  16181. /**
  16182. * Some description
  16183. * @param {number} b
  16184. *
  16185. * @returns {string} A broken up
  16186. *
  16187. * tag description.
  16188. */
  16189. // "jsdoc/tag-lines": ["error"|"warn", "always"]
  16190. // Message: Expected 1 line between tags but found 0
  16191. ````
  16192. The following patterns are not considered problems:
  16193. ````js
  16194. /**
  16195. * Some description
  16196. * @param {string} a
  16197. * @param {number} b
  16198. */
  16199. /**
  16200. * Some description
  16201. * @param {string} a
  16202. * @param {number} b
  16203. */
  16204. // "jsdoc/tag-lines": ["error"|"warn", "never"]
  16205. /**
  16206. * @param {string} a
  16207. *
  16208. * @param {string} a
  16209. */
  16210. // "jsdoc/tag-lines": ["error"|"warn", "always",{"noEndLines":true}]
  16211. /**
  16212. * @param {string} a
  16213. */
  16214. // "jsdoc/tag-lines": ["error"|"warn", "never",{"noEndLines":true}]
  16215. /** @param {number} b */
  16216. // "jsdoc/tag-lines": ["error"|"warn", "never",{"noEndLines":true}]
  16217. /**
  16218. * Some description
  16219. * @param {string} a
  16220. *
  16221. * @param {number} b
  16222. *
  16223. */
  16224. // "jsdoc/tag-lines": ["error"|"warn", "always"]
  16225. /**
  16226. * Some description
  16227. * @param {string} a
  16228. *
  16229. *
  16230. * @param {number} b
  16231. *
  16232. *
  16233. */
  16234. // "jsdoc/tag-lines": ["error"|"warn", "always",{"count":2}]
  16235. /**
  16236. * Some description
  16237. * @param {string} a
  16238. * @param {number} b
  16239. */
  16240. // "jsdoc/tag-lines": ["error"|"warn", "never",{"tags":{"param":{"lines":"any"}}}]
  16241. /**
  16242. * Some description
  16243. * @param {string} a
  16244. * @param {number} b
  16245. */
  16246. // "jsdoc/tag-lines": ["error"|"warn", "always",{"tags":{"param":{"lines":"any"}}}]
  16247. /**
  16248. * Some description
  16249. * @param {string} a
  16250. * @param {number} b
  16251. */
  16252. // "jsdoc/tag-lines": ["error"|"warn", "always",{"tags":{"param":{"lines":"never"}}}]
  16253. /**
  16254. * Some description
  16255. * @param {number} a
  16256. * @param {number} b
  16257. */
  16258. // "jsdoc/tag-lines": ["error"|"warn", "never",{"tags":{"param":{"lines":"any"}}}]
  16259. /**
  16260. * Some description
  16261. * @param {number} a
  16262. *
  16263. * @param {number} b
  16264. */
  16265. // "jsdoc/tag-lines": ["error"|"warn", "never",{"tags":{"param":{"lines":"any"}}}]
  16266. /**
  16267. * Some description
  16268. * @param {number} a
  16269. * @param {number} b
  16270. */
  16271. // "jsdoc/tag-lines": ["error"|"warn", "never",{"tags":{"param":{"lines":"never"}}}]
  16272. /**
  16273. * Some description
  16274. * @param {string} a
  16275. *
  16276. *
  16277. * @param {number} b
  16278. *
  16279. *
  16280. */
  16281. // "jsdoc/tag-lines": ["error"|"warn", "never",{"count":5,"tags":{"param":{"count":2,"lines":"always"}}}]
  16282. /**
  16283. * Some description
  16284. * @param {string} a
  16285. * @param {number} b
  16286. */
  16287. // "jsdoc/tag-lines": ["error"|"warn", "never",{"tags":{"anotherTag":{"lines":"always"}}}]
  16288. /**
  16289. * Some description
  16290. * @param {string} a
  16291. *
  16292. * This is still part of `@param`.
  16293. * @returns {SomeType} An extended
  16294. * description.
  16295. */
  16296. // "jsdoc/tag-lines": ["error"|"warn", "never"]
  16297. /**
  16298. * Some description
  16299. * @param {string} a
  16300. * @returns {SomeType} An extended
  16301. * description.
  16302. *
  16303. * This is still part of `@returns`.
  16304. */
  16305. // "jsdoc/tag-lines": ["error"|"warn", "never"]
  16306. /**
  16307. * Some description
  16308. * @param {string} a
  16309. *
  16310. * This is still part of `@param`.
  16311. *
  16312. * @returns {SomeType} An extended
  16313. * description.
  16314. *
  16315. */
  16316. // "jsdoc/tag-lines": ["error"|"warn", "always"]
  16317. /**
  16318. * Some description
  16319. * @param {string} a
  16320. *
  16321. * @returns {SomeType} An extended
  16322. * description.
  16323. *
  16324. * This is still part of `@returns`.
  16325. *
  16326. */
  16327. // "jsdoc/tag-lines": ["error"|"warn", "always"]
  16328. ````
  16329. <a name="eslint-plugin-jsdoc-rules-valid-types"></a>
  16330. ### <code>valid-types</code>
  16331. Requires all types to be valid JSDoc, Closure, or TypeScript compiler types
  16332. without syntax errors. Note that what determines a valid type is handled by
  16333. our type parsing engine, [jsdoctypeparser](https://github.com/jsdoctypeparser/jsdoctypeparser),
  16334. using [`settings.jsdoc.mode`](#eslint-plugin-jsdoc-settings-mode) to
  16335. determine whether to use jsdoctypeparser's "permissive" mode or the stricter
  16336. "jsdoc", "typescript", "closure" modes.
  16337. The following tags have their "type" portions (the segment within brackets)
  16338. checked (though those portions may sometimes be confined to namepaths,
  16339. e.g., `@modifies`):
  16340. 1. Tags with required types: `@type`, `@implements`
  16341. 1. Tags with required types in Closure or TypeScript: `@this`,
  16342. `@define` (Closure only)
  16343. 1. Tags with optional types: `@enum`, `@member` (`@var`), `@typedef`,
  16344. `@augments` (or `@extends`), `@class` (or `@constructor`), `@constant`
  16345. (or `@const`), `@module` (module paths are not planned for TypeScript),
  16346. `@namespace`, `@throws`, `@exception`, `@yields` (or `@yield`),
  16347. `@modifies` (undocumented jsdoc); `@param` (`@arg`, `@argument`),
  16348. `@property` (`@prop`), and `@returns` (`@return`) also fall into this
  16349. category, but while this rule will check their type validity, we leave
  16350. the requiring of the type portion to the rules `require-param-type`,
  16351. `require-property-type`, and `require-returns-type`, respectively.
  16352. 1. Tags with types that are available optionally in Closure: `@export`,
  16353. `@package`, `@private`, `@protected`, `@public`, `@static`;
  16354. `@template` (TypeScript also)
  16355. 1. Tags with optional types that may take free text instead: `@throws`
  16356. The following tags have their name/namepath portion (the non-whitespace
  16357. text after the tag name) checked:
  16358. 1. Name(path)-defining tags requiring namepath: `@event`, `@callback`,
  16359. `@external`, `@host`, `@name`, `@typedef`, and `@template`
  16360. (TypeScript/Closure only); `@param` (`@arg`, `@argument`) and `@property`
  16361. (`@prop`) also fall into this category, but while this rule will check
  16362. their namepath validity, we leave the requiring of the name portion
  16363. to the rules `require-param-name` and `require-property-name`,
  16364. respectively.
  16365. 1. Name(path)-defining tags (which may have value without namepath or their
  16366. namepath can be expressed elsewhere on the block):
  16367. `@class`, `@constructor`, `@constant`, `@const`, `@function`, `@func`,
  16368. `@method`, `@interface` (TypeScript tag only), `@member`, `@var`,
  16369. `@mixin`, `@namespace`, `@module` (module paths are not planned for
  16370. TypeScript)
  16371. 1. Name(path)-pointing tags requiring namepath: `@alias`, `@augments`,
  16372. `@extends`, `@lends`, `@memberof`, `@memberof!`, `@mixes`, `@this`
  16373. (jsdoc only)
  16374. 1. Name(path)-pointing tags (which may have value without namepath or their
  16375. namepath can be expressed elsewhere on the block): `@listens`, `@fires`,
  16376. `@emits`.
  16377. 1. Name(path)-pointing tags which may have free text or a namepath: `@see`
  16378. 1. Name(path)-pointing tags (multiple names in one): `@borrows`
  16379. ...with the following applying to the above sets:
  16380. - Expect tags in set 1-4 to have a valid namepath if present
  16381. - Prevent sets 2 and 4 from being empty by setting `allowEmptyNamepaths` to
  16382. `false` as these tags might have some indicative value without a path
  16383. or may allow a name expressed elsewhere on the block (but sets 1 and 3 will
  16384. always fail if empty)
  16385. - For the special case of set 6, i.e.,
  16386. `@borrows <that namepath> as <this namepath>`,
  16387. check that both namepaths are present and valid and ensure there is an `as `
  16388. between them. In the case of `<this namepath>`, it can be preceded by
  16389. one of the name path operators, `#`, `.`, or `~`.
  16390. - For the special case of `@memberof` and `@memberof!` (part of set 3), as
  16391. per the [specification](https://jsdoc.app/tags-memberof.html), they also
  16392. allow `#`, `.`, or `~` at the end (which is not allowed at the end of
  16393. normal paths).
  16394. If you define your own tags, `settings.jsdoc.structuredTags` will allow
  16395. these custom tags to be checked, with the name portion of tags checked for
  16396. valid namepaths (based on the tag's `name` value), their type portions checked
  16397. for valid types (based on the tag's `type` value), and either portion checked
  16398. for presence (based on `false` `name` or `type` values or their `required`
  16399. value). See the setting for more details.
  16400. <a name="eslint-plugin-jsdoc-rules-valid-types-options-41"></a>
  16401. #### Options
  16402. - `allowEmptyNamepaths` (default: true) - Set to `false` to bulk disallow
  16403. empty name paths with namepath groups 2 and 4 (these might often be
  16404. expected to have an accompanying name path, though they have some
  16405. indicative value without one; these may also allow names to be defined
  16406. in another manner elsewhere in the block); you can use
  16407. `settings.jsdoc.structuredTags` with the `required` key set to "name" if you
  16408. wish to require name paths on a tag-by-tag basis.
  16409. |||
  16410. |---|---|
  16411. |Context|everywhere|
  16412. |Tags|For name only unless otherwise stated: `alias`, `augments`, `borrows`, `callback`, `class` (for name and type), `constant` (for name and type), `enum` (for type), `event`, `external`, `fires`, `function`, `implements` (for type), `interface`, `lends`, `listens`, `member` (for name and type), `memberof`, `memberof!`, `mixes`, `mixin`, `modifies`, `module` (for name and type), `name`, `namespace` (for name and type), `param` (for name and type), `property` (for name and type), `returns` (for type), `see` (optionally for name), `this`, `throws` (for type), `type` (for type), `typedef` (for name and type), `yields` (for type)|
  16413. |Aliases|`extends`, `constructor`, `const`, `host`, `emits`, `func`, `method`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
  16414. |Closure-only|For type only: `package`, `private`, `protected`, `public`, `static`|
  16415. |Recommended|true|
  16416. |Options|`allowEmptyNamepaths`|
  16417. |Settings|`mode`, `structuredTags`|
  16418. The following patterns are considered problems:
  16419. ````js
  16420. /**
  16421. * @param {Array<string} foo
  16422. */
  16423. function quux() {
  16424. }
  16425. // Message: Syntax error in type: Array<string
  16426. /**
  16427. * @memberof module:namespace.SomeClass<~
  16428. */
  16429. function quux() {
  16430. }
  16431. // Message: Syntax error in namepath: module:namespace.SomeClass<~
  16432. /**
  16433. * @param someParam<~
  16434. */
  16435. function quux() {
  16436. }
  16437. // Message: Syntax error in namepath: someParam<~
  16438. /**
  16439. * @memberof module:namespace.SomeClass~<
  16440. */
  16441. function quux() {
  16442. }
  16443. // Message: Syntax error in namepath: module:namespace.SomeClass~<
  16444. /**
  16445. * @borrows foo% as bar
  16446. */
  16447. function quux() {
  16448. }
  16449. // Message: Syntax error in namepath: foo%
  16450. /**
  16451. * @borrows #foo as bar
  16452. */
  16453. function quux() {
  16454. }
  16455. // Message: Syntax error in namepath: #foo
  16456. /**
  16457. * @borrows foo as bar%
  16458. */
  16459. function quux() {
  16460. }
  16461. // Message: Syntax error in namepath: bar%
  16462. /**
  16463. * @borrows foo
  16464. */
  16465. function quux() {
  16466. }
  16467. // Message: @borrows must have an "as" expression. Found ""
  16468. /**
  16469. * @see foo%
  16470. */
  16471. function quux() {
  16472. }
  16473. // Settings: {"jsdoc":{"structuredTags":{"see":{"name":"namepath-referencing","required":["name"]}}}}
  16474. // Message: Syntax error in namepath: foo%
  16475. /**
  16476. * @mixes module:namespace.SomeClass~
  16477. */
  16478. function quux() {
  16479. }
  16480. // Message: Syntax error in namepath: module:namespace.SomeClass~
  16481. /**
  16482. * @callback
  16483. */
  16484. function quux() {
  16485. }
  16486. // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
  16487. // Message: Tag @callback must have a name/namepath.
  16488. /**
  16489. * @constant {str%ng}
  16490. */
  16491. const FOO = 'foo';
  16492. // Message: Syntax error in type: str%ng
  16493. /**
  16494. * @typedef {str%ng} UserString
  16495. */
  16496. // Message: Syntax error in type: str%ng
  16497. /**
  16498. * @typedef {string} UserStr%ng
  16499. */
  16500. // Message: Syntax error in namepath: UserStr%ng
  16501. /**
  16502. * @this
  16503. */
  16504. class Bar {};
  16505. // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
  16506. // Message: Tag @this must have either a type or namepath in "jsdoc" mode.
  16507. /**
  16508. * @aCustomTag
  16509. */
  16510. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"required":["typeOrNameRequired"]}}}}
  16511. // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
  16512. // Message: Tag @aCustomTag must have either a type or namepath.
  16513. /**
  16514. * @type
  16515. */
  16516. let foo;
  16517. // Message: Tag @type must have a type.
  16518. /**
  16519. * @modifies {bar | foo<}
  16520. */
  16521. function quux (foo, bar, baz) {}
  16522. // Message: Syntax error in type: bar | foo<
  16523. /**
  16524. * @private {BadTypeChecked<}
  16525. */
  16526. function quux () {}
  16527. // Settings: {"jsdoc":{"mode":"closure"}}
  16528. // Message: Syntax error in type: BadTypeChecked<
  16529. /**
  16530. * @this {BadTypeChecked<}
  16531. */
  16532. function quux () {}
  16533. // Settings: {"jsdoc":{"mode":"closure"}}
  16534. // Message: Syntax error in type: BadTypeChecked<
  16535. /**
  16536. * @define
  16537. */
  16538. function quux () {}
  16539. // Settings: {"jsdoc":{"mode":"closure"}}
  16540. // Message: Tag @define must have a type in "closure" mode.
  16541. /**
  16542. * @this
  16543. */
  16544. let foo;
  16545. // Settings: {"jsdoc":{"mode":"closure"}}
  16546. // Message: Tag @this must have a type in "closure" mode.
  16547. /**
  16548. * Foo function.
  16549. *
  16550. * @param {[number, string]} bar - The bar array.
  16551. */
  16552. function foo(bar) {}
  16553. // Settings: {"jsdoc":{"mode":"jsdoc"}}
  16554. // Message: Syntax error in type: [number, string]
  16555. /**
  16556. * @interface name<
  16557. */
  16558. // Settings: {"jsdoc":{"mode":"jsdoc"}}
  16559. // Message: Syntax error in namepath: name<
  16560. /**
  16561. * @module name<
  16562. */
  16563. // Settings: {"jsdoc":{"mode":"jsdoc"}}
  16564. // Message: Syntax error in namepath: name<
  16565. /**
  16566. * @module module:name<
  16567. */
  16568. // Settings: {"jsdoc":{"mode":"jsdoc"}}
  16569. // Message: Syntax error in namepath: module:name<
  16570. /**
  16571. * @interface name
  16572. */
  16573. // Settings: {"jsdoc":{"mode":"closure"}}
  16574. // Message: @interface should not have a name in "closure" mode.
  16575. /**
  16576. * @aCustomTag name
  16577. */
  16578. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"name":false}}}}
  16579. // Message: @aCustomTag should not have a name.
  16580. /**
  16581. * @typedef {SomeType}
  16582. */
  16583. function quux () {}
  16584. // Settings: {"jsdoc":{"mode":"jsdoc"}}
  16585. // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
  16586. // Message: Tag @typedef must have a name/namepath in "jsdoc" mode.
  16587. /**
  16588. * @private {SomeType}
  16589. */
  16590. function quux () {}
  16591. // Settings: {"jsdoc":{"mode":"jsdoc"}}
  16592. // Message: @private should not have a bracketed type in "jsdoc" mode.
  16593. /**
  16594. * @aCustomTag {SomeType}
  16595. */
  16596. function quux () {}
  16597. // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":false}}}}
  16598. // Message: @aCustomTag should not have a bracketed type.
  16599. /**
  16600. * @see foo%
  16601. */
  16602. function quux() {
  16603. }
  16604. // Settings: {"jsdoc":{"structuredTags":{"see":{"name":false,"required":["name"]}}}}
  16605. // Message: Cannot add "name" to `require` with the tag's `name` set to `false`
  16606. /**
  16607. * @see foo%
  16608. */
  16609. function quux() {
  16610. }
  16611. // Settings: {"jsdoc":{"structuredTags":{"see":{"required":["type"],"type":false}}}}
  16612. // Message: Cannot add "type" to `require` with the tag's `type` set to `false`
  16613. /**
  16614. * @see foo%
  16615. */
  16616. function quux() {
  16617. }
  16618. // Settings: {"jsdoc":{"structuredTags":{"see":{"name":false,"required":["typeOrNameRequired"]}}}}
  16619. // Message: Cannot add "typeOrNameRequired" to `require` with the tag's `name` set to `false`
  16620. /**
  16621. * @see foo%
  16622. */
  16623. function quux() {
  16624. }
  16625. // Settings: {"jsdoc":{"structuredTags":{"see":{"required":["typeOrNameRequired"],"type":false}}}}
  16626. // Message: Cannot add "typeOrNameRequired" to `require` with the tag's `type` set to `false`
  16627. /**
  16628. * @template T<~, R
  16629. * @param {function(!T): !R} parser
  16630. * @return {function(!Array<!T>): !Array<!R>}
  16631. */
  16632. parseArray = function(parser) {
  16633. return function(array) {
  16634. return array.map(parser);
  16635. };
  16636. };
  16637. // Settings: {"jsdoc":{"mode":"closure"}}
  16638. // Message: Syntax error in namepath: T<~
  16639. /**
  16640. * @template T, R<~
  16641. * @param {function(!T): !R} parser
  16642. * @return {function(!Array<!T>): !Array<!R>}
  16643. */
  16644. parseArray = function(parser) {
  16645. return function(array) {
  16646. return array.map(parser);
  16647. };
  16648. };
  16649. // Settings: {"jsdoc":{"mode":"closure"}}
  16650. // Message: Syntax error in namepath: R<~
  16651. /**
  16652. * @template T, R<~
  16653. * @param {function(!T): !R} parser
  16654. * @return {function(!Array<!T>): !Array<!R>}
  16655. */
  16656. parseArray = function(parser) {
  16657. return function(array) {
  16658. return array.map(parser);
  16659. };
  16660. };
  16661. // Settings: {"jsdoc":{"mode":"closure"}}
  16662. // Message: Syntax error in namepath: R<~
  16663. ````
  16664. The following patterns are not considered problems:
  16665. ````js
  16666. /**
  16667. * @param {Array<string>} foo
  16668. */
  16669. function quux() {
  16670. }
  16671. /**
  16672. * @param {string} foo
  16673. */
  16674. function quux() {
  16675. }
  16676. /**
  16677. * @param foo
  16678. */
  16679. function quux() {
  16680. }
  16681. /**
  16682. * @borrows foo as bar
  16683. */
  16684. function quux() {
  16685. }
  16686. /**
  16687. * @borrows foo as #bar
  16688. */
  16689. function quux() {
  16690. }
  16691. /**
  16692. * @see foo%
  16693. */
  16694. function quux() {
  16695. }
  16696. /**
  16697. * @alias module:namespace.SomeClass#event:ext_anevent
  16698. */
  16699. function quux() {
  16700. }
  16701. /**
  16702. * @callback foo
  16703. */
  16704. function quux() {
  16705. }
  16706. /**
  16707. * @callback
  16708. */
  16709. function quux() {
  16710. }
  16711. // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":true}]
  16712. /**
  16713. * @class
  16714. */
  16715. function quux() {
  16716. }
  16717. /**
  16718. * @see {@link foo}
  16719. */
  16720. function quux() {
  16721. }
  16722. // Settings: {"jsdoc":{"structuredTags":{"see":{"name":"namepath-referencing","required":["name"]}}}}
  16723. /**
  16724. *
  16725. * @fires {module:namespace.SomeClass#event:ext_anevent}
  16726. */
  16727. function quux() {
  16728. }
  16729. /**
  16730. * @memberof module:namespace.SomeClass~
  16731. */
  16732. function quux() {
  16733. }
  16734. /**
  16735. * @memberof! module:namespace.SomeClass.
  16736. */
  16737. function quux() {
  16738. }
  16739. /**
  16740. *
  16741. */
  16742. function quux() {
  16743. }
  16744. /**
  16745. * @aCustomTag
  16746. */
  16747. function quux() {
  16748. }
  16749. /**
  16750. * @constant {string}
  16751. */
  16752. const FOO = 'foo';
  16753. /**
  16754. * @constant {string} FOO
  16755. */
  16756. const FOO = 'foo';
  16757. /**
  16758. * @extends Foo
  16759. */
  16760. class Bar {};
  16761. /**
  16762. * @extends Foo<String>
  16763. */
  16764. class Bar {};
  16765. /**
  16766. * @extends {Foo<String>}
  16767. */
  16768. class Bar {};
  16769. // Settings: {"jsdoc":{"mode":"closure"}}
  16770. /**
  16771. * @typedef {number | string} UserDefinedType
  16772. */
  16773. /**
  16774. * @typedef {number | string}
  16775. */
  16776. let UserDefinedGCCType;
  16777. // Settings: {"jsdoc":{"mode":"closure"}}
  16778. /**
  16779. * @modifies {foo | bar}
  16780. */
  16781. function quux (foo, bar, baz) {}
  16782. /**
  16783. * @this {Navigator}
  16784. */
  16785. function quux () {}
  16786. // Settings: {"jsdoc":{"mode":"closure"}}
  16787. /**
  16788. * @export {SomeType}
  16789. */
  16790. function quux () {}
  16791. // Settings: {"jsdoc":{"mode":"closure"}}
  16792. /**
  16793. * @define {boolean}
  16794. */
  16795. function quux () {}
  16796. // Settings: {"jsdoc":{"mode":"closure"}}
  16797. /**
  16798. * @define
  16799. */
  16800. function quux () {}
  16801. /**
  16802. * Foo function.
  16803. *
  16804. * @interface foo
  16805. */
  16806. function foo(bar) {}
  16807. // Settings: {"jsdoc":{"mode":"typescript"}}
  16808. /**
  16809. * Foo function.
  16810. *
  16811. * @param {[number, string]} bar - The bar array.
  16812. */
  16813. function foo(bar) {}
  16814. // Settings: {"jsdoc":{"mode":"typescript"}}
  16815. /**
  16816. * Foo function.
  16817. *
  16818. * @param {[number, string]} bar - The bar array.
  16819. */
  16820. function foo(bar) {}
  16821. /**
  16822. * Foo function.
  16823. *
  16824. * @param {[number, string]} bar - The bar array.
  16825. */
  16826. function foo(bar) {}
  16827. // Settings: {"jsdoc":{"mode":"permissive"}}
  16828. /**
  16829. * @typedef {SomeType}
  16830. */
  16831. function quux () {}
  16832. // Settings: {"jsdoc":{"mode":"closure"}}
  16833. // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
  16834. /**
  16835. * @private {SomeType}
  16836. */
  16837. function quux () {}
  16838. // Settings: {"jsdoc":{"mode":"closure"}}
  16839. /**
  16840. * @param
  16841. */
  16842. function quux() {
  16843. }
  16844. // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
  16845. /**
  16846. * @see
  16847. */
  16848. function quux() {
  16849. }
  16850. // Settings: {"jsdoc":{"structuredTags":{"see":{"name":"namepath-referencing"}}}}
  16851. /**
  16852. * @template T, R
  16853. * @param {function(!T): !R} parser
  16854. * @return {function(!Array<!T>): !Array<!R>}
  16855. */
  16856. parseArray = function(parser) {
  16857. return function(array) {
  16858. return array.map(parser);
  16859. };
  16860. };
  16861. // Settings: {"jsdoc":{"mode":"closure"}}
  16862. /**
  16863. * @template T, R<~
  16864. * @param {function(!T): !R} parser
  16865. * @return {function(!Array<!T>): !Array<!R>}
  16866. */
  16867. parseArray = function(parser) {
  16868. return function(array) {
  16869. return array.map(parser);
  16870. };
  16871. };
  16872. // Settings: {"jsdoc":{"mode":"jsdoc"}}
  16873. /**
  16874. * @template {string} K - K must be a string or string literal
  16875. * @template {{ serious: string }} Seriousalizable - must have a serious property
  16876. * @param {K} key
  16877. * @param {Seriousalizable} object
  16878. */
  16879. function seriousalize(key, object) {
  16880. // ????
  16881. }
  16882. // Settings: {"jsdoc":{"mode":"typescript"}}
  16883. /**
  16884. * @module foo/bar
  16885. */
  16886. /**
  16887. * @module module:foo/bar
  16888. */
  16889. /**
  16890. * @template invalid namepath,T Description
  16891. */
  16892. function f() {}
  16893. // Settings: {"jsdoc":{"mode":"closure"}}
  16894. /**
  16895. * Description of complicated type.
  16896. *
  16897. * @template T Description of the T type parameter.
  16898. * @template U - Like other tags, this can have an optional hyphen before the description.
  16899. * @template V,W More parameters
  16900. * @template W,X - Also with a hyphen
  16901. */
  16902. type ComplicatedType<T, U, V, W, X> = never
  16903. /** Multi-line typedef for an options object type.
  16904. *
  16905. * @typedef {{
  16906. * prop: number
  16907. * }} MyOptions
  16908. */
  16909. /**
  16910. * @extends {SomeType}
  16911. */
  16912. class quux {}
  16913. // Settings: {"jsdoc":{"mode":"typescript"}}
  16914. ````