Skip to content

Commit 9613dde

Browse files
committed
chore: run lint
1 parent f01e8e8 commit 9613dde

19 files changed

+662
-595
lines changed

src/createElement.ts

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
import Vue from 'vue';
2-
import { currentVM, getCurrentVue } from './runtimeContext';
3-
import { defineComponentInstance } from './helper';
4-
import { warn } from './utils';
1+
import Vue from 'vue'
2+
import { currentVM, getCurrentVue } from './runtimeContext'
3+
import { defineComponentInstance } from './helper'
4+
import { warn } from './utils'
55

6-
type CreateElement = Vue['$createElement'];
6+
type CreateElement = Vue['$createElement']
77

8-
let fallbackCreateElement: CreateElement;
8+
let fallbackCreateElement: CreateElement
99

1010
const createElement: CreateElement = function createElement(...args: any) {
1111
if (!currentVM) {
12-
warn('`createElement()` has been called outside of render function.');
12+
warn('`createElement()` has been called outside of render function.')
1313
if (!fallbackCreateElement) {
14-
fallbackCreateElement = defineComponentInstance(getCurrentVue()).$createElement;
14+
fallbackCreateElement = defineComponentInstance(getCurrentVue())
15+
.$createElement
1516
}
1617

17-
return fallbackCreateElement.apply(fallbackCreateElement, args);
18+
return fallbackCreateElement.apply(fallbackCreateElement, args)
1819
}
1920

20-
return currentVM.$createElement.apply(currentVM, args);
21-
} as any;
21+
return currentVM.$createElement.apply(currentVM, args)
22+
} as any
2223

23-
export default createElement;
24+
export default createElement

src/env.d.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
import { VueConstructor } from 'vue';
2-
import { VfaState } from './vmStateManager';
3-
import { VueWatcher } from './apis/watch';
1+
import { VueConstructor } from 'vue'
2+
import { VfaState } from './vmStateManager'
3+
import { VueWatcher } from './apis/watch'
44

55
declare global {
66
interface Window {
7-
Vue: VueConstructor;
7+
Vue: VueConstructor
88
}
99
}
1010

1111
declare module 'vue/types/vue' {
1212
interface Vue {
13-
readonly _uid: number;
14-
readonly _data: Record<string, any>;
15-
_watchers: VueWatcher[];
16-
__secret_vfa_state__?: VfaState;
13+
readonly _uid: number
14+
readonly _data: Record<string, any>
15+
_watchers: VueWatcher[]
16+
__secret_vfa_state__?: VfaState
1717
}
1818

1919
interface VueConstructor {
20-
observable<T>(x: any): T;
20+
observable<T>(x: any): T
2121
util: {
22-
warn(msg: string, vm?: Vue);
22+
warn(msg: string, vm?: Vue)
2323
defineReactive(
2424
obj: Object,
2525
key: string,
2626
val: any,
2727
customSetter?: Function,
2828
shallow?: boolean
29-
);
30-
};
29+
)
30+
}
3131
}
3232
}

src/global.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// Global compile-time constants
2-
declare var __DEV__: boolean;
2+
declare var __DEV__: boolean

src/helper.ts

+26-23
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,73 @@
1-
import Vue, { VNode, ComponentOptions, VueConstructor } from 'vue';
2-
import { ComponentInstance } from './component';
3-
import { currentVue, getCurrentVM } from './runtimeContext';
4-
import { warn } from './utils';
1+
import Vue, { VNode, ComponentOptions, VueConstructor } from 'vue'
2+
import { ComponentInstance } from './component'
3+
import { currentVue, getCurrentVM } from './runtimeContext'
4+
import { warn } from './utils'
55

66
export function currentVMInFn(hook: string): ComponentInstance | null {
7-
const vm = getCurrentVM();
7+
const vm = getCurrentVM()
88
if (__DEV__ && !vm) {
99
warn(
1010
`${hook} is called when there is no active component instance to be ` +
1111
`associated with. ` +
1212
`Lifecycle injection APIs can only be used during execution of setup().`
13-
);
13+
)
1414
}
15-
return vm;
15+
return vm
1616
}
1717

1818
export function defineComponentInstance<V extends Vue = Vue>(
1919
Ctor: VueConstructor<V>,
2020
options: ComponentOptions<V> = {}
2121
) {
22-
const silent = Ctor.config.silent;
23-
Ctor.config.silent = true;
24-
const vm = new Ctor(options);
25-
Ctor.config.silent = silent;
26-
return vm;
22+
const silent = Ctor.config.silent
23+
Ctor.config.silent = true
24+
const vm = new Ctor(options)
25+
Ctor.config.silent = silent
26+
return vm
2727
}
2828

2929
export function isComponentInstance(obj: any) {
30-
return currentVue && obj instanceof currentVue;
30+
return currentVue && obj instanceof currentVue
3131
}
3232

3333
export function createSlotProxy(vm: ComponentInstance, slotName: string) {
3434
return (...args: any) => {
3535
if (!vm.$scopedSlots[slotName]) {
36-
return warn(`slots.${slotName}() got called outside of the "render()" scope`, vm);
36+
return warn(
37+
`slots.${slotName}() got called outside of the "render()" scope`,
38+
vm
39+
)
3740
}
3841

39-
return vm.$scopedSlots[slotName]!.apply(vm, args);
40-
};
42+
return vm.$scopedSlots[slotName]!.apply(vm, args)
43+
}
4144
}
4245

4346
export function resolveSlots(
4447
slots: { [key: string]: Function } | void,
4548
normalSlots: { [key: string]: VNode[] | undefined }
4649
): { [key: string]: true } {
47-
let res: { [key: string]: true };
50+
let res: { [key: string]: true }
4851
if (!slots) {
49-
res = {};
52+
res = {}
5053
} else if (slots._normalized) {
5154
// fast path 1: child component re-render only, parent did not change
52-
return slots._normalized as any;
55+
return slots._normalized as any
5356
} else {
54-
res = {};
57+
res = {}
5558
for (const key in slots) {
5659
if (slots[key] && key[0] !== '$') {
57-
res[key] = true;
60+
res[key] = true
5861
}
5962
}
6063
}
6164

6265
// expose normal slots on scopedSlots
6366
for (const key in normalSlots) {
6467
if (!(key in res)) {
65-
res[key] = true;
68+
res[key] = true
6669
}
6770
}
6871

69-
return res;
72+
return res
7073
}

src/index.ts

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
import Vue, { VueConstructor } from 'vue';
2-
import { Data, SetupFunction, SetupContext } from './component';
3-
import { currentVue } from './runtimeContext';
4-
import { install } from './install';
5-
import { mixin } from './setup';
1+
import Vue, { VueConstructor } from 'vue'
2+
import { Data, SetupFunction, SetupContext } from './component'
3+
import { currentVue } from './runtimeContext'
4+
import { install } from './install'
5+
import { mixin } from './setup'
66

77
declare module 'vue/types/options' {
88
interface ComponentOptions<V extends Vue> {
9-
setup?: SetupFunction<Data, Data>;
9+
setup?: SetupFunction<Data, Data>
1010
}
1111
}
1212

13-
const _install = (Vue: VueConstructor) => install(Vue, mixin);
13+
const _install = (Vue: VueConstructor) => install(Vue, mixin)
1414
const plugin = {
1515
install: _install,
16-
};
16+
}
1717
// Auto install if it is not done yet and `window` has `Vue`.
1818
// To allow users to avoid auto-installation in some cases,
1919
if (currentVue && typeof window !== 'undefined' && window.Vue) {
20-
_install(window.Vue);
20+
_install(window.Vue)
2121
}
2222

23-
export default plugin;
24-
export { default as createElement } from './createElement';
25-
export { SetupContext };
23+
export default plugin
24+
export { default as createElement } from './createElement'
25+
export { SetupContext }
2626
export {
2727
createComponent,
2828
defineComponent,
2929
ComponentRenderProxy,
3030
PropType,
3131
PropOptions,
32-
} from './component';
32+
} from './component'
3333
// For getting a hold of the interal instance in setup() - useful for advanced
3434
// plugins
35-
export { getCurrentVM as getCurrentInstance } from './runtimeContext';
35+
export { getCurrentVM as getCurrentInstance } from './runtimeContext'
3636

37-
export * from './apis/state';
38-
export * from './apis/lifecycle';
39-
export * from './apis/watch';
40-
export * from './apis/computed';
41-
export * from './apis/inject';
37+
export * from './apis/state'
38+
export * from './apis/lifecycle'
39+
export * from './apis/watch'
40+
export * from './apis/computed'
41+
export * from './apis/inject'

src/install.ts

