Skip to content

Conversation

@tt-a1i
Copy link
Contributor

@tt-a1i tt-a1i commented Dec 14, 2025

Summary

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 via ContentEq
  • 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

Test plan

  • All 125 pass test cases from ESLint's test suite
  • All 177 fail test cases from ESLint's test suite (adapted for TypeScript parser compatibility)
  • Snapshot tests generated and verified
  • Clippy passes
  • Formatting passes

Related to #479 (ESLint core rules umbrella issue)

@tt-a1i tt-a1i requested a review from camc314 as a code owner December 14, 2025 04:27
@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Dec 14, 2025
Copy link
Contributor

@connorshea connorshea left a 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-hq
Copy link

codspeed-hq bot commented Dec 14, 2025

CodSpeed Performance Report

Merging #16820 will not alter performance

Comparing tt-a1i:feat/linter-accessor-pairs (115137d) with main (ba8fe68)

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.

@camc314 camc314 self-assigned this Dec 14, 2025
Copy link
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!

tt-a1i and others added 11 commits December 14, 2025 13:44
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
@camc314 camc314 force-pushed the feat/linter-accessor-pairs branch from 24a5a40 to 115137d Compare December 14, 2025 13:44
@camc314 camc314 dismissed connorshea’s stale review December 14, 2025 13:45

Changes have been actioned.

@camc314 camc314 merged commit 057b75e into oxc-project:main Dec 14, 2025
19 checks passed
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.

3 participants