mirror of
https://github.com/youzan/vant.git
synced 2026-04-02 02:01:00 +08:00
feat(eslint-config): extends typescript-eslint recommended (#6076)
This commit is contained in:
@@ -13,7 +13,7 @@ function assignKey(to: ObjectIndex, from: ObjectIndex, key: string) {
|
||||
if (!hasOwnProperty.call(to, key) || !isObject(val)) {
|
||||
to[key] = val;
|
||||
} else {
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
to[key] = deepAssign(Object(to[key]), from[key]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ function fallback(fn: FrameRequestCallback): number {
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
const root = <Window>(isServer ? global : window);
|
||||
const root = (isServer ? global : window) as Window;
|
||||
|
||||
/* istanbul ignore next */
|
||||
const iRaf = root.requestAnimationFrame || fallback;
|
||||
|
||||
@@ -19,21 +19,21 @@ export function getScroller(el: HTMLElement, root: ScrollElement = window) {
|
||||
) {
|
||||
const { overflowY } = window.getComputedStyle(node);
|
||||
|
||||
if (overflowScrollReg.test(<string>overflowY)) {
|
||||
if (overflowScrollReg.test(overflowY)) {
|
||||
if (node.tagName !== 'BODY') {
|
||||
return node;
|
||||
}
|
||||
|
||||
// see: https://github.com/youzan/vant/issues/3823
|
||||
const { overflowY: htmlOverflowY } = window.getComputedStyle(
|
||||
<Element>node.parentNode
|
||||
node.parentNode as Element
|
||||
);
|
||||
|
||||
if (overflowScrollReg.test(<string>htmlOverflowY)) {
|
||||
if (overflowScrollReg.test(htmlOverflowY)) {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
node = <HTMLElement>node.parentNode;
|
||||
node = node.parentNode as HTMLElement;
|
||||
}
|
||||
|
||||
return root;
|
||||
|
||||
@@ -5,6 +5,7 @@ export { addUnit } from './format/unit';
|
||||
|
||||
export const isServer: boolean = Vue.prototype.$isServer;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
export function noop() {}
|
||||
|
||||
export function isDef(val: any): boolean {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { deepClone } from '../deep-clone';
|
||||
import { deepAssign } from '../deep-assign';
|
||||
import { isDef, get } from '..';
|
||||
import { isDef, get, noop } from '..';
|
||||
import { raf, cancelRaf } from '../dom/raf';
|
||||
import { later } from '../../../test';
|
||||
import { isEmail } from '../validate/email';
|
||||
@@ -12,22 +12,19 @@ import { camelize } from '../format/string';
|
||||
test('deepClone', () => {
|
||||
const a = { foo: 0 };
|
||||
const b = { foo: 0, bar: 1 };
|
||||
const fn = () => {};
|
||||
const arr = [a, b];
|
||||
expect(deepClone(a)).toEqual(a);
|
||||
expect(deepClone(b)).toEqual(b);
|
||||
expect(deepClone(fn)).toEqual(fn);
|
||||
expect(deepClone(noop)).toEqual(noop);
|
||||
expect(deepClone(arr)).toEqual(arr);
|
||||
expect(deepClone(undefined)).toEqual(undefined);
|
||||
expect(deepClone(1)).toEqual(1);
|
||||
});
|
||||
|
||||
test('deepAssign', () => {
|
||||
const fn = () => {};
|
||||
|
||||
expect(deepAssign({}, { foo: null })).toEqual({});
|
||||
expect(deepAssign({}, { foo: undefined })).toEqual({});
|
||||
expect(deepAssign({ fn: null }, { fn })).toEqual({ fn });
|
||||
expect(deepAssign({ noop: null }, { noop })).toEqual({ noop });
|
||||
expect(deepAssign({ foo: 0 }, { bar: 1 })).toEqual({ foo: 0, bar: 1 });
|
||||
expect(
|
||||
deepAssign({ foo: { bar: false } }, { foo: { bar: true, foo: false } })
|
||||
@@ -45,7 +42,7 @@ test('isDef', () => {
|
||||
expect(isDef(1)).toBeTruthy();
|
||||
expect(isDef('1')).toBeTruthy();
|
||||
expect(isDef({})).toBeTruthy();
|
||||
expect(isDef(() => {})).toBeTruthy();
|
||||
expect(isDef(noop)).toBeTruthy();
|
||||
});
|
||||
|
||||
test('camelize', () => {
|
||||
|
||||
Reference in New Issue
Block a user