Skip to content

Commit a637d32

Browse files
apply formatting rules (#30)
1 parent 153b817 commit a637d32

17 files changed

+72
-78
lines changed

.github/workflows/test.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ jobs:
122122
run: |
123123
cd tests
124124
yarn install --frozen-lockfile
125-
126-
- name: Install Cocoapods
125+
126+
- name: Install Cocoapods
127127
run: |
128128
cd tests/ios && pod install
129129

.mtslconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"ignore_dirs":[".git","node_modules","tests"]}
1+
{ "ignore_dirs": [".git", "node_modules", "tests"] }

.prettierignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Ignore all node_modules
2+
**/node_modules/**
3+
4+
# Autogenerated files
5+
**/.expo/**
6+
**/.next/**
7+
**/.idea/**
8+
**/.fleet/**
9+
10+
# Other
11+
**/android/**
12+
**/assets/**
13+
**/bin/**
14+
**/ios/**

.prettierrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"jsxBracketSameLine": true,
6+
"useTabs": false,
7+
"printWidth": 120,
8+
"trailingComma": "none"
9+
}

babel.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module.exports = {
33
plugins: [
44
'babel-plugin-transform-typescript-metadata',
55
['@babel/plugin-proposal-decorators', { legacy: true }],
6-
['@babel/plugin-proposal-class-properties', { loose: true }],
7-
],
6+
['@babel/plugin-proposal-class-properties', { loose: true }]
7+
]
88
};

package.json

+2-7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"scripts": {
3030
"build": "bob build",
3131
"clean": "rm -rf lib tsconfig.tsbuildinfo",
32+
"format": "prettier --write .",
3233
"typescript": "tsc --noEmit",
3334
"prepare": "bob build",
3435
"example": "yarn --cwd example",
@@ -50,6 +51,7 @@
5051
"@changesets/cli": "^2.26.2",
5152
"@types/lodash": "^4.14.200",
5253
"@types/uuid": "^9.0.1",
54+
"prettier": "^3.2.4",
5355
"react": "18.2.0",
5456
"react-native": "0.71.0",
5557
"react-native-builder-bob": "^0.18.2",
@@ -59,13 +61,6 @@
5961
"react": "*",
6062
"react-native": "*"
6163
},
62-
"prettier": {
63-
"quoteProps": "consistent",
64-
"singleQuote": true,
65-
"tabWidth": 2,
66-
"trailingComma": "es5",
67-
"useTabs": false
68-
},
6964
"react-native-builder-bob": {
7065
"source": "src",
7166
"output": "lib",

scripts/bootstrap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const options = {
77
cwd: process.cwd(),
88
env: process.env,
99
stdio: 'inherit',
10-
encoding: 'utf-8',
10+
encoding: 'utf-8'
1111
};
1212

1313
let result;

src/DBListenerManager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class DBListenerManagerInternal extends DBListenerManager {
5656
/**
5757
* COMMIT hooks occur before the commit is completed. This leads to race conditions.
5858
* Only use the rollback event to clear updates.
59-
*/
59+
*/
6060
case TransactionEvent.ROLLBACK:
6161
this.transactionReverted();
6262
break;

src/setup-open.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ export function setupOpen(QuickSQLite: ISQLite) {
117117
const res = await callback(context);
118118

119119
closeContextLock(dbName, id);
120-
resolve(res)
120+
resolve(res);
121121
} catch (ex) {
122122
closeContextLock(dbName, id);
123-
reject(ex)
123+
reject(ex);
124124
} finally {
125-
hooks?.lockReleased?.()
125+
hooks?.lockReleased?.();
126126
}
127127
}
128128
} as LockCallbackRecord);
@@ -236,4 +236,4 @@ export function setupOpen(QuickSQLite: ISQLite) {
236236
};
237237
}
238238
};
239-
}
239+
}

src/type-orm.ts

-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
// _________ _______ ______ ____ _____ __ __ _____ _____
2-
// |__ __\ \ / / __ \| ____/ __ \| __ \| \/ | /\ | __ \_ _|
3-
// | | \ \_/ /| |__) | |__ | | | | |__) | \ / | / \ | |__) || |
4-
// | | \ / | ___/| __|| | | | _ /| |\/| | / /\ \ | ___/ | |
5-
// | | | | | | | |___| |__| | | \ \| | | | / ____ \| | _| |_
6-
// |_| |_| |_| |______\____/|_| \_\_| |_| /_/ \_\_| |_____|
7-
8-
import _ from 'lodash';
91
import { QueryResult, TransactionContext, Open } from './types';
102

113
/**

tests/app.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
"resizeMode": "contain",
1212
"backgroundColor": "#ffffff"
1313
},
14-
"assetBundlePatterns": [
15-
"**/*"
16-
],
14+
"assetBundlePatterns": ["**/*"],
1715
"ios": {
1816
"supportsTablet": true,
1917
"bundleIdentifier": "com.reactnativequicksqlite.tests"

tests/babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function(api) {
1+
module.exports = function (api) {
22
api.cache(true);
33
return {
44
presets: ['babel-preset-expo'],

tests/metro.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ config.resolver.unstable_enableSymlinks = true;
2222
config.transformer.getTransformOptions = async () => ({
2323
transform: {
2424
experimentalImportSupport: false,
25-
inlineRequires: true,
26-
},
25+
inlineRequires: true
26+
}
2727
});
2828

29-
module.exports = config;
29+
module.exports = config;

tests/scripts/test.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@ program
5656

5757
program
5858
.command('run-ios')
59-
.option(
60-
'--simulatorName <name>',
61-
'The iOS simulator name (e.g., "iPhone 11")',
62-
DEFAULT_SIMULATOR_NAME
63-
)
59+
.option('--simulatorName <name>', 'The iOS simulator name (e.g., "iPhone 11")', DEFAULT_SIMULATOR_NAME)
6460
.option('--port', 'Port to run Express HTTP server for getting results on.', DEFAULT_PORT)
6561
.action(async (str, options) => {
6662
const opts = options.opts();
@@ -78,7 +74,7 @@ program
7874

7975
/** Listen for results */
8076
const server = app.listen(port);
81-
77+
8278
/** Build and run the Expo app, don't await this, we will await a response. */
8379
spawnP('Build Expo App', 'yarn', ['ios']);
8480

@@ -136,7 +132,7 @@ async function getADBDeviceName(avdName) {
136132
}
137133

138134
async function getSimulatorDeviceName(simulatorName) {
139-
try {
135+
try {
140136
const devicesOutput = await spawnP('List iOS Simulators', 'xcrun', ['simctl', 'list', 'devices', 'x']);
141137
const deviceNames = _.chain(devicesOutput.split('\n'))
142138
.map((line) => line.trim())

tests/tests/sqlite/rawQueries.spec.ts

+20-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ let db: QuickSQLiteConnection = global.db;
2323
const NUM_READ_CONNECTIONS = 3;
2424

2525
function generateUserInfo() {
26-
return { id: chance.integer(), name: chance.name(), age: chance.integer(), networth: chance.floating() };
26+
return {
27+
id: chance.integer(),
28+
name: chance.name(),
29+
age: chance.integer(),
30+
networth: chance.floating()
31+
};
2732
}
2833

2934
function createTestUser(context: { execute: (sql: string, args?: any[]) => Promise<QueryResult> } = db) {
@@ -59,7 +64,9 @@ export function registerBaseTests() {
5964
db.delete();
6065
}
6166

62-
global.db = db = open('test', { numReadConnections: NUM_READ_CONNECTIONS });
67+
global.db = db = open('test', {
68+
numReadConnections: NUM_READ_CONNECTIONS
69+
});
6370

6471
await db.execute('DROP TABLE IF EXISTS User; ');
6572
await db.execute('CREATE TABLE User ( id INT PRIMARY KEY, name TEXT NOT NULL, age INT, networth REAL) STRICT;');
@@ -480,7 +487,9 @@ export function registerBaseTests() {
480487
});
481488

482489
it('Should open a db without concurrency', async () => {
483-
const singleConnection = open('single_connection', { numReadConnections: 0 });
490+
const singleConnection = open('single_connection', {
491+
numReadConnections: 0
492+
});
484493

485494
const [p1, p2] = [
486495
singleConnection.writeLock(async () => {
@@ -570,9 +579,9 @@ export function registerBaseTests() {
570579
await db.writeLock(async (tx) => {
571580
await tx.execute('BEGIN');
572581
// Creates 100,000 Users
573-
for (let i = 0; i < numberOfUsers; i++) {
574-
await tx.execute('INSERT INTO User (id, name, age, networth) VALUES(?, ?, ?, ?)', [i, 'steven', i, 0])
575-
}
582+
for (let i = 0; i < numberOfUsers; i++) {
583+
await tx.execute('INSERT INTO User (id, name, age, networth) VALUES(?, ?, ?, ?)', [i, 'steven', i, 0]);
584+
}
576585
await tx.execute('COMMIT');
577586
});
578587

@@ -582,7 +591,9 @@ export function registerBaseTests() {
582591
});
583592

584593
it('Should attach DBs', async () => {
585-
const singleConnection = open('single_connection', { numReadConnections: 0 });
594+
const singleConnection = open('single_connection', {
595+
numReadConnections: 0
596+
});
586597
await singleConnection.execute('DROP TABLE IF EXISTS Places; ');
587598
await singleConnection.execute('CREATE TABLE Places ( id INT PRIMARY KEY, name TEXT NOT NULL) STRICT;');
588599
await singleConnection.execute('INSERT INTO "Places" (id, name) VALUES(0, "Beverly Hills")');
@@ -602,16 +613,12 @@ export function registerBaseTests() {
602613
let start = performance.now();
603614
for (let i = 0; i < 1000; ++i) {
604615
const n = randomIntFromInterval(0, 100000);
605-
await db.execute(`INSERT INTO t1(a, b, c) VALUES(?, ?, ?)`, [
606-
i + 1,
607-
n,
608-
numberName(n),
609-
]);
616+
await db.execute(`INSERT INTO t1(a, b, c) VALUES(?, ?, ?)`, [i + 1, n, numberName(n)]);
610617
}
611618
await db.execute('PRAGMA wal_checkpoint(RESTART)');
612619
let end = performance.now();
613620
let duration = end - start;
614-
621+
615622
expect(duration).lessThan(2000);
616623
});
617624
});

tests/tests/sqlite/utils.ts

+3-25
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,16 @@ export function assertAlways(condition: boolean) {
3737
}
3838
}
3939

40-
const digits = [
41-
'',
42-
'one',
43-
'two',
44-
'three',
45-
'four',
46-
'five',
47-
'six',
48-
'seven',
49-
'eight',
50-
'nine',
51-
];
40+
const digits = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
5241
const names100: string[] = [
5342
...digits,
54-
...[
55-
'ten',
56-
'eleven',
57-
'twelve',
58-
'thirteen',
59-
'fourteen',
60-
'fifteen',
61-
'sixteen',
62-
'seventeen',
63-
'eighteen',
64-
'nineteen',
65-
],
43+
...['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'],
6644
...digits.map((digit) => `twenty${digit != '' ? '-' + digit : ''}`),
6745
...digits.map((digit) => `thirty${digit != '' ? '-' + digit : ''}`),
6846
...digits.map((digit) => `forty${digit != '' ? '-' + digit : ''}`),
6947
...digits.map((digit) => `fifty${digit != '' ? '-' + digit : ''}`),
7048
...digits.map((digit) => `sixty${digit != '' ? '-' + digit : ''}`),
7149
...digits.map((digit) => `seventy${digit != '' ? '-' + digit : ''}`),
7250
...digits.map((digit) => `eighty${digit != '' ? '-' + digit : ''}`),
73-
...digits.map((digit) => `ninety${digit != '' ? '-' + digit : ''}`),
51+
...digits.map((digit) => `ninety${digit != '' ? '-' + digit : ''}`)
7452
];

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -4775,6 +4775,11 @@ prettier@^2.7.1:
47754775
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
47764776
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
47774777

4778+
prettier@^3.2.4:
4779+
version "3.2.5"
4780+
resolved "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz#e52bc3090586e824964a8813b09aba6233b28368"
4781+
integrity sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==
4782+
47784783
pretty-format@^26.5.2, pretty-format@^26.6.2:
47794784
version "26.6.2"
47804785
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93"

0 commit comments

Comments
 (0)