Skip to content

Commit 549f912

Browse files
authored
chore: enforce import/order lint rule (#24254)
A recent change in a dependency we use to enforce the order of imports included a small update to sort import from `./` before `../`. We previously warned about violations of this rule, but did not enforce it. This frequently causes files unrelated to a change being updated. With this change I've updated all violations of this rule and the lint step is now free of warnings. Most of these updates where automated, by passing `--fix` to the lint command. For a few I had to manual resolve the problem. In a small number of cases the import order could not be changed without causing a test failure. For these I have just disabled the rule per line/block and did not investigate further. This changes also updates the `import/order` rule to `error` to avoid any future issues. Existing PRs will be fine, we enforce update from main anyway. In some circumstances where new imports are added this will cause conflicts and require manual intervention. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent f46214c commit 549f912

File tree

320 files changed

+468
-454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

320 files changed

+468
-454
lines changed

Diff for: packages/@aws-cdk-testing/cli-integ/lib/package-sources/release-source.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as os from 'os';
22
import * as path from 'path';
33
import * as fs from 'fs-extra';
4+
import { IPackageSourceSetup, IPackageSource } from './source';
45
import { copyDirectoryContents } from '../files';
56
import { shell, rimraf, addToShellPath } from '../shell';
6-
import { IPackageSourceSetup, IPackageSource } from './source';
77

88
export class ReleasePackageSourceSetup implements IPackageSourceSetup {
99
readonly name = 'release';

Diff for: packages/@aws-cdk-testing/cli-integ/lib/package-sources/repo-source.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as os from 'os';
22
import * as path from 'path';
33
import * as fs from 'fs-extra';
4+
import { IPackageSourceSetup, IPackageSource } from './source';
45
import { findUp } from '../files';
56
import { shell, addToShellPath } from '../shell';
6-
import { IPackageSourceSetup, IPackageSource } from './source';
77

88
export class RepoPackageSourceSetup implements IPackageSourceSetup {
99
readonly name = 'repo';

Diff for: packages/@aws-cdk-testing/cli-integ/lib/staging/maven.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable no-console */
22
import * as path from 'path';
3-
import { writeFile } from '../files';
4-
import { shell } from '../shell';
53
import { LoginInformation } from './codeartifact';
64
import { parallelShell } from './parallel-shell';
75
import { UsageDir } from './usage-dir';
6+
import { writeFile } from '../files';
7+
import { shell } from '../shell';
88

99
// Do not try to JIT the Maven binary
1010
const NO_JIT = '-XX:+TieredCompilation -XX:TieredStopAtLevel=1';

Diff for: packages/@aws-cdk-testing/cli-integ/lib/staging/nuget.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable no-console */
2-
import { writeFile } from '../files';
3-
import { shell } from '../shell';
42
import { LoginInformation } from './codeartifact';
53
import { parallelShell } from './parallel-shell';
64
import { UsageDir } from './usage-dir';
5+
import { writeFile } from '../files';
6+
import { shell } from '../shell';
77

88
export async function nugetLogin(login: LoginInformation, usageDir: UsageDir) {
99
// NuGet.Config MUST live in the current directory or in the home directory, and there is no environment

Diff for: packages/@aws-cdk-testing/cli-integ/lib/staging/pypi.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable no-console */
22
import * as path from 'path';
3-
import { writeFile } from '../files';
4-
import { shell } from '../shell';
53
import { LoginInformation } from './codeartifact';
64
import { parallelShell } from './parallel-shell';
75
import { UsageDir } from './usage-dir';
6+
import { writeFile } from '../files';
7+
import { shell } from '../shell';
88

99
export async function pypiLogin(login: LoginInformation, usageDir: UsageDir) {
1010
// Write pip config file and set environment var

Diff for: packages/@aws-cdk/assert-internal/lib/assertion.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable import/order */
2+
// @TODO: These tests fail if all imports are at the top
13
import { Inspector } from './inspector';
24

35
export abstract class Assertion<InspectorClass extends Inspector> {

Diff for: packages/@aws-cdk/assert-internal/lib/assertions/count-resources.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { isSuperObject } from './have-resource';
12
import { Assertion, JestFriendlyAssertion } from '../assertion';
23
import { StackInspector } from '../inspector';
3-
import { isSuperObject } from './have-resource';
44

55
/**
66
* An assertion to check whether a resource of a given type and with the given properties exists, disregarding properties

Diff for: packages/@aws-cdk/assert-internal/lib/assertions/have-resource.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { anything, deepObjectLike, match, objectLike } from './have-resource-matchers';
12
import { Assertion, JestFriendlyAssertion } from '../assertion';
23
import { StackInspector } from '../inspector';
3-
import { anything, deepObjectLike, match, objectLike } from './have-resource-matchers';
44

55
/**
66
* Magic value to signify that a certain key should be absent from the property bag.

Diff for: packages/@aws-cdk/assert-internal/test/have-resource.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { mkResource, mkStack } from './cloud-artifact';
12
import {
23
ABSENT,
34
arrayWith,
@@ -9,7 +10,6 @@ import {
910
anything,
1011
stringLike,
1112
} from '../lib/index';
12-
import { mkResource, mkStack } from './cloud-artifact';
1313

1414
test('support resource with no properties', () => {
1515
const synthStack = mkStack({

Diff for: packages/@aws-cdk/assert-internal/test/match-template.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { MatchStyle } from '../lib';
21
import { mkStack } from './cloud-artifact';
2+
import { MatchStyle } from '../lib';
33
import '../jest';
44

55
describe('matchTemplate', () => {

Diff for: packages/@aws-cdk/assertions/lib/private/resources.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Match, Matcher } from '..';
21
import { AbsentMatch } from './matchers/absent';
32
import { formatAllMismatches, matchSection, formatSectionMatchFailure } from './section';
43
import { Resource, Template } from './template';
4+
import { Match, Matcher } from '..';
55

66
export function findResources(template: Template, type: string, props: any = {}): { [key: string]: { [key: string]: any } } {
77
const section = template.Resources ?? {};

Diff for: packages/@aws-cdk/assertions/lib/private/section.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { sortKeyComparator } from './sorting';
12
import { Match } from '../match';
23
import { Matcher, MatchResult } from '../matcher';
3-
import { sortKeyComparator } from './sorting';
44

55
export type MatchSuccess = { match: true, matches: { [key: string]: any }, analyzed: { [key: string]: any }, analyzedCount: number };
66
export type MatchFailure = { match: false, closestResults: Record<string, MatchResult>, analyzed: { [key: string]: any }, analyzedCount: number };

Diff for: packages/@aws-cdk/aws-apigateway/lib/integrations/lambda.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as iam from '@aws-cdk/aws-iam';
22
import * as lambda from '@aws-cdk/aws-lambda';
33
import { Lazy, Names, Token } from '@aws-cdk/core';
4+
import { AwsIntegration } from './aws';
45
import { IntegrationConfig, IntegrationOptions } from '../integration';
56
import { Method } from '../method';
6-
import { AwsIntegration } from './aws';
77

88
export interface LambdaIntegrationOptions extends IntegrationOptions {
99
/**

Diff for: packages/@aws-cdk/aws-apigateway/lib/integrations/stepfunctions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import * as iam from '@aws-cdk/aws-iam';
44
import * as sfn from '@aws-cdk/aws-stepfunctions';
55
import { Token } from '@aws-cdk/core';
66
import { RequestContext } from '.';
7+
import { AwsIntegration } from './aws';
78
import { IntegrationConfig, IntegrationOptions, PassthroughBehavior } from '../integration';
89
import { Method } from '../method';
910
import { Model } from '../model';
10-
import { AwsIntegration } from './aws';
1111
/**
1212
* Options when configuring Step Functions synchronous integration with Rest API
1313
*/

Diff for: packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/jwt.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Template } from '@aws-cdk/assertions';
22
import { HttpApi } from '@aws-cdk/aws-apigatewayv2';
33
import { Stack } from '@aws-cdk/core';
4-
import { HttpJwtAuthorizer } from '../../lib';
54
import { DummyRouteIntegration } from './integration';
5+
import { HttpJwtAuthorizer } from '../../lib';
66

77
describe('HttpJwtAuthorizer', () => {
88
test('default', () => {

Diff for: packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/lambda.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Match, Template } from '@aws-cdk/assertions';
22
import { HttpApi } from '@aws-cdk/aws-apigatewayv2';
33
import { Code, Function, Runtime } from '@aws-cdk/aws-lambda';
44
import { Duration, Stack } from '@aws-cdk/core';
5-
import { HttpLambdaAuthorizer, HttpLambdaResponseType } from '../../lib';
65
import { DummyRouteIntegration } from './integration';
6+
import { HttpLambdaAuthorizer, HttpLambdaResponseType } from '../../lib';
77

88
describe('HttpLambdaAuthorizer', () => {
99

Diff for: packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/user-pool.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Template } from '@aws-cdk/assertions';
22
import { HttpApi } from '@aws-cdk/aws-apigatewayv2';
33
import { UserPool } from '@aws-cdk/aws-cognito';
44
import { Stack } from '@aws-cdk/core';
5-
import { HttpUserPoolAuthorizer } from '../../lib';
65
import { DummyRouteIntegration } from './integration';
6+
import { HttpUserPoolAuthorizer } from '../../lib';
77

88
describe('HttpUserPoolAuthorizer', () => {
99
test('default', () => {

Diff for: packages/@aws-cdk/aws-apigatewayv2/lib/common/api-mapping.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { IResource, Resource } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
3-
import { CfnApiMapping, CfnApiMappingProps } from '../apigatewayv2.generated';
43
import { IApi } from './api';
54
import { IDomainName } from './domain-name';
65
import { IStage } from './stage';
6+
import { CfnApiMapping, CfnApiMappingProps } from '../apigatewayv2.generated';
77

88
/**
99
* Represents an ApiGatewayV2 ApiMapping resource

Diff for: packages/@aws-cdk/aws-apigatewayv2/lib/http/api.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Metric, MetricOptions } from '@aws-cdk/aws-cloudwatch';
22
import { Duration } from '@aws-cdk/core';
33
import { Construct } from 'constructs';
4-
import { CfnApi, CfnApiProps } from '../apigatewayv2.generated';
5-
import { IApi } from '../common/api';
6-
import { ApiBase } from '../common/base';
7-
import { DomainMappingOptions } from '../common/stage';
84
import { IHttpRouteAuthorizer } from './authorizer';
95
import { HttpRouteIntegration } from './integration';
106
import { BatchHttpRouteOptions, HttpMethod, HttpRoute, HttpRouteKey } from './route';
117
import { IHttpStage, HttpStage, HttpStageOptions } from './stage';
128
import { VpcLink, VpcLinkProps } from './vpc-link';
9+
import { CfnApi, CfnApiProps } from '../apigatewayv2.generated';
10+
import { IApi } from '../common/api';
11+
import { ApiBase } from '../common/base';
12+
import { DomainMappingOptions } from '../common/stage';
1313

1414
/**
1515
* Represents an HTTP API

Diff for: packages/@aws-cdk/aws-apigatewayv2/lib/http/authorizer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Duration, Resource } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
3+
import { IHttpApi } from './api';
4+
import { IHttpRoute } from './route';
35
import { CfnAuthorizer } from '../apigatewayv2.generated';
46

57
import { IAuthorizer } from '../common';
6-
import { IHttpApi } from './api';
7-
import { IHttpRoute } from './route';
88

99
/**
1010
* Supported Authorizer types

Diff for: packages/@aws-cdk/aws-apigatewayv2/lib/http/integration.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { IRole } from '@aws-cdk/aws-iam';
22
import { Resource } from '@aws-cdk/core';
33
import { Construct } from 'constructs';
4+
import { IHttpApi } from './api';
5+
import { HttpMethod, IHttpRoute } from './route';
46
import { CfnIntegration } from '../apigatewayv2.generated';
57
import { IIntegration } from '../common';
68
import { ParameterMapping } from '../parameter-mapping';
7-
import { IHttpApi } from './api';
8-
import { HttpMethod, IHttpRoute } from './route';
99

1010
/**
1111
* Represents an Integration for an HTTP API.

Diff for: packages/@aws-cdk/aws-apigatewayv2/lib/http/route.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as iam from '@aws-cdk/aws-iam';
22
import { Resource } from '@aws-cdk/core';
33
import { Construct } from 'constructs';
4-
import { CfnRoute, CfnRouteProps } from '../apigatewayv2.generated';
5-
import { IRoute } from '../common';
64
import { IHttpApi } from './api';
75
import { HttpRouteAuthorizerConfig, IHttpRouteAuthorizer } from './authorizer';
86
import { HttpRouteIntegration } from './integration';
7+
import { CfnRoute, CfnRouteProps } from '../apigatewayv2.generated';
8+
import { IRoute } from '../common';
99

1010
/**
1111
* Represents a Route for an HTTP API.

Diff for: packages/@aws-cdk/aws-apigatewayv2/lib/http/stage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Metric, MetricOptions } from '@aws-cdk/aws-cloudwatch';
22
import { Stack } from '@aws-cdk/core';
33
import { Construct } from 'constructs';
4+
import { IHttpApi } from './api';
45
import { CfnStage } from '../apigatewayv2.generated';
56
import { StageOptions, IStage, StageAttributes } from '../common';
67
import { IApi } from '../common/api';
78
import { StageBase } from '../common/base';
8-
import { IHttpApi } from './api';
99

1010
const DEFAULT_STAGE_NAME = '$default';
1111

Diff for: packages/@aws-cdk/aws-apigatewayv2/lib/websocket/api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Grant, IGrantable } from '@aws-cdk/aws-iam';
22
import { Stack } from '@aws-cdk/core';
33
import { Construct } from 'constructs';
4+
import { WebSocketRoute, WebSocketRouteOptions } from './route';
45
import { CfnApi } from '../apigatewayv2.generated';
56
import { IApi } from '../common/api';
67
import { ApiBase } from '../common/base';
7-
import { WebSocketRoute, WebSocketRouteOptions } from './route';
88

99
/**
1010
* Represents a WebSocket API

Diff for: packages/@aws-cdk/aws-apigatewayv2/lib/websocket/authorizer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Resource } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
3+
import { IWebSocketApi } from './api';
4+
import { IWebSocketRoute } from './route';
35
import { CfnAuthorizer } from '../apigatewayv2.generated';
46

57
import { IAuthorizer } from '../common';
6-
import { IWebSocketApi } from './api';
7-
import { IWebSocketRoute } from './route';
88

99
/**
1010
* Supported Authorizer types

Diff for: packages/@aws-cdk/aws-apigatewayv2/lib/websocket/integration.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Resource } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
3-
import { CfnIntegration } from '../apigatewayv2.generated';
4-
import { IIntegration } from '../common';
53
import { IWebSocketApi } from './api';
64
import { IWebSocketRoute } from './route';
5+
import { CfnIntegration } from '../apigatewayv2.generated';
6+
import { IIntegration } from '../common';
77

88
/**
99
* Represents an Integration for an WebSocket API.

Diff for: packages/@aws-cdk/aws-apigatewayv2/lib/websocket/route.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Resource } from '@aws-cdk/core';
22
import { Construct } from 'constructs';
3-
import { CfnRoute, CfnRouteResponse } from '../apigatewayv2.generated';
4-
import { IRoute } from '../common';
53
import { IWebSocketApi } from './api';
64
import { IWebSocketRouteAuthorizer, WebSocketNoneAuthorizer } from './authorizer';
75
import { WebSocketRouteIntegration } from './integration';
6+
import { CfnRoute, CfnRouteResponse } from '../apigatewayv2.generated';
7+
import { IRoute } from '../common';
88

99
/**
1010
* Represents a Route for an WebSocket API.

Diff for: packages/@aws-cdk/aws-apigatewayv2/lib/websocket/stage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Grant, IGrantable } from '@aws-cdk/aws-iam';
22
import { Stack } from '@aws-cdk/core';
33
import { Construct } from 'constructs';
4+
import { IWebSocketApi } from './api';
45
import { CfnStage } from '../apigatewayv2.generated';
56
import { StageOptions, IApi, IStage, StageAttributes } from '../common';
67
import { StageBase } from '../common/base';
7-
import { IWebSocketApi } from './api';
88

99
/**
1010
* Represents the WebSocketStage

Diff for: packages/@aws-cdk/aws-applicationautoscaling/test/scalable-target.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Annotations, Match, Template } from '@aws-cdk/assertions';
22
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
33
import * as iam from '@aws-cdk/aws-iam';
44
import * as cdk from '@aws-cdk/core';
5-
import * as appscaling from '../lib';
65
import { createScalableTarget } from './util';
6+
import * as appscaling from '../lib';
77

88
describe('scalable target', () => {
99
test('test scalable target creation', () => {

Diff for: packages/@aws-cdk/aws-applicationautoscaling/test/step-scaling-policy.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { Template } from '@aws-cdk/assertions';
22
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
33
import * as cdk from '@aws-cdk/core';
44
import * as fc from 'fast-check';
5-
import * as appscaling from '../lib';
65
import { arbitrary_input_intervals, createScalableTarget } from './util';
6+
import * as appscaling from '../lib';
77

88
describe('step scaling policy', () => {
99
test('alarm thresholds are valid numbers', () => {

Diff for: packages/@aws-cdk/aws-applicationautoscaling/test/target-tracking.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Template } from '@aws-cdk/assertions';
22
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
33
import * as cdk from '@aws-cdk/core';
4-
import * as appscaling from '../lib';
54
import { createScalableTarget } from './util';
5+
import * as appscaling from '../lib';
66

77
describe('target tracking', () => {
88
test('test setup target tracking on predefined metric', () => {

Diff for: packages/@aws-cdk/aws-autoscaling-common/test/intervals.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as fc from 'fast-check';
2+
import { arbitrary_complete_intervals } from './util';
23
import * as appscaling from '../lib';
34
import { findAlarmThresholds, normalizeIntervals } from '../lib/interval-utils';
4-
import { arbitrary_complete_intervals } from './util';
55

66
describe('intervals', () => {
77
test('test bounds propagation', () => {

Diff for: packages/@aws-cdk/aws-cloudfront/test/distribution.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as iam from '@aws-cdk/aws-iam';
44
import * as lambda from '@aws-cdk/aws-lambda';
55
import * as s3 from '@aws-cdk/aws-s3';
66
import { App, Duration, Stack } from '@aws-cdk/core';
7+
import { defaultOrigin, defaultOriginGroup } from './test-origin';
78
import {
89
CfnDistribution,
910
Distribution,
@@ -18,7 +19,6 @@ import {
1819
SecurityPolicyProtocol,
1920
SSLMethod,
2021
} from '../lib';
21-
import { defaultOrigin, defaultOriginGroup } from './test-origin';
2222

2323
let app: App;
2424
let stack: Stack;

Diff for: packages/@aws-cdk/aws-cloudfront/test/integ.cloudfront-cross-region-cert.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import * as acm from '@aws-cdk/aws-certificatemanager';
22
import * as route53 from '@aws-cdk/aws-route53';
33
import * as cdk from '@aws-cdk/core';
44
import { IntegTest } from '@aws-cdk/integ-tests';
5-
import * as cloudfront from '../lib';
65
import { TestOrigin } from './test-origin';
6+
import * as cloudfront from '../lib';
77

88
const account = process.env.CDK_INTEG_ACCOUNT ?? process.env.CDK_DEFAULT_ACCOUNT;
99
const hostedZoneId = process.env.CDK_INTEG_HOSTED_ZONE_ID ?? process.env.HOSTED_ZONE_ID;

Diff for: packages/@aws-cdk/aws-cloudfront/test/integ.distribution-basic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as iam from '@aws-cdk/aws-iam';
22
import * as cdk from '@aws-cdk/core';
33
import { IntegTest } from '@aws-cdk/integ-tests';
4-
import * as cloudfront from '../lib';
54
import { TestOrigin } from './test-origin';
5+
import * as cloudfront from '../lib';
66

77
const app = new cdk.App();
88
const stack = new cdk.Stack(app, 'integ-distribution-basic');

0 commit comments

Comments
 (0)