Skip to content

refactor(lint): enable class-methods-use-this ESLint rule - W-22068833#7208

Open
mshanemc wants to merge 9 commits intodevelopfrom
feature/class-methods-use-this
Open

refactor(lint): enable class-methods-use-this ESLint rule - W-22068833#7208
mshanemc wants to merge 9 commits intodevelopfrom
feature/class-methods-use-this

Conversation

@mshanemc
Copy link
Copy Markdown
Contributor

What issues does this PR fix or reference?

@W-22068833@

Before/After

  • Bump eslint-plugin-unicorn to 64.0.0; enable prefer-simple-condition-first
  • Add aura resources to eslint ignore list
  • Enable class-methods-use-this rule; fix violations in apex-testing
  • Remove unnecessary wrapper methods in apex-testing
  • Enable class-methods-use-this rule in soql

Made with Cursor

mshanemc and others added 5 commits April 16, 2026 15:27
…imple-condition-first

Upgrades eslint-plugin-unicorn from 62.0.0 to 64.0.0 and enables the new
prefer-simple-condition-first rule to enforce simpler conditions first in
logical expressions for better readability.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds packages/salesforcedx-vscode-lightning/src/resources/** to the eslint
ignore patterns. These files contain vendored third-party code (Aura framework,
polyfills) that use patterns incompatible with modern lint rules like
no-array-reverse. The unicorn/no-array-reverse rule is already enabled and now
applies only to our codebase, not vendored code.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Addresses 20 class-methods-use-this violations by extracting utility methods
to module-level functions where appropriate and suppressing the rule for
interface implementations.

Changes:
- Extracted pure utility functions to module level in testController.ts,
  orgApexClassProvider.ts, apexTestingDiscoveryFsProvider.ts, and
  apexTestRunCodeAction.ts
- Added eslint-disable comments for methods that must remain instance methods
  due to interface requirements (ParametersGatherer, LibraryCommandletExecutor,
  FileSystemProvider, etc.)
- Wrapper methods delegate to module-level functions for cleaner separation

This aligns with the preference for module-level functions over static methods
or unnecessary instance methods.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Removes pointless wrapper methods that only delegated to module-level
functions. Calls module-level functions directly instead.

Changes:
- testController.ts: removed 4 wrapper methods, call functions directly
- apexTestRunCodeAction.ts: removed 2 wrapper methods, extracted
  handleDiagnostics to module level

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Enables class-methods-use-this rule for SOQL packages and addresses 15
violations by adding eslint-disable comments for polymorphic methods and
interface implementations.

All violations are legitimate cases where methods must remain instance
methods due to:
- Abstract class polymorphism (validators, analyzers)
- Interface implementations (DataProvider, SelectCount)
- Protected helper methods in parser infrastructure

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@mshanemc mshanemc requested a review from a team as a code owner April 16, 2026 21:42
@mshanemc mshanemc requested a review from diyer April 16, 2026 21:42
@mshanemc mshanemc requested review from daphne-sfdc and removed request for diyer April 17, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants