Skip to content

Commit 9f6bc29

Browse files
committed
feat(linter/plugins): stub out all Context APIs
1 parent 2c2dee4 commit 9f6bc29

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ const FILE_CONTEXT = freeze({
137137
return SOURCE_CODE;
138138
},
139139

140+
/**
141+
* Language options used when parsing this file.
142+
*/
143+
get languageOptions(): Record<string, unknown> {
144+
if (filePath === null) throw new Error('Cannot access `context.languageOptions` in `createOnce`');
145+
throw new Error('`context.languageOptions` is not implemented yet.'); // TODO
146+
},
147+
140148
/**
141149
* Settings for the file being linted.
142150
*/
@@ -156,6 +164,68 @@ const FILE_CONTEXT = freeze({
156164
extend(this: FileContext, extension: Record<string | number | symbol, unknown>): FileContext {
157165
return freeze(ObjectAssign(ObjectCreate(this), extension));
158166
},
167+
168+
// ---------------
169+
// Deprecated APIs
170+
// ---------------
171+
172+
/**
173+
* Parser options for the file being linted.
174+
* @deprecated Use `languageOptions` instead.
175+
*/
176+
get parserOptions(): Record<string, unknown> {
177+
// TODO: Implement this?
178+
throw new Error('`context.parserOptions` is deprecated. Use `languageOptions` instead.');
179+
},
180+
181+
/**
182+
* The path to the parser used to parse this file.
183+
* @deprecated No longer supported.
184+
*/
185+
get parserPath(): string {
186+
// TODO: Implement this?
187+
throw new Error('`context.parserPath` is deprecated. No longer supported.');
188+
},
189+
190+
/**
191+
* Get current working directory.
192+
* @returns The current working directory.
193+
* @deprecated Use `cwd` instead.
194+
*/
195+
getCwd(): string {
196+
// TODO: Implement this?
197+
throw new Error('`context.getCwd` is deprecated. Use `cwd` instead.');
198+
},
199+
200+
/**
201+
* Get absolute path of the file being linted.
202+
* @returns Absolute path of the file being linted.
203+
* @deprecated Use `filename` instead.
204+
*/
205+
getFilename(): string {
206+
// TODO: Implement this?
207+
throw new Error('`context.getFilename` is deprecated. Use `filename` instead.');
208+
},
209+
210+
/**
211+
* Get physical absolute path of the file being linted.
212+
* @returns Physical absolute path of the file being linted.
213+
* @deprecated Use `physicalFilename` instead.
214+
*/
215+
getPhysicalFilename(): string {
216+
// TODO: Implement this?
217+
throw new Error('`context.getPhysicalFilename` is deprecated. Use `physicalFilename` instead.');
218+
},
219+
220+
/**
221+
* Get source code of the file being linted.
222+
* @returns Source code of the file being linted.
223+
* @deprecated Use `sourceCode` instead.
224+
*/
225+
getSourceCode(): SourceCode {
226+
// TODO: Implement this?
227+
throw new Error('`context.getSourceCode` is deprecated. Use `sourceCode` instead.');
228+
},
159229
});
160230

161231
/**

0 commit comments

Comments
 (0)