Skip to content

Commit

Permalink
chore: enforce trailing comma style (#536)
Browse files Browse the repository at this point in the history
To help reduce line diffs in the future.

---

_By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license_
  • Loading branch information
echeung-amzn authored Jul 2, 2024
1 parent 8e1f062 commit cf26388
Show file tree
Hide file tree
Showing 166 changed files with 1,278 additions and 1,266 deletions.
1 change: 1 addition & 0 deletions .prettierrc.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
DependencyType,
ReleasableCommits,
} from "projen";
import { TrailingComma } from "projen/lib/javascript";

const CDK_VERSION = "2.112.0";

Expand Down Expand Up @@ -75,13 +76,18 @@ _By submitting this pull request, I confirm that my contribution is made under t

// Code linting config
prettier: true,
prettierOptions: {
settings: {
trailingComma: TrailingComma.ALL,
},
},
});

// Experimental modules
["@aws-cdk/aws-redshift-alpha"].forEach((dep) => {
project.deps.addDependency(
`${dep}@${CDK_VERSION}-alpha.0`,
DependencyType.DEVENV
DependencyType.DEVENV,
);
});
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60310
Expand Down
40 changes: 20 additions & 20 deletions lib/common/alarm/AlarmFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,26 +545,26 @@ export class AlarmFactory {
new AlarmNamingStrategy(
props.globalAlarmDefaults.alarmNamePrefix,
props.localAlarmNamePrefix,
props.globalAlarmDefaults.dedupeStringProcessor
props.globalAlarmDefaults.dedupeStringProcessor,
);
}

