Skip to content

eslint-plugin: helperArgIndex option for custom write helpers with non-standard argument positions #122

@sdougbrown

Description

@sdougbrown

Context

no-write-owned-fields checks write candidate arguments by looking at a hardcoded position per helper name (getCandidateIndex). The six built-in helpers from @umpire/write and @umpire/drizzle are covered. Custom helpers added via writeHelpers fall back to index 1 (checkCreate-style).

This silently fails for Drizzle-style wrappers where the candidate is at index 2 or 3:

// checkPrismaCreate(model, ump, data, options?) — candidate at index 2
'@umpire/no-write-owned-fields': ['warn', {
  writeHelpers: ['checkPrismaCreate', 'checkPrismaModelCreate'],
}]
// ↑ silently checks index 1 (the ump instance), never fires

Proposed API

A helperArgIndex map that supplements (not replaces) the hardcoded table:

'@umpire/no-write-owned-fields': ['warn', {
  writeHelpers: ['checkPrismaCreate', 'checkPrismaModelCreate'],
  helperArgIndex: { checkPrismaCreate: 2, checkPrismaModelCreate: 2 },
}]

The built-in helpers keep their hardcoded positions. The map is only consulted for helpers not already in the hardcoded table.

When to do this

Hold until a second first-party adapter (@umpire/prisma or similar) exists — that gives a real call shape to validate the API against and ensures the argument convention in CONTRIBUTING.md is actually being followed. The current documentation note in the schema description is the interim mitigation.

Related

  • drizzleHelperKind option for model-style custom drizzle helpers (separate issue)
  • CONTRIBUTING.md §Database Adapters — documents the argument convention new adapters must follow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions