Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enable unbound-method eslint rule #165

Merged
merged 4 commits into from
Feb 27, 2025
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
1 change: 1 addition & 0 deletions .eslintrc.json

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

1 change: 1 addition & 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.

1 change: 1 addition & 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.

1 change: 1 addition & 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.

1 change: 1 addition & 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.

1 change: 1 addition & 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.

5 changes: 3 additions & 2 deletions packages/@aws-cdk/cloud-assembly-schema/lib/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class Manifest {
* Ideally, we would start writing the `camelCased` and translate to how CloudFormation expects it when needed. But this requires nasty
* backwards-compatibility code and it just doesn't seem to be worth the effort.
*/
private static patchStackTagsOnRead(manifest: assembly.AssemblyManifest) {
private static patchStackTagsOnRead(this: void, manifest: assembly.AssemblyManifest) {
return Manifest.replaceStackTags(manifest, (tags) =>
tags.map((diskTag: any) => ({
key: diskTag.Key,
Expand All @@ -273,6 +273,7 @@ export class Manifest {
* should have dedicated properties preceding this (e.g `assumeRoleArn` and `assumeRoleExternalId`).
*/
private static validateAssumeRoleAdditionalOptions(
this: void,
instance: any,
key: string,
_schema: jsonschema.Schema,
Expand Down Expand Up @@ -301,7 +302,7 @@ export class Manifest {
*
* Translate stack tags metadata if it has the "right" casing.
*/
private static patchStackTagsOnWrite(manifest: assembly.AssemblyManifest) {
private static patchStackTagsOnWrite(this: void, manifest: assembly.AssemblyManifest) {
return Manifest.replaceStackTags(manifest, (tags) =>
tags.map(
(memTag) =>
Expand Down
1 change: 1 addition & 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.

1 change: 1 addition & 0 deletions packages/@aws-cdk/node-bundle/.eslintrc.json

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

1 change: 1 addition & 0 deletions packages/@aws-cdk/toolkit-lib/.eslintrc.json

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

2 changes: 1 addition & 1 deletion packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ export class Toolkit extends CloudAssemblySourceBuilder implements AsyncDisposab

const stacksAndTheirAssetManifests = stacks.flatMap((stack) => [
stack,
...stack.dependencies.filter(cxapi.AssetManifestArtifact.isAssetManifestArtifact),
...stack.dependencies.filter(x => cxapi.AssetManifestArtifact.isAssetManifestArtifact(x)),
]);
const workGraph = new WorkGraphBuilder({ ioHost, action }, prebuildAssets).build(stacksAndTheirAssetManifests);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-extraneous-dependencies,@typescript-eslint/unbound-method */
/**
* A Jest environment that buffers outputs to `console.log()` and only shows it for failing tests.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/user-input-gen/.eslintrc.json

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

1 change: 1 addition & 0 deletions packages/@aws-cdk/yarn-cling/.eslintrc.json

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

1 change: 1 addition & 0 deletions packages/aws-cdk/.eslintrc.json

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

6 changes: 3 additions & 3 deletions packages/aws-cdk/lib/api/work-graph/work-graph-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ export class WorkGraphBuilder {

function stacksFromAssets(artifacts: cxapi.CloudArtifact[]) {
const ret = new Map<cxapi.AssetManifestArtifact, cxapi.CloudFormationStackArtifact>();
for (const stack of artifacts.filter(cxapi.CloudFormationStackArtifact.isCloudFormationStackArtifact)) {
const assetArtifacts = stack.dependencies.filter(cxapi.AssetManifestArtifact.isAssetManifestArtifact);
for (const stack of artifacts.filter(x => cxapi.CloudFormationStackArtifact.isCloudFormationStackArtifact(x))) {
const assetArtifacts = stack.dependencies.filter((x) => cxapi.AssetManifestArtifact.isAssetManifestArtifact(x));
for (const art of assetArtifacts) {
ret.set(art, stack);
}
Expand All @@ -188,5 +188,5 @@ function stacksFromAssets(artifacts: cxapi.CloudArtifact[]) {
}

function onlyStacks(artifacts: cxapi.CloudArtifact[]) {
return artifacts.filter(cxapi.CloudFormationStackArtifact.isCloudFormationStackArtifact);
return artifacts.filter(x => cxapi.CloudFormationStackArtifact.isCloudFormationStackArtifact(x));
}
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/cli/cdk-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ export class CdkToolkit {

const stacksAndTheirAssetManifests = stacks.flatMap((stack) => [
stack,
...stack.dependencies.filter(cxapi.AssetManifestArtifact.isAssetManifestArtifact),
...stack.dependencies.filter(x => cxapi.AssetManifestArtifact.isAssetManifestArtifact(x)),
]);
const workGraph = new WorkGraphBuilder({
ioHost: this.ioHost,
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/test/jest-bufferedconsole.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-extraneous-dependencies,@typescript-eslint/unbound-method */
/**
* A Jest environment that buffers outputs to `console.log()` and only shows it for failing tests.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/cdk-assets/.eslintrc.json

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

1 change: 1 addition & 0 deletions packages/cdk/.eslintrc.json

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

3 changes: 3 additions & 0 deletions projenrc/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ export const ESLINT_RULES = {
],
}],

// Unbound methods are a JavaScript footgun
'@typescript-eslint/unbound-method': 'error',

// Overrides for plugin:jest/recommended
'jest/expect-expect': 'off',
'jest/no-conditional-expect': 'off',
Expand Down