Skip to content

Commit 4a13a74

Browse files
committed
fix: ts and lint
1 parent 6161d79 commit 4a13a74

File tree

9 files changed

+56
-56
lines changed

9 files changed

+56
-56
lines changed

example/src/Database.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {DataSource} from 'typeorm'
2-
import type {QueryResult} from 'react-native-quick-sqlite'
3-
import {typeORMDriver} from 'react-native-quick-sqlite'
4-
import {Book} from './model/Book'
5-
import {User} from './model/User'
1+
import { DataSource } from 'typeorm'
2+
import type { QueryResult } from 'react-native-quick-sqlite'
3+
import { typeORMDriver } from 'react-native-quick-sqlite'
4+
import { Book } from './model/Book'
5+
import { User } from './model/User'
66
let datasource: DataSource
77

88
export async function typeORMInit() {

example/src/screens/BenchmarkScreen.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ export const BenchmarkScreen: React.FC<Props> = () => {
105105
const startBenchmarks = useCallback(async () => {
106106
console.log('START BENCHMARKS')
107107

108-
setResults({});
109-
setIsLoading(true);
110-
console.log('--------- BEGINNING NitroSQLite BENCHMARKS ---------');
108+
setResults({})
109+
setIsLoading(true)
110+
console.log('--------- BEGINNING NitroSQLite BENCHMARKS ---------')
111111

112112
async function start(i = 0): Promise<void> {
113113
const benchmark = benchmarks[i]!
@@ -121,9 +121,9 @@ export const BenchmarkScreen: React.FC<Props> = () => {
121121

122122
await start()
123123

124-
console.log('--------- FINISHED NitroSQLite BENCHMARKS! ---------');
125-
setIsLoading(false);
126-
}, []);
124+
console.log('--------- FINISHED NitroSQLite BENCHMARKS! ---------')
125+
setIsLoading(false)
126+
}, [])
127127

128128
const Results = useMemo(
129129
() =>

example/src/screens/HomeScreen.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from 'react'
2-
import {ScrollView, Text, TouchableOpacity} from 'react-native'
3-
import type {NativeStackScreenProps} from '@react-navigation/native-stack'
4-
import type {ParamList} from '../navigation'
5-
import {StatusBar} from 'expo-status-bar'
6-
import {ScreenStyles} from '../styles'
2+
import { ScrollView, Text, TouchableOpacity } from 'react-native'
3+
import type { NativeStackScreenProps } from '@react-navigation/native-stack'
4+
import type { ParamList } from '../navigation'
5+
import { StatusBar } from 'expo-status-bar'
6+
import { ScreenStyles } from '../styles'
77

88
type Props = NativeStackScreenProps<ParamList, 'NitroSQLite Example'>
99

10-
export const HomeScreen: React.FC<Props> = ({navigation}) => {
10+
export const HomeScreen: React.FC<Props> = ({ navigation }) => {
1111
return (
1212
<ScrollView contentContainerStyle={ScreenStyles.container}>
1313
<TouchableOpacity onPress={() => navigation.navigate('Unit Tests')}>

example/src/screens/UnitTestScreen.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, {useEffect, useState} from 'react'
2-
import {ScrollView, Text} from 'react-native'
3-
import type {MochaTestResult} from '../tests/MochaSetup'
4-
import {runTests} from '../tests/MochaSetup'
5-
import {registerUnitTests} from '../tests/unitTests.spec'
6-
import {ScreenStyles} from '../styles'
1+
import React, { useEffect, useState } from 'react'
2+
import { ScrollView, Text } from 'react-native'
3+
import type { MochaTestResult } from '../tests/MochaSetup'
4+
import { runTests } from '../tests/MochaSetup'
5+
import { registerUnitTests } from '../tests/unitTests.spec'
6+
import { ScreenStyles } from '../styles'
77

88
export const UnitTestScreen: React.FC = () => {
99
const [results, setResults] = useState<MochaTestResult[]>([])
@@ -21,8 +21,9 @@ export const UnitTestScreen: React.FC = () => {
2121
contentContainerStyle={[
2222
ScreenStyles.container,
2323
// eslint-disable-next-line react-native/no-inline-styles
24-
{alignItems: 'flex-start'},
25-
]}>
24+
{ alignItems: 'flex-start' },
25+
]}
26+
>
2627
{results.map((r, i) => {
2728
if (r.type === 'grouping') return <Text key={i}>{r.description}</Text>
2829

example/src/tests/db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
QuickSQLiteConnection,
44
BatchQueryCommand,
55
} from 'react-native-quick-sqlite'
6-
import {open} from 'react-native-quick-sqlite'
6+
import { open } from 'react-native-quick-sqlite'
77

88
const chance = new Chance()
99

example/src/tests/typeorm.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type {Repository} from 'typeorm'
2-
import {DataSource} from 'typeorm'
3-
import {beforeAll, it, describe, beforeEachAsync} from './MochaRNAdapter'
4-
import {typeORMDriver} from 'react-native-quick-sqlite'
5-
import {User} from '../model/User'
6-
import {Book} from '../model/Book'
1+
import type { Repository } from 'typeorm'
2+
import { DataSource } from 'typeorm'
3+
import { beforeAll, it, describe, beforeEachAsync } from './MochaRNAdapter'
4+
import { typeORMDriver } from 'react-native-quick-sqlite'
5+
import { User } from '../model/User'
6+
import { Book } from '../model/Book'
77
import chai from 'chai'
88

99
const expect = chai.expect
@@ -14,7 +14,7 @@ let bookRepository: Repository<Book>
1414

1515
export function registerTypeORMTests() {
1616
describe('Typeorm tests', () => {
17-
beforeAll(done => {
17+
beforeAll((done) => {
1818
dataSource = new DataSource({
1919
type: 'react-native',
2020
database: 'typeormDb.sqlite',
@@ -31,7 +31,7 @@ export function registerTypeORMTests() {
3131
bookRepository = dataSource.getRepository(Book)
3232
done()
3333
})
34-
.catch(e => {
34+
.catch((e) => {
3535
console.error('error initializing typeORM datasource', e)
3636
throw e
3737
})

example/src/tests/unitTests.spec.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import type {
33
QuickSQLiteConnection,
44
BatchQueryCommand,
55
} from 'react-native-quick-sqlite'
6-
import {beforeEach, describe, it} from './MochaRNAdapter'
6+
import { beforeEach, describe, it } from './MochaRNAdapter'
77
import chai from 'chai'
8-
import {testDb as testDbInternal, resetTestDb} from './db'
8+
import { testDb as testDbInternal, resetTestDb } from './db'
9+
import { User } from '../model/User'
910

1011
function isError(e: unknown): e is Error {
1112
return e instanceof Error
@@ -129,7 +130,7 @@ export function registerUnitTests() {
129130
const age = chance.integer()
130131
const networth = chance.floating()
131132

132-
await testDb.transaction(tx => {
133+
await testDb.transaction((tx) => {
133134
const res = tx.execute(
134135
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
135136
[id, name, age, networth]
@@ -159,7 +160,7 @@ export function registerUnitTests() {
159160
const age = chance.integer()
160161
const networth = chance.floating()
161162

162-
await testDb.transaction(tx => {
163+
await testDb.transaction((tx) => {
163164
const res = tx.execute(
164165
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
165166
[id, name, age, networth]
@@ -198,7 +199,7 @@ export function registerUnitTests() {
198199
// ACT: Start multiple transactions to upsert and select the same record
199200
const promises = []
200201
for (let iteration = 1; iteration <= iterations; iteration++) {
201-
const promised = testDb.transaction(tx => {
202+
const promised = testDb.transaction((tx) => {
202203
// ACT: Upsert statement to create record / increment the value
203204
tx.execute(
204205
`
@@ -245,7 +246,7 @@ export function registerUnitTests() {
245246
const age = chance.integer()
246247
const networth = chance.floating()
247248

248-
await testDb.transaction(tx => {
249+
await testDb.transaction((tx) => {
249250
const res = tx.execute(
250251
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
251252
[id, name, age, networth]
@@ -283,7 +284,7 @@ export function registerUnitTests() {
283284
const age = chance.integer()
284285
const networth = chance.floating()
285286

286-
await testDb.transaction(tx => {
287+
await testDb.transaction((tx) => {
287288
try {
288289
tx.execute(
289290
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
@@ -319,7 +320,7 @@ export function registerUnitTests() {
319320
const age = chance.integer()
320321
const networth = chance.floating()
321322

322-
await testDb.transaction(tx => {
323+
await testDb.transaction((tx) => {
323324
tx.execute(
324325
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
325326
[id, name, age, networth]
@@ -347,7 +348,7 @@ export function registerUnitTests() {
347348
})
348349

349350
it('Transaction, rejects on invalid query', async () => {
350-
const promised = testDb.transaction(tx => {
351+
const promised = testDb.transaction((tx) => {
351352
tx.execute('SELECT * FROM [tableThatDoesNotExist];')
352353
})
353354
// ASSERT: should return a promise that eventually rejects
@@ -364,8 +365,8 @@ export function registerUnitTests() {
364365

365366
it('Transaction, handle async callback', async () => {
366367
let ranCallback = false
367-
const promised = testDb.transaction(async tx => {
368-
await new Promise<void>(done => {
368+
const promised = testDb.transaction(async (tx) => {
369+
await new Promise<void>((done) => {
369370
setTimeout(() => done(), 50)
370371
})
371372
tx.execute('SELECT * FROM [User];')
@@ -384,7 +385,7 @@ export function registerUnitTests() {
384385
const age = chance.integer()
385386
const networth = chance.floating()
386387

387-
await testDb.transaction(async tx => {
388+
await testDb.transaction(async (tx) => {
388389
const res = await tx.executeAsync(
389390
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
390391
[id, name, age, networth]
@@ -415,7 +416,7 @@ export function registerUnitTests() {
415416
const networth = chance.floating()
416417

417418
try {
418-
await testDb.transaction(async tx => {
419+
await testDb.transaction(async (tx) => {
419420
await tx.executeAsync(
420421
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
421422
[id, name, age, networth]
@@ -441,7 +442,7 @@ export function registerUnitTests() {
441442
const age = chance.integer()
442443
const networth = chance.floating()
443444

444-
await testDb.transaction(async tx => {
445+
await testDb.transaction(async (tx) => {
445446
await tx.executeAsync(
446447
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
447448
[id, name, age, networth]
@@ -466,7 +467,7 @@ export function registerUnitTests() {
466467
const age = chance.integer()
467468
const networth = chance.floating()
468469

469-
await testDb.transaction(async tx => {
470+
await testDb.transaction(async (tx) => {
470471
await tx.executeAsync(
471472
'INSERT INTO "User" (id, name, age, networth) VALUES(?, ?, ?, ?)',
472473
[id, name, age, networth]
@@ -491,7 +492,7 @@ export function registerUnitTests() {
491492
// ACT: Start multiple async transactions to upsert and select the same record
492493
const promises = []
493494
for (let iteration = 1; iteration <= iterations; iteration++) {
494-
const promised = testDb.transaction(async tx => {
495+
const promised = testDb.transaction(async (tx) => {
495496
// ACT: Upsert statement to create record / increment the value
496497
await tx.executeAsync(
497498
`
@@ -549,7 +550,7 @@ export function registerUnitTests() {
549550
})
550551

551552
it('Async transaction, rejects on invalid query', async () => {
552-
const promised = testDb.transaction(async tx => {
553+
const promised = testDb.transaction(async (tx) => {
553554
await tx.executeAsync('SELECT * FROM [tableThatDoesNotExist];')
554555
})
555556

@@ -592,7 +593,7 @@ export function registerUnitTests() {
592593

593594
const res = testDb.execute('SELECT * FROM User')
594595
expect(res.rows?._array).to.eql([
595-
{id: id1, name: name1, age: age1, networth: networth1},
596+
{ id: id1, name: name1, age: age1, networth: networth1 },
596597
{
597598
id: id2,
598599
name: name2,
@@ -628,7 +629,7 @@ export function registerUnitTests() {
628629

629630
const res = testDb.execute('SELECT * FROM User')
630631
expect(res.rows?._array).to.eql([
631-
{id: id1, name: name1, age: age1, networth: networth1},
632+
{ id: id1, name: name1, age: age1, networth: networth1 },
632633
{
633634
id: id2,
634635
name: name2,

package/src/operations/transaction.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export const transaction = (
9999

100100
throw executionError
101101
} finally {
102-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
103102
locks[dbName]!.inProgress = false
104103
isFinalized = false
105104
startNextTransaction(dbName)
@@ -128,7 +127,7 @@ function startNextTransaction(dbName: string) {
128127

129128
if (locks[dbName].queue.length > 0) {
130129
locks[dbName].inProgress = true
131-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
130+
132131
const tx = locks[dbName].queue.shift()!
133132
setImmediate(() => {
134133
tx.start()

package/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export interface QuickSQLiteConnection {
1717
loadFileAsync(location: string): Promise<FileLoadResult>
1818
}
1919

20-
// eslint-disable-next-line no-restricted-syntax
2120
export enum ColumnType {
2221
BOOLEAN,
2322
NUMBER,

0 commit comments

Comments
 (0)