diff --git a/package-lock.json b/package-lock.json index dd2fdcd..7389dda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@checkdigit/eslint-plugin", - "version": "7.17.0", + "version": "7.17.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@checkdigit/eslint-plugin", - "version": "7.17.0", + "version": "7.17.1", "license": "MIT", "dependencies": { "@typescript-eslint/type-utils": "^8.46.0", diff --git a/package.json b/package.json index 5ef36ea..5416506 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@checkdigit/eslint-plugin", - "version": "7.17.0", + "version": "7.17.1", "description": "Check Digit eslint plugins", "keywords": [ "eslint", diff --git a/src/aws/require-aws-bare-bones.spec.ts b/src/aws/require-aws-bare-bones.spec.ts index 9000f2d..d390ca7 100644 --- a/src/aws/require-aws-bare-bones.spec.ts +++ b/src/aws/require-aws-bare-bones.spec.ts @@ -110,6 +110,12 @@ createTester().run(ruleId, rule, { { code: `import { type UploadOptions } from '@aws-sdk/lib-storage';`, }, + { + code: `import type { Credentials } from '@aws-sdk/client-sts';`, + }, + { + code: `import { S3Client, type S3 } from '@aws-sdk/client-s3';`, + }, ], invalid: [ { diff --git a/src/aws/require-aws-bare-bones.ts b/src/aws/require-aws-bare-bones.ts index aa66731..d80cd55 100644 --- a/src/aws/require-aws-bare-bones.ts +++ b/src/aws/require-aws-bare-bones.ts @@ -6,8 +6,8 @@ import getDocumentationUrl from '../get-documentation-url.ts'; export const ruleId = 'require-aws-bare-bones'; export const MESSAGE_ID_AGGREGATED_CLIENT = 'noAggregatedClient'; -const BARE_BONES_SUFFIXES = new Set(['Client', 'Command', 'Exception', 'Input', 'Output']); -const AWS_LIB_AGGREGATED_SUFFIXES = new Set(['Document', 'Paginator', 'Utils', 'Service', 'Collection', 'Manager']); +const BARE_BONES_SUFFIXES = ['Client', 'Command', 'Exception', 'Input', 'Output']; +const AWS_LIB_AGGREGATED_SUFFIXES = ['Document', 'Paginator', 'Utils', 'Service', 'Collection', 'Manager']; const AWS_SDK_CLIENT = '@aws-sdk/client-'; const AWS_SDK_LIB = '@aws-sdk/lib-'; @@ -22,7 +22,7 @@ const kebabToPascal = (str: string): string => .map((item) => item.charAt(0).toUpperCase() + item.slice(1)) .join(''); -const endsWithAnySuffix = (name: string, suffixes: Set): boolean => { +const endsWithAnySuffix = (name: string, suffixes: string[]): boolean => { for (const suffix of suffixes) { if (name.endsWith(suffix)) { return true; @@ -64,16 +64,14 @@ const rule: ESLintUtils.RuleModule = create create(context) { return { ImportDeclaration(node) { - if (!isAwsSdkClientModule(node)) { + if (node.importKind === 'type' || !isAwsSdkClientModule(node)) { return; } for (const specifier of node.specifiers) { - const isTypeImport = specifier.type === AST_NODE_TYPES.ImportSpecifier && specifier.importKind === 'type'; - if ( specifier.type === AST_NODE_TYPES.ImportSpecifier && - !isTypeImport && + specifier.importKind !== 'type' && isAggregatedClient(specifier.local.name, node.source.value) ) { context.report({