mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix linting
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
9414626c66
commit
92ddb33467
@ -63,14 +63,14 @@ describe("emit-telemetry-from-specific-function-calls", () => {
|
|||||||
di.register(
|
di.register(
|
||||||
whiteListedInjectable,
|
whiteListedInjectable,
|
||||||
whiteListedInjectableWithArgument,
|
whiteListedInjectableWithArgument,
|
||||||
nonWhiteListedInjectable
|
nonWhiteListedInjectable,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
injectedWhiteListedFunction = di.inject(whiteListedInjectable);
|
injectedWhiteListedFunction = di.inject(whiteListedInjectable);
|
||||||
|
|
||||||
injectedWhiteListedFunctionWithArgument = di.inject(
|
injectedWhiteListedFunctionWithArgument = di.inject(
|
||||||
whiteListedInjectableWithArgument
|
whiteListedInjectableWithArgument,
|
||||||
);
|
);
|
||||||
|
|
||||||
injectedNonWhiteListedFunction = di.inject(nonWhiteListedInjectable);
|
injectedNonWhiteListedFunction = di.inject(nonWhiteListedInjectable);
|
||||||
@ -135,7 +135,7 @@ describe("emit-telemetry-from-specific-function-calls", () => {
|
|||||||
|
|
||||||
injectedWhiteListedFunctionWithArgument(
|
injectedWhiteListedFunctionWithArgument(
|
||||||
"irrelevant-argument",
|
"irrelevant-argument",
|
||||||
someObservable
|
someObservable,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -14,9 +14,8 @@ import assert from "assert";
|
|||||||
import { isFunction } from "lodash/fp";
|
import { isFunction } from "lodash/fp";
|
||||||
import emitTelemetryInjectable from "./emit-telemetry.injectable";
|
import emitTelemetryInjectable from "./emit-telemetry.injectable";
|
||||||
|
|
||||||
import telemetryWhiteListForFunctionsInjectable, {
|
import type { WhiteListItem } from "./telemetry-white-list-for-functions.injectable";
|
||||||
WhiteListItem,
|
import telemetryWhiteListForFunctionsInjectable from "./telemetry-white-list-for-functions.injectable";
|
||||||
} from "./telemetry-white-list-for-functions.injectable";
|
|
||||||
|
|
||||||
const telemetryDecoratorInjectable = getInjectable({
|
const telemetryDecoratorInjectable = getInjectable({
|
||||||
id: "telemetry-decorator",
|
id: "telemetry-decorator",
|
||||||
@ -25,7 +24,7 @@ const telemetryDecoratorInjectable = getInjectable({
|
|||||||
const emitTelemetry = diForDecorator.inject(emitTelemetryInjectable);
|
const emitTelemetry = diForDecorator.inject(emitTelemetryInjectable);
|
||||||
|
|
||||||
const whiteList = diForDecorator.inject(
|
const whiteList = diForDecorator.inject(
|
||||||
telemetryWhiteListForFunctionsInjectable
|
telemetryWhiteListForFunctionsInjectable,
|
||||||
);
|
);
|
||||||
|
|
||||||
const whitleListMap = getWhitleListMap(whiteList);
|
const whitleListMap = getWhitleListMap(whiteList);
|
||||||
@ -33,32 +32,32 @@ const telemetryDecoratorInjectable = getInjectable({
|
|||||||
return {
|
return {
|
||||||
decorate:
|
decorate:
|
||||||
(instantiateToBeDecorated: any) =>
|
(instantiateToBeDecorated: any) =>
|
||||||
(di: DiContainerForInjection, instantiationParameter: any) => {
|
(di: DiContainerForInjection, instantiationParameter: any) => {
|
||||||
const instance = instantiateToBeDecorated(di, instantiationParameter);
|
const instance = instantiateToBeDecorated(di, instantiationParameter);
|
||||||
|
|
||||||
if (isFunction(instance)) {
|
if (isFunction(instance)) {
|
||||||
return (...args: any[]) => {
|
return (...args: any[]) => {
|
||||||
const currentContext = di.context.at(-1);
|
const currentContext = di.context.at(-1);
|
||||||
|
|
||||||
assert(currentContext);
|
assert(currentContext);
|
||||||
|
|
||||||
const whiteListed = whitleListMap.get(
|
const whiteListed = whitleListMap.get(
|
||||||
currentContext.injectable.id
|
currentContext.injectable.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (whiteListed) {
|
if (whiteListed) {
|
||||||
emitTelemetry({
|
emitTelemetry({
|
||||||
action: currentContext.injectable.id,
|
action: currentContext.injectable.id,
|
||||||
params: whiteListed.getParams(...args),
|
params: whiteListed.getParams(...args),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance(...args);
|
return instance(...args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -73,18 +72,18 @@ const getWhitleListMap = (whiteList: WhiteListItem[]) =>
|
|||||||
whiteList.map((item) =>
|
whiteList.map((item) =>
|
||||||
typeof item === "string"
|
typeof item === "string"
|
||||||
? [
|
? [
|
||||||
item,
|
item,
|
||||||
{
|
{
|
||||||
getParams: (...args: any[]) => undefined,
|
getParams: () => undefined,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
item.id,
|
item.id,
|
||||||
{
|
{
|
||||||
getParams: item.getParams,
|
getParams: item.getParams,
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
export default telemetryDecoratorInjectable;
|
export default telemetryDecoratorInjectable;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user