Skip to content

Commit c17caad

Browse files
committed
linting and benchmark
1 parent 6153915 commit c17caad

15 files changed

Lines changed: 1000 additions & 680 deletions

.editorconfig

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# Top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
indent_style = space
9+
indent_size = 2
10+
end_of_line = lf
11+
charset = utf-8
12+
trim_trailing_whitespace = true
13+
insert_final_newline = true
14+
15+
# Matches multiple files with the same settings
16+
[*.js]
17+
indent_size = 2
18+
19+
[*.json]
20+
indent_size = 2
21+
22+
[*.yml]
23+
indent_size = 2
24+
25+
[*.md]
26+
trim_trailing_whitespace = false
27+
indent_size = 2
28+
29+
[*.sql]
30+
indent_size = 2
31+
32+
# C/C++ files
33+
[*.cc]
34+
indent_size = 2
35+
indent_style = tab
36+
max_line_length = 100
37+
38+
[*.h]
39+
indent_size = 2
40+
indent_style = tab
41+
max_line_length = 100
42+
43+
# Makefile and GYP files use tabs
44+
[{Makefile,*.gyp}]
45+
indent_style = tab
46+
47+
# Dockerfiles
48+
[Dockerfile]
49+
indent_size = 2
50+
51+
# YAML files
52+
[*.yaml]
53+
indent_size = 2

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
"indent": ["error", 4],
99
"linebreak-style": ["error", "unix"],
1010
"semi": ["error", "always"],
11-
"no-cond-assign": ["error", "always"]
11+
"no-cond-assign": ["error", "always"],
12+
"no-inner-declarations": "off"
1213
}
1314
};

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Mark SQLite database files as binary to prevent line ending conversions
2+
*.db binary
3+
*.sqlite binary
4+
*.sqlite3 binary

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"tar": "^7.5.10"
5151
},
5252
"devDependencies": {
53+
"benchmark": "^2.1.4",
5354
"eslint": "8.56.0",
5455
"mocha": "10.2.0",
5556
"prebuild": "13.0.1"
@@ -73,6 +74,7 @@
7374
"prebuild": "prebuild --runtime napi --all --verbose",
7475
"rebuild": "node-gyp rebuild",
7576
"upload": "prebuild --verbose --prerelease",
77+
"lint": "eslint lib/ test/ tools/",
7678
"test": "node test/support/createdb.js && mocha -R spec --timeout 480000"
7779
},
7880
"license": "BSD-3-Clause",

test/.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ module.exports = {
22
env: {
33
mocha: true,
44
},
5+
extends: '../.eslintrc.js',
6+
rules: {
7+
'no-unused-vars': 'off'
8+
}
59
};

test/async_calls.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"use strict"
1+
"use strict";
22

33
var sqlite3 = require('..');
44
const assert = require("assert");

test/patching.test.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var sqlite3 = require('..');
22
var assert = require('assert');
3+
var helper = require('./support/helper');
34

45
describe('patching', function() {
56
describe("Database", function() {
@@ -20,8 +21,8 @@ describe('patching', function() {
2021
it('allow patching native functions', function() {
2122
var myFun = function myFunction() {
2223
return "Success";
23-
}
24-
24+
};
25+
2526
assert.doesNotThrow(() => {
2627
sqlite3.Database.prototype.close = myFun;
2728
});
@@ -91,8 +92,8 @@ describe('patching', function() {
9192
it('allow patching native functions', function() {
9293
var myFun = function myFunction() {
9394
return "Success";
94-
}
95-
95+
};
96+
9697
assert.doesNotThrow(() => {
9798
sqlite3.Statement.prototype.bind = myFun;
9899
});
@@ -147,6 +148,10 @@ describe('patching', function() {
147148
var backup;
148149
var originalFunctions = {};
149150

151+
before(function () {
152+
helper.ensureExists('test/tmp');
153+
});
154+
150155
before(function() {
151156
originalFunctions.step = sqlite3.Backup.prototype.step;
152157
originalFunctions.finish = sqlite3.Backup.prototype.finish;
@@ -155,8 +160,8 @@ describe('patching', function() {
155160
it('allow patching native functions', function() {
156161
var myFun = function myFunction() {
157162
return "Success";
158-
}
159-
163+
};
164+
160165
assert.doesNotThrow(() => {
161166
sqlite3.Backup.prototype.step = myFun;
162167
});
@@ -165,7 +170,7 @@ describe('patching', function() {
165170
});
166171

167172
db = new sqlite3.Database(':memory:');
168-
backup = db.backup("somefile", myFun);
173+
backup = db.backup("test/tmp/patching_backup.db", myFun);
169174
assert.strictEqual(backup.step(), "Success");
170175
assert.strictEqual(backup.finish(), "Success");
171176
});
@@ -176,6 +181,7 @@ describe('patching', function() {
176181
sqlite3.Backup.prototype.finish = originalFunctions.finish;
177182
backup.finish();
178183
}
184+
helper.deleteFile('test/tmp/patching_backup.db');
179185
if(db != null) {
180186
db.close();
181187
}

test/support/createdb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function createdb(callback) {
1919
return str;
2020
}
2121

22-
// Make sure the file exists and is also valid.
22+
// Make sure the file exists and is also valid.
2323
if (existsSync(db_path) && statSync(db_path).size !== 0) {
2424
console.log('okay: database already created (' + db_path + ')');
2525
if (callback) callback();

test/unicode.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('unicode', function() {
7171
// Generate random data.
7272
var data = [];
7373
var length = Math.floor(Math.random() * 1000) + 200;
74-
for (var i = 0; i < length; i++) {
74+
for (i = 0; i < length; i++) {
7575
data.push(randomString());
7676
}
7777

tools/.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
extends: '../.eslintrc.js',
3+
rules: {
4+
'no-unused-vars': 'off'
5+
}
6+
};

0 commit comments

Comments
 (0)