Skip to content

Commit

Permalink
chore: enforce eol-last rule (#32335)
Browse files Browse the repository at this point in the history
### Reason for this change

This rule was previously not enforced and implementation inconsistent.
Enforcing a new line at the end of the file makes it easier to append
files.

### Description of changes

**No code changes! Only formatting.** 💅🏻 

And a bit of config:

- Added a new eslint rule for `eol-last`
- Added a VSCode seting to automatically insert newlines
- Applied the rule to all non-compliant files

Best reviewed with whitespace changes ignored:
https://github.com/aws/aws-cdk/pull/32335/files?w=1

### Description of how you validated changes

No code changes, purely formatting.

### Checklist
- [x] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
  • Loading branch information
mrgrain authored Nov 29, 2024
1 parent dc7574a commit 81cde0e
Show file tree
Hide file tree
Showing 778 changed files with 840 additions and 839 deletions.
1 change: 1 addition & 0 deletions aws-cdk.code-workspace
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"folders": [{ "path": "." }],
"settings": {
"files.insertFinalNewline": true,
"jest.jestCommandLine": "node_modules/.bin/jest",
"jest.autoRun": "off",
"jest.virtualFolders": [
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/bin/test-root.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as path from 'path';
// eslint-disable-next-line no-console
console.log(path.resolve(__dirname, '..'));
console.log(path.resolve(__dirname, '..'));
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/eventually.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ const eventually = async <T>(call: () => Promise<T>, options?: EventuallyOptions
throw new Error('An unexpected error has occurred.');
};

export default eventually;
export default eventually;
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ export async function fetchPreviousVersion(token: string, options?: {
if (previousMVRelease) { return previousMVRelease; }

throw new Error(`Unable to find previous version given ${JSON.stringify(options)}`);
};
};
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export * from './with-aws';
export * from './with-cdk-app';
export * from './with-packages';
export * from './with-temporary-directory';
export * from './resources';
export * from './resources';
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export function chunk<A>(n: number, xs: A[]): A[][] {
}

return ret;
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/memoize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export function memoize0<A>(fn: () => Promise<A>): () => Promise<A> {
}
return promise;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ export class ReleasePackageSource implements IPackageSource {
return `${frameworkVersion}-alpha.0`;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ child.once('close', code => {
if (code) {
process.exitCode = code;
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export interface IPackageSource {
* Not all tests will respect this.
*/
requestedAlphaVersion(): string;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export function packageSourceInSubprocess(): IPackageSource {
case 'release': return new ReleasePackageSource();
default: throw new Error(`Unrecognized package source: ${process.env.PACKAGE_SOURCE}`);
}
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/staging/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ async function writeNpmLoginToken(usageDir: UsageDir, endpoint: string, token: s
return rcFile;
}

// Environment variable, .npmrc in same directory as package.json or in home dir
// Environment variable, .npmrc in same directory as package.json or in home dir
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/staging/nuget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ async function writeNuGetConfigFile(filename: string, login: LoginInformation) {
</configuration>`);
}

// NuGet.Config in current directory
// NuGet.Config in current directory
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ export async function parallelShell<A>(
}));

await q.onEmpty();
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/staging/pypi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ export async function uploadPythonPackages(packages: string[], login: LoginInfor
}
return 'fail';
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ export class UsageDir {
// eslint-disable-next-line no-console
console.log(` source ${this.directory}/activate.bash`);
}
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/with-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export function withPackages<A extends object>(block: (context: A & PackageConte
packages: packageSourceInSubprocess(),
});
};
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/lib/with-timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ export function withTimeout<A>(seconds: number, block: (x: A) => Promise<void>)
timeOut,
]);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ function* range(n: number) {
for (let i = 0; i < n; i++) {
yield i;
}
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk-testing/cli-integ/test/xpmutex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ function waitFor(pred: () => boolean): Promise<void> {
}
}, 5);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ import { integTest, withTemporaryDirectory, ShellHelper, withPackages } from '..
await shell.shell([`${venvPath}/bin/pytest`], { modEnv: venv });
await shell.shell(['cdk', 'synth'], { modEnv: venv });
})));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ async function removeDevDependencies(context: TemporaryDirectoryContext) {
const pj = JSON.parse(await fs.readFile(filename, { encoding: 'utf-8' }));
delete pj.devDependencies;
await fs.writeFile(filename, JSON.stringify(pj, undefined, 2), { encoding: 'utf-8' });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ integTest('typescript init lib', withTemporaryDirectory(withPackages(async (cont
await shell.shell(['npm', 'ls']); // this will fail if we have unmet peer dependencies
await shell.shell(['npm', 'run', 'build']);
await shell.shell(['npm', 'run', 'test']);
})));
})));
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ exports.handler = async (evt: any) => {
'Access-Control-Allow-Origin': '*',
},
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ new integ.IntegTest(app, 'LambdaTest', {
testCases: [stack],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ new integ.IntegTest(app, 'specrestapi-import-deployment-stage', {
testCases: [stack],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ const app = new cdk.App();
const testCase = new Test(app, 'test-apigateway-spec-restapi');
new IntegTest(app, 'apigateway-spec-restapi', {
testCases: [testCase],
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ new IntegTest(app, 'aws-apigateway-stepfunctions-startexecution-without-default-
],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ new IntegTest(app, 'aws-apigateway-stepfunctions-startexecution', {
],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export const handler = async (event: AWSLambda.APIGatewayProxyEventV2) => {
return {
isAuthorized: key === '123',
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export const handler = async () => {
'Content-Type': 'application/json',
},
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export const handler = async (event: any, _context: any = {}): Promise<any> => {
} else {
throw new Error('Unauthorized');
}
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ integ.assertions.httpApiCall(httpApi.apiEndpoint + '/thirdroute').expect(Expecte
integ.assertions.httpApiCall(httpApi.apiEndpoint + '/thirdroute/subroute').expect(ExpectedResult.objectLike({
body: 'success-hit-third-lambda',
status: 200,
}));
}));
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ function lambdaProxyEndpoint(s: Stack): HttpApi {
return new HttpApi(s, 'LambdaProxyApi', {
defaultIntegration: new HttpLambdaIntegration('DefaultIntegration', handler),
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ const endpoint = new HttpApi(stack, 'LambdaProxyApi', {

new CfnOutput(stack, 'Endpoint', {
value: endpoint.url!,
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ httpApi.addRoutes({
new integ.IntegTest(app, 'stepfunctions-integration-integ-test', {
testCases: [stack],
});
app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ new WebSocketStage(

new IntegTest(app, 'Integ', { testCases: [stack] });

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ new apigw.WebSocketApi(stack, 'MyWebsocketApi', {
apiKeySelectionExpression: apigw.WebSocketApiKeySelectionExpression.HEADER_X_API_KEY,
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Application.addAgentToEcs(taskDef);

new IntegTest(app, 'appconfig-application', {
testCases: [stack],
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,4 @@ function generateDummyRole(): iam.Role {
}));

return role;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ new IntegTest(app, 'api', {
testCases: [stack],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ new IntegTest(app, 'api', {
testCases: [stack],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ new IntegTest(app, 'api', {
testCases: [stack],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ new IntegTest(app, 'api', {
testCases: [stack],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ new IntegTest(app, 'api', {
testCases: [stack],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ new IntegTest(app, 'api', {
testCases: [stack],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ new IntegTest(app, 'api', {
testCases: [stack],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ new IntegTest(app, 'api', {
testCases: [stack],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ new IntegTest(app, 'api', {
testCases: [stack],
});

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ api.addEnvironmentVariable('EnvKey2', 'non-empty-2');

new IntegTest(app, 'IntegTestEnvironmentVariables', { testCases: [stack] });

app.synth();
app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ function asgHandler(_event: any, _context: any, callback: any) {
// eslint-disable-next-line quote-props
const result = { 'InstanceIDs': instanceIds };
return callback(undefined, result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ const stack = new TestStack(app, 'cdk-backup-selection');

new IntegTest(app, 'BackupSelectionTest', {
testCases: [stack],
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ new IntegTest(app, 'integ-test', {
testCases: [stack],
diffAssets: true,
enableLookups: true,
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ new cloudfront.Distribution(stack, 'Distribution', {

new IntegTest(app, 'rest-api-origin-custom-origin-path', {
testCases: [stack],
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ integ.assertions.awsApiCall('CloudFront', 'getDistributionConfig', {
]),
},
}),
}));
}));
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ const integ = new IntegTest(app, 's3-encrypted-bucket-origin-oac', {
const call = integ.assertions.httpApiCall(`https://${distribution.distributionDomainName}/test.html`);
call.expect(ExpectedResult.objectLike({
body: 'ecb13420-3826-4f11-a1b5-a4ac2f65c7c6',
}));
}));
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ integ.assertions.awsApiCall('CloudFront', 'getOriginAccessControlConfig', {
SigningBehavior: 'always',
OriginAccessControlOriginType: 's3',
},
}));
}));
Loading

0 comments on commit 81cde0e

Please sign in to comment.