Skip to content

eslint: allow bracket notation for process.env - #335596

Draft
Alexandru Dima (alexdima) wants to merge 2 commits into
mainfrom
agents/allow-bracket-notation-dictionary-receivers
Draft

eslint: allow bracket notation for process.env#335596
Alexandru Dima (alexdima) wants to merge 2 commits into
mainfrom
agents/allow-bracket-notation-dictionary-receivers

Conversation

@alexdima

@alexdima Alexandru Dima (alexdima) commented Sep 10, 2026

Copy link
Copy Markdown
Member

Summary

Add one small built-in exception to local/code-no-bracket-notation-for-identifiers for environment-variable names accessed directly through process.env:

process.env['ProgramW6432'];
process.env['PROGRAMFILES'];
process.env['https_proxy'];

The exception covers reads, writes, deletes, and direct optional chaining. Dot notation remains valid as well.

  • No new rule options, receiver-path machinery, or ESLint configuration changes.
  • No exceptions for aliases, safeProcess.env, opts, or other receivers.
  • Existing ordinary/private-member checks and autofixes stay in place.
  • Remove the misleading blanket claim that bracket notation bypasses type checking.

This supersedes the earlier configurable approach discussed in #334768. The final diff contains only the existing rule and its tests: no application-source notation conversions or migration-allowlist changes.

Validation

  • Focused rule tests: 34 passed
  • Targeted TypeScript 6 checking for the rule and tests
  • ESLint with --max-warnings=0
  • Targeted repository hygiene and normal pre-commit hooks
  • git diff --check

Add exact receiver-path exceptions without requiring type-aware linting. Configure environment and scoped dictionary receivers, preserve checks for ordinary members, and cover the behavior with rule and configuration tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 10, 2026 23:29

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.

Copilot review overview

🟢 Approval recommended

The implementation is focused, consistent with the stated scope, and comprehensively tested.

Review tier: Balanced
Findings: None

What changed in this PR

Adds scoped bracket-notation exceptions for dictionary-like receivers while preserving enforcement elsewhere.

Changes:

  • Adds exact structural receiver matching to the ESLint rule.
  • Configures global and file-specific receiver exceptions.
  • Adds rule and configuration regression tests.
File Description
.eslint-plugin-local/​code-no-bracket-notation-for-identifiers.ts Implements configurable receiver-path exceptions.
eslint.config.js Defines environment and file-scoped exceptions.
build/​lib/​test/​codeNoBracketNotationForIdentifiers.test.ts Tests matching, enforcement, autofixes, and configuration scope.

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

Replace configurable receiver matching and file-scoped overrides with a single built-in process.env check. Keep aliases and all other receivers under the existing rule.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@alexdima Alexandru Dima (alexdima) changed the title eslint: allow bracket notation for dictionary receivers eslint: allow bracket notation for process.env Sep 11, 2026
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