Members
members restricts the names a file declares on a type, interface or class, or the names it
calls. Use it for rules like “a repository port has no find* queries”.
"*.repository.ts": members: - message: 'Port method "{name}" is a query. Put it in queries/.' subject: members declares: [type, interface] in: "*RepositoryShape" match: "find*" matchNot: [findOneById, findManyByIds]type UserRepositoryShape = { readonly findOneById: (id: UserId) => Effect<UserRoot>; readonly findOneByEmail: (email: string) => Effect<UserRoot>; // reported};Fields
Section titled “Fields”members is a list. Each entry is its own rule, so a violation names the one that fired.
| Field | Meaning |
|---|---|
message |
Why. {name} is replaced with the offending name. Required. |
subject |
members (declared names) or calls (called names). Required. |
declares |
members only: declaration kinds to read, type, interface, class. Omit for all. |
in |
members only: globs against the declaration’s own name. |
match |
Names the rule is about. Omit for every name. |
matchNot |
Names removed from match. |
allow |
Names that are fine. Anything matched and not allowed is a violation. |
probe |
{ source, name }. See Authored probes. |
Written on a folder, a rule covers the subtree. declares: [class] reaches an adapter
class rather than the port type it implements.
subject: calls checks callee names, such as useState in useState(0) or useEffect in
React.useEffect(fn). It can’t tell React’s useState from a local function of the same name.
"*.view.tsx": members: - message: "`{name}` puts state in the View. It belongs in the ViewModel." subject: calls match: "use[A-Z]*" allow: [useAtomValue, useAtomSet, useId, useCallback]use[A-Z]* matches hooks but not user. See
Patterns.
Which declarations are read
Section titled “Which declarations are read”A rule reads the members written in a named type alias (including through intersections,
unions and parentheses), interface or class, under that declaration’s name:
type Base = { save(): void };type Port = Base & { findOneById(): void }; // Port.findOneById; save is read as Base.saveReferences aren’t followed, so in must name the declaration where the member is written.
Not read: anonymous classes and class expressions, constructors, private #names, index,
call and construct signatures, mapped types, and computed keys.
Authored probes
Section titled “Authored probes”An authored probe proves the rule reads your code’s shape: source is parsed at load and
the rule must report name, or the policy fails to load.
probe: source: "export type TodosRepositoryShape = { findOneByEmail(): void };" name: findOneByEmailSee Probes.