Skip to content
Merged
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: 4 additions & 3 deletions apps/oxlint/src-js/plugins/fix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const { prototype: ArrayPrototype, from: ArrayFrom } = Array,
// Type of `fix` function.
// `fix` can return a single fix, an array of fixes, or any iterator that yields fixes.
// e.g. `(function*() { yield fix1; yield fix2; })()`
export type FixFn = (fixer: Fixer) => Fix | Array<Fix | null> | IterableIterator<Fix | null> | null;
export type FixFn = (
fixer: Fixer,
) => Fix | Array<Fix | null | undefined> | IterableIterator<Fix | null | undefined> | null | undefined;

// Type of a fix, as returned by `fix` function.
export type Fix = { range: Range; text: string };
Expand Down Expand Up @@ -106,10 +108,9 @@ export function getFixes(diagnostic: Diagnostic, internal: InternalContext): Fix
// Check prototype instead of using `Array.isArray()`, to ensure it is a native `Array`,
// not a subclass which may have overridden `toJSON()` in a way which could make `JSON.stringify()` throw
if (getPrototypeOf(fixes) !== ArrayPrototype || hasOwn(fixes, 'toJSON')) {
fixes = ArrayFrom(fixes as IterableIterator<Fix>);
fixes = ArrayFrom(fixes);
isCloned = true;
}
assertIs<Array<Fix | null>>(fixes);

const fixesLen = fixes.length;
if (fixesLen === 0) return null;
Expand Down
Loading