Skip to content

Commit 3552c28

Browse files
authored
Merge pull request #706 from share/dev-dep-upgrades-2026
Update dev dependencies, replace Node 18 with Node 24 in CI
2 parents b6deed8 + 4e88e27 commit 3552c28

9 files changed

Lines changed: 141 additions & 116 deletions

File tree

.eslintrc.js

Lines changed: 0 additions & 67 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
strategy:
1616
matrix:
1717
node:
18-
- 18
1918
- 20
2019
- 22
20+
- 24
2121
services:
2222
mongodb:
2323
image: mongo:4.4

eslint.config.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
const js = require("@eslint/js");
2+
const {
3+
defineConfig,
4+
globalIgnores,
5+
} = require("eslint/config");
6+
const eslintConfigGoogle = require('eslint-config-google');
7+
8+
// The ESLint ecmaVersion argument is inconsistently used. Some rules will ignore it entirely, so if the rule has
9+
// been set, it will still error even if it's not applicable to that version number. Since Google sets these
10+
// rules, we have to turn them off ourselves.
11+
var DISABLED_ES6_OPTIONS = {
12+
'no-var': 'off',
13+
'prefer-rest-params': 'off'
14+
};
15+
16+
var SHAREDB_RULES = {
17+
// Comma dangle is not supported in ES3
18+
'comma-dangle': ['error', 'never'],
19+
// We control our own objects and prototypes, so no need for this check
20+
'guard-for-in': 'off',
21+
// Google prescribes different indents for different cases. Let's just use 2 spaces everywhere. Note that we have
22+
// to override ESLint's default of 0 indents for this.
23+
indent: ['error', 2, {
24+
SwitchCase: 1
25+
}],
26+
'linebreak-style': 'off',
27+
// Less aggressive line length than Google, which is especially useful when we have a lot of callbacks in our code
28+
'max-len': ['error',
29+
{
30+
code: 120,
31+
tabWidth: 2,
32+
ignoreUrls: true
33+
}
34+
],
35+
// Google overrides the default ESLint behaviour here, which is slightly better for catching erroneously unused
36+
// variables
37+
'no-unused-vars': ['error', {
38+
vars: 'all',
39+
args: 'after-used',
40+
// This can be removed once the minimum ES version is ES2019 or newer, and catch statements
41+
// are updated to use optional catch binding.
42+
caughtErrors: 'none',
43+
}],
44+
// It's more readable to ensure we only have one statement per line
45+
'max-statements-per-line': ['error', { max: 1 }],
46+
// ES3 doesn't support spread
47+
'prefer-spread': 'off',
48+
// as-needed quote props are easier to write
49+
'quote-props': ['error', 'as-needed'],
50+
'require-jsdoc': 'off',
51+
'valid-jsdoc': 'off',
52+
};
53+
54+
module.exports = defineConfig([
55+
{
56+
extends: [eslintConfigGoogle],
57+
ignores: ['eslint.config.js'],
58+
59+
languageOptions: {
60+
ecmaVersion: 3,
61+
sourceType: "commonjs",
62+
63+
parserOptions: {
64+
allowReserved: true,
65+
},
66+
},
67+
68+
rules: Object.assign({}, DISABLED_ES6_OPTIONS, SHAREDB_RULES),
69+
},
70+
globalIgnores(["docs/"]),
71+
{
72+
files: ["examples/counter-json1-vite/*.js"],
73+
74+
languageOptions: {
75+
ecmaVersion: 2015,
76+
sourceType: "module",
77+
78+
parserOptions: {
79+
allowReserved: false,
80+
},
81+
},
82+
83+
rules: {
84+
quotes: ["error", "single"],
85+
},
86+
}
87+
]);

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
"ot-json0": "^1.1.0"
1212
},
1313
"devDependencies": {
14-
"chai": "^4.3.7",
15-
"coveralls": "^3.1.1",
16-
"eslint": "^8.47.0",
14+
"@eslint/js": "^10.0.1",
15+
"chai": "^6.2.2",
16+
"eslint": "^10.1.0",
1717
"eslint-config-google": "^0.14.0",
18-
"mocha": "^10.2.0",
19-
"nyc": "^15.1.0",
18+
"mocha": "^11.7.5",
19+
"nyc": "^18.0.0",
2020
"ot-json0-v2": "https://github.com/ottypes/json0#90a3ae26364c4fa3b19b6df34dad46707a704421",
2121
"ot-json1": "^1.0.2",
2222
"rich-text": "^4.1.0",
2323
"sharedb-legacy": "npm:sharedb@1.1.0",
24-
"sinon": "^15.2.0",
25-
"sinon-chai": "^3.7.0"
24+
"sinon": "^21.0.3",
25+
"sinon-chai": "^4.0.1"
2626
},
2727
"files": [
2828
"lib/",
@@ -34,8 +34,8 @@
3434
"docs:start": "cd docs && bundle exec jekyll serve --livereload",
3535
"test": "mocha",
3636
"test-cover": "nyc --temp-dir=coverage -r text -r lcov npm test",
37-
"lint": "./node_modules/.bin/eslint --ignore-path .gitignore '**/*.js'",
38-
"lint:fix": "npm run lint -- --fix"
37+
"lint": "eslint",
38+
"lint:fix": "eslint --fix"
3939
},
4040
"repository": {
4141
"type": "git",

test/.jshintrc

Lines changed: 0 additions & 22 deletions
This file was deleted.

test/client/query-subscribe.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ module.exports = function(options) {
1313
});
1414

1515
afterEach(function() {
16+
if (sinon.clock) {
17+
sinon.clock.uninstall();
18+
}
1619
sinon.restore();
1720
});
1821

@@ -517,7 +520,7 @@ function commonTests(options) {
517520
});
518521

519522
it('pollDebounce option reduces subsequent poll interval', function(done) {
520-
var clock = sinon.useFakeTimers();
523+
var clock = util.useFakeTimers();
521524
var connection = this.backend.connect();
522525
this.backend.db.canPollDoc = function() {
523526
return false;
@@ -539,7 +542,7 @@ function commonTests(options) {
539542
connection.get('items', i.toString()).on('error', done).create({}, function(err) {
540543
if (err) return done(err);
541544
counter++;
542-
if (counter === 9) clock.tickAsync(10000);
545+
if (counter === 9) clock.tick(10000);
543546
});
544547
}
545548
}
@@ -561,12 +564,12 @@ function commonTests(options) {
561564
// event firing the first time, while sharedb is definitely
562565
// debouncing
563566
connection.get('items', '0').on('error', done).create({}, function() {
564-
clock.tickAsync(3000);
567+
clock.tick(3000);
565568
});
566569
});
567570

568571
it('db.pollDebounce option reduces subsequent poll interval', function(done) {
569-
var clock = sinon.useFakeTimers();
572+
var clock = util.useFakeTimers();
570573
var connection = this.backend.connect();
571574
this.backend.db.canPollDoc = function() {
572575
return false;
@@ -589,7 +592,7 @@ function commonTests(options) {
589592
connection.get('items', i.toString()).on('error', done).create({}, function(err) {
590593
if (err) return done(err);
591594
counter++;
592-
if (counter === 9) clock.tickAsync(10000);
595+
if (counter === 9) clock.tick(10000);
593596
});
594597
}
595598
}
@@ -611,12 +614,12 @@ function commonTests(options) {
611614
// event firing the first time, while sharedb is definitely
612615
// debouncing
613616
connection.get('items', '0').on('error', done).create({}, function() {
614-
clock.tickAsync(3000);
617+
clock.tick(3000);
615618
});
616619
});
617620

618621
it('pollInterval updates a subscribed query after an unpublished create', function(done) {
619-
var clock = sinon.useFakeTimers();
622+
var clock = util.useFakeTimers();
620623
var connection = this.backend.connect();
621624
this.backend.suppressPublish = true;
622625
var query = connection.createSubscribeQuery(
@@ -626,7 +629,7 @@ function commonTests(options) {
626629
function(err) {
627630
if (err) return done(err);
628631
connection.get('dogs', 'fido').on('error', done).create({}, function() {
629-
clock.tickAsync(51);
632+
clock.tick(51);
630633
});
631634
}
632635
);
@@ -638,15 +641,15 @@ function commonTests(options) {
638641
});
639642

640643
it('db.pollInterval updates a subscribed query after an unpublished create', function(done) {
641-
var clock = sinon.useFakeTimers();
644+
var clock = util.useFakeTimers();
642645
var connection = this.backend.connect();
643646
this.backend.suppressPublish = true;
644647
this.backend.db.pollDebounce = 0;
645648
this.backend.db.pollInterval = 50;
646649
var query = connection.createSubscribeQuery('dogs', this.matchAllDbQuery, null, function(err) {
647650
if (err) return done(err);
648651
connection.get('dogs', 'fido').on('error', done).create({}, function() {
649-
clock.tickAsync(51);
652+
clock.tick(51);
650653
});
651654
});
652655
query.on('error', done);
@@ -657,7 +660,7 @@ function commonTests(options) {
657660
});
658661

659662
it('pollInterval captures additional unpublished creates', function(done) {
660-
var clock = sinon.useFakeTimers();
663+
var clock = util.useFakeTimers();
661664
var connection = this.backend.connect();
662665
this.backend.suppressPublish = true;
663666
var count = 0;
@@ -667,7 +670,7 @@ function commonTests(options) {
667670
var doc = connection.get('dogs', count.toString()).on('error', done);
668671
doc.create({}, function(e) {
669672
if (e) return done(e);
670-
clock.tickAsync(2000);
673+
clock.tick(2000);
671674
});
672675
});
673676
query.on('error', done);
@@ -677,10 +680,10 @@ function commonTests(options) {
677680
var doc = connection.get('dogs', count.toString()).on('error', done);
678681
doc.create({}, function(e) {
679682
if (e) return done(e);
680-
clock.tickAsync(10000);
683+
clock.tick(10000);
681684
});
682685
});
683-
clock.tickAsync(1);
686+
clock.tick(1);
684687
});
685688

686689
it('query extra is returned to client', function(done) {

test/client/snapshot-timestamp-request.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var Backend = require('../../lib/backend');
22
var expect = require('chai').expect;
33
var MemoryDb = require('../../lib/db/memory');
44
var MemoryMilestoneDb = require('../../lib/milestone-db/memory');
5+
var util = require('../util');
56
var sinon = require('sinon');
67
var async = require('async');
78

@@ -17,12 +18,12 @@ describe('SnapshotTimestampRequest', function() {
1718
var ONE_DAY = 1000 * 60 * 60 * 24;
1819

1920
beforeEach(function() {
20-
clock = sinon.useFakeTimers(day1);
21+
clock = util.useFakeTimers(day1);
2122
backend = new Backend();
2223
});
2324

2425
afterEach(function(done) {
25-
clock.uninstall();
26+
sinon.restore();
2627
backend.close(done);
2728
});
2829

test/setup.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var sinon = require('sinon');
33
var sinonChai = require('sinon-chai');
44
var chai = require('chai');
55

6-
chai.use(sinonChai);
6+
chai.use(sinonChai.default);
77

88
if (process.env.LOGGING !== 'true') {
99
// Silence the logger for tests by setting all its methods to no-ops
@@ -15,5 +15,8 @@ if (process.env.LOGGING !== 'true') {
1515
}
1616

1717
afterEach(function() {
18+
if (sinon.clock) {
19+
sinon.clock.uninstall();
20+
}
1821
sinon.restore();
1922
});

0 commit comments

Comments
 (0)