Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions apps/oxlint/src-js/plugins/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 9 additions & 4 deletions apps/oxlint/test/tokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading