Skip to content

Commit be0ca45

Browse files
committed
chore(pinia-orm): Update lint rules & packages
1 parent a2e7b9d commit be0ca45

File tree

199 files changed

+3886
-4222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+3886
-4222
lines changed

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
]
7070
},
7171
"pnpm": {
72+
"packageExtensions": {
73+
"@vue/composition-api": {
74+
"peerDependencies": {
75+
"vue": "*"
76+
}
77+
}
78+
},
7279
"overrides": {
7380
"ufo": "^0.8.4",
7481
"std-env": "^3.1.1"

packages/nuxt/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,22 @@
4444
"pinia-orm": ">=1.6.7"
4545
},
4646
"dependencies": {
47-
"@nuxt/kit": "^3.5.2"
47+
"@nuxt/kit": "^3.7.0"
4848
},
4949
"devDependencies": {
50-
"@nuxt/devtools": "^0.5.5",
51-
"@nuxt/module-builder": "^0.4.0",
50+
"@nuxt/devtools": "^0.8.2",
51+
"@nuxt/module-builder": "^0.5.0",
5252
"@nuxt/schema": "^3.5.2",
5353
"@nuxtjs/eslint-config-typescript": "^12.0.0",
5454
"@pinia/nuxt": "^0.4.11",
5555
"@types/prettier": "^2.7.2",
5656
"eslint": "^8.41.0",
57-
"nuxt": "^3.3.2",
57+
"nuxt": "^3.7.0",
5858
"pinia": "^2.1.3",
5959
"pinia-orm": "^1.0.0",
6060
"prettier": "^3.0.0",
6161
"std-env": "^3.3.3",
62-
"typescript": "^5.0.4",
62+
"typescript": "^5.2.2",
6363
"vite": "^4.3.9",
6464
"vue": "^3.3.4"
6565
},

packages/pinia-orm/.eslintrc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
{
2-
"extends": "@antfu",
2+
"extends": "@nuxtjs/eslint-config-typescript",
3+
"parser": "@typescript-eslint/parser",
34
"rules": {
5+
"no-useless-constructor": "off",
6+
"no-use-before-define": "off",
47
"no-self-compare": "off",
8+
"func-call-spacing": "off",
59
"no-console": [
610
"warn",
7-
{ "allow": ["clear", "info", "error", "dir", "trace", "log", "time", "timeEnd"] }
11+
{ "allow": ["clear", "info", "error", "dir", "trace", "time", "timeEnd", "warn"] }
812
]
913
}
1014
}

packages/pinia-orm/build.config.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,22 @@ export default defineBuildConfig({
1313
{ input: 'src/packages/nanoid/async', name: 'nanoid/async' },
1414
{ input: 'src/packages/nanoid/non-secure', name: 'nanoid/non-secure' },
1515
{ input: 'src/packages/uuid/v1', name: 'uuid/v1' },
16-
{ input: 'src/packages/uuid/v4', name: 'uuid/v4' },
16+
{ input: 'src/packages/uuid/v4', name: 'uuid/v4' }
1717
],
1818
declaration: true,
1919
failOnWarn: false,
2020
clean: true,
2121
externals: ['@/composables', 'nanoid', 'uuid', 'nanoid/async', 'nanoid/non-secure', 'pinia'],
2222
rollup: {
23-
emitCJS: true,
23+
emitCJS: true
2424
},
2525
hooks: {
2626
'build:done': (ctx) => {
2727
ctx.buildEntries.filter(entry => entry.path.includes('.cjs') && !entry.path.includes('shared')).forEach((entry) => {
2828
fs.rename(`${ctx.options.outDir}/${entry.path}`, `${ctx.options.outDir}/${entry.path}`.replace('cjs', 'js'), (err) => {
29-
if (err)
30-
console.log(`ERROR: ${err}`)
29+
if (err) { console.error(`ERROR: ${err}`) }
3130
})
3231
})
33-
},
34-
},
32+
}
33+
}
3534
})

