Skip to content

Commit 0e79874

Browse files
authored
chore: enforce no-throw-literal (#32331)
### Reason for this change As part of #32324 we are enforcing stricter rules on thrown errors. ### Description of changes Enforce the `no-throw-literal` eslint rule. Fix the one instance that wasn't compliant yet. ### Description of how you validated changes Manual testing. Only changed code is in supporting CLI tool. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 77fbddf commit 0e79874

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

tools/@aws-cdk/cdk-build-tools/config/eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ module.exports = {
4747
'@cdklabs/no-invalid-path': [ 'error' ],
4848
'@cdklabs/promiseall-no-unbounded-parallelism': [ 'error' ],
4949

50+
// Error handling
51+
'no-throw-literal': [ 'error' ],
52+
5053
// Require use of the `import { foo } from 'bar';` form instead of `import foo = require('bar');`
5154
'@typescript-eslint/no-require-imports': ['error'],
5255
'@typescript-eslint/indent': ['error', 2],

tools/@aws-cdk/spec2cdk/lib/util/patterned-name.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export function parsePattern<A extends string>(pattern: string, fields: { [k in A]: unknown }): PatternedString<A> {
22
const placeholders = Object.keys(fields);
33
if (!placeholders.some((param) => pattern.includes(param))) {
4-
throw `Error: --pattern must contain one of [${placeholders.join(', ')}]`;
4+
throw new Error(`--pattern must contain one of [${placeholders.join(', ')}]`);
55
}
66

77
return (values: { [k in A]: string }) => {

0 commit comments

Comments
 (0)