Skip to content

[eslint-plugin] Add null-prototype-dictionaries rule and refine no-null rule#5759

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/revise-no-null-eslint-rule
Draft

[eslint-plugin] Add null-prototype-dictionaries rule and refine no-null rule#5759
Copilot wants to merge 4 commits intomainfrom
copilot/revise-no-null-eslint-rule

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

  • Add Object.create(null) exemption to the no-null ESLint rule so that creating prototype-less dictionaries doesn't trigger a lint error
  • Add __proto__: null exemption to the no-null ESLint rule (both identifier and string-literal key forms) so that object literals with null prototype don't trigger a lint error
  • Create new null-prototype-dictionaries ESLint rule that flags empty {} object literals typed as Record<string, T> (or { [key: string]: T }), recommending Object.create(null) instead
  • Register the new null-prototype-dictionaries rule in the plugin's index.ts
  • Add comprehensive tests for the no-null rule covering: null comparisons (allowed), Object.create(null) (allowed), __proto__: null (allowed), and various invalid usages (flagged)
  • Add comprehensive tests for the null-prototype-dictionaries rule covering: empty dictionary literals (flagged), Object.create(null) (allowed), non-empty literals (allowed), non-dictionary types (allowed), and edge cases like Record<"a"|"b", T> and interfaces with index signatures
  • Build and test pass (226 tests)

Copilot AI and others added 4 commits April 7, 2026 22:56
…r Record types

Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/88c04cb4-f442-4fe2-8991-6a20aa3c6f9b

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
…ate(null) for empty ones

Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/39bd15e2-0089-46b6-99ac-4bd914e5ba0a

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
…null in no-null

Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/1d063584-7336-4ab7-b4d0-e2a46bebba49

Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this to Needs triage in Bug Triage Apr 8, 2026
@dmichon-msft dmichon-msft changed the title eslint-plugin: Refine null-prototype-dictionaries and no-null rules [eslint-plugin] Add null-prototype-dictionaries rule and refine no-null rule Apr 9, 2026
Copilot AI requested a review from dmichon-msft April 9, 2026 00:04
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