-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(awslint): linting is slow (#27860)
Reduces runtime of `awslint` against `aws-cdk-lib` from ~70s down to ~15s. Speed up 1: Reduce rule definitions (~1s) Speed up 2: Make core checks fqn based only (~5s) Speed up 3: Optimize code paths to defer expensive checks (~4s) Speed up 4: Locked typesystem (~25s) Speed up 5: Faster camel casing (~15s) ![giphy](https://github.com/aws/aws-cdk/assets/379814/4a8eb1dd-d045-48a2-8a4d-0a1e36db8b3b) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
13 changed files
with
278 additions
and
2,107 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as changeCase from 'change-case'; | ||
|
||
function cachedTransform(transform: (x: string) => string): (x: string) => string { | ||
const CACHE = new Map<string, string>(); | ||
return (x) => { | ||
const prev = CACHE.get(x); | ||
if (prev) { | ||
return prev; | ||
} | ||
|
||
const transformed = transform(x); | ||
CACHE.set(x, transformed); | ||
return transformed; | ||
}; | ||
} | ||
|
||
export const camelize = cachedTransform((x: string) => changeCase.camelCase(x)); | ||
export const pascalize = cachedTransform((x: string) => changeCase.pascalCase(x)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.