packages/eslint-plugin-jsdoc-scribe/rules/utils
packages/eslint-plugin-jsdoc-scribe/rules/utils.js
Functions(21)
ESLint 9's `context.sourceCode` vs the older `context.getSourceCode()` — support both.
| Parameter | Type | Optional | Description |
|---|---|---|---|
context | any |
Returns:
any Signature
getSourceCode(context: any): any
Finds the JSDoc block comment immediately preceding `node`, if any.
Mirrors lib/extractor.js's readJSDoc(): last leading comment, must start
with a second asterisk (`/**`, not just `/*`).
| Parameter | Type | Optional | Description |
|---|---|---|---|
sourceCode | any | ||
node | any |
Returns:
any Signature
getJSDocComment(sourceCode: any, node: any): any
Splits a JSDoc comment's inner text (comment.value, i.e. without the
surrounding /* * /) into { description, tags }, where each tag is
{ tag, rest, raw }.
| Parameter | Type | Optional | Description |
|---|---|---|---|
commentValue | any |
Returns:
any Signature
parseComment(commentValue: any): any
Extract a {type} prefix from a tag's `rest` string (same brace-depth walk as lib/extractor.js).
| Parameter | Type | Optional | Description |
|---|---|---|---|
str | any |
Returns:
any Signature
extractBraced(str: any): any
All @param tags as [{ name, type, description, optional }], preserving documented order.
| Parameter | Type | Optional | Description |
|---|---|---|---|
tags | any |
Returns:
any Signature
extractParamTags(tags: any): any
The @returns/@return tag, if any, as { type, description }.
| Parameter | Type | Optional | Description |
|---|---|---|---|
tags | any |
Returns:
any Signature
extractReturnsTag(tags: any): any
Every function parameter name, in declared order — best-effort for destructuring/rest.
| Parameter | Type | Optional | Description |
|---|---|---|---|
params | any |
Returns:
any Signature
paramNames(params: any): any
Best-effort, purely syntactic type guess from a default value — no semantics, no AI.
| Parameter | Type | Optional | Description |
|---|---|---|---|
node | any |
Returns:
any Signature
inferTypeFromDefault(node: any): any
[{ name, type, optional }] for every real function parameter — used by the
autofixers to know what to document for a parameter that has no existing
own "any type" marker — unless a default value gives a syntactic hint),
since plain ESTree carries no type annotations to read.
| Parameter | Type | Optional | Description |
|---|---|---|---|
params | any |
Returns:
any Signature
paramInfos(params: any): any
True if the function body contains a `return <expr>;` at its own boundary (not inside a nested function).
| Parameter | Type | Optional | Description |
|---|---|---|---|
node | any |
Returns:
any Signature
hasReturnWithValue(node: any): any
MethodDefinition's actual function params/body live on node.value, not the node itself.
| Parameter | Type | Optional | Description |
|---|---|---|---|
node | any |
Returns:
any Signature
functionParams(node: any): any
Signature
functionBodyNode(node: any): any
Shared visitor wiring for every rule that inspects function-like
documentable nodes (function declarations, `const x = function/arrow`,
and class methods — constructors included, getters/setters excluded,
matching lib/lint.js's own scope). Calls `handler(node, jsdocComment)`
once per candidate, where `node` is the reportable node (function decl,
variable declarator, or method definition) and `jsdocComment` is the
associated comment token or null.
| Parameter | Type | Optional | Description |
|---|---|---|---|
context | any | ||
handler | any |
Returns:
any Signature
visitFunctionLike(context: any, handler: any): any
Signature
viaVariableDeclarator(fnNode: any)
The node ESLint should attach the report to — usually the node itself, unless it's a var-declared function.
| Parameter | Type | Optional | Description |
|---|---|---|---|
node | any |
Returns:
any Signature
reportNodeOf(node: any): any
Signature
todoParamDescription(name: any): any
Signature
ensureSentence(text: any): any
Exact indentation string of the line `pos` sits on in the source text.
| Parameter | Type | Optional | Description |
|---|---|---|---|
sourceCode | any | ||
pos | any |
Returns:
any Signature
indentOf(sourceCode: any, pos: any): any
Rebuilds an entire function-like JSDoc block from real AST truth (actual
parameter names/order, whether the function really returns a value) merged
with whatever valid prose already existed, returning the full replacement
text (including the `/**`/`* /` delimiters) ready for `fixer.replaceText`.
Mirrors lib/fix.js's rebuildFunctionBlock() — same placeholder templates,
same "preserve what we can't safely interpret" rule for other tags, same
mechanical drop of an unnecessary @returns.
| Parameter | Type | Optional | Description |
|---|---|---|---|
sourceCode | any | ||
node | any | ||
jsdocComment | any |
Returns:
any Signature
rebuildFunctionComment(sourceCode: any, node: any, jsdocComment: any): any
Line-level, non-destructive fix for a comment that isn't tied to a specific
function context (empty-tags / no-multi-asterisks / no-blank-block-descriptions
all scan every comment in the file, not just ones attached to a function).
Returns the new full comment text, or null if this rule finds nothing to
change. Mirrors lib/fix.js's lightFixGenericBlock().
| Parameter | Type | Optional | Description |
|---|---|---|---|
jsdocComment | any | ||
ruleName | any | ||
description | any |
Returns:
any Signature
lightFixComment(jsdocComment: any, ruleName: any, description: any): any
Variables & Constants(51)
Signature
const { KNOWN_TAGS, NO_DESC_TAGS }: anySignature
const TODO_RETURNS_DESCRIPTION: string
Signature
const { description, tags }: anySignature
const reallyReturnsAValue: any