Package Exports
- @es-joy/jsdoccomment
Readme
@es-joy/jsdoccomment
This project aims to preserve and expand upon the
SourceCode#getJSDocComment functionality of the deprecated ESLint method.
It also exports a number of functions currently for working with JSDoc:
parseComment- For parsingcomment-parserin a JSDoc-specific manner. Might wish to have tags with or without tags, etc. derived from a split off JSON file.commentHandler- Used byeslint-plugin-jsdoc. Might be removed in future.commentParserToESTree- Converts comment-parser AST to ESTree/ESLint/Babel friendly ASTjsdoctypeparserToESTree- Converts jsdoctypeparser AST to ESTree/ESLint/Babel friendly ASTjsdocVisitorKeys- The VisitorKeys forJSDocBlock,JSDocDescriptionLine, andJSDocTag. Might change.jsdocTypeVisitorKeys- VisitorKeys for jsdoctypeparser. More likely to be subject to change.getTokenizers- A utility. Might be removed in future.toCamelCase- A utility. Might be removed in future.hasSeeWithLink- A utility to detect if a tag is@seeand has a@linkdefaultNoTypes= The tags which allow no types by default:default,defaultvalue,see;defaultNoNames- The tags which allow no names by default:access,author,default,defaultvalue,description,example,exception,license,return,returns,since,summary,throws,version,variation
ESLint AST produced for comment-parser nodes (JSDocBlock, JSDocTag, and JSDocDescriptionLine)
Note: Although not added in this package, @es-joy/jsdoc-eslint-parser adds
a jsdoc property to other ES nodes (using this project's getJSDocComment
to determine the specific comment-block that will be attached as AST).
JSDocBlock
Has two visitable properties:
tags(an array ofJSDocTag; see below)descriptionLines(an array ofJSDocDescriptionLinefor multiline descriptions).
Has the following custom non-visitable property:
lastDescriptionLine- A number
May also have the following non-visitable properties from comment-parser:
description- Same asdescriptionLinesbut as a string with newlines.delimiterpostDelimiterend
JSDocTag
Has three visitable properties:
parsedType(thejsdoctypeparserAST representaiton of the tag's type (see thejsdoctypeparsersection below)).descriptionLines' (an array ofJSDocDescriptionLinefor multiline descriptions)typeLines(an array ofJSDocTypeLinefor multiline type strings)
May also have the following non-visitable properties from comment-parser
(note that all are included from comment-parser except end as that is only
for JSDoc blocks and note that type is renamed to rawType):
description- Same asdescriptionLinesbut as a string with newlines.rawType-comment-parserhas this named astype, but because of a conflict with ESTree usingtypefor Node type, we renamed it torawType. It is otherwise the same as incomment-parser, i.e., a string with newlines, though with the initial{and final}stripped out. SeetypeLinesfor the array version of this property.startdelimiterpostDelimitertag(this does differ fromcomment-parsernow in terms of our stripping the initial@)postTagnamepostNametypepostType
JSDocDescriptionLine
No visitable properties.
May also have the following non-visitable properties from comment-parser:
delimiterpostDelimiterstartdescription
JSDocTypeLine
No visitable properties.
May also have the following non-visitable properties from comment-parser:
delimiterpostDelimiterstartrawType- Renamed fromcomment-parserto avoid a conflict. See explanation underJSDocTag
ESLint AST produced for jsdoctypeparser
The type has been changed for the type AST. Relative to jsdoctypeparser
nodes, the type will have a JSDocType prefix added plus a camel-casing of the
old type name, so, e.g., INSTANCE_MEMBER will become
JSDocTypeInstanceMember.
See jsdoctypeparser
for the current list of node types which are transformed in this manner.
Otherwise, the node properties are as in jsdoctypeparser.
The jsdoctypeparser visitor keys are also modified accordingly.
Installation
npm i @es-joy/jsdoccommentChangelog
The changelog can be found on the CHANGES.md.
Authors and license
Brett Zamir and contributors.
MIT License, see the included LICENSE-MIT.txt file.
To-dos
- Get complete code coverage
- If
comment-parser(andjsdoctypeparser) are not exporting proper ESLint AST, then provide simple utilities to convert their AST