Skip to content

Commit 3ee22b2

Browse files
committed
docs(linter/plugins): fix JSDoc comments for tokens methods (#16063)
Fix a mistake I made in #16062, caught by AI, but only after it was merged. Also, correct the types for `skipOptions` param for `getFirstTokenBetween` and `getLastTokenBetween` so they match the doc comment. This may or may not be correct, so added TODO comments to check.
1 parent f257b5c commit 3ee22b2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,7 @@ export function getTokensBefore(
917917
/**
918918
* Get the token that follows a given node or token.
919919
* @param nodeOrToken - The AST node or token.
920+
* @param skipOptions? - Options object.
920921
* If is a number, equivalent to `{ skip: n }`.
921922
* If is a function, equivalent to `{ filter: fn }`.
922923
* @returns `Token`, or `null` if all were skipped.
@@ -1142,6 +1143,7 @@ export function getTokensBetween(
11421143
* Get the first token between two non-overlapping nodes.
11431144
* @param nodeOrToken1 - Node before the desired token range.
11441145
* @param nodeOrToken2 - Node after the desired token range.
1146+
* @param skipOptions? - Options object.
11451147
* If is a number, equivalent to `{ skip: n }`.
11461148
* If is a function, equivalent to `{ filter: fn }`.
11471149
* @returns `Token`, or `null` if all were skipped.
@@ -1150,8 +1152,10 @@ export function getTokensBetween(
11501152
export function getFirstTokenBetween(
11511153
nodeOrToken1: NodeOrToken | Comment,
11521154
nodeOrToken2: NodeOrToken | Comment,
1153-
skipOptions?: SkipOptions | null,
1155+
skipOptions?: SkipOptions | number | FilterFn | null,
11541156
): Token | null {
1157+
// TODO: Check that `skipOptions` being a number or a function is supported by ESLint in this method.
1158+
// Original type def was `SkipOptions | null`. I (@overlookmotel) assume that was a mistake.
11551159
throw new Error('`sourceCode.getFirstTokenBetween` not implemented yet'); // TODO
11561160
}
11571161
/* oxlint-enable no-unused-vars */
@@ -1179,6 +1183,7 @@ export function getFirstTokensBetween(
11791183
* Get the last token between two non-overlapping nodes.
11801184
* @param nodeOrToken1 - Node before the desired token range.
11811185
* @param nodeOrToken2 - Node after the desired token range.
1186+
* @param skipOptions? - Options object.
11821187
* If is a number, equivalent to `{ skip: n }`.
11831188
* If is a function, equivalent to `{ filter: fn }`.
11841189
* @returns `Token`, or `null` if all were skipped.
@@ -1187,8 +1192,10 @@ export function getFirstTokensBetween(
11871192
export function getLastTokenBetween(
11881193
nodeOrToken1: NodeOrToken | Comment,
11891194
nodeOrToken2: NodeOrToken | Comment,
1190-
skipOptions?: SkipOptions | null,
1195+
skipOptions?: SkipOptions | number | FilterFn | null,
11911196
): Token | null {
1197+
// TODO: Check that `skipOptions` being a number or a function is supported by ESLint in this method.
1198+
// Original type def was `SkipOptions | null`. I (@overlookmotel) assume that was a mistake.
11921199
throw new Error('`sourceCode.getLastTokenBetween` not implemented yet'); // TODO
11931200
}
11941201
/* oxlint-enable no-unused-vars */

0 commit comments

Comments
 (0)