Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintrc.json

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

4 changes: 4 additions & 0 deletions packages/@aws-cdk/cdk-build-tools/.eslintrc.json

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

4 changes: 3 additions & 1 deletion packages/@aws-cdk/cdk-build-tools/lib/bockfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ namespace bockfs {
* Turn a fake path into a real path
*/
export function path(fakePath: string) {
if (fakePath.startsWith('/')) { fakePath = fakePath.slice(1); } // Force path to be non-absolute
if (fakePath.startsWith('/')) {
fakePath = fakePath.slice(1);
} // Force path to be non-absolute
return path_.join(bockFsRoot, fakePath);
}

Expand Down
16 changes: 12 additions & 4 deletions packages/@aws-cdk/cdk-build-tools/lib/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,19 @@ export async function makeExecutable(javascriptFile: string): Promise<void> {
*/
async function makeShellScriptExecutable(script: string) {
try {
if (await canExecute(script)) { return; }
if (!await isShellScript(script)) { return; }
if (await canExecute(script)) {
return;
}
if (!await isShellScript(script)) {
return;
}
await util.promisify(fs.chmod)(script, 0o755);
} catch (e: any) {
// If it happens that this file doesn't exist, that's fine. It's
// probably a file that can be found on the $PATH.
if (e.code === 'ENOENT') { return; }
if (e.code === 'ENOENT') {
return;
}
throw e;
}
}
Expand All @@ -161,7 +167,9 @@ async function canExecute(fileName: string): Promise<boolean> {
await util.promisify(fs.access)(fileName, fs.constants.X_OK);
return true;
} catch (e: any) {
if (e.code === 'EACCES') { return false; }
if (e.code === 'EACCES') {
return false;
}
throw e;
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/cdk-build-tools/lib/package-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export async function listFiles(dirName: string, predicate: (x: File) => boolean

return ret;
} catch (e: any) {
if (e.code === 'ENOENT') { return []; }
if (e.code === 'ENOENT') {
return [];
}
throw e;
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/cdk-build-tools/lib/timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export class Timer {
}

public humanTime() {
if (!this.timeMs) { return '???'; }
if (!this.timeMs) {
return '???';
}

const parts = [];

Expand Down
4 changes: 4 additions & 0 deletions packages/@aws-cdk/cdk-cli-wrapper/.eslintrc.json

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

8 changes: 6 additions & 2 deletions packages/@aws-cdk/cdk-cli-wrapper/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export function exec(commandLine: string[], options: { cwd?: string; json?: bool
cwd: options.cwd,
});

if (proc.error) { throw proc.error; }
if (proc.error) {
throw proc.error;
}
if (proc.status !== 0) {
if (process.stderr) { // will be 'null' in verbose mode
process.stderr.write(proc.stderr);
Expand All @@ -26,7 +28,9 @@ export function exec(commandLine: string[], options: { cwd?: string; json?: bool

try {
if (options.json) {
if (output.length === 0) { return {}; }
if (output.length === 0) {
return {};
}

return JSON.parse(output);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/cdk-cli-wrapper/test/cdk-wrapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ beforeEach(() => {
});
spawnMock = jest.spyOn(child_process, 'spawn').mockImplementation(jest.fn(() => {
return {
on: jest.fn(() => {}),
on: jest.fn(() => {
}),
} as unknown as child_process.ChildProcess;
}));
});
Expand Down
4 changes: 4 additions & 0 deletions packages/@aws-cdk/cli-lib-alpha/.eslintrc.json

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

3 changes: 2 additions & 1 deletion packages/@aws-cdk/cli-lib-alpha/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export class AwsCdkCli implements IAwsCdkCli {

private constructor(
private readonly cli: (args: string[]) => Promise<number | void>,
) {}
) {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ewwwwwww

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We looked at this and we cannot enforce this consistently because we want to allow empty statements with comments inside of them.


/**
* Execute the CLI with a list of arguments
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/cli-lib-alpha/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ jest.mock('../../../aws-cdk/lib', () => {
exec: jest.fn(original.exec),
};
});
const stdoutMock = jest.spyOn(process.stdout, 'write').mockImplementation(() => { return true; });
const stdoutMock = jest.spyOn(process.stdout, 'write').mockImplementation(() => {
return true;
});

beforeEach(() => {
stdoutMock.mockClear();
Expand Down
4 changes: 4 additions & 0 deletions packages/@aws-cdk/cli-plugin-contract/.eslintrc.json

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

4 changes: 4 additions & 0 deletions packages/@aws-cdk/cloud-assembly-schema/.eslintrc.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ export interface AmiContextQuery extends ContextLookupRoleOptions {
/**
* Query to availability zone context provider
*/
export interface AvailabilityZonesContextQuery extends ContextLookupRoleOptions {}
export interface AvailabilityZonesContextQuery extends ContextLookupRoleOptions {
}

/**
* Query to hosted zone context provider
Expand Down Expand Up @@ -256,7 +257,8 @@ export interface LoadBalancerFilter extends ContextLookupRoleOptions {
/**
* Query input for looking up a load balancer
*/
export interface LoadBalancerContextQuery extends LoadBalancerFilter {}
export interface LoadBalancerContextQuery extends LoadBalancerFilter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ewwww again

}

/**
* The protocol for connections from clients to the load balancer
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/cloud-assembly-schema/lib/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ export class Manifest {
});
}

private constructor() {}
private constructor() {
}
}

type Endofunctor<A> = (x: A) => A;
Expand Down
4 changes: 4 additions & 0 deletions packages/@aws-cdk/cloudformation-diff/.eslintrc.json

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

4 changes: 3 additions & 1 deletion packages/@aws-cdk/cloudformation-diff/lib/diff-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ function propagateReplacedReferences(template: object, logicalId: string): boole

function replaceReference(obj: any) {
const keys = Object.keys(obj);
if (keys.length !== 1) { return false; }
if (keys.length !== 1) {
return false;
}
const key = keys[0];

if (key === 'Ref') {
Expand Down
19 changes: 14 additions & 5 deletions packages/@aws-cdk/cloudformation-diff/lib/diff/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ export class TemplateDiff implements ITemplateDiff {
const ret = new Array<ResourceChange>();

for (const [resourceLogicalId, resourceChange] of Object.entries(this.resources.changes)) {
if (!resourceChange) { continue; }
if (!resourceChange) {
continue;
}

const commonProps = {
oldProperties: resourceChange.oldProperties,
Expand Down Expand Up @@ -370,7 +372,8 @@ export class PropertyDifference<ValueType> extends Difference<ValueType> {
}

export class DifferenceCollection<V, T extends IDifference<V>> {
constructor(private readonly diffs: { [logicalId: string]: T }) {}
constructor(private readonly diffs: { [logicalId: string]: T }) {
}

public get changes(): { [logicalId: string]: T } {
return onlyChanges(this.diffs);
Expand All @@ -382,7 +385,9 @@ export class DifferenceCollection<V, T extends IDifference<V>> {

public get(logicalId: string): T {
const ret = this.diffs[logicalId];
if (!ret) { throw new Error(`No object with logical ID '${logicalId}'`); }
if (!ret) {
throw new Error(`No object with logical ID '${logicalId}'`);
}
return ret;
}

Expand Down Expand Up @@ -518,7 +523,9 @@ export enum ResourceImpact {
* able to determine some properties impact).
*/
function worstImpact(one: ResourceImpact, two?: ResourceImpact): ResourceImpact {
if (!two) { return one; }
if (!two) {
return one;
}
const badness = {
[ResourceImpact.NO_CHANGE]: 0,
[ResourceImpact.WILL_IMPORT]: 0,
Expand Down Expand Up @@ -685,7 +692,9 @@ export class ResourceDifference implements IDifference<Resource> {
}
// Check the Type first
if (this.resourceTypes.oldType !== this.resourceTypes.newType) {
if (this.resourceTypes.oldType === undefined) { return ResourceImpact.WILL_CREATE; }
if (this.resourceTypes.oldType === undefined) {
return ResourceImpact.WILL_CREATE;
}
if (this.resourceTypes.newType === undefined) {
return this.oldValue!.DeletionPolicy === 'Retain'
? ResourceImpact.WILL_ORPHAN
Expand Down
40 changes: 30 additions & 10 deletions packages/@aws-cdk/cloudformation-diff/lib/diff/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import { Resource, SpecDatabase } from '@aws-cdk/service-spec-types';
* @returns +true+ if both +lvalue+ and +rvalue+ are equivalent to each other.
*/
export function deepEqual(lvalue: any, rvalue: any): boolean {
if (lvalue === rvalue) { return true; }
if (lvalue === rvalue) {
return true;
}
// CloudFormation allows passing strings into boolean-typed fields
if (((typeof lvalue === 'string' && typeof rvalue === 'boolean') ||
(typeof lvalue === 'boolean' && typeof rvalue === 'string')) &&
Expand All @@ -30,12 +32,20 @@ export function deepEqual(lvalue: any, rvalue: any): boolean {
safeParseFloat(lvalue) === safeParseFloat(rvalue)) {
return true;
}
if (typeof lvalue !== typeof rvalue) { return false; }
if (Array.isArray(lvalue) !== Array.isArray(rvalue)) { return false; }
if (typeof lvalue !== typeof rvalue) {
return false;
}
if (Array.isArray(lvalue) !== Array.isArray(rvalue)) {
return false;
}
if (Array.isArray(lvalue) /* && Array.isArray(rvalue) */) {
if (lvalue.length !== rvalue.length) { return false; }
if (lvalue.length !== rvalue.length) {
return false;
}
for (let i = 0 ; i < lvalue.length ; i++) {
if (!deepEqual(lvalue[i], rvalue[i])) { return false; }
if (!deepEqual(lvalue[i], rvalue[i])) {
return false;
}
}
return true;
}
Expand All @@ -45,15 +55,23 @@ export function deepEqual(lvalue: any, rvalue: any): boolean {
return false;
}
const keys = Object.keys(lvalue);
if (keys.length !== Object.keys(rvalue).length) { return false; }
if (keys.length !== Object.keys(rvalue).length) {
return false;
}
for (const key of keys) {
if (!rvalue.hasOwnProperty(key)) { return false; }
if (!rvalue.hasOwnProperty(key)) {
return false;
}
if (key === 'DependsOn') {
if (!dependsOnEqual(lvalue[key], rvalue[key])) { return false; }
if (!dependsOnEqual(lvalue[key], rvalue[key])) {
return false;
}
// check differences other than `DependsOn`
continue;
}
if (!deepEqual(lvalue[key], rvalue[key])) { return false; }
if (!deepEqual(lvalue[key], rvalue[key])) {
return false;
}
}
return true;
}
Expand Down Expand Up @@ -84,7 +102,9 @@ function dependsOnEqual(lvalue: any, rvalue: any): boolean {

// allows arrays passed to DependsOn to be equivalent irrespective of element order
if (Array.isArray(lvalue) && Array.isArray(rvalue)) {
if (lvalue.length !== rvalue.length) { return false; }
if (lvalue.length !== rvalue.length) {
return false;
}
for (let i = 0 ; i < lvalue.length ; i++) {
for (let j = 0 ; j < lvalue.length ; j++) {
if ((!deepEqual(lvalue[i], rvalue[j])) && (j === lvalue.length - 1)) {
Expand Down
8 changes: 6 additions & 2 deletions packages/@aws-cdk/cloudformation-diff/lib/format-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ function lineBetween(rowA: string[], rowB: string[]) {
}

function buildColumnConfig(widths: number[] | undefined): { [index: number]: table.ColumnUserConfig } | undefined {
if (widths === undefined) { return undefined; }
if (widths === undefined) {
return undefined;
}

const ret: { [index: number]: table.ColumnUserConfig } = {};
widths.forEach((width, i) => {
Expand Down Expand Up @@ -60,7 +62,9 @@ function calculateColumnWidths(rows: string[][], terminalWidth: number): number[
const contentWidth = terminalWidth - 2 - columns.length * 3;

// If we don't exceed the terminal width, do nothing
if (sum(columns) <= contentWidth) { return columns; }
if (sum(columns) <= contentWidth) {
return columns;
}

const fairShare = Math.min(contentWidth / columns.length);
const smallColumns = columns.filter(w => w < fairShare);
Expand Down
Loading