@cjser/es-joy__jsdoccomment 0.96.0-cjser.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ Copyright JS Foundation and other contributors, https://js.foundation
2
+ Copyright (c) 2021 Brett Zamir
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,250 @@
1
+ # @es-joy/jsdoccomment
2
+
3
+ [![NPM](https://img.shields.io/npm/v/@es-joy/jsdoccomment.svg?label=npm)](https://www.npmjs.com/package/@es-joy/jsdoccomment)
4
+ [![License](https://img.shields.io/badge/license-MIT-yellowgreen.svg?style=flat)](https://github.com/es-joy/jsdoccomment/blob/main/LICENSE-MIT.txt)
5
+ [![Build Status](https://github.com/es-joy/jsdoccomment/workflows/CI/CD/badge.svg)](#)
6
+ [![API Docs](https://img.shields.io/badge/API%20Documentation-476ff0)](https://es-joy.github.io/jsdoccomment/docs/)
7
+
8
+ See the **[Demo](https://es-joy.github.io/jsdoccomment/demo/)** and
9
+ **[Docs](https://es-joy.github.io/jsdoccomment/docs/)**.
10
+
11
+ This project aims to preserve and expand upon the
12
+ `SourceCode#getJSDocComment` functionality of the deprecated ESLint method.
13
+
14
+ It also exports a number of functions currently for working with JSDoc:
15
+
16
+ ## API
17
+
18
+ ### `parseComment`
19
+
20
+ For parsing `comment-parser` in a JSDoc-specific manner.
21
+ Might wish to have tags with or without tags, etc. derived from a split off
22
+ JSON file.
23
+
24
+ ### `commentParserToESTree`
25
+
26
+ Converts [comment-parser](https://github.com/syavorsky/comment-parser)
27
+ AST to ESTree/ESLint/Babel friendly AST. See the "ESLint AST..." section below.
28
+
29
+ ### `estreeToString`
30
+
31
+ Stringifies. In addition to the node argument, it accepts an optional second
32
+ options object with a single `preferRawType` key. If you don't need to modify
33
+ JSDoc type AST, you might wish to set this to `true` to get the benefits of
34
+ preserving the raw form, but for AST-based stringification of JSDoc types,
35
+ keep it `false` (the default).
36
+
37
+ ### `jsdocVisitorKeys`
38
+
39
+ The [VisitorKeys](https://github.com/eslint/eslint-visitor-keys)
40
+ for `JsdocBlock`, `JsdocDescriptionLine`, and `JsdocTag`. More likely to be
41
+ subject to change or dropped in favor of another type parser.
42
+
43
+ ### `jsdocTypeVisitorKeys`
44
+
45
+ Just a re-export of [VisitorKeys](https://github.com/eslint/eslint-visitor-keys)
46
+ from [`jsdoc-type-pratt-parser`](https://github.com/simonseyock/jsdoc-type-pratt-parser/).
47
+
48
+ ### `getDefaultTagStructureForMode`
49
+
50
+ Provides info on JSDoc tags:
51
+
52
+ - `nameContents` ('namepath-referencing'|'namepath-defining'|
53
+ 'dual-namepath-referencing'|false) - Whether and how a name is allowed
54
+ following any type. Tags without a proper name (value `false`) may still
55
+ have a description (which can appear like a name); `descriptionAllowed`
56
+ in such cases would be `true`.
57
+ The presence of a truthy `nameContents` value is therefore only intended
58
+ to signify whether separate parsing should occur for a name vs. a
59
+ description, and what its nature should be.
60
+ - `nameRequired` (boolean) - Whether a name must be present following any type.
61
+ - `descriptionAllowed` (boolean) - Whether a description (following any name)
62
+ is allowed.
63
+ - `typeAllowed` (boolean) - Whether the tag accepts a curly bracketed portion.
64
+ Even without a type, a tag may still have a name and/or description.
65
+ - `typeRequired` (boolean) - Whether a curly bracketed type must be present.
66
+ - `typeOrNameRequired` (boolean) - Whether either a curly bracketed type is
67
+ required or a name, but not necessarily both.
68
+
69
+ ### Miscellaneous
70
+
71
+ Also currently exports these utilities:
72
+
73
+ - `getTokenizers` - Used with `parseComment` (its main core).
74
+ - `hasSeeWithLink` - A utility to detect if a tag is `@see` and has a `@link`.
75
+ - `commentHandler` - Used by `eslint-plugin-jsdoc`.
76
+ - `commentParserToESTree`- Converts [comment-parser](https://github.com/syavorsky/comment-parser)
77
+ AST to ESTree/ESLint/Babel friendly AST.
78
+ - `jsdocVisitorKeys` - The [VisitorKeys](https://github.com/eslint/eslint-visitor-keys)
79
+ for `JSDocBlock`, `JSDocDescriptionLine`, and `JSDocTag`.
80
+ - `jsdocTypeVisitorKeys` - [VisitorKeys](https://github.com/eslint/eslint-visitor-keys)
81
+ for `jsdoc-type-pratt-parser`.
82
+ - `defaultNoTypes` = The tags which allow no types by default:
83
+ `default`, `defaultvalue`, `description`, `example`, `file`,
84
+ `fileoverview`, `license`, `overview`, `see`, `summary`
85
+ - `defaultNoNames` - The tags which allow no names by default:
86
+ `access`, `author`, `default`, `defaultvalue`, `description`, `example`,
87
+ `exception`, `file`, `fileoverview`, `kind`, `license`, `overview`,
88
+ `return`, `returns`, `since`, `summary`, `throws`, `version`, `variation`
89
+
90
+ ## ESLint AST produced for `comment-parser` nodes (`JsdocBlock`, `JsdocTag`, and `JsdocDescriptionLine`)
91
+
92
+ Note: Although not added in this package, `@es-joy/jsdoc-eslint-parser` adds
93
+ a `jsdoc` property to other ES nodes (using this project's `getJSDocComment`
94
+ to determine the specific comment-block that will be attached as AST).
95
+
96
+ ### `JsdocBlock`
97
+
98
+ Has the following visitable properties:
99
+
100
+ 1. `descriptionLines` (an array of `JsdocDescriptionLine` for multiline
101
+ descriptions).
102
+ 1. `tags` (an array of `JsdocTag`; see below)
103
+ 1. `inlineTags` (an array of `JsdocInlineTag`; see below)
104
+
105
+ Has the following custom non-visitable property:
106
+
107
+ 1. `delimiterLineBreak` - A string containing any line break after `delimiter`.
108
+ 2. `lastDescriptionLine` - A number
109
+ 3. `endLine` - A number representing the line number with `end`/`terminal`
110
+ 4. `descriptionStartLine` - A 0+ number indicating the line where any
111
+ description begins
112
+ 5. `descriptionEndLine` - A 0+ number indicating the line where the description
113
+ ends
114
+ 6. `hasPreterminalDescription` - Set to 0 or 1. On if has a block description
115
+ on the same line as the terminal `*/`.
116
+ 7. `hasPreterminalTagDescription` - Set to 0 or 1. On if has a tag description
117
+ on the same line as the terminal `*/`.
118
+ 8. `preterminalLineBreak` - A string containing any line break before `terminal`.
119
+
120
+ May also have the following non-visitable properties from `comment-parser`:
121
+
122
+ 1. `description` - Same as `descriptionLines` but as a string with newlines.
123
+ 2. `delimiter`
124
+ 3. `postDelimiter`
125
+ 4. `lineEnd`
126
+ 5. `initial` (from `start`)
127
+ 6. `terminal` (from `end`)
128
+
129
+ ### `JsdocTag`
130
+
131
+ Has the following visitable properties:
132
+
133
+ 1. `parsedType` (the `jsdoc-type-pratt-parser` AST representation of the tag's
134
+ type (see the `jsdoc-type-pratt-parser` section below)).
135
+ 1. `typeLines` (an array of `JsdocTypeLine` for multiline type strings)
136
+ 1. `descriptionLines` (an array of `JsdocDescriptionLine` for multiline
137
+ descriptions)
138
+ 1. `inlineTags` (an array of `JsdocInlineTag`)
139
+
140
+ May also have the following non-visitable properties from `comment-parser`
141
+ (note that all are included from `comment-parser` except `end` as that is only
142
+ for JSDoc blocks and note that `type` is renamed to `rawType` and `start` to
143
+ `initial`):
144
+
145
+ 1. `description` - Same as `descriptionLines` but as a string with newlines.
146
+ 2. `rawType` - `comment-parser` has this named as `type`, but because of a
147
+ conflict with ESTree using `type` for Node type, we renamed it to
148
+ `rawType`. It is otherwise the same as in `comment-parser`, i.e., a string
149
+ with newlines, though with the initial `{` and final `}` stripped out.
150
+ See `typeLines` for the array version of this property.
151
+ 3. `initial` - Renamed from `start` to avoid potential conflicts with
152
+ Acorn-style parser processing tools
153
+ 4. `delimiter`
154
+ 5. `postDelimiter`
155
+ 6. `tag` (this does differ from `comment-parser` now in terms of our stripping
156
+ the initial `@`)
157
+ 7. `postTag`
158
+ 8. `name`
159
+ 9. `postName`
160
+ 10. `postType`
161
+
162
+ ### `JsdocDescriptionLine`
163
+
164
+ No visitable properties.
165
+
166
+ May also have the following non-visitable properties from `comment-parser`:
167
+
168
+ 1. `delimiter`
169
+ 2. `postDelimiter`
170
+ 3. `initial` (from `start`)
171
+ 4. `description`
172
+
173
+ ### `JsdocTypeLine`
174
+
175
+ No visitable properties.
176
+
177
+ May also have the following non-visitable properties from `comment-parser`:
178
+
179
+ 1. `delimiter`
180
+ 2. `postDelimiter`
181
+ 3. `initial` (from `start`)
182
+ 4. `rawType` - Renamed from `comment-parser` to avoid a conflict. See
183
+ explanation under `JsdocTag`
184
+
185
+ ### `JsdocInlineTag`
186
+
187
+ No visitable properties.
188
+
189
+ Has the following non-visitable properties:
190
+
191
+ 1. `format`: 'pipe' | 'plain' | 'prefix' | 'space'. These follow the styles of [`@link`](https://jsdoc.app/tags-inline-link.html) or [`@tutorial`](https://jsdoc.app/tags-inline-tutorial.html).
192
+ 1. `pipe`: `{@link namepathOrURL|link text}`
193
+ 2. `plain`: `{@link namepathOrURL}`
194
+ 3. `prefix`: `[link text]{@link namepathOrURL}`
195
+ 4. `space`: `{@link namepathOrURL link text (after the first space)}`
196
+ 2. `namepathOrURL`: string
197
+ 3. `tag`: string. The standard allows `tutorial` or `link`
198
+ 4. `text`: string
199
+
200
+ ## ESLint AST produced for `jsdoc-type-pratt-parser`
201
+
202
+ The AST, including `type`, remains as is from [jsdoc-type-pratt-parser](https://github.com/simonseyock/jsdoc-type-pratt-parser/).
203
+
204
+ The type will always begin with a `JsdocType` prefix added, along with a
205
+ camel-cased type name, e.g., `JsdocTypeUnion`.
206
+
207
+ The `jsdoc-type-pratt-parser` visitor keys are also preserved without change.
208
+
209
+ You can get a sense of the structure of these types using the parser's
210
+ [tester](https://jsdoc-type-pratt-parser.github.io/jsdoc-type-pratt-parser/).
211
+
212
+ ## Installation
213
+
214
+ ```shell
215
+ npm i @es-joy/jsdoccomment
216
+ ```
217
+
218
+ ## Changelog
219
+
220
+ The changelog can be found on the [CHANGES.md](https://github.com/es-joy/jsdoccomment/blob/main/CHANGES.md).
221
+
222
+ <!--## Contributing
223
+
224
+ Everyone is welcome to contribute. Please take a moment to review the [contributing guidelines](CONTRIBUTING.md).
225
+ -->
226
+
227
+ ## Authors and license
228
+
229
+ [Brett Zamir](http://brett-zamir.me/) and
230
+ [contributors](https://github.com/es-joy/jsdoccomment/graphs/contributors).
231
+
232
+ MIT License, see the included [LICENSE-MIT.txt](https://github.com/es-joy/jsdoccomment/blob/main/LICENSE-MIT.txt) file.
233
+
234
+ ## To-dos
235
+
236
+ 1. Get complete code coverage
237
+ 1. Given that `esquery` expects a `right` property to search for `>` (the
238
+ child selector), we should perhaps insist, for example, that params are
239
+ the child property for `JsdocBlock` or such. Where `:has()` is currently
240
+ needed, one could thus instead just use `>`.
241
+ 1. Might add `trailing` for `JsdocBlock` to know whether it is followed by a
242
+ line break or what not; `comment-parser` does not provide, however
243
+ 1. Fix and properly utilize `indent` argument (challenging for
244
+ `eslint-plugin-jsdoc` but needed for `jsdoc-eslint-parser` stringifiers
245
+ to be more faithful); should also then use the proposed `trailing` as well
246
+
247
+ ## cjser
248
+
249
+ This package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.
250
+ Original repository: https://github.com/es-joy/jsdoccomment
@@ -0,0 +1,421 @@
1
+ import * as estree from 'estree';
2
+ import * as comment_parser from 'comment-parser';
3
+ import * as jsdoc_type_pratt_parser from '@cjser/jsdoc-type-pratt-parser';
4
+ export * from '@cjser/jsdoc-type-pratt-parser';
5
+ export { visitorKeys as jsdocTypeVisitorKeys } from '@cjser/jsdoc-type-pratt-parser';
6
+ import * as _typescript_eslint_types from '@typescript-eslint/types';
7
+ import * as eslint from 'eslint';
8
+
9
+ type JsdocTypeLine = {
10
+ delimiter: string;
11
+ postDelimiter: string;
12
+ rawType: string;
13
+ initial: string;
14
+ type: 'JsdocTypeLine';
15
+ };
16
+ type JsdocDescriptionLine = {
17
+ delimiter: string;
18
+ description: string;
19
+ postDelimiter: string;
20
+ initial: string;
21
+ type: 'JsdocDescriptionLine';
22
+ };
23
+ /**
24
+ * An inline tag whose `text` is the unescaped label value.
25
+ */
26
+ type JsdocInlineTagNoType = {
27
+ format: 'pipe' | 'plain' | 'prefix' | 'space';
28
+ namepathOrURL: string;
29
+ tag: string;
30
+ text: string;
31
+ };
32
+ type JsdocInlineTag = JsdocInlineTagNoType & {
33
+ type: 'JsdocInlineTag';
34
+ };
35
+ type JsdocTag = {
36
+ delimiter: string;
37
+ description: string;
38
+ descriptionLines: JsdocDescriptionLine[];
39
+ initial: string;
40
+ inlineTags: JsdocInlineTag[];
41
+ name: string;
42
+ postDelimiter: string;
43
+ postName: string;
44
+ postTag: string;
45
+ postType: string;
46
+ rawType: string;
47
+ parsedType: jsdoc_type_pratt_parser.RootResult | null;
48
+ tag: string;
49
+ type: 'JsdocTag';
50
+ typeLines: JsdocTypeLine[];
51
+ };
52
+ type Integer = number;
53
+ type JsdocBlock = {
54
+ delimiter: string;
55
+ delimiterLineBreak: string;
56
+ description: string;
57
+ descriptionEndLine?: Integer;
58
+ descriptionLines: JsdocDescriptionLine[];
59
+ descriptionStartLine?: Integer;
60
+ hasPreterminalDescription: 0 | 1;
61
+ hasPreterminalTagDescription?: 1;
62
+ initial: string;
63
+ inlineTags: JsdocInlineTag[];
64
+ lastDescriptionLine?: Integer;
65
+ endLine: Integer;
66
+ lineEnd: string;
67
+ postDelimiter: string;
68
+ tags: JsdocTag[];
69
+ terminal: string;
70
+ preterminalLineBreak: string;
71
+ type: 'JsdocBlock';
72
+ };
73
+ type JtppOptions = {
74
+ module?: boolean;
75
+ strictMode?: boolean;
76
+ asyncFunctionBody?: boolean;
77
+ classContext?: boolean;
78
+ computedPropertyParser?: (text: string, options?: any) => unknown;
79
+ };
80
+ type CommentParserToESTreeOptions = {
81
+ /**
82
+ * By default, empty lines are
83
+ * compacted; set to 'preserve' to preserve empty comment lines.
84
+ */
85
+ spacing?: 'compact' | 'preserve';
86
+ throwOnTypeParsingErrors?: boolean;
87
+ jsdocTypePrattParserArgs?: JtppOptions;
88
+ };
89
+ /**
90
+ * @typedef {{
91
+ * module?: boolean;
92
+ * strictMode?: boolean;
93
+ * asyncFunctionBody?: boolean;
94
+ * classContext?: boolean;
95
+ * computedPropertyParser?: (text: string, options?: any) => unknown;
96
+ * }} JtppOptions
97
+ */
98
+ /**
99
+ * @typedef {object} CommentParserToESTreeOptions
100
+ * @property {'compact'|'preserve'} [spacing] By default, empty lines are
101
+ * compacted; set to 'preserve' to preserve empty comment lines.
102
+ * @property {boolean} [throwOnTypeParsingErrors]
103
+ * @property {JtppOptions} [jsdocTypePrattParserArgs]
104
+ */
105
+ /**
106
+ * Converts comment parser AST to ESTree format.
107
+ * @param {import('./index.js').JsdocBlockWithInline} jsdoc
108
+ * @param {import('@cjser/jsdoc-type-pratt-parser').ParseMode} mode
109
+ * @param {CommentParserToESTreeOptions} [opts]
110
+ * @returns {JsdocBlock}
111
+ */
112
+ declare function commentParserToESTree(
113
+ jsdoc: JsdocBlockWithInline,
114
+ mode?: jsdoc_type_pratt_parser.ParseMode,
115
+ { spacing, throwOnTypeParsingErrors, jsdocTypePrattParserArgs }?: CommentParserToESTreeOptions,
116
+ ): JsdocBlock;
117
+ declare namespace jsdocVisitorKeys {
118
+ let JsdocBlock: string[];
119
+ let JsdocDescriptionLine: any[];
120
+ let JsdocTypeLine: any[];
121
+ let JsdocTag: string[];
122
+ let JsdocInlineTag: any[];
123
+ }
124
+
125
+ /**
126
+ * @param {{
127
+ * mode: import('@cjser/jsdoc-type-pratt-parser').ParseMode,
128
+ * [key: string]: any
129
+ * }} settings
130
+ * @param {import('./commentParserToESTree.js').
131
+ * CommentParserToESTreeOptions} [commentParserToESTreeOptions]
132
+ * @returns {import('./index.js').CommentHandler}
133
+ */
134
+ declare function commentHandler(
135
+ settings: {
136
+ mode: jsdoc_type_pratt_parser.ParseMode;
137
+ [key: string]: any;
138
+ },
139
+ commentParserToESTreeOptions?: CommentParserToESTreeOptions,
140
+ ): CommentHandler;
141
+
142
+ /**
143
+ * @todo convert for use by escodegen (until may be patched to support
144
+ * custom entries?).
145
+ * @param {import('./commentParserToESTree.js').JsdocBlock|
146
+ * import('./commentParserToESTree.js').JsdocDescriptionLine|
147
+ * import('./commentParserToESTree.js').JsdocTypeLine|
148
+ * import('./commentParserToESTree.js').JsdocTag|
149
+ * import('./commentParserToESTree.js').JsdocInlineTag|
150
+ * import('@cjser/jsdoc-type-pratt-parser').RootResult
151
+ * } node
152
+ * @param {import('./index.js').ESTreeToStringOptions} [opts]
153
+ * @throws {Error}
154
+ * @returns {string}
155
+ */
156
+ declare function estreeToString(
157
+ node:
158
+ JsdocBlock | JsdocDescriptionLine | JsdocTypeLine | JsdocTag | JsdocInlineTag | jsdoc_type_pratt_parser.RootResult,
159
+ opts?: ESTreeToStringOptions,
160
+ ): string;
161
+
162
+ type Token =
163
+ | eslint.AST.Token
164
+ | estree.Comment
165
+ | {
166
+ type: eslint.AST.TokenType | 'Line' | 'Block' | 'Shebang';
167
+ range: [number, number];
168
+ value: string;
169
+ };
170
+ type ESLintOrTSNode = eslint.Rule.Node | _typescript_eslint_types.TSESTree.Node;
171
+ type int = number;
172
+ type DecoratedNode =
173
+ | ESLintOrTSNode
174
+ | estree.Comment
175
+ | (eslint.Rule.Node & {
176
+ declaration?: any;
177
+ decorators?: any[];
178
+ });
179
+ type Settings = {
180
+ maxLines: int;
181
+ minLines: int;
182
+ skipInvokedExpressionsForCommentFinding?: boolean;
183
+ [name: string]: any;
184
+ };
185
+ /**
186
+ * @typedef {{
187
+ * maxLines: int,
188
+ * minLines: int,
189
+ * skipInvokedExpressionsForCommentFinding?: boolean,
190
+ * [name: string]: any
191
+ * }} Settings
192
+ */
193
+ /**
194
+ * Reduces the provided node to the appropriate node for evaluating
195
+ * JSDoc comment status.
196
+ *
197
+ * @param {ESLintOrTSNode} node An AST node.
198
+ * @param {import('eslint').SourceCode} sourceCode The ESLint SourceCode.
199
+ * @param {Settings} [settings]
200
+ * @returns {ESLintOrTSNode} The AST node that
201
+ * can be evaluated for appropriate JSDoc comments.
202
+ */
203
+ declare function getReducedASTNode(
204
+ node: ESLintOrTSNode,
205
+ sourceCode: eslint.SourceCode,
206
+ settings?: Settings,
207
+ ): ESLintOrTSNode;
208
+ /**
209
+ * Retrieves the JSDoc comment for a given node.
210
+ *
211
+ * @param {import('eslint').SourceCode} sourceCode The ESLint SourceCode
212
+ * @param {ESLintOrTSNode} node The AST node to get
213
+ * the comment for.
214
+ * @param {Settings} settings The settings in context
215
+ * @param {{checkOverloads?: boolean}} [opts]
216
+ * @returns {Token|null} The Block comment
217
+ * token containing the JSDoc comment for the given node or
218
+ * null if not found.
219
+ * @public
220
+ */
221
+ declare function getJSDocComment(
222
+ sourceCode: eslint.SourceCode,
223
+ node: ESLintOrTSNode,
224
+ settings: Settings,
225
+ opts?: {
226
+ checkOverloads?: boolean;
227
+ },
228
+ ): Token | null;
229
+ /**
230
+ * Retrieves the comment preceding a given node.
231
+ *
232
+ * @param {import('eslint').SourceCode} sourceCode The ESLint SourceCode
233
+ * @param {ESLintOrTSNode} node The AST node to get
234
+ * the comment for.
235
+ * @param {{maxLines: int, minLines: int, [name: string]: any}} settings The
236
+ * settings in context
237
+ * @returns {Token|null} The Block comment
238
+ * token containing the JSDoc comment for the given node or
239
+ * null if not found.
240
+ * @public
241
+ */
242
+ declare function getNonJsdocComment(
243
+ sourceCode: eslint.SourceCode,
244
+ node: ESLintOrTSNode,
245
+ settings: {
246
+ maxLines: int;
247
+ minLines: int;
248
+ [name: string]: any;
249
+ },
250
+ ): Token | null;
251
+ /**
252
+ * @typedef {(
253
+ * ESLintOrTSNode|
254
+ * import('estree').Comment|
255
+ * import('eslint').Rule.Node & {declaration?: any, decorators?: any[]}
256
+ * )} DecoratedNode
257
+ */
258
+ /**
259
+ * @param {DecoratedNode} node
260
+ * @returns {import('@typescript-eslint/types').TSESTree.Decorator|undefined}
261
+ */
262
+ declare function getDecorator(node: DecoratedNode): _typescript_eslint_types.TSESTree.Decorator | undefined;
263
+ /**
264
+ * Checks for the presence of a JSDoc comment for the given node and returns it.
265
+ *
266
+ * @param {ESLintOrTSNode} astNode The AST node to get
267
+ * the comment for.
268
+ * @param {import('eslint').SourceCode} sourceCode
269
+ * @param {{maxLines: int, minLines: int, [name: string]: any}} settings
270
+ * @param {{nonJSDoc?: boolean}} [opts]
271
+ * @returns {Token|null} The Block comment token containing the JSDoc comment
272
+ * for the given node or null if not found.
273
+ */
274
+ declare function findJSDocComment(
275
+ astNode: ESLintOrTSNode,
276
+ sourceCode: eslint.SourceCode,
277
+ settings: {
278
+ maxLines: int;
279
+ minLines: int;
280
+ [name: string]: any;
281
+ },
282
+ opts?: {
283
+ nonJSDoc?: boolean;
284
+ },
285
+ ): Token | null;
286
+ /**
287
+ * Checks for the presence of a comment following the given node and
288
+ * returns it.
289
+ *
290
+ * This method is experimental.
291
+ *
292
+ * @param {import('eslint').SourceCode} sourceCode
293
+ * @param {ESLintOrTSNode} astNode The AST node to get
294
+ * the comment for.
295
+ * @returns {Token|null} The comment token containing the comment
296
+ * for the given node or null if not found.
297
+ */
298
+ declare function getFollowingComment(sourceCode: eslint.SourceCode, astNode: ESLintOrTSNode): Token | null;
299
+
300
+ declare function hasSeeWithLink(spec: comment_parser.Spec): boolean;
301
+ declare const defaultNoTypes: string[];
302
+ declare const defaultNoNames: string[];
303
+ /**
304
+ * Can't import `comment-parser/es6/parser/tokenizers/index.js`,
305
+ * so we redefine here.
306
+ */
307
+ type CommentParserTokenizer = (spec: comment_parser.Spec) => comment_parser.Spec;
308
+ /**
309
+ * Can't import `comment-parser/es6/parser/tokenizers/index.js`,
310
+ * so we redefine here.
311
+ * @typedef {(spec: import('comment-parser').Spec) =>
312
+ * import('comment-parser').Spec} CommentParserTokenizer
313
+ */
314
+ /**
315
+ * @param {object} [cfg]
316
+ * @param {string[]} [cfg.noTypes]
317
+ * @param {string[]} [cfg.noNames]
318
+ * @returns {CommentParserTokenizer[]}
319
+ */
320
+ declare function getTokenizers({
321
+ noTypes,
322
+ noNames,
323
+ }?: {
324
+ noTypes?: string[];
325
+ noNames?: string[];
326
+ }): CommentParserTokenizer[];
327
+ /**
328
+ * Accepts a comment token or complete comment string and converts it into
329
+ * `comment-parser` AST.
330
+ * @param {string | {value: string}} commentOrNode
331
+ * @param {string} [indent] Whitespace
332
+ * @returns {import('./index.js').JsdocBlockWithInline}
333
+ */
334
+ declare function parseComment(
335
+ commentOrNode:
336
+ | string
337
+ | {
338
+ value: string;
339
+ },
340
+ indent?: string,
341
+ ): JsdocBlockWithInline;
342
+
343
+ /**
344
+ * Splits the `{@ prefix}` from remaining `Spec.lines[].token.description`
345
+ * into the `inlineTags` tokens, and populates `spec.inlineTags`
346
+ * @param {import('comment-parser').Block} block
347
+ * @returns {import('./index.js').JsdocBlockWithInline}
348
+ */
349
+ declare function parseInlineTags(block: comment_parser.Block): JsdocBlockWithInline;
350
+
351
+ /**
352
+ * An inline tag whose `text` is the unescaped label value.
353
+ */
354
+ type InlineTag = JsdocInlineTagNoType & {
355
+ start: number;
356
+ end: number;
357
+ };
358
+ type JsdocTagWithInline = comment_parser.Spec & {
359
+ line?: Integer;
360
+ inlineTags: (JsdocInlineTagNoType & {
361
+ line?: Integer;
362
+ })[];
363
+ };
364
+ /**
365
+ * Expands on comment-parser's `Block` interface.
366
+ */
367
+ type JsdocBlockWithInline = {
368
+ description: string;
369
+ source: comment_parser.Line[];
370
+ problems: comment_parser.Problem[];
371
+ tags: JsdocTagWithInline[];
372
+ inlineTags: (JsdocInlineTagNoType & {
373
+ line?: Integer;
374
+ })[];
375
+ };
376
+ type ESTreeToStringOptions = {
377
+ preferRawType?: boolean;
378
+ jtppStringificationRules?: (node: estree.Node, options?: any) => string;
379
+ };
380
+ type CommentHandler = (commentSelector: string, jsdoc: JsdocBlockWithInline) => boolean;
381
+
382
+ export {
383
+ JsdocBlock,
384
+ JsdocDescriptionLine,
385
+ JsdocInlineTag,
386
+ JsdocTag,
387
+ JsdocTypeLine,
388
+ commentHandler,
389
+ commentParserToESTree,
390
+ defaultNoNames,
391
+ defaultNoTypes,
392
+ estreeToString,
393
+ findJSDocComment,
394
+ getDecorator,
395
+ getFollowingComment,
396
+ getJSDocComment,
397
+ getNonJsdocComment,
398
+ getReducedASTNode,
399
+ getTokenizers,
400
+ hasSeeWithLink,
401
+ jsdocVisitorKeys,
402
+ parseComment,
403
+ parseInlineTags,
404
+ };
405
+ export type {
406
+ CommentHandler,
407
+ CommentParserToESTreeOptions,
408
+ CommentParserTokenizer,
409
+ DecoratedNode,
410
+ ESLintOrTSNode,
411
+ ESTreeToStringOptions,
412
+ InlineTag,
413
+ Integer,
414
+ JsdocBlockWithInline,
415
+ JsdocInlineTagNoType,
416
+ JsdocTagWithInline,
417
+ JtppOptions,
418
+ Settings,
419
+ Token,
420
+ int,
421
+ };