aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
2.96k stars 557 forks source link

chore(eslint): consistent type imports #6104

Open siddsriv opened 1 month ago

siddsriv commented 1 month ago

Description

introduces a new eslint rule to enforce consistent type imports using the import type syntax.

running eslint with the --fix flag will enforce this rule and modify your file according to the consistent type imports eslint rule.

Testing

as an example:

import { S3Client, PutObjectCommand, PutObjectCommandInput } from "@aws-sdk/client-s3";

upon running eslint on this file, it would throw:

1:1  error  Import "PutObjectCommandInput" is only used as types  

this should be written as so (can be done by running eslint with the --fix flag):

import type { PutObjectCommandInput } from "@aws-sdk/client-s3";
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";

For this repo,

% npx eslint lib      
.
.
.
✖ 8 problems (0 errors, 8 warnings)

and,

% npx eslint packages
.
.
.
✖ 188 problems (0 errors, 188 warnings)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.