From 0caf1a6b8522a44131eba12410e67ef4f25d5486 Mon Sep 17 00:00:00 2001 From: Vieltojarvi <lvielto@amazon.com> Date: Fri, 6 Sep 2024 15:52:03 -0700 Subject: [PATCH 1/6] ai-constructs is added to no-amplify-errors --- packages/eslint-rules/src/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/eslint-rules/src/index.ts b/packages/eslint-rules/src/index.ts index 202c961837..e987c12be5 100644 --- a/packages/eslint-rules/src/index.ts +++ b/packages/eslint-rules/src/index.ts @@ -24,11 +24,14 @@ export const configs = { files: ['packages/cli/src/**'], excludedFiles: ['**/*.test.ts'], rules: { - 'amplify-backend-rules/prefer-amplify-errors': 'off', //will be changed to 'error' in the future + 'amplify-backend-rules/prefer-amplify-errors': 'off', }, }, { - files: ['packages/auth-construct/src/**'], + files: [ + 'packages/auth-construct/src/**', + 'packages/ai-constructs/src/**', + ], rules: { 'amplify-backend-rules/no-amplify-errors': 'error', }, From 1282b5a6b0c89a3b144794d90b2a242a61303dcd Mon Sep 17 00:00:00 2001 From: Vieltojarvi <lvielto@amazon.com> Date: Mon, 9 Sep 2024 11:25:19 -0700 Subject: [PATCH 2/6] activated no-amplify-errors in multiple packages --- packages/eslint-rules/src/index.ts | 7 ++++++- .../src/get_backend_output_with_error_handling.ts | 4 ++++ packages/schema-generator/src/generate_schema.ts | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/eslint-rules/src/index.ts b/packages/eslint-rules/src/index.ts index e987c12be5..c4dea55a36 100644 --- a/packages/eslint-rules/src/index.ts +++ b/packages/eslint-rules/src/index.ts @@ -24,13 +24,18 @@ export const configs = { files: ['packages/cli/src/**'], excludedFiles: ['**/*.test.ts'], rules: { - 'amplify-backend-rules/prefer-amplify-errors': 'off', + 'amplify-backend-rules/prefer-amplify-errors': 'off', //will be changed to 'error' in the future }, }, { files: [ 'packages/auth-construct/src/**', 'packages/ai-constructs/src/**', + 'packages/backend-output-storage/src/**', + 'packages/deployed-backend-client/src/**', + 'packages/form-generator/src/**', + 'packages/model-generator/src/**', + 'packages/schema-generator/src/**', ], rules: { 'amplify-backend-rules/no-amplify-errors': 'error', diff --git a/packages/model-generator/src/get_backend_output_with_error_handling.ts b/packages/model-generator/src/get_backend_output_with_error_handling.ts index 98fb6ffc70..1c5e9feb84 100644 --- a/packages/model-generator/src/get_backend_output_with_error_handling.ts +++ b/packages/model-generator/src/get_backend_output_with_error_handling.ts @@ -20,6 +20,7 @@ export const getBackendOutputWithErrorHandling = async ( error instanceof BackendOutputClientError && error.code === BackendOutputClientErrorType.DEPLOYMENT_IN_PROGRESS ) { + // eslint-disable-next-line amplify-backend-rules/no-amplify-errors throw new AmplifyUserError( 'DeploymentInProgressError', { @@ -33,6 +34,7 @@ export const getBackendOutputWithErrorHandling = async ( error instanceof BackendOutputClientError && error.code === BackendOutputClientErrorType.NO_STACK_FOUND ) { + // eslint-disable-next-line amplify-backend-rules/no-amplify-errors throw new AmplifyUserError( 'StackDoesNotExistError', { @@ -47,6 +49,7 @@ export const getBackendOutputWithErrorHandling = async ( error instanceof BackendOutputClientError && error.code === BackendOutputClientErrorType.CREDENTIALS_ERROR ) { + // eslint-disable-next-line amplify-backend-rules/no-amplify-errors throw new AmplifyUserError( 'CredentialsError', { @@ -61,6 +64,7 @@ export const getBackendOutputWithErrorHandling = async ( error instanceof BackendOutputClientError && error.code === BackendOutputClientErrorType.ACCESS_DENIED ) { + // eslint-disable-next-line amplify-backend-rules/no-amplify-errors throw new AmplifyUserError( 'AccessDeniedError', { diff --git a/packages/schema-generator/src/generate_schema.ts b/packages/schema-generator/src/generate_schema.ts index 666fa823bf..bfe5e28ea8 100644 --- a/packages/schema-generator/src/generate_schema.ts +++ b/packages/schema-generator/src/generate_schema.ts @@ -39,6 +39,7 @@ export class SchemaGenerator { } catch (err) { const databaseError = err as DatabaseConnectError; if (databaseError.code === 'ETIMEDOUT') { + // eslint-disable-next-line amplify-backend-rules/no-amplify-errors throw new AmplifyUserError<AmplifyGenerateSchemaError>( 'DatabaseConnectionError', { @@ -117,6 +118,7 @@ export const parseDatabaseUrl = (databaseUrl: string): SQLDataSourceConfig => { ).filter((part) => !config[part]); if (missingParts.length > 0) { + // eslint-disable-next-line amplify-backend-rules/no-amplify-errors throw new AmplifyUserError<AmplifyGenerateSchemaError>( 'DatabaseUrlParseError', { @@ -132,6 +134,7 @@ export const parseDatabaseUrl = (databaseUrl: string): SQLDataSourceConfig => { return config; } catch (err) { const error = err as Error; + // eslint-disable-next-line amplify-backend-rules/no-amplify-errors throw new AmplifyUserError<AmplifyGenerateSchemaError>( 'DatabaseUrlParseError', { From 70b680265541287dbd46fb82cc305f7beed36cb6 Mon Sep 17 00:00:00 2001 From: Vieltojarvi <lvielto@amazon.com> Date: Mon, 9 Sep 2024 11:26:50 -0700 Subject: [PATCH 3/6] added changeset --- .changeset/nice-jobs-crash.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/nice-jobs-crash.md diff --git a/.changeset/nice-jobs-crash.md b/.changeset/nice-jobs-crash.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/nice-jobs-crash.md @@ -0,0 +1,2 @@ +--- +--- From ee58ea41c1bd1986e2e21120d99c2a4c6b33dcf1 Mon Sep 17 00:00:00 2001 From: Vieltojarvi <lvielto@amazon.com> Date: Mon, 9 Sep 2024 11:44:43 -0700 Subject: [PATCH 4/6] changeset updated --- .changeset/flat-snakes-judge.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/flat-snakes-judge.md diff --git a/.changeset/flat-snakes-judge.md b/.changeset/flat-snakes-judge.md new file mode 100644 index 0000000000..e14e799859 --- /dev/null +++ b/.changeset/flat-snakes-judge.md @@ -0,0 +1,6 @@ +--- +'@aws-amplify/schema-generator': patch +'@aws-amplify/model-generator': patch +--- + +added inline ignores to reasonable violations of no-amplify-errors lint rule From 9df4fd0e87cc5c8d1c8c77e208f23a502ef6681d Mon Sep 17 00:00:00 2001 From: Vieltojarvi <lvielto@amazon.com> Date: Mon, 9 Sep 2024 14:03:58 -0700 Subject: [PATCH 5/6] removed changeset for schema-generator and model-generator --- .changeset/flat-snakes-judge.md | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .changeset/flat-snakes-judge.md diff --git a/.changeset/flat-snakes-judge.md b/.changeset/flat-snakes-judge.md deleted file mode 100644 index e14e799859..0000000000 --- a/.changeset/flat-snakes-judge.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@aws-amplify/schema-generator': patch -'@aws-amplify/model-generator': patch ---- - -added inline ignores to reasonable violations of no-amplify-errors lint rule From 7dc0b16343d34e44693cec42a2c10716b68a1f48 Mon Sep 17 00:00:00 2001 From: Vieltojarvi <lvielto@amazon.com> Date: Mon, 9 Sep 2024 14:15:50 -0700 Subject: [PATCH 6/6] adjusting changesets --- .changeset/happy-adults-think.md | 6 ++++++ .changeset/nice-jobs-crash.md | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .changeset/happy-adults-think.md delete mode 100644 .changeset/nice-jobs-crash.md diff --git a/.changeset/happy-adults-think.md b/.changeset/happy-adults-think.md new file mode 100644 index 0000000000..2283459512 --- /dev/null +++ b/.changeset/happy-adults-think.md @@ -0,0 +1,6 @@ +--- +'@aws-amplify/schema-generator': patch +'@aws-amplify/model-generator': patch +--- + +activated no-amplify-errors, ignored lines with valid violations diff --git a/.changeset/nice-jobs-crash.md b/.changeset/nice-jobs-crash.md deleted file mode 100644 index a845151cc8..0000000000 --- a/.changeset/nice-jobs-crash.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ----