Skip to content

Commit a80a0f5

Browse files
skulidropekclaude
andcommitted
fix(lint): apply unicorn v65 fixes to packages/lib/src (missed in previous commits)
Same changes as packages/app/src/lib — the lib package has its own copy that also gets linted: - prefer-includes: docker-git-config-search, state-repo/env, errors, gitlab-token-preflight - prefer-includes + find() pattern: core/auto-agent-flags (preserves AgentMode narrowing) - consistent-compound-words: isUnixUsername, sshUsernamePatternDescription, unixUsernamePattern in core/domain, core/command-builders-shared, shell/config Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 99b7eaf commit a80a0f5

8 files changed

Lines changed: 21 additions & 29 deletions

File tree

packages/lib/src/core/auto-agent-flags.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ export const resolveAutoAgentFlags = (
1313
if (requested === "auto") {
1414
return Either.right({ agentMode: undefined, agentAuto: true })
1515
}
16-
if (requested === "claude" || requested === "codex" || requested === "gemini" || requested === "grok") {
17-
return Either.right({ agentMode: requested, agentAuto: true })
16+
const agentModes: readonly AgentMode[] = ["claude", "codex", "gemini", "grok"]
17+
const matchedMode = agentModes.find((mode) => mode === requested)
18+
if (matchedMode !== undefined) {
19+
return Either.right({ agentMode: matchedMode, agentAuto: true })
1820
}
1921
return Either.left({
2022
_tag: "InvalidOption",

packages/lib/src/core/command-builders-shared.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import {
55
defaultTemplateConfig,
66
isDockerNetworkMode,
77
isGpuMode,
8-
isUnixUserName,
8+
isUnixUsername,
99
type ParseError,
10-
sshUserNamePatternDescription
10+
sshUsernamePatternDescription
1111
} from "./domain.js"
1212

1313
const parsePort = (value: string): Either.Either<number, ParseError> => {
@@ -105,11 +105,11 @@ export const parseSshUser = (
105105
option: "--ssh-user"
106106
})
107107
}
108-
if (!isUnixUserName(candidate)) {
108+
if (!isUnixUsername(candidate)) {
109109
return Either.left({
110110
_tag: "InvalidOption",
111111
option: "--ssh-user",
112-
reason: `expected Linux user name matching ${sshUserNamePatternDescription}`
112+
reason: `expected Linux user name matching ${sshUsernamePatternDescription}`
113113
})
114114
}
115115
return Either.right(candidate)

packages/lib/src/core/domain.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,20 @@ export type AgentMode = "claude" | "codex" | "gemini" | "grok"
6363
export type DockerNetworkMode = "shared" | "project"
6464
export type GpuMode = "none" | "all"
6565

66-
const unixUserNamePattern = /^[a-z_][a-z0-9_-]{0,31}$/
66+
const unixUsernamePattern = /^[a-z_][a-z0-9_-]{0,31}$/
6767

68-
export const sshUserNamePatternDescription = "^[a-z_][a-z0-9_-]{0,31}$"
68+
export const sshUsernamePatternDescription = "^[a-z_][a-z0-9_-]{0,31}$"
6969

7070
// CHANGE: define the SSH user name invariant in the core domain
7171
// WHY: generated Dockerfiles and entrypoints interpolate sshUser into shell-sensitive user commands
7272
// QUOTE(ТЗ): n/a
7373
// REF: PR-281-coderabbit-sshUser-validation
7474
// SOURCE: n/a
75-
// FORMAT THEOREM: forall u: isUnixUserName(u) -> not contains_shell_metacharacters(u)
75+
// FORMAT THEOREM: forall u: isUnixUsername(u) -> not contains_shell_metacharacters(u)
7676
// PURITY: CORE
7777
// INVARIANT: accepted user names contain only lowercase Linux account-name characters
7878
// COMPLEXITY: O(n)/O(1) where n = |value|
79-
export const isUnixUserName = (value: string): boolean => unixUserNamePattern.test(value)
79+
export const isUnixUsername = (value: string): boolean => unixUsernamePattern.test(value)
8080

8181
export interface TemplateConfig {
8282
readonly containerName: string

packages/lib/src/shell/config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { Effect, Either } from "effect"
88

99
import {
1010
defaultTemplateConfig,
11-
isUnixUserName,
11+
isUnixUsername,
1212
type ProjectConfig,
13-
sshUserNamePatternDescription
13+
sshUsernamePatternDescription
1414
} from "../core/domain.js"
1515
import { ConfigDecodeError, ConfigNotFoundError } from "./errors.js"
1616
import { resolveBaseDir } from "./paths.js"
@@ -101,12 +101,12 @@ const validateProjectConfig = (
101101
path: string,
102102
config: ProjectConfig
103103
): Effect.Effect<ProjectConfig, ConfigDecodeError> =>
104-
isUnixUserName(config.template.sshUser)
104+
isUnixUsername(config.template.sshUser)
105105
? Effect.succeed(config)
106106
: Effect.fail(
107107
new ConfigDecodeError({
108108
path,
109-
message: `template.sshUser must match ${sshUserNamePatternDescription}`
109+
message: `template.sshUser must match ${sshUsernamePatternDescription}`
110110
})
111111
)
112112

packages/lib/src/usecases/docker-git-config-search.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ type DockerGitConfigSearchState = {
1111
const isDockerGitConfig = (entry: string): boolean => entry.endsWith("docker-git.json")
1212

1313
const shouldSkipDir = (entry: string): boolean =>
14-
entry === ".git" ||
15-
entry === ".orch" ||
16-
entry === ".docker-git" ||
17-
entry === ".cache" ||
18-
entry === "node_modules" ||
19-
entry === "tmp"
14+
[".git", ".orch", ".docker-git", ".cache", "node_modules", "tmp"].includes(entry)
2015

2116
const isNotFoundStatError = (error: PlatformError): boolean =>
2217
error._tag === "SystemError" && error.reason === "NotFound"

packages/lib/src/usecases/errors.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ export type AppError =
4747
type NonParseError = Exclude<AppError, ParseError>
4848

4949
const isParseError = (error: AppError): error is ParseError =>
50-
error._tag === "UnknownCommand" ||
51-
error._tag === "UnknownOption" ||
52-
error._tag === "MissingOptionValue" ||
53-
error._tag === "MissingRequiredOption" ||
54-
error._tag === "InvalidOption" ||
55-
error._tag === "UnexpectedArgument"
50+
["UnknownCommand", "UnknownOption", "MissingOptionValue", "MissingRequiredOption", "InvalidOption", "UnexpectedArgument"].includes(error._tag)
5651

5752
const renderDockerAccessHeadline = (issue: DockerAccessError["issue"]): string =>
5853
issue === "PermissionDenied"

packages/lib/src/usecases/gitlab-token-preflight.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const mapGitlabRepoAccessStatus = (status: number): GitlabRepoAccessStatus => {
9393
if (status >= 200 && status < 300) {
9494
return "accessible"
9595
}
96-
if (status === 401 || status === 403 || status === 404) {
96+
if ([401, 403, 404].includes(status)) {
9797
return "notAccessible"
9898
}
9999
return "unknown"

packages/lib/src/usecases/state-repo/env.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export const isTruthyEnv = (value: string): boolean => {
22
const normalized = value.trim().toLowerCase()
3-
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on"
3+
return ["1", "true", "yes", "on"].includes(normalized)
44
}
55

66
export const isFalsyEnv = (value: string): boolean => {
77
const normalized = value.trim().toLowerCase()
8-
return normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off"
8+
return ["0", "false", "no", "off"].includes(normalized)
99
}
1010

1111
export const autoPullEnvKey = "DOCKER_GIT_STATE_AUTO_PULL"

0 commit comments

Comments
 (0)