Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions apps/oxlint/src-js/plugins/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ const FILE_CONTEXT = freeze({
* @deprecated Use `sourceCode` instead.
*/
getSourceCode(): SourceCode {
// TODO: Implement this?
throw new Error('`context.getSourceCode` is deprecated. Use `sourceCode` instead.');
if (filePath === null) throw new Error('Cannot access `context.getSourceCode()` in `createOnce`');
return SOURCE_CODE;
},
});

Expand Down
4 changes: 4 additions & 0 deletions apps/oxlint/test/fixtures/sourceCode/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const SPAN: Node = {

const createRule: Rule = {
create(context) {
assert(context.getSourceCode() === context.sourceCode);

const { ast, lines, text } = context.sourceCode;

let locs = '';
Expand Down Expand Up @@ -75,6 +77,8 @@ const createOnceRule: Rule = {

return {
before() {
assert(context.getSourceCode() === context.sourceCode);

ast = context.sourceCode.ast;
const { lines, text } = context.sourceCode;

Expand Down
Loading