Skip to content

Commit b2de90b

Browse files
committed
refactor(linter/plugins): remove | undefined from optional function params types (#15885)
`| undefined` in optional function params (e.g. `param?: string | undefined`) is pointless. Remove them.
1 parent db6a110 commit b2de90b

File tree

2 files changed

+17
-30
lines changed

2 files changed

+17
-30
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,7 @@ export const SOURCE_CODE = Object.freeze({
154154
* @param afterCount? - The number of characters after the node to retrieve.
155155
* @returns Source text representing the AST node.
156156
*/
157-
getText(
158-
node?: Ranged | null | undefined,
159-
beforeCount?: number | null | undefined,
160-
afterCount?: number | null | undefined,
161-
): string {
157+
getText(node?: Ranged | null, beforeCount?: number | null, afterCount?: number | null): string {
162158
if (sourceText === null) initSourceText();
163159

164160
// ESLint treats all falsy values for `node` as undefined

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

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export type FilterFn = (token: Token) => boolean;
5959
/* oxlint-disable no-unused-vars */
6060
export function getTokens(
6161
node: Node,
62-
countOptions?: CountOptions | number | FilterFn | null | undefined,
63-
afterCount?: number | null | undefined,
62+
countOptions?: CountOptions | number | FilterFn | null,
63+
afterCount?: number | null,
6464
): Token[] {
6565
throw new Error('`sourceCode.getTokens` not implemented yet'); // TODO
6666
}
@@ -74,10 +74,7 @@ export function getTokens(
7474
* @returns `Token`, or `null` if all were skipped.
7575
*/
7676
/* oxlint-disable no-unused-vars */
77-
export function getFirstToken(
78-
node: Node,
79-
skipOptions?: SkipOptions | number | FilterFn | null | undefined,
80-
): Token | null {
77+
export function getFirstToken(node: Node, skipOptions?: SkipOptions | number | FilterFn | null): Token | null {
8178
throw new Error('`sourceCode.getFirstToken` not implemented yet'); // TODO
8279
}
8380
/* oxlint-enable no-unused-vars */
@@ -90,10 +87,7 @@ export function getFirstToken(
9087
* @returns Array of `Token`s.
9188
*/
9289
/* oxlint-disable no-unused-vars */
93-
export function getFirstTokens(
94-
node: Node,
95-
countOptions?: CountOptions | number | FilterFn | null | undefined,
96-
): Token[] {
90+
export function getFirstTokens(node: Node, countOptions?: CountOptions | number | FilterFn | null): Token[] {
9791
throw new Error('`sourceCode.getFirstTokens` not implemented yet'); // TODO
9892
}
9993
/* oxlint-enable no-unused-vars */
@@ -105,10 +99,7 @@ export function getFirstTokens(
10599
* @returns `Token`, or `null` if all were skipped.
106100
*/
107101
/* oxlint-disable no-unused-vars */
108-
export function getLastToken(
109-
node: Node,
110-
skipOptions?: SkipOptions | number | FilterFn | null | undefined,
111-
): Token | null {
102+
export function getLastToken(node: Node, skipOptions?: SkipOptions | number | FilterFn | null): Token | null {
112103
throw new Error('`sourceCode.getLastToken` not implemented yet'); // TODO
113104
}
114105
/* oxlint-enable no-unused-vars */
@@ -120,7 +111,7 @@ export function getLastToken(
120111
* @returns Array of `Token`s.
121112
*/
122113
// oxlint-disable-next-line no-unused-vars
123-
export function getLastTokens(node: Node, countOptions?: CountOptions | number | FilterFn | null | undefined): Token[] {
114+
export function getLastTokens(node: Node, countOptions?: CountOptions | number | FilterFn | null): Token[] {
124115
throw new Error('`sourceCode.getLastTokens` not implemented yet'); // TODO
125116
}
126117

@@ -133,7 +124,7 @@ export function getLastTokens(node: Node, countOptions?: CountOptions | number |
133124
/* oxlint-disable no-unused-vars */
134125
export function getTokenBefore(
135126
nodeOrToken: NodeOrToken | Comment,
136-
skipOptions?: SkipOptions | number | FilterFn | null | undefined,
127+
skipOptions?: SkipOptions | number | FilterFn | null,
137128
): Token | null {
138129
throw new Error('`sourceCode.getTokenBefore` not implemented yet'); // TODO
139130
}
@@ -166,7 +157,7 @@ export function getTokenOrCommentBefore(nodeOrToken: NodeOrToken | Comment, skip
166157
/* oxlint-disable no-unused-vars */
167158
export function getTokensBefore(
168159
nodeOrToken: NodeOrToken | Comment,
169-
countOptions?: CountOptions | number | FilterFn | null | undefined,
160+
countOptions?: CountOptions | number | FilterFn | null,
170161
): Token[] {
171162
throw new Error('`sourceCode.getTokensBefore` not implemented yet'); // TODO
172163
}
@@ -181,7 +172,7 @@ export function getTokensBefore(
181172
/* oxlint-disable no-unused-vars */
182173
export function getTokenAfter(
183174
nodeOrToken: NodeOrToken | Comment,
184-
skipOptions?: SkipOptions | number | FilterFn | null | undefined,
175+
skipOptions?: SkipOptions | number | FilterFn | null,
185176
): Token | null {
186177
throw new Error('`sourceCode.getTokenAfter` not implemented yet'); // TODO
187178
}
@@ -214,7 +205,7 @@ export function getTokenOrCommentAfter(nodeOrToken: NodeOrToken | Comment, skip?
214205
/* oxlint-disable no-unused-vars */
215206
export function getTokensAfter(
216207
nodeOrToken: NodeOrToken | Comment,
217-
countOptions?: CountOptions | number | FilterFn | null | undefined,
208+
countOptions?: CountOptions | number | FilterFn | null,
218209
): Token[] {
219210
throw new Error('`sourceCode.getTokensAfter` not implemented yet'); // TODO
220211
}
@@ -238,7 +229,7 @@ export function getTokensAfter(
238229
export function getTokensBetween(
239230
nodeOrToken1: NodeOrToken | Comment,
240231
nodeOrToken2: NodeOrToken | Comment,
241-
countOptions?: CountOptions | number | FilterFn | null | undefined,
232+
countOptions?: CountOptions | number | FilterFn | null,
242233
): Token[] {
243234
throw new Error('`sourceCode.getTokensBetween` not implemented yet'); // TODO
244235
}
@@ -255,7 +246,7 @@ export function getTokensBetween(
255246
export function getFirstTokenBetween(
256247
nodeOrToken1: NodeOrToken | Comment,
257248
nodeOrToken2: NodeOrToken | Comment,
258-
skipOptions?: SkipOptions | null | undefined,
249+
skipOptions?: SkipOptions | null,
259250
): Token | null {
260251
throw new Error('`sourceCode.getFirstTokenBetween` not implemented yet'); // TODO
261252
}
@@ -272,7 +263,7 @@ export function getFirstTokenBetween(
272263
export function getFirstTokensBetween(
273264
nodeOrToken1: NodeOrToken | Comment,
274265
nodeOrToken2: NodeOrToken | Comment,
275-
countOptions?: CountOptions | number | FilterFn | null | undefined,
266+
countOptions?: CountOptions | number | FilterFn | null,
276267
): Token[] {
277268
throw new Error('`sourceCode.getFirstTokensBetween` not implemented yet'); // TODO
278269
}
@@ -289,7 +280,7 @@ export function getFirstTokensBetween(
289280
export function getLastTokenBetween(
290281
nodeOrToken1: NodeOrToken | Comment,
291282
nodeOrToken2: NodeOrToken | Comment,
292-
skipOptions?: SkipOptions | null | undefined,
283+
skipOptions?: SkipOptions | null,
293284
): Token | null {
294285
throw new Error('`sourceCode.getLastTokenBetween` not implemented yet'); // TODO
295286
}
@@ -306,7 +297,7 @@ export function getLastTokenBetween(
306297
export function getLastTokensBetween(
307298
nodeOrToken1: NodeOrToken | Comment,
308299
nodeOrToken2: NodeOrToken | Comment,
309-
countOptions?: CountOptions | number | FilterFn | null | undefined,
300+
countOptions?: CountOptions | number | FilterFn | null,
310301
): Token[] {
311302
throw new Error('`sourceCode.getLastTokensBetween` not implemented yet'); // TODO
312303
}
@@ -319,7 +310,7 @@ export function getLastTokensBetween(
319310
* @returns The token starting at index, or `null` if no such token.
320311
*/
321312
// oxlint-disable-next-line no-unused-vars
322-
export function getTokenByRangeStart(index: number, rangeOptions?: RangeOptions | null | undefined): Token | null {
313+
export function getTokenByRangeStart(index: number, rangeOptions?: RangeOptions | null): Token | null {
323314
throw new Error('`sourceCode.getTokenByRangeStart` not implemented yet'); // TODO
324315
}
325316

0 commit comments

Comments
 (0)