diff --git a/apps/oxlint/src-js/plugins/tokens.ts b/apps/oxlint/src-js/plugins/tokens.ts index db5f92cb40b38..a07c353caf4e7 100644 --- a/apps/oxlint/src-js/plugins/tokens.ts +++ b/apps/oxlint/src-js/plugins/tokens.ts @@ -919,14 +919,9 @@ export function getTokenAfter( * @param skip - Number of tokens to skip. * @returns `Token`, or `null` if all were skipped. */ -/* oxlint-disable no-unused-vars */ export function getTokenOrCommentAfter(nodeOrToken: NodeOrToken | Comment, skip?: number): Token | null { - // TODO: Implement equivalent of: - // `return getTokenAfter(nodeOrToken, { includeComments: true, skip });` - // But could use a const object at top level for options object, to avoid creating temporary object on each call. - throw new Error('`sourceCode.getTokenOrCommentAfter` not implemented yet'); + return getTokenAfter(nodeOrToken, { includeComments: true, skip }); } -/* oxlint-enable no-unused-vars */ /** * Get the tokens that follow a given node or token. diff --git a/apps/oxlint/test/tokens.test.ts b/apps/oxlint/test/tokens.test.ts index 1df6486452539..b737203c05aa9 100644 --- a/apps/oxlint/test/tokens.test.ts +++ b/apps/oxlint/test/tokens.test.ts @@ -769,11 +769,16 @@ describe('when calling getTokenOrCommentBefore', () => { getTokenOrCommentBefore; }); +// https://github.com/eslint/eslint/blob/v9.39.1/tests/lib/languages/js/source-code/token-store.js#L1584-L1602 describe('when calling getTokenOrCommentAfter', () => { - /* oxlint-disable-next-line no-disabled-tests expect-expect */ - it('is to be implemented'); - /* oxlint-disable-next-line no-unused-expressions */ - getTokenOrCommentAfter; + it('should retrieve one token or comment after a node', () => { + expect(getTokenOrCommentAfter(VariableDeclaratorIdentifier)!.value).toBe('B'); + }); + + it('should skip a given number of tokens', () => { + expect(getTokenOrCommentAfter(VariableDeclaratorIdentifier, 1)!.value).toBe('='); + expect(getTokenOrCommentAfter(VariableDeclaratorIdentifier, 2)!.value).toBe('C'); + }); }); describe('when calling getFirstToken & getTokenAfter', () => {