Skip to content

Commit

Permalink
chore: address some lint warnings (#6548)
Browse files Browse the repository at this point in the history
* chore: delete empty test files

* chore(test): suppress `@typescript-eslint/no-explicit-any` linter warnings in tests

* chore(test): address `@typescript-eslint/no-shadow` warnings in tests

* chore: address `@typescript-eslint/no-shadow` warnings

* chore: remove unnecessary `any` type in generic args

* chore: disable test-specific lint warnings

* chore: remove unnecessary `any`

* chore: replace type `{}` with `Record<string, unknown>` in action types
  • Loading branch information
vvagaytsev authored Oct 15, 2024
1 parent a2826a9 commit 5e1fa21
Show file tree
Hide file tree
Showing 71 changed files with 261 additions and 184 deletions.
24 changes: 12 additions & 12 deletions core/src/actions/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ export interface ActionDescription {

export abstract class BaseAction<
C extends BaseActionConfig = BaseActionConfig,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> {
// TODO: figure out why kind and type come out as any types on Action type
public readonly kind: C["kind"]
Expand Down Expand Up @@ -687,8 +687,8 @@ export abstract class BaseAction<

export abstract class RuntimeAction<
C extends BaseRuntimeActionConfig = BaseRuntimeActionConfig,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> extends BaseAction<C, StaticOutputs, RuntimeOutputs> {
/**
* Return the Build action specified on the `build` field if defined, otherwise null
Expand Down Expand Up @@ -717,8 +717,8 @@ export abstract class RuntimeAction<
// FIXME: Might be possible to remove in a later TypeScript version or through some hacks.
export interface ResolvedActionExtension<
C extends BaseRuntimeActionConfig = BaseRuntimeActionConfig,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> {
getDependencyResult(ref: ActionReference | Action): GraphResult | null

Expand All @@ -740,8 +740,8 @@ export interface ResolvedActionExtension<
// TODO: see if we can avoid the duplication here with ResolvedBuildAction
export abstract class ResolvedRuntimeAction<
Config extends BaseRuntimeActionConfig = BaseRuntimeActionConfig,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
>
extends RuntimeAction<Config, StaticOutputs, RuntimeOutputs>
implements ResolvedActionExtension<Config, StaticOutputs, RuntimeOutputs>
Expand Down Expand Up @@ -819,8 +819,8 @@ export abstract class ResolvedRuntimeAction<

export interface ExecutedActionExtension<
_ extends BaseRuntimeActionConfig = BaseRuntimeActionConfig,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> {
getOutput<K extends keyof (StaticOutputs & RuntimeOutputs)>(
key: K
Expand All @@ -832,8 +832,8 @@ export interface ExecutedActionExtension<
// TODO: see if we can avoid the duplication here with ResolvedBuildAction
export abstract class ExecutedRuntimeAction<
C extends BaseRuntimeActionConfig = BaseRuntimeActionConfig,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
>
extends ResolvedRuntimeAction<C, StaticOutputs, RuntimeOutputs>
implements ExecutedActionExtension<C, StaticOutputs, RuntimeOutputs>
Expand Down
12 changes: 6 additions & 6 deletions core/src/actions/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ export const buildActionConfigSchema = createSchema({

export class BuildAction<
C extends BuildActionConfig<any, any> = BuildActionConfig<any, any>,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> extends BaseAction<C, StaticOutputs, RuntimeOutputs> {
override kind = "Build" as const
// TODO:
Expand Down Expand Up @@ -194,8 +194,8 @@ export class BuildAction<
// TODO: see if we can avoid the duplication here with ResolvedRuntimeAction
export class ResolvedBuildAction<
C extends BuildActionConfig<any, any> = BuildActionConfig<any, any>,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
>
extends BuildAction<C, StaticOutputs, RuntimeOutputs>
implements ResolvedActionExtension<C, StaticOutputs, RuntimeOutputs>
Expand Down Expand Up @@ -251,8 +251,8 @@ export class ResolvedBuildAction<

export class ExecutedBuildAction<
C extends BuildActionConfig<any, any> = BuildActionConfig<any, any>,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
>
extends ResolvedBuildAction<C, StaticOutputs, RuntimeOutputs>
implements ExecutedActionExtension<C, StaticOutputs, RuntimeOutputs>
Expand Down
12 changes: 6 additions & 6 deletions core/src/actions/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const deployActionConfigSchema = memoize(() =>

export class DeployAction<
C extends DeployActionConfig = any,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> extends RuntimeAction<C, StaticOutputs, RuntimeOutputs> {
override kind = "Deploy" as const
override _staticOutputs: StaticOutputs = {} as StaticOutputs
Expand All @@ -49,8 +49,8 @@ export class DeployAction<

export class ResolvedDeployAction<
C extends DeployActionConfig = any,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> extends ResolvedRuntimeAction<C, StaticOutputs, RuntimeOutputs> {
override kind = "Deploy" as const

Expand All @@ -65,8 +65,8 @@ export class ResolvedDeployAction<

export class ExecutedDeployAction<
C extends DeployActionConfig = any,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> extends ExecutedRuntimeAction<C, StaticOutputs, RuntimeOutputs> {
override kind = "Deploy" as const

Expand Down
12 changes: 6 additions & 6 deletions core/src/actions/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const runActionConfigSchema = memoize(() =>

export class RunAction<
C extends RunActionConfig = RunActionConfig,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> extends RuntimeAction<C, StaticOutputs, RuntimeOutputs> {
override kind = "Run" as const
override _staticOutputs: StaticOutputs = {} as StaticOutputs
Expand All @@ -49,8 +49,8 @@ export class RunAction<

export class ResolvedRunAction<
C extends RunActionConfig = RunActionConfig,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> extends ResolvedRuntimeAction<C, StaticOutputs, RuntimeOutputs> {
override kind = "Run" as const

Expand All @@ -65,8 +65,8 @@ export class ResolvedRunAction<

export class ExecutedRunAction<
C extends RunActionConfig = RunActionConfig,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> extends ExecutedRuntimeAction<C, StaticOutputs, RuntimeOutputs> {
override kind = "Run" as const

Expand Down
12 changes: 6 additions & 6 deletions core/src/actions/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const testActionConfigSchema = memoize(() =>

export class TestAction<
C extends TestActionConfig = any,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> extends RuntimeAction<C, StaticOutputs, RuntimeOutputs> {
override kind = "Test" as const
override _staticOutputs: StaticOutputs = {} as StaticOutputs
Expand All @@ -49,8 +49,8 @@ export class TestAction<

export class ResolvedTestAction<
C extends TestActionConfig = any,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> extends ResolvedRuntimeAction<C, StaticOutputs, RuntimeOutputs> {
override kind = "Test" as const

Expand All @@ -65,8 +65,8 @@ export class ResolvedTestAction<

export class ExecutedTestAction<
C extends TestActionConfig = any,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> extends ExecutedRuntimeAction<C, StaticOutputs, RuntimeOutputs> {
override kind = "Test" as const

Expand Down
16 changes: 8 additions & 8 deletions core/src/actions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ export type ActionState = (typeof actionStateTypes)[number]

export interface ActionStatus<
T extends BaseAction = BaseAction,
D extends {} = any,
O extends {} = GetActionOutputType<T>,
D extends Record<string, unknown> = any,
O extends Record<string, unknown> = GetActionOutputType<T>,
> extends ValidResultType {
state: ActionState
detail: D | null
Expand Down Expand Up @@ -173,7 +173,7 @@ export interface ActionWrapperParams<C extends BaseActionConfig> {
variables: DeepPrimitiveMap
}

export interface ResolveActionParams<C extends BaseActionConfig, StaticOutputs extends {} = any> {
export interface ResolveActionParams<C extends BaseActionConfig, StaticOutputs extends Record<string, unknown> = any> {
resolvedGraph: ResolvedConfigGraph
dependencyResults: GraphResults
executedDependencies: ExecutedAction[]
Expand All @@ -186,21 +186,21 @@ export interface ResolveActionParams<C extends BaseActionConfig, StaticOutputs e

export type ResolvedActionWrapperParams<
C extends BaseActionConfig,
StaticOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
> = ActionWrapperParams<C> & ResolveActionParams<C, StaticOutputs>

export interface ExecuteActionParams<
C extends BaseActionConfig = BaseActionConfig,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> {
status: ActionStatus<BaseAction<C, StaticOutputs>, any, RuntimeOutputs>
}

export type ExecutedActionWrapperParams<
C extends BaseActionConfig,
StaticOutputs extends {} = any,
RuntimeOutputs extends {} = any,
StaticOutputs extends Record<string, unknown> = any,
RuntimeOutputs extends Record<string, unknown> = any,
> = ResolvedActionWrapperParams<C, StaticOutputs> & ExecuteActionParams<C, StaticOutputs, RuntimeOutputs>

export type GetActionOutputType<T> = T extends BaseAction<any, infer O> ? O : any
Expand Down
2 changes: 1 addition & 1 deletion core/src/cli/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export async function checkForUpdates(config: GlobalConfigStore, logger: Log) {
}

export interface PickCommandResult {
command: Command<{}, {}, any> | CommandGroup | undefined
command: Command<{}, {}> | CommandGroup | undefined
rest: string[]
matchedPath: undefined
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/commands/self-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ export class SelfUpdateCommand extends Command<SelfUpdateArgs, SelfUpdateOpts> {
const latestVersions = await getLatestVersions(10, log)

log.info(`Here are the latest available versions: ` + latestVersions.join(styles.highlight(", ")))
} catch (err) {
log.debug(`Could not retrieve the latest available versions, ${err}`)
} catch (e) {
log.debug(`Could not retrieve the latest available versions, ${e}`)
}

return {
Expand Down
1 change: 1 addition & 0 deletions core/src/config/zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { envVarRegex, identifierRegex, joiIdentifierDescription, userIdentifierR

// Add metadata support to schemas. See https://github.com/colinhacks/zod/issues/273#issuecomment-1434077058
declare module "zod" {
// eslint-disable-next-line @typescript-eslint/no-shadow
interface ZodType {
getMetadata(): Record<string, any>
setMetadata(meta: Record<string, any>): this
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugin/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export type ActionRuntimeRemotePlugin = {
}

// TODO-0.13.0: update this schema in 0.13.0
export interface RunResult {
export type RunResult = {
success: boolean
exitCode?: number
// FIXME: we should avoid native Date objects
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugin/handlers/Build/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface PublishActionParams<T extends BuildAction = BuildAction> extends Plugi
tagOverride?: string
}

export interface PublishActionDetail {
export type PublishActionDetail = {
published: boolean
message?: string
identifier?: string
Expand Down
6 changes: 3 additions & 3 deletions core/src/plugins/container/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ export interface ContainerDeploySpec extends ContainerCommonDeploySpec {

export type ContainerDeployActionConfig = DeployActionConfig<"container", ContainerDeploySpec>

export interface ContainerDeployOutputs {
export type ContainerDeployOutputs = {
deployedImageId: string
}

Expand Down Expand Up @@ -894,7 +894,7 @@ const artifactsSchema = memoize(() =>
.example([{ source: "/report/**/*" }])
)

export interface ContainerTestOutputs {
export type ContainerTestOutputs = {
log: string
}

Expand Down Expand Up @@ -956,7 +956,7 @@ export const containerRunActionSchema = createSchema({

// BUILD //

export interface ContainerBuildOutputs {
export type ContainerBuildOutputs = {
"localImageName": string
"localImageId": string
"deploymentImageName": string
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/kubernetes/kubernetes-type/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const kubernetesDeploySchema = () =>
})
.rename("devMode", "sync")

export interface KubernetesRunOutputs {
export type KubernetesRunOutputs = {
log: string
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/types/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const forwardablePortSchema = createSchema({
keys: forwardablePortKeys,
})

export interface ServiceStatus<D = any, O = PrimitiveMap> {
export type ServiceStatus<D = any, O = PrimitiveMap> = {
createdAt?: string
detail: D
mode?: ActionMode
Expand Down
2 changes: 1 addition & 1 deletion core/test/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"rules": {
// In tests we sometimes make these chains and while they are technically wrong
// they make the tests more readable.
"@typescript-eslint/no-non-null-asserted-optional-chain": "warn"
"@typescript-eslint/no-non-null-asserted-optional-chain": "off"
}
}
2 changes: 2 additions & 0 deletions core/test/integ/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export async function getArtifactRegistryClient() {
})
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isGCloudServiceError(err: any): err is GCloudServiceError {
if (err === undefined) {
return false
Expand All @@ -92,6 +93,7 @@ function isGCloudServiceError(err: any): err is GCloudServiceError {
interface GCloudServiceError {
code: number
details: string
// eslint-disable-next-line @typescript-eslint/no-explicit-any
metadata: any
}

Expand Down
Loading

0 comments on commit 5e1fa21

Please sign in to comment.