Skip to content

feat(linter): implement disallows using this in an exported function rule#15745

Merged
camc314 merged 11 commits intooxc-project:mainfrom
re-taro:feat/no-this-in-exported-function
Dec 11, 2025
Merged

feat(linter): implement disallows using this in an exported function rule#15745
camc314 merged 11 commits intooxc-project:mainfrom
re-taro:feat/no-this-in-exported-function

Conversation

@re-taro
Copy link
Copy Markdown
Contributor

@re-taro re-taro commented Nov 16, 2025

Summary

close: #15359

I implemented disallows using this in an exported function rule for oxc

@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app bot commented Nov 16, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Nov 16, 2025
@re-taro re-taro force-pushed the feat/no-this-in-exported-function branch from 832c92e to 6b210a8 Compare November 16, 2025 09:42
@re-taro re-taro marked this pull request as ready for review November 16, 2025 09:46
@re-taro re-taro requested a review from camc314 as a code owner November 16, 2025 09:46
Copilot AI review requested due to automatic review settings November 16, 2025 09:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a new linter rule no-this-in-exported-function for the oxc linter that detects and warns against using this in exported functions, as this becomes undefined in most bundlers when functions are exported and imported.

Key Changes:

  • New linter rule implementation with AST visitor pattern to detect this usage in exported functions
  • Comprehensive test coverage with 13 pass cases and 12 fail cases
  • Integration of the rule into the oxc linter module system

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/oxc_linter/src/rules/oxc/no_this_in_exported_function.rs Core implementation of the rule with AST visitor, diagnostic generation, and test cases
crates/oxc_linter/src/snapshots/oxc_no_this_in_exported_function.snap Snapshot file containing expected diagnostic output for failing test cases
crates/oxc_linter/src/rules.rs Registration of the new rule in the oxc module system

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 16, 2025

CodSpeed Performance Report

Merging #15745 will not alter performance

Comparing re-taro:feat/no-this-in-exported-function (a15f0c9) with main (2195150)

Summary

✅ 4 untouched
⏩ 41 skipped1

Footnotes

  1. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@re-taro re-taro changed the title feat(linter/oxc): implement disallows using this in an exported function rule feat(linter): implement disallows using this in an exported function rule Nov 16, 2025
@re-taro
Copy link
Copy Markdown
Contributor Author

re-taro commented Dec 6, 2025

@camc314

Would you mind taking a moment to leave a review?

@re-taro
Copy link
Copy Markdown
Contributor Author

re-taro commented Dec 10, 2025

@camc314

I'm terribly sorry to trouble you again. I'd be most grateful if you could take a look at this too!

@camc314 camc314 self-assigned this Dec 10, 2025
Copy link
Copy Markdown
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! - sorry this one slipped by me!

@camc314
Copy link
Copy Markdown
Contributor

camc314 commented Dec 10, 2025

@sapphi-red do you mind taking a quick pass and having a look at this? thanks!

@camc314 camc314 assigned camc314 and sapphi-red and unassigned camc314 Dec 10, 2025
@camc314 camc314 merged commit 725a5c0 into oxc-project:main Dec 11, 2025
19 checks passed
@re-taro re-taro deleted the feat/no-this-in-exported-function branch December 11, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: add a new rule that disallows using this in an exported function

4 participants