Skip to content

Commit

Permalink
Fix all lint errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
jumperchen committed Jan 30, 2024
1 parent f2b3e07 commit 5ab6941
Show file tree
Hide file tree
Showing 18 changed files with 1,459 additions and 887 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ module.exports = {
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-parameter-properties': 'error', // deprecated
'@typescript-eslint/parameter-properties': 'error', // deprecated
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-this-alias': 'warn',
'@typescript-eslint/restrict-plus-operands': 'warn',
Expand All @@ -410,6 +410,9 @@ module.exports = {
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/unified-signatures': 'off', // TSDoc overloaded functions
'@typescript-eslint/no-redundant-type-constituents': 'warn',
'@typescript-eslint/no-dynamic-delete': 'warn',
'@typescript-eslint/no-extraneous-class': 'off',
'zk/noMixedHtml': [ 2, {
'htmlFunctionRules': [
'dom(?:(?!Evt|Target).)', 'getStyle', 'getSclass', 'getZclass', 'HTML_$',
Expand Down
2,248 changes: 1,408 additions & 840 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions zk/src/main/resources/web/js/zk/anima.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ zk.animating = animating;
* @see {@link zk.animating}
* @since 5.0.6
*/
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
export function afterAnimate(fn: () => void, delay?: number): boolean | void {
if (zk.animating())
_aftAnims.push(fn);
Expand Down
6 changes: 3 additions & 3 deletions zk/src/main/resources/web/js/zk/au.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export namespace au_global {
for (var c in code as Record<number | string, string>)
zAu.setErrorURI(parseInt(c), code[c] as string);
} else
zAu._errURIs['' + code] = uri!;
zAu._errURIs['' + String(code)] = uri!;
}
/**
* Sets the URI for the server-push related error.
Expand Down Expand Up @@ -538,7 +538,7 @@ export namespace au_global {
zAu.setPushErrorURI(parseInt(c), code[c] as string);
return;
}
_perrURIs['' + code] = uri!;
_perrURIs['' + String(code)] = uri!;
}

////Ajax Send////
Expand Down Expand Up @@ -965,7 +965,7 @@ export namespace au_global {
if (!forceAjax && ws) {
zk.copy(content, zWs.encode(j, aureq, dt));
} else {
content += zAu.encode(j, aureq, dt);
(content as string) += zAu.encode(j, aureq, dt);
}
zk.copy(rtags, (aureq.opts || {}).rtags);
}
Expand Down
2 changes: 1 addition & 1 deletion zk/src/main/resources/web/js/zk/dateImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export namespace dateImpl_global {
return this._getTzMoment().year(year).valueOf();
}
toString(): string {
return this._getTzMoment().toString();
return String(this._getTzMoment());
}
valueOf(): number {
return this._moment.valueOf();
Expand Down
28 changes: 14 additions & 14 deletions zk/src/main/resources/web/js/zk/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1494,11 +1494,12 @@ export class JQZK {
vparentNode(real?: boolean): HTMLElement | undefined {
var el = this.jq[0];
if (el) {
var v = el['z_vp'] as undefined | HTMLElement; //might be empty
let v = el['z_vp'] as undefined | string; //might be empty
if (v) return jq('#' + v)[0];
v = el['z_vpagt'] as undefined | HTMLElement;
if (v && (v = jq('#' + v)[0]))
return v.parentNode as HTMLElement | undefined;
v = el['z_vpagt'] as undefined | string;
let agt: HTMLElement | undefined;
if (v && (agt = jq('#' + v)[0]))
return agt.parentNode as HTMLElement | undefined;
if (real)
return el.parentNode as HTMLElement | undefined;
}
Expand Down Expand Up @@ -1547,23 +1548,22 @@ export class JQZK {
undoVParent(): this {
if (this.hasVParent()) {
var el = this.jq[0],
p = el['z_vp'] as undefined | HTMLElement,
agt = el['z_vpagt'] as string | HTMLElement,
p = el['z_vp'] as undefined | string,
agt = el['z_vpagt'] as string,
$agt = jq('#' + agt);
el['z_vp'] = el['z_vpagt'] = undefined;
agt = $agt[0];

p = (p ? jq('#' + p)[0] : agt ? agt.parentNode : undefined) as undefined | HTMLElement;
if (p) {
const agtNode = $agt[0],
parent = (p ? jq('#' + p)[0] : agtNode ? agtNode.parentNode : undefined) as undefined | HTMLElement;
if (parent) {

// Bug 3049181
zjq._fixedVParent(el);

if (agt) {
p.insertBefore(el, agt);
if (agtNode) {
parent.insertBefore(el, agtNode);
$agt.remove();
} else
p.appendChild(el);
parent.appendChild(el);

var cf: undefined | zk.Widget, parentWidget: undefined | zk.Widget, a: undefined | HTMLElement;
// ZK-851
Expand Down Expand Up @@ -1713,7 +1713,7 @@ export class JQZK {
* <p>To parse a style (e.g., 'width:10px;padding:2px') to a map of style names and values, use {@link jq.parseStyle}.
* @deprecated As of release 5.0.2, use jq.css(map) instead
*/
setStyles(styles: JQuery.PlainObject<string | number | ((this: HTMLElement, index: number, value: string) => string | number | void | undefined)>): this {
setStyles(styles: JQuery.PlainObject<string | number | ((this: HTMLElement, index: number, value: string) => string | number | undefined)>): this {
this.jq.css(styles);
return this;
}
Expand Down
4 changes: 2 additions & 2 deletions zk/src/main/resources/web/js/zk/domtouch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ zk.override(zk.Widget.prototype, _xWidget, {
this._holdTimeout = undefined;
}
};
jq(this.$n()!).on('touchstart', this.proxy(this._tapHoldStart))
jq(this.$n()).on('touchstart', this.proxy(this._tapHoldStart))
.on('touchmove', this.proxy(this._tapHoldMove)) //cancel hold if moved
.on('click', this.proxy(this._tapHoldClick)) //prevent click during hold
.on('touchend', this.proxy(this._tapHoldEnd));
Expand All @@ -276,7 +276,7 @@ zk.override(zk.Widget.prototype, _xWidget, {
unbindTapHold_() {
if (this.isListen('onRightClick') || (window.zul && this instanceof zul.Widget && this.getContext())) { //also register context menu to tapHold event
this._startHold = this._cancelHold = undefined;
jq(this.$n()!).off('touchstart', this.proxy(this._tapHoldStart))
jq(this.$n()).off('touchstart', this.proxy(this._tapHoldStart))
.off('touchmove', this.proxy(this._tapHoldMove)) //cancel hold if moved
.off('click', this.proxy(this._tapHoldClick)) //prevent click during hold
.off('touchend', this.proxy(this._tapHoldEnd));
Expand Down
8 changes: 4 additions & 4 deletions zk/src/main/resources/web/js/zk/drag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface DraggableOptions {
snap?: zk.Offset | ((dg: Draggable, offset: zk.Offset) => zk.Offset);
}

var _dragging = {},
var _dragging = new Map(),
_actTmout: undefined | number, //if not null, it means _activate() is called but not really activated
_stackup: undefined | HTMLIFrameElement, _activedg: undefined | Draggable, _initPt: zk.Offset, _dnEvt: boolean | zk.Event | undefined,
_lastPt: zk.Offset | undefined, _lastScrlPt: zk.Offset | undefined;
Expand Down Expand Up @@ -121,7 +121,7 @@ export interface DraggableOptions {
var node: undefined | HTMLElement & {_$opacity?} = dg.node;
if (node) {
node._$opacity = jq(node).css('opacity');
_dragging[node.toString()] = true;
_dragging.set(node, true);
}
if (node) {
jq(node)
Expand Down Expand Up @@ -150,7 +150,7 @@ export interface DraggableOptions {
duration: 200,
queue: '_draggable',
complete: function () {
delete _dragging[node!.toString()];
_dragging.delete(node);
}
});
}
Expand Down Expand Up @@ -813,7 +813,7 @@ export class Draggable extends zk.Object {
var node = this.node,
evt = jq.Event.zk(devt),
target = devt.target as HTMLElement;
if (_actTmout || (node && _dragging[node.toString()]) || evt.which != 1
if (_actTmout || _dragging.has(node) || evt.which != 1
|| (zk.webkit && jq.nodeName(target, 'select'))
|| (zk(target).isInput() && this.control != zk.Widget.$(target)))
return;
Expand Down
2 changes: 1 addition & 1 deletion zk/src/main/resources/web/js/zk/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export namespace eff {
let zic = n.style.zIndex || jq(n).css('z-index');
if (zic && zic != 'auto') {
zicv = zk.parseInt(zic);
if (zi == 'auto' || zicv > zi)
if (zi == 'auto' || zicv > (zi as number))
zi = zicv;
}
}
Expand Down
6 changes: 3 additions & 3 deletions zk/src/main/resources/web/js/zk/evt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class Event<TData = unknown> extends zk.Object {
* @since 9.5.0
* @see {@link zKeys}
*/
isPressed(...args: string[]): boolean {
isPressed(...args: zKeys[]): boolean {
let keyCount = 0,
result = true;
for (var i = 0, len = args.length; i < len; i++) {
Expand All @@ -294,7 +294,7 @@ export class Event<TData = unknown> extends zk.Object {
keyCount++;
if (keyCount > 1)
throw 'Invalid key combination';
else if (arg != this.key)
else if (arg as string != this.key)
result = false;
} else if ((arg == zKeys.META && !this.metaKey) || (arg == zKeys.ALT && !this.altKey)
|| (arg == zKeys.CONTROL && !this.ctrlKey) || (arg == zKeys.SHIFT && !this.shiftKey)) {
Expand Down Expand Up @@ -452,7 +452,7 @@ function _target(inf: zk.Widget | [zk.Widget, CallableFunction]): zk.Widget {
function _fn(inf, o: zk.Widget, name: string): CallableFunction {
const fn = (Array.isArray(inf) ? inf[1] : o[name]) as undefined | CallableFunction;
if (!fn)
throw (o.className || o) + ':' + name + ' not found';
throw (o.className || o.widgetName) + ':' + name + ' not found';
return fn;
}
function _sync(): void {
Expand Down
4 changes: 2 additions & 2 deletions zk/src/main/resources/web/js/zk/fmt/numfmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export let Number = {
var useMinsuFmt;
if (fmt.indexOf(';') != -1) {
var fmtArr = fmt.split(';');
useMinsuFmt = val < 0;
useMinsuFmt = (val as number) < 0;
fmt = fmtArr[useMinsuFmt ? 1 : 0];
}

Expand All @@ -106,7 +106,7 @@ export let Number = {
var pureFmtStr = efmt.pureFmtStr,
ind = efmt.purejdot,
fixed = ind >= 0 ? pureFmtStr.length - ind - 1 : 0,
valStr = (val + '').replace(/[^e\-0123456789.]/g, '').substring(val < 0 ? 1 : 0),
valStr = (val + '').replace(/[^e\-0123456789.]/g, '').substring((val as number) < 0 ? 1 : 0),
ei = valStr.lastIndexOf('e'),
indVal = valStr.indexOf('.'),
valFixed = indVal >= 0 ? (ei < 0 ? valStr.length : ei) - indVal - 1 : 0,
Expand Down
1 change: 1 addition & 0 deletions zk/src/main/resources/web/js/zk/pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ export function afterLoad(func: CallableFunction): boolean
* @see {@link load}
*/
export function afterLoad(pkgs: string, func: CallableFunction, front?: boolean): void
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
export function afterLoad(a: string | CallableFunction, b?: CallableFunction, front?: boolean): boolean | void {
if (typeof a == 'string') {
if (!b) return true;
Expand Down
19 changes: 9 additions & 10 deletions zk/src/main/resources/web/js/zk/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ function _unlistenFlex(wgt: zk.Widget): void {
* It is the low-level utility reserved for overriding for advanced customization.
*/
// zk scope
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export var DnD = class { //for easy overriding
/**
* @returns the drop target from the event, or the element from the event's
Expand Down Expand Up @@ -2818,8 +2817,8 @@ new zul.wnd.Window({
this._zIndex = zIndex;
var n = this.$n();
if (n) {
n.style.zIndex = zIndex >= 0 ? (zIndex as string) : '';
if (opts && opts.fire) this.fire('onZIndex', (zIndex > 0 || zIndex === 0) ? zIndex : -1, {ignorable: true});
n.style.zIndex = (zIndex as number) >= 0 ? (zIndex as string) : '';
if (opts && opts.fire) this.fire('onZIndex', ((zIndex as number) > 0 || zIndex === 0) ? zIndex : -1, {ignorable: true});
}
}
return this;
Expand Down Expand Up @@ -3085,7 +3084,7 @@ new zul.wnd.Window({
if ((!no || !no.top) && (s = this.getTop()))
out += 'top:' + s + ';';
let zIndex;
if ((!no || !no.zIndex) && (zIndex = this.getZIndex()) >= 0)
if ((!no || !no.zIndex) && ((zIndex = this.getZIndex() as number)) >= 0)
out += 'z-index:' + zIndex + ';';
return DOMPurify.sanitize(out);
}
Expand Down Expand Up @@ -3364,11 +3363,11 @@ new zul.wnd.Window({
rerender(skipper?: Skipper | number): this
rerender(skipper?: Skipper | number): this {
if (this.desktop) {
if (!skipper || skipper > 0) { //default: 0
if (!skipper || (skipper as number) > 0) { //default: 0
_rerender(this, typeof skipper === 'number' ? skipper : 0);
return this;
}
if (skipper < 0)
if ((skipper as number) < 0)
skipper = undefined; //negative -> immediately

var n = this.$n();
Expand Down Expand Up @@ -4983,7 +4982,7 @@ new zul.wnd.Window({
if (fn) {
inf[listener] = bklsns[listener]
// eslint-disable-next-line no-new-func
= typeof fn != 'function' ? new Function('var event=arguments[0];' + fn) : fn;
= typeof fn != 'function' ? new Function('var event=arguments[0];' + (fn as string)) : fn;
this.listen(inf);
}
return this;
Expand All @@ -5000,7 +4999,7 @@ new zul.wnd.Window({
if (fn) {
inf[listener0] = bklsns[listener0]
// eslint-disable-next-line no-new-func
= typeof fn != 'function' ? new Function('var event=arguments[0];' + fn) : fn;
= typeof fn != 'function' ? new Function('var event=arguments[0];' + (fn as string)) : fn;
this.listen(inf);
}
return this;
Expand Down Expand Up @@ -6666,7 +6665,7 @@ export namespace widget_global {
var widget = zk.Widget.$(n, opts);
if (widget)
return widget.$service();
zk.error('Not found ZK Service with [' + n + ']');
zk.error('Not found ZK Service with [' + String(n) + ']');
return undefined;
}
};
Expand Down Expand Up @@ -6993,7 +6992,7 @@ export var NoDOM = class NoDOM {
var context = this.$getInterceptorContext$();
for (var w = this.firstChild; w; w = w.nextSibling) {
if (visible)
w.setDomVisible_(w.$n()!, w.isVisible()!, opts);
w.setDomVisible_(w.$n()!, w.isVisible(), opts);
else
w.setDomVisible_(w.$n()!, visible, opts);
}
Expand Down
2 changes: 1 addition & 1 deletion zk/src/main/resources/web/js/zk/zswipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class Swipe extends zk.Object {
// eslint-disable-next-line @typescript-eslint/dot-notation
this.node = node ? jq(node, zk)[0] as HTMLElement | undefined : widget['node'] as HTMLElement | undefined || (widget.$n ? widget.$n() : undefined);
if (!this.node)
throw 'Handle required for ' + widget;
throw 'Handle required for ' + widget.uuid + ' on ' + widget.widgetName;

this.opts = zk.$default(opts, {
scrollThreshold: 5,
Expand Down
2 changes: 1 addition & 1 deletion zk/src/main/resources/web/js/zk/zuml/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function _create0(parent: zk.Widget, e: HTMLElement, args: unknown, cwgts: zk.Wi
} else if ('attribute' == tn) {
var attnm = _eval(parent, e.getAttribute('name'), args);
if (!attnm)
throw 'The name attribute required, ' + e;
throw 'The name attribute required, for ' + tn;
parent.set(attnm, zk.xml.Utl.getElementValue(e));
return;
} else {
Expand Down
2 changes: 1 addition & 1 deletion zkbind/src/main/resources/web/js/zkbind/Binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function $(n: string | HTMLElement | zk.Event | JQuery.Event, opts?: Bind
var widget = zk.Widget.$(n, opts);
if (widget)
return widget.$binder();
zk.error('Not found ZK Binder with [' + n + ']');
zk.error('Not found ZK Binder with [' + String(n) + ']');
}
zkbind.$ = $;

Expand Down
4 changes: 2 additions & 2 deletions zul/src/main/resources/web/js/zul/mesh/MeshWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function _calcMinWd(wgt: MeshWidget): MeshWidth {
wd = ftwd;
wds[i] = wd;
// Bug ZK-2772 don't plus one when frozen exists.
if (!wgt.frozen && (zk.ff! > 4 || zk.safari)) // firefox4 & IE9, 10, 11 & safari still cause break line in case B50-3147926 column 1
if (!wgt.frozen && ((zk.ff as number) > 4 || zk.safari)) // firefox4 & IE9, 10, 11 & safari still cause break line in case B50-3147926 column 1
++wds[i];
width += wds[i]; // using wds[i] instead of wd for B50-3183172.zul
if (w)
Expand All @@ -152,7 +152,7 @@ function _calcMinWd(wgt: MeshWidget): MeshWidth {
wds[i] = wd;

// Bug ZK-2772 don't plus one when frozen exists.
if (!wgt.frozen && (zk.ff! > 4)) // firefox4 & IE9, 10, 11 still cause break line in case B50-3147926 column 1
if (!wgt.frozen && ((zk.ff as number) > 4)) // firefox4 & IE9, 10, 11 still cause break line in case B50-3147926 column 1
++wds[i];
width += wds[i]; // using wds[i] instead of wd for B50-3183172.zul
}
Expand Down
2 changes: 1 addition & 1 deletion zul/src/main/resources/web/js/zul/sel/SelectWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export abstract class SelectWidget extends zul.mesh.MeshWidget {
zk(selectedItem).scrollIntoView(this.ebody);
}

if ((zk.edge_legacy || zk.ff! >= 4) && this.ebody && this._nativebar) { // B50-ZK-293: FF5 misses to fire onScroll
if ((zk.edge_legacy || (zk.ff as number) >= 4) && this.ebody && this._nativebar) { // B50-ZK-293: FF5 misses to fire onScroll
// B50-ZK-440: ebody can be null when ROD
this._currentTop = this.ebody.scrollTop;
this._currentLeft = this.ebody.scrollLeft;
Expand Down

0 comments on commit 5ab6941

Please sign in to comment.