-
-
Notifications
You must be signed in to change notification settings - Fork 763
feat(linter): implement eslint/accessor-pairs rule #16820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
connorshea
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few suggestions
CodSpeed Performance ReportMerging #16820 will not alter performanceComparing Summary
Footnotes
|
camc314
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Implements the ESLint `accessor-pairs` rule that enforces getter/setter pairs in objects, classes, and TypeScript interfaces. ## Features - Checks for setters without getters (default: enabled) - Checks for getters without setters (default: disabled) - Supports object literals, class bodies, and Object.defineProperty/defineProperties/create - TypeScript support for interfaces and type literals (enforceForTSTypes option) - Handles computed property keys using structural comparison - Separates static and instance members in classes ## Configuration options - `setWithoutGet` (default: true) - Report setters without getters - `getWithoutSet` (default: false) - Report getters without setters - `enforceForClassMembers` (default: true) - Apply to class members - `enforceForTSTypes` (default: false) - Apply to TypeScript interfaces/types Closes oxc-project#479 (partially)
- Use DefaultRuleConfig for cleaner configuration parsing - Use direct imports instead of inline paths (ClassElement) - Apply rustfmt formatting fixes
Add global reference check to avoid false positives when Object or Reflect is shadowed by a local variable. Uses ctx.scoping().find_binding() to verify the identifier refers to the global object.
- Use #[serde(default)] at struct level instead of per-field defaults - Remove default_true helper function - Add config = AccessorPairsConfig to declare_oxc_lint! macro - Add doc comments for config options
24a5a40 to
115137d
Compare
Summary
Implements the ESLint
accessor-pairsrule that enforces getter/setter pairs in objects, classes, and TypeScript interfaces.Features
enforceForTSTypesoption)ContentEqConfiguration options
setWithoutGet(default: true) - Report setters without gettersgetWithoutSet(default: false) - Report getters without settersenforceForClassMembers(default: true) - Apply to class membersenforceForTSTypes(default: false) - Apply to TypeScript interfaces/typesTest plan
Related to #479 (ESLint core rules umbrella issue)