Skip to content

Commit 24fde64

Browse files
sreenathsJohanAhlen
authored andcommitted
[ui] Vue 3 - Fixed lint errors in Web Component Wrapper
1 parent c39ed2d commit 24fde64

File tree

4 files changed

+37
-32
lines changed

4 files changed

+37
-32
lines changed

desktop/core/src/desktop/js/catalog/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ export const fetchSample = ({
435435
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
436436
// @ts-ignore
437437
const transformResponse = (response: unknown) => {
438+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
439+
// @ts-ignore
438440
return JSON.bigdataParse(response);
439441
};
440442
const resultPromise = post<SampleResponse>(

desktop/core/src/desktop/js/types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ export interface hueWindow {
5050
WEB_SOCKETS_ENABLED?: boolean;
5151
WS_CHANNEL?: string;
5252
hueDebug?: HueDebug;
53+
DISABLE_LOCAL_STORAGE?: boolean;
5354
}

desktop/core/src/desktop/js/utils/storageUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type LocalStorageGet = {
2222
};
2323
export const getFromLocalStorage: LocalStorageGet = <T>(key: string, defaultValue?: T) => {
2424
const defaultOrNull = typeof defaultValue !== 'undefined' ? defaultValue : null;
25-
if (!window.localStorage || window.DISABLE_LOCAL_STORAGE) {
25+
if (!window.localStorage || (<hueWindow>window).DISABLE_LOCAL_STORAGE) {
2626
return defaultOrNull;
2727
}
2828

@@ -47,7 +47,7 @@ export const setInLocalStorage = (key: string, value: unknown): void => {
4747
if (!window.localStorage) {
4848
return;
4949
}
50-
if (window.DISABLE_LOCAL_STORAGE) {
50+
if ((<hueWindow>window).DISABLE_LOCAL_STORAGE) {
5151
window.localStorage.clear();
5252
return;
5353
}

desktop/core/src/desktop/js/vue/wrapper/utils.ts

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
import { ComponentPublicInstance, h, VNode } from "vue";
1+
import { ComponentPublicInstance, h, VNode } from 'vue';
22

3+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34
export type KeyHash = { [key: string]: any };
45

5-
const camelizeRE = /-(\w)/g
6+
const camelizeRE = /-(\w)/g;
67
export const camelize = (str: string): string => {
7-
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
8-
}
8+
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
9+
};
910

10-
const hyphenateRE = /\B([A-Z])/g
11+
const hyphenateRE = /\B([A-Z])/g;
1112
export const hyphenate = (str: string): string => {
12-
return str.replace(hyphenateRE, '-$1').toLowerCase()
13-
}
13+
return str.replace(hyphenateRE, '-$1').toLowerCase();
14+
};
1415

1516
export function setInitialProps(propsList: string[]): KeyHash {
16-
const res: KeyHash = {}
17+
const res: KeyHash = {};
1718
propsList.forEach(key => {
18-
res[key] = undefined
19-
})
20-
return res
21-
}
22-
23-
export function injectHook (options: KeyHash, key: string, hook: Function) {
24-
options[key] = [].concat(options[key] || [])
25-
options[key].unshift(hook)
19+
res[key] = undefined;
20+
});
21+
return res;
2622
}
2723

28-
export function callHooks (vm: ComponentPublicInstance | undefined, hook: string) {
24+
export function callHooks(vm: ComponentPublicInstance | undefined, hook: string): void {
2925
if (vm) {
3026
let hooks = vm.$options[hook] || [];
31-
if(!Array.isArray(hooks)) {
27+
if (!Array.isArray(hooks)) {
3228
hooks = [hooks];
3329
}
34-
hooks.forEach((hook: Function) => {
30+
hooks.forEach((hook: () => void): void => {
3531
hook.call(vm);
3632
});
3733
}
3834
}
3935

40-
export function createCustomEvent (name: string, args: any) {
36+
export function createCustomEvent(name: string, args: unknown): CustomEvent {
4137
return new CustomEvent(name, {
4238
bubbles: false,
4339
cancelable: false,
4440
detail: args
45-
})
41+
});
4642
}
4743

48-
const isBoolean = (val: any) => /function Boolean/.test(String(val));
49-
const isNumber = (val: any) => /function Number/.test(String(val));
44+
const isBoolean = (val: unknown) => /function Boolean/.test(String(val));
45+
const isNumber = (val: unknown) => /function Number/.test(String(val));
5046

51-
export function convertAttributeValue (value: any, name: string, { type }: { type?: any } = {}) {
47+
export function convertAttributeValue(
48+
value: unknown,
49+
name: string,
50+
{ type }: { type?: unknown } = {}
51+
): unknown {
5252
if (isBoolean(type)) {
5353
if (value === 'true' || value === 'false') {
5454
return value === 'true';
@@ -58,14 +58,14 @@ export function convertAttributeValue (value: any, name: string, { type }: { typ
5858
}
5959
return value != null;
6060
} else if (isNumber(type)) {
61-
const parsed = parseFloat(value);
61+
const parsed = parseFloat(<string>value);
6262
return isNaN(parsed) ? value : parsed;
6363
} else {
6464
return value;
6565
}
6666
}
6767

68-
export function toVNodes (children: NodeListOf<ChildNode>): (VNode | null)[] {
68+
export function toVNodes(children: NodeListOf<ChildNode>): (VNode | null)[] {
6969
const res: (VNode | null)[] = [];
7070

7171
for (let i = 0, l = children.length; i < l; i++) {
@@ -75,11 +75,13 @@ export function toVNodes (children: NodeListOf<ChildNode>): (VNode | null)[] {
7575
return res;
7676
}
7777

78-
function toVNode (node: any): VNode | null {
78+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
79+
function toVNode(node: any): VNode | null {
7980
if (node.nodeType === 3) {
8081
return node.data.trim() ? node.data : null;
8182
} else if (node.nodeType === 1) {
82-
const data = {
83+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
84+
const data: { attrs: any; domProps: any; slot?: any } = {
8385
attrs: getAttributes(node),
8486
domProps: {
8587
innerHTML: node.innerHTML
@@ -93,11 +95,11 @@ function toVNode (node: any): VNode | null {
9395

9496
return h(node.tagName, data);
9597
} else {
96-
return null
98+
return null;
9799
}
98100
}
99101

100-
function getAttributes (node: any): KeyHash {
102+
function getAttributes(node: { attributes: { nodeName: string; nodeValue: unknown }[] }): KeyHash {
101103
const res: KeyHash = {};
102104
for (let i = 0, l = node.attributes.length; i < l; i++) {
103105
const attr = node.attributes[i];

0 commit comments

Comments
 (0)