+35-26
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,67 @@
1-
import { AnyObject } from './types/basic';
2-
import { hasSymbol, hasOwn, isPlainObject, assert } from './utils';
3-
import { isRef } from './reactivity';
4-
import { setCurrentVue, currentVue } from './runtimeContext';
5-
import { VueConstructor } from 'vue';
1+
import { AnyObject } from './types/basic'
2+
import { hasSymbol, hasOwn, isPlainObject, assert } from './utils'
3+
import { isRef } from './reactivity'
4+
import { setCurrentVue, currentVue } from './runtimeContext'
5+
import { VueConstructor } from 'vue'
66

77
/**
88
* Helper that recursively merges two data objects together.
99
*/
1010
function mergeData(from: AnyObject, to: AnyObject): Object {
11-
if (!from) return to;
12-
let key: any;
13-
let toVal: any;
14-
let fromVal: any;
11+
if (!from) return to
12+
let key: any
13+
let toVal: any
14+
let fromVal: any
1515

16-
const keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from);
16+
const keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from)
1717

1818
for (let i = 0; i < keys.length; i++) {
19-
key = keys[i];
19+
key = keys[i]
2020
// in case the object is already observed...
21-
if (key === '__ob__') continue;
22-
toVal = to[key];
23-
fromVal = from[key];
21+
if (key === '__ob__') continue
22+
toVal = to[key]
23+
fromVal = from[key]
2424
if (!hasOwn(to, key)) {
25-
to[key] = fromVal;
25+
to[key] = fromVal
2626
} else if (
2727
toVal !== fromVal &&
2828
isPlainObject(toVal) &&
2929
!isRef(toVal) &&
3030
isPlainObject(fromVal) &&
3131
!isRef(fromVal)
3232
) {
33-
mergeData(fromVal, toVal);
33+
mergeData(fromVal, toVal)
3434
}
3535
}
36-
return to;
36+
return to
3737
}
3838

39-
export function install(Vue: VueConstructor, _install: (Vue: VueConstructor) => void) {
39+
export function install(
40+
Vue: VueConstructor,
41+
_install: (Vue: VueConstructor) => void
42+
) {
4043
if (currentVue && currentVue === Vue) {
4144
if (__DEV__) {
42-
assert(false, 'already installed. Vue.use(plugin) should be called only once');
45+
assert(
46+
false,
47+
'already installed. Vue.use(plugin) should be called only once'
48+
)
4349
}
44-
return;
50+
return
4551
}
4652

47-
Vue.config.optionMergeStrategies.setup = function (parent: Function, child: Function) {
53+
Vue.config.optionMergeStrategies.setup = function (
54+
parent: Function,
55+
child: Function
56+
) {
4857
return function mergedSetupFn(props: any, context: any) {
4958
return mergeData(
5059
typeof parent === 'function' ? parent(props, context) || {} : {},
5160
typeof child === 'function' ? child(props, context) || {} : {}
52-
);
53-
};
54-
};
61+
)
62+
}
63+
}
5564

56-
setCurrentVue(Vue);
57-
_install(Vue);
65+
setCurrentVue(Vue)
66+
_install(Vue)
5867
}

src/runtimeContext.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import { VueConstructor } from 'vue';
2-
import { ComponentInstance } from './component';
3-
import { assert } from './utils';
1+
import { VueConstructor } from 'vue'
2+
import { ComponentInstance } from './component'
3+
import { assert } from './utils'
44

5-
let currentVue: VueConstructor | null = null;
6-
let currentVM: ComponentInstance | null = null;
5+
let currentVue: VueConstructor | null = null
6+
let currentVM: ComponentInstance | null = null
77

88
export function getCurrentVue(): VueConstructor {
99
if (__DEV__) {
10-
assert(currentVue, `must call Vue.use(plugin) before using any function.`);
10+
assert(currentVue, `must call Vue.use(plugin) before using any function.`)
1111
}
1212

13-
return currentVue!;
13+
return currentVue!
1414
}
1515

1616
export function setCurrentVue(vue: VueConstructor) {
17-
currentVue = vue;
17+
currentVue = vue
1818
}
1919

2020
export function getCurrentVM(): ComponentInstance | null {
21-
return currentVM;
21+
return currentVM
2222
}
2323

2424
export function setCurrentVM(vm: ComponentInstance | null) {
25-
currentVM = vm;
25+
currentVM = vm
2626
}
2727

28-
export { currentVue, currentVM };
28+
export { currentVue, currentVM }

0 commit comments

Comments
 (0)