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
13 changes: 12 additions & 1 deletion apps/oxlint/src-js/plugins/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import type { RuleAndContext } from './load.ts';
import type { SourceCode } from './source_code.ts';
import type { Location, Ranged } from './types.ts';

const { hasOwn, keys: ObjectKeys, freeze } = Object;
const { hasOwn, keys: ObjectKeys, freeze, assign: ObjectAssign, create: ObjectCreate } = Object;

// Diagnostic in form passed by user to `Context#report()`
export type Diagnostic = DiagnosticWithNode | DiagnosticWithLoc;
Expand Down Expand Up @@ -134,6 +134,17 @@ const FILE_CONTEXT = freeze({
if (settings === null) initSettings();
return settings;
},

/**
* Create a new object with the current object as the prototype and
* the specified properties as its own properties.
* @param extension - The properties to add to the new object.
* @returns A new object with the current object as the prototype
* and the specified properties as its own properties.
*/
extend(this: FileContext, extension: Record<string | number | symbol, unknown>): FileContext {
return freeze(ObjectAssign(ObjectCreate(this), extension));
},
});

type FileContext = typeof FILE_CONTEXT;
Expand Down
Loading