Skip to content

Commit ef0e6c3

Browse files
committed
feat(linter/plugins): add options to Context (#13810)
Add `options` property to `Context`. At present we don't support custom options for JS plugins, but adding the `options` property as an empty array for now avoids errors in some existing ESLint rules.
1 parent 6245c8c commit ef0e6c3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ interface InternalContext {
4444
ruleIndex: number;
4545
// Absolute path of file being linted
4646
filePath: string;
47+
// Options
48+
options: unknown[];
4749
}
4850

4951
/**
@@ -65,6 +67,7 @@ export class Context {
6567
id: fullRuleName,
6668
filePath: '',
6769
ruleIndex: 0,
70+
options: [],
6871
};
6972
}
7073

@@ -84,6 +87,11 @@ export class Context {
8487
return this.#internal.filePath;
8588
}
8689

90+
// Getter for options for file being linted.
91+
get options() {
92+
return this.#internal.options;
93+
}
94+
8795
/**
8896
* Report error.
8997
* @param diagnostic - Diagnostic object
@@ -98,6 +106,7 @@ export class Context {
98106

99107
static {
100108
setupContextForFile = (context, ruleIndex, filePath) => {
109+
// TODO: Support `options`
101110
const internal = context.#internal;
102111
internal.ruleIndex = ruleIndex;
103112
internal.filePath = filePath;

0 commit comments

Comments
 (0)