addAlarm(
metric: MetricWithAlarmSupport,
props: AddAlarmProps
props: AddAlarmProps,
): AlarmWithAnnotation {
// adjust the metric

const metricAdjuster = props.metricAdjuster
? CompositeMetricAdjuster.of(
props.metricAdjuster,
DefaultMetricAdjuster.INSTANCE
DefaultMetricAdjuster.INSTANCE,
)
: DefaultMetricAdjuster.INSTANCE;
const adjustedMetric = metricAdjuster.adjustMetric(
metric,
this.alarmScope,
props
props,
);

// metric that will be ultimately used to create the alarm
Expand All @@ -574,11 +574,11 @@ export class AlarmFactory {

const actionsEnabled = this.determineActionsEnabled(
props.actionsEnabled,
props.disambiguator
props.disambiguator,
);
const action = this.determineAction(
props.disambiguator,
props.actionOverride
props.actionOverride,
);
const alarmName = this.alarmNamingStrategy.getName(props);
const alarmNameSuffix = props.alarmNameSuffix;
Expand All @@ -587,7 +587,7 @@ export class AlarmFactory {
props.alarmDescription,
props.alarmDescriptionOverride,
props.runbookLink,
props.documentationLink
props.documentationLink,
);
const dedupeString = this.alarmNamingStrategy.getDedupeString(props);
const evaluateLowSampleCountPercentile =
Expand All @@ -604,7 +604,7 @@ export class AlarmFactory {

if (evaluationPeriods < datapointsToAlarm) {
throw new Error(
`evaluationPeriods must be greater than or equal to datapointsToAlarm for ${alarmName}`
`evaluationPeriods must be greater than or equal to datapointsToAlarm for ${alarmName}`,
);
}

Expand Down Expand Up @@ -639,7 +639,7 @@ export class AlarmFactory {
metricSampleCountId = props.sampleCountMetricId;
} else {
throw new Error(
"sampleCountMetricId must be specified when using minSampleCountToEvaluateDatapoint with a multiple-metric MathExpression"
"sampleCountMetricId must be specified when using minSampleCountToEvaluateDatapoint with a multiple-metric MathExpression",
);
}
} else {
Expand Down Expand Up @@ -704,18 +704,18 @@ export class AlarmFactory {
datapointsToAlarm: 1,
evaluationPeriods: 1,
actionsEnabled,
}
},
);
alarm = new CompositeAlarm(this.alarmScope, `${alarmName}-WithSamples`, {
actionsEnabled,
compositeAlarmName: `${alarmName}-WithSamples`,
alarmDescription: this.joinDescriptionParts(
alarmDescription,
`Min number of samples to alarm: ${props.minMetricSamplesToAlarm}`
`Min number of samples to alarm: ${props.minMetricSamplesToAlarm}`,
),
alarmRule: AlarmRule.allOf(
AlarmRule.fromAlarm(primaryAlarm, AlarmState.ALARM),
AlarmRule.not(AlarmRule.fromAlarm(noSamplesAlarm, AlarmState.ALARM))
AlarmRule.not(AlarmRule.fromAlarm(noSamplesAlarm, AlarmState.ALARM)),
),
});
}
Expand Down Expand Up @@ -769,7 +769,7 @@ export class AlarmFactory {
alarmRuleWhenAlarming: AlarmRule.fromAlarm(alarm, AlarmState.ALARM),
alarmRuleWhenInsufficientData: AlarmRule.fromAlarm(
alarm,
AlarmState.INSUFFICIENT_DATA
AlarmState.INSUFFICIENT_DATA,
),
dedupeString,
annotation,
Expand All @@ -779,11 +779,11 @@ export class AlarmFactory {

addCompositeAlarm(
alarms: AlarmWithAnnotation[],
props: AddCompositeAlarmProps
props: AddCompositeAlarmProps,
): CompositeAlarm {
const actionsEnabled = this.determineActionsEnabled(
props?.actionsEnabled,
props?.disambiguator
props?.disambiguator,
);
const action =
props.actionOverride ?? this.globalAlarmDefaults.action ?? noopAction();
Expand All @@ -793,7 +793,7 @@ export class AlarmFactory {
props?.alarmDescription ?? "Composite alarm",
props?.alarmDescriptionOverride,
props?.runbookLink,
props?.documentationLink
props?.documentationLink,
);
const dedupeString = this.alarmNamingStrategy.getDedupeString(namingInput);
const alarmRule = this.determineCompositeAlarmRule(alarms, props);
Expand Down Expand Up @@ -822,7 +822,7 @@ export class AlarmFactory {

protected determineCompositeAlarmRule(
alarms: AlarmWithAnnotation[],
props: AddCompositeAlarmProps
props: AddCompositeAlarmProps,
): IAlarmRule {
const alarmRules = alarms.map((alarm) => alarm.alarmRuleWhenAlarming);
const operator = props.compositeOperator ?? CompositeAlarmOperator.OR;
Expand All @@ -838,7 +838,7 @@ export class AlarmFactory {

protected determineActionsEnabled(
actionsEnabled?: boolean,
disambiguator?: string
disambiguator?: string,
): boolean {
if (actionsEnabled !== undefined) {
// alarm-specific override to true or false
Expand All @@ -857,7 +857,7 @@ export class AlarmFactory {

protected determineAction(
disambiguator?: string,
actionOverride?: IAlarmActionStrategy
actionOverride?: IAlarmActionStrategy,
): IAlarmActionStrategy {
// Explicit override
if (actionOverride) {
Expand Down Expand Up @@ -888,7 +888,7 @@ export class AlarmFactory {
alarmDescription: string,
alarmDescriptionOverride?: string,
runbookLinkOverride?: string,
documentationLinkOverride?: string
documentationLinkOverride?: string,
) {
const parts = [alarmDescriptionOverride ?? alarmDescription];

Expand Down
4 changes: 2 additions & 2 deletions lib/common/alarm/AlarmNamingStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class AlarmNamingStrategy implements IAlarmNamingStrategy {
constructor(
globalPrefix: string,
localPrefix: string,
dedupeStringStrategy?: IAlarmDedupeStringProcessor
dedupeStringStrategy?: IAlarmDedupeStringProcessor,
) {
this.globalPrefix = globalPrefix;
this.localPrefix = localPrefix;
Expand Down Expand Up @@ -71,7 +71,7 @@ export class AlarmNamingStrategy implements IAlarmNamingStrategy {
getDedupeString(props: AlarmNamingInput) {
if (props.dedupeStringOverride) {
return this.dedupeStringStrategy.processDedupeStringOverride(
props.dedupeStringOverride
props.dedupeStringOverride,
);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/common/alarm/IAlarmAnnotationStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export abstract class FillingAlarmAnnotationStrategy
}

protected abstract createAnnotationToFill(
props: AlarmAnnotationStrategyProps
props: AlarmAnnotationStrategyProps,
): HorizontalAnnotation;

protected getAlarmingRangeShade(
props: AlarmAnnotationStrategyProps
props: AlarmAnnotationStrategyProps,
): Shading | undefined {
switch (props.comparisonOperator) {
case ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD:
Expand All @@ -87,7 +87,7 @@ export abstract class FillingAlarmAnnotationStrategy
*/
export class DefaultAlarmAnnotationStrategy extends FillingAlarmAnnotationStrategy {
protected createAnnotationToFill(
props: AlarmAnnotationStrategyProps
props: AlarmAnnotationStrategyProps,
): HorizontalAnnotation {
return props.alarm.toAnnotation();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/common/alarm/action/MultipleAlarmActionStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function multipleActions(...actions: IAlarmActionStrategy[]) {
}

export function isMultipleAlarmActionStrategy(
obj?: any
obj?: any,
): obj is MultipleAlarmActionStrategy {
return !!(obj && obj instanceof MultipleAlarmActionStrategy);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/common/alarm/action/OpsItemAlarmActionStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function createLowSeverityOpsItem(category?: OpsItemCategory) {
*/
export function createOpsItem(
severity: OpsItemSeverity,
category?: OpsItemCategory
category?: OpsItemCategory,
) {
return new OpsItemAlarmActionStrategy(severity, category);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/common/alarm/action/SnsAlarmActionStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
export function notifySns(
onAlarmTopic: ITopic,
onOkTopic?: ITopic,
onInsufficientDataTopic?: ITopic
onInsufficientDataTopic?: ITopic,
): IAlarmActionStrategy {
return new SnsAlarmActionStrategy({
onAlarmTopic,
Expand Down Expand Up @@ -62,7 +62,7 @@ export class SnsAlarmActionStrategy implements IAlarmActionStrategy {

if (this.onInsufficientDataTopic) {
props.alarm.addInsufficientDataAction(
new SnsAction(this.onInsufficientDataTopic)
new SnsAction(this.onInsufficientDataTopic),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class CompositeMetricAdjuster implements IMetricAdjuster {
adjustMetric(
metric: MetricWithAlarmSupport,
alarmScope: Construct,
props: AddAlarmProps
props: AddAlarmProps,
): MetricWithAlarmSupport {
let adjustedMetric = metric;
for (const adjuster of this.adjusters) {
Expand Down
2 changes: 1 addition & 1 deletion lib/common/alarm/metric-adjuster/DefaultMetricAdjuster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class DefaultMetricAdjuster implements IMetricAdjuster {
adjustMetric(
metric: MetricWithAlarmSupport,
_: Construct,
props: AddAlarmProps
props: AddAlarmProps,
): MetricWithAlarmSupport {
let adjustedMetric = metric;
if (props.period) {
Expand Down
2 changes: 1 addition & 1 deletion lib/common/alarm/metric-adjuster/IMetricAdjuster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export interface IMetricAdjuster {
adjustMetric(
metric: MetricWithAlarmSupport,
alarmScope: Construct,
props: AddAlarmProps
props: AddAlarmProps,
): MetricWithAlarmSupport;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export class Route53HealthCheckMetricAdjuster implements IMetricAdjuster {
adjustMetric(
metric: MetricWithAlarmSupport,
alarmScope: Construct,
props: AddAlarmProps
props: AddAlarmProps,
): MetricWithAlarmSupport {
// Route53 health checks do not support composite alarms
if (props.minMetricSamplesToAlarm) {
throw new Error(
"Alarms with 'minMetricSamplesToAlarm' are not supported."
"Alarms with 'minMetricSamplesToAlarm' are not supported.",
);
}

Expand All @@ -57,7 +57,7 @@ export class Route53HealthCheckMetricAdjuster implements IMetricAdjuster {
// Route53 health checks only support a subset of statistics
if (!SUPPORTED_STATS.has(statistic)) {
throw new Error(
`Metrics with statistic '${statistic}' are not supported.`
`Metrics with statistic '${statistic}' are not supported.`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/common/metric/AnomalyDetectionMathExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class AnomalyDetectionMathExpression extends MathExpression {
}

cfnAlarm.addPropertyOverride(`Metrics.${index}.ReturnData`, returnData);
}
},
);

return alarm;
Expand Down
2 changes: 1 addition & 1 deletion lib/common/metric/BaseMetricFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface BaseMetricFactoryProps {
}

export abstract class BaseMetricFactory<
PropsType extends BaseMetricFactoryProps
PropsType extends BaseMetricFactoryProps,
> {
protected readonly metricFactory: MetricFactory;

Expand Down
Loading

0 comments on commit cf26388

Please sign in to comment.