Skip to content
Merged
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
6 changes: 6 additions & 0 deletions apps/oxlint/src-js/plugins/source_code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ export const SOURCE_CODE = Object.freeze({
return ast;
},

/**
* `true` if the AST is in ESTree format.
*/
// This property is present in ESLint's `SourceCode`, but is undocumented
isESTree: true,

/**
* `ScopeManager` for the file.
*/
Expand Down
4 changes: 4 additions & 0 deletions apps/oxlint/test/fixtures/sourceCode/output.snap.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
| 25 => { line: 5, column: 0 }("<EOF>")
| ast: "foo"
| visitorKeys: left, right
| isESTree: true
,-[files/1.js:1:1]
1 | let foo, bar;
: ^
Expand Down Expand Up @@ -83,6 +84,7 @@
| 25 => { line: 5, column: 0 }("<EOF>")
| ast: "foo"
| visitorKeys: left, right
| isESTree: true
,-[files/1.js:1:1]
1 | let foo, bar;
: ^
Expand Down Expand Up @@ -174,6 +176,7 @@
| 9 => { line: 2, column: 0 }("<EOF>")
| ast: "qux"
| visitorKeys: left, right
| isESTree: true
,-[files/2.js:1:1]
1 | let qux;
: ^
Expand Down Expand Up @@ -203,6 +206,7 @@
| 9 => { line: 2, column: 0 }("<EOF>")
| ast: "qux"
| visitorKeys: left, right
| isESTree: true
,-[files/2.js:1:1]
1 | let qux;
: ^
Expand Down
6 changes: 4 additions & 2 deletions apps/oxlint/test/fixtures/sourceCode/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const createRule: Rule = {
`locs:${locs}\n` +
// @ts-ignore
`ast: "${ast.body[0].declarations[0].id.name}"\n` +
`visitorKeys: ${sourceCode.visitorKeys.BinaryExpression.join(", ")}`,
`visitorKeys: ${sourceCode.visitorKeys.BinaryExpression.join(", ")}\n` +
`isESTree: ${sourceCode.isESTree}`,
node: SPAN,
});

Expand Down Expand Up @@ -103,7 +104,8 @@ const createOnceRule: Rule = {
`locs:${locs}\n` +
// @ts-ignore
`ast: "${ast.body[0].declarations[0].id.name}"\n` +
`visitorKeys: ${sourceCode.visitorKeys.BinaryExpression.join(", ")}`,
`visitorKeys: ${sourceCode.visitorKeys.BinaryExpression.join(", ")}\n` +
`isESTree: ${sourceCode.isESTree}`,
node: SPAN,
});
},
Expand Down
Loading