From 59290f6110afe2632af250ccd055b6fb872111e5 Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Fri, 20 Dec 2024 09:09:23 -0800 Subject: [PATCH] refactor(pass-style): Avoid name convention conflict (#2666) closes: #XXXX https://github.com/Agoric/agoric-sdk/pull/10751 ## Description We generally use names of the form `^([A-Z]\w*)I$`, i.e., identifiers beginning with a capital letter and ending with a lone capital "I", for interface guards. However there were some uses of the same form of name for typescript interfaces. Because interfaces and interface guards are adjacent concepts, this could be confusing. This PR fixes this for endo. The companion https://github.com/Agoric/agoric-sdk/pull/10751 fixes it for agoric-sdk. Because the endo names in question were not exported, there is clearly no dependency between these two PRs. ### Security Considerations Consistent naming conventions makes code more reviewable, which is good for security. ### Scaling Considerations none ### Documentation Considerations Consistent naming conventions helps documentation and its readers. ### Testing Considerations none ### Compatibility Considerations Because these names are not exported, and are only type names erased prior to execution, none. ### Upgrade Considerations Because these are only type names that are erased prior to execution, none. --- packages/eslint-plugin/lib/configs/internal.js | 11 +++++++++++ packages/pass-style/src/types.d.ts | 12 ++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/eslint-plugin/lib/configs/internal.js b/packages/eslint-plugin/lib/configs/internal.js index 17cc652059..79ba090b5a 100644 --- a/packages/eslint-plugin/lib/configs/internal.js +++ b/packages/eslint-plugin/lib/configs/internal.js @@ -49,6 +49,17 @@ module.exports = { // RESM does not support ?? nor ?. operators, so we must avoid them expressly. '@endo/no-optional-chaining': 'error', '@endo/no-nullish-coalescing': 'error', + '@typescript-eslint/naming-convention': [ + 'error', + { + selector: 'interface', + format: ['PascalCase'], + custom: { + regex: '.*I$', + match: false, + }, + }, + ], }, overrides: [ { diff --git a/packages/pass-style/src/types.d.ts b/packages/pass-style/src/types.d.ts index fdcd419a74..346eac0ab3 100644 --- a/packages/pass-style/src/types.d.ts +++ b/packages/pass-style/src/types.d.ts @@ -85,14 +85,14 @@ export type Passable< > = void | Primitive | Container | PC | E; export type Container = - | CopyArrayI - | CopyRecordI - | CopyTaggedI; -interface CopyArrayI + | CopyArrayInterface + | CopyRecordInterface + | CopyTaggedInterface; +interface CopyArrayInterface extends CopyArray> {} -interface CopyRecordI +interface CopyRecordInterface extends CopyRecord> {} -interface CopyTaggedI +interface CopyTaggedInterface extends CopyTagged> {} export type PassStyleOf = {