Skip to content

Commit 6b5205c

Browse files
committed
feat(linter/plugins): implement deprecated SourceCode#getJSDocComment method (#15653)
Add `SourceCode#getJSDocComment` method. It currently throws an "unimplemented" error. This concludes the `Context` API additions. Every method, getter, and property listed in ESLint's [custom rules docs](https://eslint.org/docs/latest/extend/custom-rules) are now present in our API too. Note: `Plugin` and `Rule` types may still be missing properties.
1 parent 5eccff1 commit 6b5205c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

apps/oxlint/src-js/plugins/comments.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,17 @@ export function commentsExistBetween(nodeOrToken1: NodeOrToken, nodeOrToken2: No
200200
comments[firstCommentBetween].end <= nodeOrToken2.range[0]
201201
);
202202
}
203+
204+
/**
205+
* Retrieve the JSDoc comment for a given node.
206+
*
207+
* @deprecated
208+
*
209+
* @param node - The AST node to get the comment for.
210+
* @returns The JSDoc comment for the given node, or `null` if not found.
211+
*/
212+
/* oxlint-disable no-unused-vars */
213+
export function getJSDocComment(node: Node): Comment | null {
214+
throw new Error('`sourceCode.getJSDocComment` is not supported at present (and deprecated)'); // TODO
215+
}
216+
/* oxlint-enable no-unused-vars */

apps/oxlint/src-js/plugins/source_code.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ export const SOURCE_CODE = Object.freeze({
212212
getCommentsAfter: commentMethods.getCommentsAfter,
213213
getCommentsInside: commentMethods.getCommentsInside,
214214
commentsExistBetween: commentMethods.commentsExistBetween,
215+
getJSDocComment: commentMethods.getJSDocComment,
215216

216217
// Scope methods
217218
isGlobalReference: scopeMethods.isGlobalReference,

0 commit comments

Comments
 (0)