Skip to content

Commit 47a4e1d

Browse files
authored
chore: enforce consistent-type-imports eslint rule on modern packages (#204)
I would have liked to use the `verbatimModuleSyntax` tsconfig, but that's only available for ESM projects. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
1 parent e3b0856 commit 47a4e1d

Some content is hidden

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

47 files changed

+105
-154
lines changed

.eslintrc.json

+1-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,11 @@ tmpToolkitHelpers.package.addField('exports', {
720720
'./util': './lib/util/index.js',
721721
});
722722

723+
tmpToolkitHelpers.eslint?.addRules({
724+
'@cdklabs/no-throw-default-error': 'error',
725+
'@typescript-eslint/consistent-type-imports': 'error',
726+
});
727+
723728
//////////////////////////////////////////////////////////////////////
724729

725730
let CLI_SDK_VERSION: '2' | '3' = ('3' as any);
@@ -1219,7 +1224,8 @@ new S3DocsPublishing(toolkitLib, {
12191224

12201225
// Eslint rules
12211226
toolkitLib.eslint?.addRules({
1222-
'@cdklabs/no-throw-default-error': ['error'],
1227+
'@cdklabs/no-throw-default-error': 'error',
1228+
'@typescript-eslint/consistent-type-imports': 'error',
12231229
'import/no-restricted-paths': ['error', {
12241230
zones: [{
12251231
target: './',

packages/@aws-cdk/cdk-build-tools/.eslintrc.json

+1-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/cdk-cli-wrapper/.eslintrc.json

+1-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/cli-lib-alpha/.eslintrc.json

+1-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/cli-plugin-contract/.eslintrc.json

+1-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/cloud-assembly-schema/.eslintrc.json

+1-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/cloudformation-diff/.eslintrc.json

+1-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/node-bundle/.eslintrc.json

+1-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/tmp-toolkit-helpers/.eslintrc.json

+4-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/io-host.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IoMessage, IoRequest } from './io-message';
1+
import type { IoMessage, IoRequest } from './io-message';
22

33
export interface IIoHost {
44
/**

packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/io-message.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ToolkitAction } from './toolkit-action';
1+
import type { ToolkitAction } from './toolkit-action';
22

33
/**
44
* The reporting level of the message.

packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/action-aware.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { IIoHost } from '../io-host';
2-
import { IoMessage, IoRequest } from '../io-message';
3-
import { ToolkitAction } from '../toolkit-action';
1+
import type { IIoHost } from '../io-host';
2+
import type { IoMessage, IoRequest } from '../io-message';
3+
import type { ToolkitAction } from '../toolkit-action';
44

55
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
66
export type SimplifiedMessage<T> = Pick<IoMessage<T>, 'level' | 'code' | 'message' | 'data'>;

packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/message-maker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { IoMessageCode, IoMessageLevel } from '../io-message';
2-
import { ActionLessMessage, ActionLessRequest } from './action-aware';
1+
import type { IoMessageCode, IoMessageLevel } from '../io-message';
2+
import type { ActionLessMessage, ActionLessRequest } from './action-aware';
33

44
/**
55
* Information for each IO Message Code.

packages/@aws-cdk/tmp-toolkit-helpers/src/util/objects.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { isArray, isObject, Obj } from './types';
1+
import type { Obj } from './types';
2+
import { isArray, isObject } from './types';
23
import { ToolkitError } from '../api/toolkit-error';
34

45
/**

packages/@aws-cdk/tmp-toolkit-helpers/src/util/yaml-cfn.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as yaml from 'yaml';
2-
import * as yaml_cst from 'yaml/parse-cst';
2+
import type * as yaml_cst from 'yaml/parse-cst';
33
import * as yaml_types from 'yaml/types';
44

55
/**

packages/@aws-cdk/toolkit-lib/.eslintrc.json

+3-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/toolkit-lib/lib/actions/bootstrap/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as cxapi from '@aws-cdk/cx-api';
1+
import type * as cxapi from '@aws-cdk/cx-api';
22
import { environmentsFromDescriptors } from './private';
33
import type { Tag } from '../../api/aws-cdk';
44
import type { ICloudAssemblySource } from '../../api/cloud-assembly';

packages/@aws-cdk/toolkit-lib/lib/actions/bootstrap/private/helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as cxapi from '@aws-cdk/cx-api';
1+
import type * as cxapi from '@aws-cdk/cx-api';
22
import { ToolkitError } from '../../../api/shared-public';
33

44
/**

packages/@aws-cdk/toolkit-lib/lib/actions/deploy/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CloudFormationStackArtifact } from '@aws-cdk/cx-api';
1+
import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api';
22
import type { BaseDeployOptions } from './private/deploy-options';
33
import type { Tag } from '../../api/aws-cdk';
44

packages/@aws-cdk/toolkit-lib/lib/actions/deploy/private/deploy-options.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DeploymentMethod, DeployOptions, HotswapMode } from '..';
1+
import type { DeploymentMethod, DeployOptions, HotswapMode } from '..';
22
import type { CloudWatchLogEventMonitor } from '../../../api/aws-cdk';
33
import type { StackSelector } from '../../../api/cloud-assembly';
44

packages/@aws-cdk/toolkit-lib/lib/actions/deploy/private/helpers.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { DeployOptions, HotswapProperties } from '..';
2-
import { Deployments, EcsHotswapProperties, HotswapPropertyOverrides, type WorkGraph } from '../../../api/aws-cdk';
1+
import type { DeployOptions, HotswapProperties } from '..';
2+
import type { Deployments, WorkGraph } from '../../../api/aws-cdk';
3+
import { EcsHotswapProperties, HotswapPropertyOverrides } from '../../../api/aws-cdk';
34

45
export function buildParameterMap(parameters?: Map<string, string | undefined>): { [name: string]: { [name: string]: string | undefined } } {
56
const parameterMap: {

packages/@aws-cdk/toolkit-lib/lib/actions/diff/private/helpers.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { DescribeChangeSetOutput, fullDiff } from '@aws-cdk/cloudformation-diff';
2-
import * as cxapi from '@aws-cdk/cx-api';
1+
import type { DescribeChangeSetOutput } from '@aws-cdk/cloudformation-diff';
2+
import { fullDiff } from '@aws-cdk/cloudformation-diff';
3+
import type * as cxapi from '@aws-cdk/cx-api';
34
import { ToolkitError } from '../../../api/shared-public';
45
import { RequireApproval } from '../../deploy';
56

packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/cached-source.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { CloudAssembly } from '@aws-cdk/cx-api';
2-
import { ICloudAssemblySource } from '../types';
1+
import type { CloudAssembly } from '@aws-cdk/cx-api';
2+
import type { ICloudAssemblySource } from '../types';
33

44
/**
55
* A CloudAssemblySource that is caching its result once produced.

packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/context-aware-source.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { MissingContext } from '@aws-cdk/cloud-assembly-schema';
2-
import * as cxapi from '@aws-cdk/cx-api';
3-
import { ToolkitServices } from '../../../toolkit/private';
2+
import type * as cxapi from '@aws-cdk/cx-api';
3+
import type { ToolkitServices } from '../../../toolkit/private';
44
import { type Context, contextproviders, PROJECT_CONTEXT } from '../../aws-cdk';
55
import { CODES } from '../../io/private';
6-
import { ActionAwareIoHost } from '../../shared-private';
6+
import type { ActionAwareIoHost } from '../../shared-private';
77
import { ToolkitError } from '../../shared-public';
8-
import { ICloudAssemblySource } from '../types';
8+
import type { ICloudAssemblySource } from '../types';
99

1010
export interface ContextAwareCloudAssemblyProps {
1111
/**

packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/identity-source.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type * as cxapi from '@aws-cdk/cx-api';
2-
import { ICloudAssemblySource } from '../types';
2+
import type { ICloudAssemblySource } from '../types';
33

44
/**
55
* A CloudAssemblySource that is representing a already existing and produced CloudAssembly.

packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/private/prepare-source.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import * as fs from 'fs-extra';
77
import { lte } from 'semver';
88
import { prepareDefaultEnvironment as oldPrepare, prepareContext, spaceAvailableForContext, Settings, loadTree, some, versionNumber } from '../../../api/aws-cdk';
99
import { splitBySize } from '../../../private/util';
10-
import { ToolkitServices } from '../../../toolkit/private';
10+
import type { ToolkitServices } from '../../../toolkit/private';
1111
import { CODES } from '../../io/private';
12-
import { ActionAwareIoHost } from '../../shared-private';
12+
import type { ActionAwareIoHost } from '../../shared-private';
1313
import { ToolkitError } from '../../shared-public';
1414
import type { AppSynthOptions, LoadAssemblyOptions } from '../source-builder';
1515

0 commit comments

Comments
 (0)