Skip to content

Commit

Permalink
chore: enforce consistent-type-imports eslint rule on modern packag…
Browse files Browse the repository at this point in the history
…es (#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
  • Loading branch information
mrgrain authored Mar 6, 2025
1 parent e3b0856 commit 47a4e1d
Show file tree
Hide file tree
Showing 47 changed files with 105 additions and 154 deletions.
7 changes: 1 addition & 6 deletions .eslintrc.json

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

8 changes: 7 additions & 1 deletion .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,11 @@ tmpToolkitHelpers.package.addField('exports', {
'./util': './lib/util/index.js',
});

tmpToolkitHelpers.eslint?.addRules({
'@cdklabs/no-throw-default-error': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
});

//////////////////////////////////////////////////////////////////////

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

// Eslint rules
toolkitLib.eslint?.addRules({
'@cdklabs/no-throw-default-error': ['error'],
'@cdklabs/no-throw-default-error': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'import/no-restricted-paths': ['error', {
zones: [{
target: './',
Expand Down
7 changes: 1 addition & 6 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.

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

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

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

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

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

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

11 changes: 4 additions & 7 deletions packages/@aws-cdk/tmp-toolkit-helpers/.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
@@ -1,4 +1,4 @@
import { IoMessage, IoRequest } from './io-message';
import type { IoMessage, IoRequest } from './io-message';

export interface IIoHost {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ToolkitAction } from './toolkit-action';
import type { ToolkitAction } from './toolkit-action';

/**
* The reporting level of the message.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IIoHost } from '../io-host';
import { IoMessage, IoRequest } from '../io-message';
import { ToolkitAction } from '../toolkit-action';
import type { IIoHost } from '../io-host';
import type { IoMessage, IoRequest } from '../io-message';
import type { ToolkitAction } from '../toolkit-action';

export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
export type SimplifiedMessage<T> = Pick<IoMessage<T>, 'level' | 'code' | 'message' | 'data'>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IoMessageCode, IoMessageLevel } from '../io-message';
import { ActionLessMessage, ActionLessRequest } from './action-aware';
import type { IoMessageCode, IoMessageLevel } from '../io-message';
import type { ActionLessMessage, ActionLessRequest } from './action-aware';

/**
* Information for each IO Message Code.
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/tmp-toolkit-helpers/src/util/objects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isArray, isObject, Obj } from './types';
import type { Obj } from './types';
import { isArray, isObject } from './types';
import { ToolkitError } from '../api/toolkit-error';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/tmp-toolkit-helpers/src/util/yaml-cfn.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as yaml from 'yaml';
import * as yaml_cst from 'yaml/parse-cst';
import type * as yaml_cst from 'yaml/parse-cst';
import * as yaml_types from 'yaml/types';

/**
Expand Down
12 changes: 3 additions & 9 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.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as cxapi from '@aws-cdk/cx-api';
import type * as cxapi from '@aws-cdk/cx-api';
import { environmentsFromDescriptors } from './private';
import type { Tag } from '../../api/aws-cdk';
import type { ICloudAssemblySource } from '../../api/cloud-assembly';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as cxapi from '@aws-cdk/cx-api';
import type * as cxapi from '@aws-cdk/cx-api';
import { ToolkitError } from '../../../api/shared-public';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/toolkit-lib/lib/actions/deploy/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CloudFormationStackArtifact } from '@aws-cdk/cx-api';
import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api';
import type { BaseDeployOptions } from './private/deploy-options';
import type { Tag } from '../../api/aws-cdk';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeploymentMethod, DeployOptions, HotswapMode } from '..';
import type { DeploymentMethod, DeployOptions, HotswapMode } from '..';
import type { CloudWatchLogEventMonitor } from '../../../api/aws-cdk';
import type { StackSelector } from '../../../api/cloud-assembly';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DeployOptions, HotswapProperties } from '..';
import { Deployments, EcsHotswapProperties, HotswapPropertyOverrides, type WorkGraph } from '../../../api/aws-cdk';
import type { DeployOptions, HotswapProperties } from '..';
import type { Deployments, WorkGraph } from '../../../api/aws-cdk';
import { EcsHotswapProperties, HotswapPropertyOverrides } from '../../../api/aws-cdk';

export function buildParameterMap(parameters?: Map<string, string | undefined>): { [name: string]: { [name: string]: string | undefined } } {
const parameterMap: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DescribeChangeSetOutput, fullDiff } from '@aws-cdk/cloudformation-diff';
import * as cxapi from '@aws-cdk/cx-api';
import type { DescribeChangeSetOutput } from '@aws-cdk/cloudformation-diff';
import { fullDiff } from '@aws-cdk/cloudformation-diff';
import type * as cxapi from '@aws-cdk/cx-api';
import { ToolkitError } from '../../../api/shared-public';
import { RequireApproval } from '../../deploy';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CloudAssembly } from '@aws-cdk/cx-api';
import { ICloudAssemblySource } from '../types';
import type { CloudAssembly } from '@aws-cdk/cx-api';
import type { ICloudAssemblySource } from '../types';

/**
* A CloudAssemblySource that is caching its result once produced.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { MissingContext } from '@aws-cdk/cloud-assembly-schema';
import * as cxapi from '@aws-cdk/cx-api';
import { ToolkitServices } from '../../../toolkit/private';
import type * as cxapi from '@aws-cdk/cx-api';
import type { ToolkitServices } from '../../../toolkit/private';
import { type Context, contextproviders, PROJECT_CONTEXT } from '../../aws-cdk';
import { CODES } from '../../io/private';
import { ActionAwareIoHost } from '../../shared-private';
import type { ActionAwareIoHost } from '../../shared-private';
import { ToolkitError } from '../../shared-public';
import { ICloudAssemblySource } from '../types';
import type { ICloudAssemblySource } from '../types';

export interface ContextAwareCloudAssemblyProps {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as cxapi from '@aws-cdk/cx-api';
import { ICloudAssemblySource } from '../types';
import type { ICloudAssemblySource } from '../types';

/**
* A CloudAssemblySource that is representing a already existing and produced CloudAssembly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import * as fs from 'fs-extra';
import { lte } from 'semver';
import { prepareDefaultEnvironment as oldPrepare, prepareContext, spaceAvailableForContext, Settings, loadTree, some, versionNumber } from '../../../api/aws-cdk';
import { splitBySize } from '../../../private/util';
import { ToolkitServices } from '../../../toolkit/private';
import type { ToolkitServices } from '../../../toolkit/private';
import { CODES } from '../../io/private';
import { ActionAwareIoHost } from '../../shared-private';
import type { ActionAwareIoHost } from '../../shared-private';
import { ToolkitError } from '../../shared-public';
import type { AppSynthOptions, LoadAssemblyOptions } from '../source-builder';

Expand Down
Loading

0 comments on commit 47a4e1d

Please # to comment.