Skip to content

Commit cbf754f

Browse files
committed
chore(core): lint --fix
1 parent 1e4c70c commit cbf754f

File tree

8 files changed

+151
-140
lines changed

8 files changed

+151
-140
lines changed

packages/@posva/vuefire-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"pretest": "npm run lint",
2525
"test": "npm run unit",
2626
"unit": "jest",
27-
"lint": "eslint --fix --ext=js,html src test",
27+
"lint": "eslint --fix src test",
2828
"dev": "npm run unit -- --watchAll"
2929
},
3030
"bugs": {

packages/@posva/vuefire-core/src/index.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createSnapshot, extractRefs, callOnceWithArg, walkGet, walkSet } from './utils'
22

3-
function unsubscribeAll(subs) {
3+
function unsubscribeAll (subs) {
44
for (const sub in subs) {
55
subs[sub].unsub()
66
}
@@ -9,7 +9,7 @@ function unsubscribeAll(subs) {
99
// NOTE not convinced by the naming of subscribeToRefs and subscribeToDocument
1010
// first one is calling the other on every ref and subscribeToDocument may call
1111
// updateDataFromDocumentSnapshot which may call subscribeToRefs as well
12-
function subscribeToRefs({ subs, refs, target, path, data, depth, ops, resolve }, options) {
12+
function subscribeToRefs ({ subs, refs, target, path, data, depth, ops, resolve }, options) {
1313
const refKeys = Object.keys(refs)
1414
const missingKeys = Object.keys(subs).filter(refKey => refKeys.indexOf(refKey) < 0)
1515
// unbind keys that are no longer there
@@ -22,7 +22,7 @@ function subscribeToRefs({ subs, refs, target, path, data, depth, ops, resolve }
2222
let resolvedCount = 0
2323
const totalToResolve = refKeys.length
2424
const validResolves = Object.create(null)
25-
function deepResolve(key) {
25+
function deepResolve (key) {
2626
if (key in validResolves) {
2727
if (++resolvedCount >= totalToResolve) resolve(path)
2828
}
@@ -50,16 +50,16 @@ function subscribeToRefs({ subs, refs, target, path, data, depth, ops, resolve }
5050
path: docPath,
5151
depth,
5252
ops,
53-
resolve: deepResolve.bind(null, docPath),
53+
resolve: deepResolve.bind(null, docPath)
5454
},
5555
options
5656
),
57-
path: ref.path,
57+
path: ref.path
5858
}
5959
})
6060
}
6161

62-
export function bindCollection(
62+
export function bindCollection (
6363
{ vm, key, collection, ops, resolve, reject },
6464
options = { maxRefDepth: 2 }
6565
) {
@@ -92,7 +92,7 @@ export function bindCollection(
9292
path: newIndex,
9393
depth: 0,
9494
ops,
95-
resolve: resolve.bind(null, doc),
95+
resolve: resolve.bind(null, doc)
9696
},
9797
options
9898
)
@@ -117,7 +117,7 @@ export function bindCollection(
117117
target: array,
118118
path: newIndex,
119119
depth: 0,
120-
resolve,
120+
resolve
121121
},
122122
options
123123
)
@@ -127,7 +127,7 @@ export function bindCollection(
127127
ops.remove(array, oldIndex)
128128
// array.splice(oldIndex, 1)
129129
unsubscribeAll(arraySubs.splice(oldIndex, 1)[0])
130-
},
130+
}
131131
}
132132

133133
const unbind = collection.onSnapshot(ref => {
@@ -171,7 +171,7 @@ export function bindCollection(
171171
}
172172
}
173173

174-
function updateDataFromDocumentSnapshot(
174+
function updateDataFromDocumentSnapshot (
175175
{ snapshot, target, path, subs, ops, depth = 0, resolve },
176176
options = { maxRefDepth: 2 }
177177
) {
@@ -188,13 +188,13 @@ function updateDataFromDocumentSnapshot(
188188
path,
189189
ops,
190190
depth,
191-
resolve,
191+
resolve
192192
},
193193
options
194194
)
195195
}
196196

197-
function subscribeToDocument({ ref, target, path, depth, resolve, ops }, options) {
197+
function subscribeToDocument ({ ref, target, path, depth, resolve, ops }, options) {
198198
const subs = Object.create(null)
199199
const unbind = ref.onSnapshot(doc => {
200200
if (doc.exists) {
@@ -206,7 +206,7 @@ function subscribeToDocument({ ref, target, path, depth, resolve, ops }, options
206206
ops,
207207
subs,
208208
depth,
209-
resolve,
209+
resolve
210210
},
211211
options
212212
)
@@ -234,7 +234,7 @@ function subscribeToDocument({ ref, target, path, depth, resolve, ops }, options
234234
* @param {OperationsType<any>} ops
235235
* @param {*} options
236236
*/
237-
export function bindDocument({ vm, key, document, resolve, reject, ops }, options) {
237+
export function bindDocument ({ vm, key, document, resolve, reject, ops }, options) {
238238
// TODO warning check if key exists?
239239
// const boundRefs = Object.create(null)
240240

@@ -252,7 +252,7 @@ export function bindDocument({ vm, key, document, resolve, reject, ops }, option
252252
path: key,
253253
subs,
254254
ops,
255-
resolve,
255+
resolve
256256
},
257257
options
258258
)

packages/@posva/vuefire-core/src/utils.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* @param {firebase.firestore.DocumentSnapshot} doc
77
* @return {DocumentData}
88
*/
9-
export function createSnapshot(doc) {
9+
export function createSnapshot (doc) {
1010
// defaults everything to false, so no need to set
1111
return Object.defineProperty(doc.data(), 'id', {
12-
value: doc.id,
12+
value: doc.id
1313
})
1414
}
1515

@@ -18,7 +18,7 @@ export function createSnapshot(doc) {
1818
* @param {any} o
1919
* @returns {boolean}
2020
*/
21-
function isObject(o) {
21+
function isObject (o) {
2222
return o && typeof o === 'object'
2323
}
2424

@@ -28,7 +28,7 @@ function isObject(o) {
2828
* should be o is Date https://github.com/Microsoft/TypeScript/issues/26297
2929
* @returns {boolean}
3030
*/
31-
function isTimestamp(o) {
31+
function isTimestamp (o) {
3232
return o.toDate
3333
}
3434

@@ -37,7 +37,7 @@ function isTimestamp(o) {
3737
* @param {*} o
3838
* @returns {boolean}
3939
*/
40-
function isRef(o) {
40+
function isRef (o) {
4141
return o && o.onSnapshot
4242
}
4343

@@ -49,7 +49,7 @@ function isRef(o) {
4949
* @param {[firebase.firestore.DocumentData, Record<string, Reference>]} result
5050
* @returns {[firebase.firestore.DocumentData, Record<string, Reference>]}
5151
*/
52-
export function extractRefs(doc, oldDoc = {}, path = '', result = [{}, {}]) {
52+
export function extractRefs (doc, oldDoc = {}, path = '', result = [{}, {}]) {
5353
// must be set here because walkGet can return null or undefined
5454
oldDoc = oldDoc || {}
5555
const idDescriptor = Object.getOwnPropertyDescriptor(doc, 'id')
@@ -92,7 +92,7 @@ export function extractRefs(doc, oldDoc = {}, path = '', result = [{}, {}]) {
9292
* @param {() => T} argFn
9393
* @returns {() => K | undefined}
9494
*/
95-
export function callOnceWithArg(fn, argFn) {
95+
export function callOnceWithArg (fn, argFn) {
9696
/** @type {boolean | undefined} */
9797
let called
9898
return () => {
@@ -109,7 +109,7 @@ export function callOnceWithArg(fn, argFn) {
109109
* @param {string} path
110110
* @returns {any}
111111
*/
112-
export function walkGet(obj, path) {
112+
export function walkGet (obj, path) {
113113
return path.split('.').reduce((target, key) => target[key], obj)
114114
}
115115

@@ -120,7 +120,7 @@ export function walkGet(obj, path) {
120120
* @param {any} value
121121
* @returns
122122
*/
123-
export function walkSet(obj, path, value) {
123+
export function walkSet (obj, path, value) {
124124
// path can be a number
125125
const keys = ('' + path).split('.')
126126
const key = keys.pop()

packages/@posva/vuefire-core/test/collection.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('collections', () => {
7676
configurable: false,
7777
enumerable: false,
7878
writable: false,
79-
value: `u${i}`,
79+
value: `u${i}`
8080
})
8181
})
8282
})

packages/@posva/vuefire-core/test/document.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('documents', () => {
4242
configurable: false,
4343
enumerable: false,
4444
writable: false,
45-
value: 'some-id',
45+
value: 'some-id'
4646
})
4747
})
4848

packages/@posva/vuefire-core/test/refs-collections.spec.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('refs in collections', () => {
88
items: null,
99
a: null,
1010
b: null,
11-
c: null,
11+
c: null
1212
}
1313
ops = createOps(walkSet)
1414
bind = (key, collection, options) => {
@@ -29,7 +29,7 @@ describe('refs in collections', () => {
2929
it('binds refs on collections', async () => {
3030
await bind('items', collection)
3131

32-
expect(vm.items).toEqual([{ ref: { isA: true } }, { ref: { isB: true } }])
32+
expect(vm.items).toEqual([{ ref: { isA: true }}, { ref: { isB: true }}])
3333
})
3434

3535
it('waits for array to be fully populated', async () => {
@@ -42,9 +42,9 @@ describe('refs in collections', () => {
4242

4343
expect(data).toEqual(vm.items)
4444
expect(vm.items).toEqual([
45-
{ ref: { isA: true } },
46-
{ ref: { isB: true } },
47-
{ ref: { isC: true } },
45+
{ ref: { isA: true }},
46+
{ ref: { isB: true }},
47+
{ ref: { isC: true }}
4848
])
4949
})
5050

@@ -58,9 +58,9 @@ describe('refs in collections', () => {
5858
await delay(5)
5959

6060
expect(vm.items).toEqual([
61-
{ ref: { isA: true } },
62-
{ ref: { isB: true } },
63-
{ ref: { isC: true } },
61+
{ ref: { isA: true }},
62+
{ ref: { isB: true }},
63+
{ ref: { isC: true }}
6464
])
6565
})
6666

@@ -87,7 +87,7 @@ describe('refs in collections', () => {
8787
it('unbinds nested refs when the collection is unbound', async () => {
8888
const items = db.collection()
8989
const spyA = spyUnbind(a)
90-
await items.add({ ref: { ref: a } })
90+
await items.add({ ref: { ref: a }})
9191
await bind('items', items)
9292

9393
expect(spyA).toHaveBeenCalledTimes(0)
@@ -127,7 +127,7 @@ describe('refs in collections', () => {
127127
await first.update({ newThing: true })
128128
await delay(5)
129129

130-
expect(vm.items).toEqual([{ ref: { isA: true }, newThing: true }, { ref: { isB: true } }])
130+
expect(vm.items).toEqual([{ ref: { isA: true }, newThing: true }, { ref: { isB: true }}])
131131
})
132132

133133
it('keeps old data of refs when modifying an item', async () => {
@@ -136,7 +136,7 @@ describe('refs in collections', () => {
136136

137137
expect(vm.items[0]).toEqual({
138138
ref: { isA: true },
139-
newThing: true,
139+
newThing: true
140140
})
141141
})
142142

@@ -156,9 +156,9 @@ describe('refs in collections', () => {
156156
expect(vm.items).toEqual([
157157
{
158158
a: {
159-
b: b.path,
160-
},
161-
},
159+
b: b.path
160+
}
161+
}
162162
])
163163

164164
await bind('items', collection, { maxRefDepth: 3 })
@@ -167,11 +167,11 @@ describe('refs in collections', () => {
167167
a: {
168168
b: {
169169
c: {
170-
d: d.path,
171-
},
172-
},
173-
},
174-
},
170+
d: d.path
171+
}
172+
}
173+
}
174+
}
175175
])
176176
})
177177

@@ -190,13 +190,13 @@ describe('refs in collections', () => {
190190
item: {
191191
item: {
192192
item: {
193-
item: item.path,
194-
},
195-
},
196-
},
197-
},
198-
},
199-
},
193+
item: item.path
194+
}
195+
}
196+
}
197+
}
198+
}
199+
}
200200
])
201201
})
202202
})

0 commit comments

Comments
 (0)