packages/pinia-orm/package.json

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,20 @@
6363
"@pinia-orm/normalizr": ">=1.6.0"
6464
},
6565
"devDependencies": {
66-
"@antfu/eslint-config": "^0.39.3",
66+
"@nuxtjs/eslint-config-typescript": "^12.1.0",
6767
"@pinia/testing": "^0.1.2",
6868
"@size-limit/preset-small-lib": "^8.2.4",
6969
"@types/node": "^18.16.16",
7070
"@types/prettier": "^2.7.2",
7171
"@types/uuid": "^9.0.1",
72-
"@vitest/coverage-c8": "^0.31.2",
72+
"@typescript-eslint/parser": "^6.5.1-alpha.11",
73+
"@vitest/coverage-v8": "^0.34.3",
7374
"@vitest/ui": "^0.31.2",
7475
"@vue/composition-api": "^1.7.1",
7576
"@vue/test-utils": "^2.3.2",
7677
"c8": "^8.0.0",
7778
"core-js": "^3.30.2",
78-
"eslint": "^8.41.0",
79+
"eslint": "^8.48.0",
7980
"happy-dom": "^10.0.3",
8081
"mkdist": "^1.2.0",
8182
"nanoid": "^4.0.2",
@@ -84,11 +85,11 @@
8485
"size-limit": "^8.2.4",
8586
"std-env": "^3.3.3",
8687
"tsup": "^7.0.0",
87-
"typescript": "^5.0.4",
88+
"typescript": "^5.2.2",
8889
"unbuild": "^2.0.0",
8990
"uuid": "^9.0.0",
9091
"vite": "^4.3.9",
91-
"vitest": "^0.31.2",
92+
"vitest": "^0.34.3",
9293
"vue": "^3.3.4",
9394
"vue-demi": "^0.14.5",
9495
"vue2": "npm:vue@^2.7.3"
@@ -121,14 +122,5 @@
121122
"bugs": {
122123
"url": "https://github.com/CodeDredd/pinia-orm/issues"
123124
},
124-
"homepage": "https://github.com/CodeDredd/pinia-orm#readme",
125-
"pnpm": {
126-
"packageExtensions": {
127-
"@vue/composition-api": {
128-
"peerDependencies": {
129-
"vue": "*"
130-
}
131-
}
132-
}
133-
}
125+
"homepage": "https://github.com/CodeDredd/pinia-orm#readme"
134126
}

