mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 11:17:41 +00:00
[improvement] update eslint config (#2288)
This commit is contained in:
@@ -4,15 +4,15 @@
|
||||
import '../locale';
|
||||
import bem from '../mixins/bem';
|
||||
import i18n from '../mixins/i18n';
|
||||
import { isDef } from './';
|
||||
import { isDef } from '.';
|
||||
|
||||
function install(Vue) {
|
||||
Vue.component(this.name, this);
|
||||
};
|
||||
}
|
||||
|
||||
function returnArray() {
|
||||
return [];
|
||||
};
|
||||
}
|
||||
|
||||
function defaultProps(props) {
|
||||
Object.keys(props).forEach(key => {
|
||||
@@ -30,7 +30,7 @@ function defaultProps(props) {
|
||||
});
|
||||
}
|
||||
|
||||
export default function(sfc) {
|
||||
export default function (sfc) {
|
||||
sfc.name = 'van-' + sfc.name;
|
||||
sfc.install = sfc.install || install;
|
||||
sfc.mixins = sfc.mixins || [];
|
||||
|
@@ -7,7 +7,7 @@ import Loading from '../loading';
|
||||
import Cell from '../cell';
|
||||
import CellGroup from '../cell-group';
|
||||
|
||||
export default function(sfc) {
|
||||
export default function (sfc) {
|
||||
sfc.components = Object.assign(sfc.components || {}, {
|
||||
Icon,
|
||||
Loading,
|
||||
@@ -15,4 +15,4 @@ export default function(sfc) {
|
||||
CellGroup
|
||||
});
|
||||
return createBasic(sfc);
|
||||
};
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { isDef, isObj } from './';
|
||||
/* eslint-disable no-use-before-define */
|
||||
import { isDef, isObj } from '.';
|
||||
|
||||
const { hasOwnProperty } = Object.prototype;
|
||||
|
||||
@@ -17,10 +18,9 @@ function assignKey(to, from, key) {
|
||||
}
|
||||
|
||||
export default function assign(to, from) {
|
||||
for (const key in from) {
|
||||
if (hasOwnProperty.call(from, key)) {
|
||||
assignKey(to, from, key);
|
||||
}
|
||||
}
|
||||
Object.keys(from).forEach(key => {
|
||||
assignKey(to, from, key);
|
||||
});
|
||||
|
||||
return to;
|
||||
}
|
||||
|
@@ -3,7 +3,8 @@ import deepAssign from './deep-assign';
|
||||
export default function deepClone(obj) {
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(item => deepClone(item));
|
||||
} else if (typeof obj === 'object') {
|
||||
}
|
||||
if (typeof obj === 'object') {
|
||||
return deepAssign({}, obj);
|
||||
}
|
||||
return obj;
|
||||
|
@@ -1,6 +1,10 @@
|
||||
import { isServer } from './';
|
||||
/* eslint-disable no-empty */
|
||||
/* eslint-disable getter-return */
|
||||
/* eslint-disable import/no-mutable-exports */
|
||||
import { isServer } from '.';
|
||||
|
||||
export let supportsPassive = false;
|
||||
|
||||
if (!isServer) {
|
||||
try {
|
||||
const opts = {};
|
||||
|
@@ -34,7 +34,7 @@ function isAndroid() {
|
||||
|
||||
function range(num, min, max) {
|
||||
return Math.min(Math.max(num, min), max);
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
get,
|
||||
|
@@ -1,16 +1,16 @@
|
||||
import { isServer } from './';
|
||||
import { isServer } from '.';
|
||||
|
||||
export default {
|
||||
// get nearest scroll element
|
||||
getScrollEventTarget(element, rootParent = window) {
|
||||
let currentNode = element;
|
||||
let node = element;
|
||||
// bugfix, see http://w3help.org/zh-cn/causes/SD9013 and http://stackoverflow.com/questions/17016740/onscroll-function-is-not-working-for-chrome
|
||||
while (currentNode && currentNode.tagName !== 'HTML' && currentNode.tagName !== 'BODY' && currentNode.nodeType === 1 && currentNode !== rootParent) {
|
||||
const overflowY = this.getComputedStyle(currentNode).overflowY;
|
||||
while (node && node.tagName !== 'HTML' && node.tagName !== 'BODY' && node.nodeType === 1 && node !== rootParent) {
|
||||
const { overflowY } = this.getComputedStyle(node);
|
||||
if (overflowY === 'scroll' || overflowY === 'auto') {
|
||||
return currentNode;
|
||||
return node;
|
||||
}
|
||||
currentNode = currentNode.parentNode;
|
||||
node = node.parentNode;
|
||||
}
|
||||
return rootParent;
|
||||
},
|
||||
|
@@ -40,15 +40,15 @@ test('camelize', () => {
|
||||
|
||||
test('get', () => {
|
||||
expect(get({ a: 1 }, 'a')).toEqual(1);
|
||||
expect(get({ a: { b: 2 }}, 'a.b')).toEqual(2);
|
||||
expect(get({ a: { b: 2 }}, 'a.b.c')).toEqual('');
|
||||
expect(get({ a: { b: 2 } }, 'a.b')).toEqual(2);
|
||||
expect(get({ a: { b: 2 } }, 'a.b.c')).toEqual('');
|
||||
});
|
||||
|
||||
test('isAndroid', () => {
|
||||
expect(isAndroid()).toBeFalsy();
|
||||
});
|
||||
|
||||
test('raf', async() => {
|
||||
test('raf', async () => {
|
||||
const spy = jest.fn();
|
||||
raf(spy);
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
export default function mobile(value) {
|
||||
value = value.replace(/[^-|\d]/g, '');
|
||||
return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9\-]{10,13}$/.test(value);
|
||||
return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user