mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Up to now `eslint-plugin-brace-rules` was used to enforce a common brace style for JavaScript code. This plugin was however updated the last time over 9 years ago and will be incompatible with ESLint v10, as that [removes `context.getSourceCode()`][1], the plugin relies on. To keep the eslint config working with ESLint v10, this replaces `eslint-plugin-brace-rules` with the [`@stylistic/brace-style`][2] rule from `@stylistic/eslint-plugin`, a package we already use. While `@stylistic/brace-style` doesn't offer an option to format braces in exactly the same way as before, the "allman" style seems to be the one closest to the existing code. [1]: https://eslint.org/blog/2025/11/eslint-v10.0.0-alpha.0-released/#removed-deprecated-rule-context-members [2]: https://eslint.style/rules/brace-style
36 lines
999 B
JavaScript
36 lines
999 B
JavaScript
/**
|
|
* This is an auto-proxying class that adds profiling to all method.
|
|
* Can be quite useful to track where time is spent in the GUI.
|
|
* Usage: Just add "extens Profilable" to your class
|
|
* and call super() in the constructor as appropriate.
|
|
* Give your class a name if you want the ouput to be usable.
|
|
*
|
|
* It is recommended to only use this class when actually working on profiling,
|
|
* or the profiler2 graph will be very cluttered.
|
|
*/
|
|
var ProfilableMixin = (Parent) => class Profilable extends (() => Parent || Object)()
|
|
{
|
|
constructor()
|
|
{
|
|
super();
|
|
return new Proxy(this, {
|
|
"get": (target, prop, receiver) =>
|
|
{
|
|
let ret = Reflect.get(target, prop);
|
|
if (typeof ret !== 'function')
|
|
return ret;
|
|
{
|
|
ret = ret.bind(receiver);
|
|
return (...a) =>
|
|
{
|
|
Engine.ProfileStart(target.constructor.name + ":" + prop);
|
|
const ret2 = ret(...a);
|
|
Engine.ProfileStop();
|
|
return ret2;
|
|
};
|
|
}
|
|
}
|
|
});
|
|
}
|
|
};
|
|
var Profilable = ProfilableMixin();
|