Skip to content

Commit

Permalink
build: configure tslint to ban performance.mark usages (#52505)
Browse files Browse the repository at this point in the history
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker.

PR Close #52505
  • Loading branch information
alan-agius4 authored and atscott committed Nov 3, 2023
1 parent 80e7a0f commit 7ff5152
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions devtools/projects/ng-devtools-backend/src/lib/hooks/index.ts
Expand Up @@ -21,6 +21,7 @@ type Method = keyof LifecycleProfile|'changeDetection'|string;

const recordMark = (s: string, method: Method) => {
if (supportsPerformance) {
// tslint:disable-next-line:ban
performance.mark(`${markName(s, method)}_start`);
}
};
Expand All @@ -31,6 +32,7 @@ const endMark = (nodeName: string, method: Method) => {
const start = `${name}_start`;
const end = `${name}_end`;
if (performance.getEntriesByName(start).length > 0) {
// tslint:disable-next-line:ban
performance.mark(end);
performance.measure(name, start, end);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/util/performance.ts
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

// tslint:disable:no-performance
// tslint:disable:ban
/**
* A guarded `performance.mark`.
*
Expand Down
3 changes: 2 additions & 1 deletion tslint.json
Expand Up @@ -76,7 +76,8 @@
{
"name": ["*", "getMutableClone"],
"message": "Use a ts.factory.update* or ts.factory.create* method instead."
}
},
{"name": ["performance", "mark"], "message": "`performance` methods aren't not fully supported in all environments like JSDOM and Cloudflare workers. Use 'performanceMark' from '@angular/core' instead."}
]
},
"jsRules": {
Expand Down

0 comments on commit 7ff5152

Please sign in to comment.