packages/pinia-orm/src/cache/SimpleCache.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ export interface StoredData<T> {
88
const DEFAULT_EXPIRATION_SECONDS = 5 * 60
99

1010
export class SimpleCache {
11-
constructor(private cache = new Map()) {}
11+
constructor (private cache = new Map()) {}
1212

13-
clear(): void {
13+
clear (): void {
1414
this.cache = new Map()
1515
}
1616

17-
size(): number {
17+
size (): number {
1818
return this.cache.size
1919
}
2020

21-
private computeExpirationTime(expiresInSeconds: number): number {
21+
private computeExpirationTime (expiresInSeconds: number): number {
2222
return new Date().getTime() + expiresInSeconds * 1000
2323
}
2424

2525
// Store the data in memory and attach to the object expiration containing the
2626
// expiration time.
27-
set<T>({ key, data, expiration = DEFAULT_EXPIRATION_SECONDS }: StoredData<T>): T {
27+
set<T> ({ key, data, expiration = DEFAULT_EXPIRATION_SECONDS }: StoredData<T>): T {
2828
this.cache.set(key, { data, expiration: this.computeExpirationTime(expiration) })
2929

3030
return data
3131
}
3232

3333
// Will get specific data from the Map object based on a key and return null if
3434
// the data has expired.
35-
get<T>(key: string): T | null {
35+
get<T> (key: string): T | null {
3636
if (this.cache.has(key)) {
3737
const { data, expiration } = this.cache.get(key) as StoredData<T>
3838

@@ -42,7 +42,7 @@ export class SimpleCache {
4242
return null
4343
}
4444

45-
private hasExpired(expiration: number): boolean {
45+
private hasExpired (expiration: number): boolean {
4646
return expiration < new Date().getTime()
4747
}
4848
}

packages/pinia-orm/src/cache/WeakCache.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,49 @@ export class WeakCache<K, V extends object> implements Map<K, V> {
44

55
#map = new Map<K, WeakRef<V>>()
66

7-
has(key: K) {
7+
has (key: K) {
88
return !!(this.#map.has(key) && this.#map.get(key)?.deref())
99
}
1010

11-
get(key: K): V {
11+
get (key: K): V {
1212
const weakRef = this.#map.get(key)
13-
if (!weakRef)
13+
if (!weakRef) {
1414
// @ts-expect-error object has no undefined
1515
return undefined
16+
}
1617

1718
const value = weakRef.deref()
18-
if (value)
19-
return value
19+
if (value) { return value }
2020

2121
// If it cant be dereference, remove the key
2222
this.#map.delete(key)
2323
// @ts-expect-error object has no undefined
2424
return undefined
2525
}
2626

27-
set(key: K, value: V) {
27+
set (key: K, value: V) {
2828
this.#map.set(key, new WeakRef<V>(value))
2929
return this
3030
}
3131

32-
get size(): number {
32+
get size (): number {
3333
return this.#map.size
3434
}
3535

36-
clear(): void {
36+
clear (): void {
3737
this.#map.clear()
3838
}
3939

40-
delete(key: K): boolean {
40+
delete (key: K): boolean {
4141
this.#map.delete(key)
4242
return false
4343
}
4444

45-
forEach(cb: (value: V, key: K, map: Map<K, V>) => void): void {
46-
for (const [key, value] of this) cb(value, key, this)
45+
forEach (cb: (value: V, key: K, map: Map<K, V>) => void): void {
46+
for (const [key, value] of this) { cb(value, key, this) }
4747
}
4848

49-
* [Symbol.iterator](): IterableIterator<[K, V]> {
49+
* [Symbol.iterator] (): IterableIterator<[K, V]> {
5050
for (const [key, weakRef] of this.#map) {
5151
const ref = weakRef.deref()
5252

@@ -59,15 +59,15 @@ export class WeakCache<K, V extends object> implements Map<K, V> {
5959
}
6060
}
6161

62-
* entries(): IterableIterator<[K, V]> {
63-
for (const [key, value] of this) yield [key, value]
62+
* entries (): IterableIterator<[K, V]> {
63+
for (const [key, value] of this) { yield [key, value] }
6464
}
6565

66-
* keys(): IterableIterator<K> {
67-
for (const [key] of this) yield key
66+
* keys (): IterableIterator<K> {
67+
for (const [key] of this) { yield key }
6868
}
6969

70-
* values(): IterableIterator<V> {
71-
for (const [, value] of this) yield value
70+
* values (): IterableIterator<V> {
71+
for (const [, value] of this) { yield value }
7272
}
7373
}

packages/pinia-orm/src/composables/collection/useCollect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ export interface UseCollect<M extends Model = Model> {
2222
/**
2323
* Return all possible helper functions for the collection
2424
*/
25-
export function useCollect<M extends Model = Model>(models: Collection<M>): UseCollect<M> {
25+
export function useCollect<M extends Model = Model> (models: Collection<M>): UseCollect<M> {
2626
return {
2727
sum: field => useSum(models, field),
2828
min: field => useMin(models, field),
2929
max: field => useMax(models, field),
3030
pluck: field => usePluck(models, field),
3131
groupBy: fields => useGroupBy(models, fields),
3232
sortBy: (sort, flags: SortFlags = 'SORT_REGULAR') => useSortBy(models, sort, flags),
33-
keys: () => useKeys(models),
33+
keys: () => useKeys(models)
3434
}
3535
}

packages/pinia-orm/src/composables/collection/useGroupBy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* The useGroupBy method groups the collection's items by a given key.
33
*/
4-
export function useGroupBy<T extends Record<string, any>>(models: T[], fields: string[] | string): Record<string, T[]> {
4+
export function useGroupBy<T extends Record<string, any>> (models: T[], fields: string[] | string): Record<string, T[]> {
55
const grouped: Record<string, T[]> = {}
66
const props = Array.isArray(fields) ? fields : [fields]
77

packages/pinia-orm/src/composables/collection/useKeys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import type { Collection } from '../../../src'
33
/**
44
* The keys method returns all of the collection's primary keys
55
*/
6-
export function useKeys(models: Collection): string[] {
6+
export function useKeys (models: Collection): string[] {
77
return models.map(model => model[model.$getLocalKey()])
88
}

0 commit comments

Comments
 (0)