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
3 changes: 3 additions & 0 deletions napi/oxlint2/src-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class Context {
// Index into `ruleIds` sent from Rust. Set before calling `rule`'s `create` method.
#ruleIndex;
// Absolute path of file being linted. Set before calling `rule`'s `create` method.
filename;
// Absolute path of file being linted. Set before calling `rule`'s `create` method.
physicalFilename;

/**
Expand Down Expand Up @@ -117,6 +119,7 @@ class Context {
*/
setupContextForFile = (context, ruleIndex, filePath) => {
context.#ruleIndex = ruleIndex;
context.filename = filePath;
context.physicalFilename = filePath;
};
}
Expand Down
14 changes: 13 additions & 1 deletion napi/oxlint2/test/__snapshots__/e2e.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ exports[`oxlint2 CLI > should receive data via \`context\` 1`] = `
: ^
\`----

x context-plugin(log-context): filename: files/1.js
,-[files/1.js:1:1]
1 | let x;
: ^
\`----

x context-plugin(log-context): physicalFilename: files/1.js
,-[files/1.js:1:1]
1 | let x;
Expand All @@ -342,13 +348,19 @@ exports[`oxlint2 CLI > should receive data via \`context\` 1`] = `
: ^
\`----

x context-plugin(log-context): filename: files/2.js
,-[files/2.js:1:1]
1 | let y;
: ^
\`----

x context-plugin(log-context): physicalFilename: files/2.js
,-[files/2.js:1:1]
1 | let y;
: ^
\`----

Found 0 warnings and 4 errors.
Found 0 warnings and 6 errors.
Finished in Xms on 2 files using X threads."
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export default {
node: SPAN,
});

context.report({
message: `filename: ${relativePath(context.filename)}`,
node: SPAN,
});

context.report({
message: `physicalFilename: ${relativePath(context.physicalFilename)}`,
node: SPAN,
Expand Down
Loading