Skip to content

Commit 980e501

Browse files
committed
Lint cleanup
1 parent 4ed92cf commit 980e501

File tree

4 files changed

+50
-32
lines changed

4 files changed

+50
-32
lines changed

src/make-find-mixin.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default function makeFindMixin(options) {
8282
return providedParams
8383
} else {
8484
// Returning null fetchParams allows the query to be skipped.
85-
return (fetchParams || fetchParams === null) ? fetchParams : params
85+
return fetchParams || fetchParams === null ? fetchParams : params
8686
}
8787
}
8888

@@ -100,7 +100,10 @@ export default function makeFindMixin(options) {
100100

101101
// If both queries are provided, we're not using fall-through pagination.
102102
// User can pass `paginate: false` to force old behavior with a single query.
103-
if (this[FETCH_PARAMS] && this[PARAMS] || this[PARAMS] && this[PARAMS].paginate === false) {
103+
if (
104+
(this[FETCH_PARAMS] && this[PARAMS]) ||
105+
(this[PARAMS] && this[PARAMS].paginate === false)
106+
) {
104107
return this.$store.getters[`${serviceName}/find`](this[PARAMS]).data
105108
}
106109

@@ -113,7 +116,11 @@ export default function makeFindMixin(options) {
113116
const pagination = this[PAGINATION][params.qid || this[QID]] || {}
114117
const response = skip != null && limit != null ? { limit, skip } : {}
115118
const queryInfo = getQueryInfo(params, response)
116-
const items = getItemsFromQueryInfo(pagination, queryInfo, serviceState.keyedById)
119+
const items = getItemsFromQueryInfo(
120+
pagination,
121+
queryInfo,
122+
serviceState.keyedById
123+
)
117124

118125
if (items && items.length) {
119126
return items
@@ -149,9 +156,15 @@ export default function makeFindMixin(options) {
149156
const cachedDebounceFunction = this[`${FIND_ACTION}Debounced`]
150157
const mostRecentTime = this[`${FIND_ACTION}MostRecentDebounceTime`]
151158

152-
if (!cachedDebounceFunction || mostRecentTime != paramsToUse.debounce) {
159+
if (
160+
!cachedDebounceFunction ||
161+
mostRecentTime != paramsToUse.debounce
162+
) {
153163
this[`${FIND_ACTION}MostRecentDebounceTime`] = paramsToUse.debounce
154-
this[`${FIND_ACTION}Debounced`] = debounce(this[FIND_ACTION], paramsToUse.debounce)
164+
this[`${FIND_ACTION}Debounced`] = debounce(
165+
this[FIND_ACTION],
166+
paramsToUse.debounce
167+
)
155168
}
156169
return this[`${FIND_ACTION}Debounced`](paramsToUse)
157170
} else {
@@ -167,9 +180,10 @@ export default function makeFindMixin(options) {
167180
})
168181

169182
if (!this[LOCAL]) {
170-
const shouldExecuteQuery = typeof this[QUERY_WHEN] === 'function'
171-
? this[QUERY_WHEN](paramsToUse)
172-
: this[QUERY_WHEN]
183+
const shouldExecuteQuery =
184+
typeof this[QUERY_WHEN] === 'function'
185+
? this[QUERY_WHEN](paramsToUse)
186+
: this[QUERY_WHEN]
173187

174188
if (shouldExecuteQuery) {
175189
if (paramsToUse) {
@@ -212,7 +226,8 @@ export default function makeFindMixin(options) {
212226
const pagination = this[PAGINATION]
213227
const { qid, queryId, pageId } = getQueryInfo(params)
214228
const queryInfo = _get(pagination, `[${qid}][${queryId}]`) || {}
215-
const pageInfo = _get(pagination, `[${qid}][${queryId}][${pageId}]`) || {}
229+
const pageInfo =
230+
_get(pagination, `[${qid}][${queryId}][${pageId}]`) || {}
216231

217232
return { queryInfo, pageInfo }
218233
}

src/service-module/make-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export default function makeModel(options: FeathersVuexOptions) {
386386
return _merge({}, this)
387387
}
388388
}
389-
for (var n in EventEmitter.prototype) {
389+
for (const n in EventEmitter.prototype) {
390390
BaseModel[n] = EventEmitter.prototype[n]
391391
}
392392

src/utils.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ export function readCookie(cookies, name) {
105105
if (!cookies) {
106106
return undefined
107107
}
108-
var nameEQ = name + '='
109-
var ca = cookies.split(';')
110-
for (var i = 0; i < ca.length; i++) {
111-
var c = ca[i]
108+
const nameEQ = name + '='
109+
const ca = cookies.split(';')
110+
for (let i = 0; i < ca.length; i++) {
111+
let c = ca[i]
112112
while (c.charAt(0) === ' ') {
113113
c = c.substring(1, c.length)
114114
}
@@ -142,7 +142,7 @@ const authDefaults = {
142142
export function getValidPayloadFromToken(token) {
143143
if (token) {
144144
try {
145-
var payload = decode(token)
145+
const payload = decode(token)
146146
return payloadIsValid(payload) ? payload : undefined
147147
} catch (error) {
148148
return undefined
@@ -240,7 +240,7 @@ export function getModelName(Model) {
240240

241241
export function registerModel(Model, globalModels, apiPrefix, servicePath) {
242242
const modelName = getModelName(Model)
243-
let path = apiPrefix ? `${apiPrefix}.${modelName}` : modelName
243+
const path = apiPrefix ? `${apiPrefix}.${modelName}` : modelName
244244

245245
setByDot(globalModels, path, Model)
246246
globalModels.byServicePath[servicePath] = Model
@@ -284,7 +284,8 @@ export function updateOriginal(original, newData) {
284284
// If the old prop is null or undefined, and the new prop is neither
285285
} else if (
286286
(oldProp === null || oldProp === undefined) &&
287-
(newProp !== null && newProp !== undefined)
287+
newProp !== null &&
288+
newProp !== undefined
288289
) {
289290
shouldCopyProp = true
290291
// If both old and new are arrays
@@ -310,7 +311,10 @@ export function updateOriginal(original, newData) {
310311
})
311312
}
312313

313-
export function getQueryInfo(params: Params = {}, response: Partial<Pick<Paginated<any>, 'limit' | 'skip'>> = {}) {
314+
export function getQueryInfo(
315+
params: Params = {},
316+
response: Partial<Pick<Paginated<any>, 'limit' | 'skip'>> = {}
317+
) {
314318
const query = params.query || {}
315319
const qid: string = params.qid || 'default'
316320
const $limit =
@@ -369,9 +373,7 @@ export function makeNamespace(namespace, servicePath, nameStyle) {
369373
export function getServicePath(service: Service<any>, Model: any) {
370374
if (!service.name && !service.path && !Model.servicePath) {
371375
throw new Error(
372-
`Service for model named ${
373-
Model.name
374-
} is missing a path or name property. The feathers adapter needs to be updated with a PR to expose this property. You can work around this by adding a static servicePath = passing a 'servicePath' attribute in the options: makeServicePlugin({servicePath: '/path/to/my/service'})`
376+
`Service for model named ${Model.name} is missing a path or name property. The feathers adapter needs to be updated with a PR to expose this property. You can work around this by adding a static servicePath = passing a 'servicePath' attribute in the options: makeServicePlugin({servicePath: '/path/to/my/service'})`
375377
)
376378
}
377379

@@ -380,7 +382,7 @@ export function getServicePath(service: Service<any>, Model: any) {
380382

381383
export function randomString(length) {
382384
let text = ''
383-
let possible =
385+
const possible =
384386
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
385387

386388
for (let i = 0; i < length; i++) {
@@ -413,8 +415,8 @@ export function mergeWithAccessors(
413415
) {
414416
const sourceProps = Object.getOwnPropertyNames(source)
415417
const destProps = Object.getOwnPropertyNames(dest)
416-
let sourceIsVueObservable = sourceProps.includes('__ob__')
417-
let destIsVueObservable = destProps.includes('__ob__')
418+
const sourceIsVueObservable = sourceProps.includes('__ob__')
419+
const destIsVueObservable = destProps.includes('__ob__')
418420
sourceProps.forEach(key => {
419421
const sourceDesc = Object.getOwnPropertyDescriptor(source, key)
420422
const destDesc = Object.getOwnPropertyDescriptor(dest, key)
@@ -505,7 +507,7 @@ export function checkNamespace(namespace, item, debug) {
505507
}
506508

507509
export function assignIfNotPresent(Model, props): void {
508-
for (let key in props) {
510+
for (const key in props) {
509511
if (!Model.hasOwnProperty(key)) {
510512
Model[key] = props[key]
511513
}

test/make-find-mixin.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,16 @@ function makeContext() {
2121

2222
class FindModel extends BaseModel {
2323
public static modelName = 'FindModel'
24-
public static test: boolean = true
24+
public static test = true
2525
}
2626

2727
return { FindModel, BaseModel, makeServicePlugin }
2828
}
2929

30-
// @ts-ignore
3130
Vue.use(Vuex)
32-
// @ts-ignore
3331
Vue.use(FeathersVuex)
3432

35-
describe('Find Mixin', function () {
33+
describe('Find Mixin', function() {
3634
const { makeServicePlugin, FindModel } = makeContext()
3735
const serviceName = 'todos'
3836
const store = new Vuex.Store({
@@ -44,7 +42,7 @@ describe('Find Mixin', function () {
4442
]
4543
})
4644

47-
it('correctly forms mixin data', function () {
45+
it('correctly forms mixin data', function() {
4846
const todosMixin = makeFindMixin({ service: 'todos' })
4947

5048
interface TodosComponent {
@@ -75,7 +73,10 @@ describe('Find Mixin', function () {
7573
)
7674
assert(vm.todosServiceName === 'todos', 'service name was correct')
7775
assert(vm.isFindTodosPending === false, 'loading boolean is in place')
78-
assert(vm.haveTodosBeenRequestedOnce === false, 'requested once boolean is in place')
76+
assert(
77+
vm.haveTodosBeenRequestedOnce === false,
78+
'requested once boolean is in place'
79+
)
7980
assert(vm.haveTodosLoadedOnce === false, 'loaded once boolean is in place')
8081
assert(typeof vm.findTodos === 'function', 'the find action is in place')
8182
assert(vm.todosLocal === false, 'local boolean is false by default')
@@ -95,7 +96,7 @@ describe('Find Mixin', function () {
9596
)
9697
})
9798

98-
it.skip('correctly forms mixin data for dynamic service', function () {
99+
it.skip('correctly forms mixin data for dynamic service', function() {
99100
const tasksMixin = makeFindMixin({
100101
service() {
101102
return this.serviceName

0 commit comments

Comments
 (0)