Skip to content

Require ECMAScript private class members - #5945

Draft
Bharat Middha (bmiddha) wants to merge 4 commits into
bmiddha/native-private-fields-integrationfrom
bmiddha/enforce-native-private-fields
Draft

Require ECMAScript private class members#5945
Bharat Middha (bmiddha) wants to merge 4 commits into
bmiddha/native-private-fields-integrationfrom
bmiddha/enforce-native-private-fields

Conversation

@bmiddha

@bmiddha Bharat Middha (bmiddha) commented Aug 19, 2026

Copy link
Copy Markdown
Member

Summary

  • add @rushstack/prefer-ecmascript-private-members
  • require native # syntax for private fields, methods, and accessors
  • leave private constructors and constructor parameter properties unchanged
  • enable the rule in legacy and flat shared ESLint profiles
  • document runtime-privacy rationale and unsafe-autofix boundary

Dependency

Draft/stacked on the integration branch for #5939, #5940, #5941, #5942, and #5943. Retarget to main after those migrations merge.

Validation

  • rush build --to @rushstack/eslint-config --verbose
  • rush test --only @rushstack/eslint-plugin --only @rushstack/eslint-config --verbose
  • 208 ESLint plugin tests passed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8ebd5bf2-c44b-42d5-be25-e7936d4b0a14
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8ebd5bf2-c44b-42d5-be25-e7936d4b0a14
@bmiddha Bharat Middha (bmiddha) changed the title Require ECMAScript private class fields Require ECMAScript private class members Aug 19, 2026
@bmiddha

Copy link
Copy Markdown
Member Author

Scope update: the new ESLint rule now enforces ECMAScript #private syntax for private fields, methods, getters, and setters. Private constructors and constructor parameter properties remain excluded because they have no direct native-private equivalent. The refreshed stack passes all 208 ESLint plugin tests.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds and enables an ESLint rule requiring native ECMAScript private class members.

Changes:

  • Implements and tests the new rule.
  • Enables it in legacy and flat profiles.
  • Documents behavior and release changes.

Reviewed changes

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

Show a summary per file
File Description
eslint/eslint-plugin/src/prefer-ecmascript-private-members.ts Implements the rule.
eslint/eslint-plugin/src/test/prefer-ecmascript-private-members.test.ts Tests supported member forms and exemptions.
eslint/eslint-plugin/src/index.ts Exports the rule.
eslint/eslint-plugin/README.md Documents rationale and usage.
eslint/eslint-config/profile/_common.js Enables the legacy rule.
eslint/eslint-config/flat/profile/_common.js Enables the flat rule.
common/changes/@rushstack/eslint-plugin/native-private-fields_2026-08-18-12-00-00.json Records the plugin change.
common/changes/@rushstack/eslint-config/native-private-fields_2026-08-18-12-00-00.json Records the config change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

'@rushstack/no-new-null': 'warn',

// RATIONALE: See the @rushstack/eslint-plugin documentation
'@rushstack/prefer-ecmascript-private-members': 'warn',
'@rushstack/no-new-null': 'warn',

// RATIONALE: See the @rushstack/eslint-plugin documentation
'@rushstack/prefer-ecmascript-private-members': 'warn',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

2 participants