Skip to content

Commit d7e66b0

Browse files
authored
refactor: Bump ESLint to 9.6.0 (#2214)
1 parent c856289 commit d7e66b0

36 files changed

+1755
-712
lines changed

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.15.0

.eslintrc.json eslint.config.js

+44-24
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
1-
{
2-
"root": true,
3-
"extends": [
4-
"eslint:recommended",
5-
"plugin:jsdoc/recommended",
6-
"plugin:@typescript-eslint/recommended"
1+
const eslint = require('@eslint/js');
2+
const tseslint = require('typescript-eslint');
3+
const jsdoc = require('eslint-plugin-jsdoc');
4+
5+
module.exports = tseslint.config({
6+
files: ['**/*.js', '**/*.ts'],
7+
extends: [
8+
eslint.configs.recommended,
9+
...tseslint.configs.recommended,
710
],
8-
"env": {
9-
"node": true,
10-
"es6": true
11-
},
12-
"parser": "@typescript-eslint/parser",
13-
"globals": {
14-
"wx": true
15-
},
16-
"plugins": [
17-
"jsdoc",
18-
"@typescript-eslint"
19-
],
20-
"parserOptions": {
21-
"ecmaVersion": 6,
22-
"sourceType": "module",
23-
"requireConfigFile": false
11+
plugins: {
12+
'@typescript-eslint': tseslint.plugin,
13+
jsdoc,
2414
},
2515
"rules": {
2616
"indent": ["error", 2],
@@ -44,6 +34,18 @@
4434
"@typescript-eslint/no-explicit-any": "off",
4535
"@typescript-eslint/no-var-requires": "off",
4636
"@typescript-eslint/no-non-null-assertion": "off",
37+
"@typescript-eslint/no-unused-vars": [
38+
"error",
39+
{
40+
"args": "all",
41+
"argsIgnorePattern": "^_",
42+
"caughtErrors": "all",
43+
"caughtErrorsIgnorePattern": "^_",
44+
"destructuredArrayIgnorePattern": "^_",
45+
"varsIgnorePattern": "^_",
46+
"ignoreRestSiblings": true
47+
}
48+
],
4749
"jsdoc/require-jsdoc": 0,
4850
"jsdoc/require-returns-description": 0,
4951
"jsdoc/require-param-description": 0,
@@ -67,5 +69,23 @@
6769
]
6870
}
6971
]
70-
}
71-
}
72+
},
73+
languageOptions: {
74+
parser: tseslint.parser,
75+
globals: {
76+
__dirname: true,
77+
beforeEach: true,
78+
Buffer: true,
79+
console: true,
80+
describe: true,
81+
fail: true,
82+
expect: true,
83+
global: true,
84+
it: true,
85+
jasmine: true,
86+
process: true,
87+
spyOn: true,
88+
},
89+
},
90+
});
91+

integration/test/IncrementTest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe('Increment', () => {
178178
object.save().then(() => {
179179
try {
180180
object.increment('not_score');
181-
} catch (e) {
181+
} catch (_) {
182182
done();
183183
}
184184
});

integration/test/ParseLiveQueryTest.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Parse LiveQuery', () => {
2727
query.equalTo('objectId', object.id);
2828
const subscription = await query.subscribe();
2929
const promise = resolvingPromise();
30-
subscription.on('update', (object, original, response) => {
30+
subscription.on('update', (object, _original, response) => {
3131
assert.equal(object.get('foo'), 'bar');
3232
assert.equal(response.installationId, installationId);
3333
promise.resolve();
@@ -51,7 +51,7 @@ describe('Parse LiveQuery', () => {
5151
}
5252
const subscription = client.subscribe(query);
5353
const promise = resolvingPromise();
54-
subscription.on('update', (object, original, response) => {
54+
subscription.on('update', (object, _original, response) => {
5555
assert.equal(object.get('foo'), 'bar');
5656
assert.equal(response.installationId, installationId);
5757
promise.resolve();
@@ -427,7 +427,7 @@ describe('Parse LiveQuery', () => {
427427
query.equalTo('objectId', object.id);
428428
const subscription = await query.subscribe();
429429
const promise = resolvingPromise();
430-
subscription.on('update', (object, original, response) => {
430+
subscription.on('update', (object, _original, response) => {
431431
assert.equal(object.get('foo'), 'bar');
432432
assert.equal(response.installationId, installationId);
433433
promise.resolve();

integration/test/ParseLocalDatastoreTest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2481,7 +2481,7 @@ function runTest(controller) {
24812481
assert.equal(objAgain.get('owner').get('age'), 21);
24822482
try {
24832483
await Parse.User.logOut();
2484-
} catch (e) {
2484+
} catch (_) {
24852485
/* */
24862486
}
24872487
});

integration/test/ParseObjectTest.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,7 @@ describe('Parse Object', () => {
19471947
const lo = new LimitedObject();
19481948
try {
19491949
lo.set('immutable', 'mutable');
1950-
} catch (e) {
1950+
} catch (_) {
19511951
done();
19521952
}
19531953
});
@@ -1961,7 +1961,7 @@ describe('Parse Object', () => {
19611961
const lo = new LimitedObject();
19621962
try {
19631963
lo.unset('immutable');
1964-
} catch (e) {
1964+
} catch (_) {
19651965
done();
19661966
}
19671967
});

integration/test/ParsePolygonTest.js

+18-34
Original file line numberDiff line numberDiff line change
@@ -76,31 +76,25 @@ describe('Polygon', () => {
7676
}, done.fail);
7777
});
7878

79-
it('fail save with 3 point minumum', done => {
80-
try {
79+
it('fail save with 3 point minumum', () => {
80+
expect(function () {
8181
new Parse.Polygon([[0, 0]]);
82-
} catch (e) {
83-
done();
84-
}
82+
}).toThrow();
8583
});
8684

87-
it('fail save with non array', done => {
88-
try {
85+
it('fail save with non array', () => {
86+
expect(function () {
8987
new Parse.Polygon(123);
90-
} catch (e) {
91-
done();
92-
}
88+
}).toThrow();
9389
});
9490

95-
it('fail save with invalid array', done => {
96-
try {
91+
it('fail save with invalid array', () => {
92+
expect(function () {
9793
new Parse.Polygon([['str1'], ['str2'], ['str3']]);
98-
} catch (e) {
99-
done();
100-
}
94+
}).toThrow();
10195
});
10296

103-
it('containsPoint', done => {
97+
it('containsPoint', () => {
10498
const points = [
10599
[0, 0],
106100
[0, 1],
@@ -113,10 +107,9 @@ describe('Polygon', () => {
113107

114108
assert.equal(polygon.containsPoint(inside), true);
115109
assert.equal(polygon.containsPoint(outside), false);
116-
done();
117110
});
118111

119-
it('equality', done => {
112+
it('equality', () => {
120113
const points = [
121114
[0, 0],
122115
[0, 1],
@@ -129,7 +122,6 @@ describe('Polygon', () => {
129122
[2, 2],
130123
[2, 0],
131124
];
132-
133125
const polygonA = new Parse.Polygon(points);
134126
const polygonB = new Parse.Polygon(points);
135127
const polygonC = new Parse.Polygon(diff);
@@ -140,11 +132,9 @@ describe('Polygon', () => {
140132

141133
assert.equal(polygonA.equals(true), false);
142134
assert.equal(polygonA.equals(polygonC), false);
143-
144-
done();
145135
});
146136

147-
it('supports polygonContains', done => {
137+
it('supports polygonContains', async () => {
148138
const p1 = [
149139
[0, 0],
150140
[0, 1],
@@ -164,7 +154,6 @@ describe('Polygon', () => {
164154
[15, 10],
165155
[10, 10],
166156
];
167-
168157
const polygon1 = new Parse.Polygon(p1);
169158
const polygon2 = new Parse.Polygon(p2);
170159
const polygon3 = new Parse.Polygon(p3);
@@ -173,17 +162,12 @@ describe('Polygon', () => {
173162
const obj2 = new TestObject({ polygon: polygon2 });
174163
const obj3 = new TestObject({ polygon: polygon3 });
175164

176-
Parse.Object.saveAll([obj1, obj2, obj3])
177-
.then(() => {
178-
const point = new Parse.GeoPoint(0.5, 0.5);
179-
const query = new Parse.Query(TestObject);
180-
query.polygonContains('polygon', point);
181-
return query.find();
182-
})
183-
.then(results => {
184-
assert.equal(results.length, 2);
185-
done();
186-
}, done.fail);
165+
await Parse.Object.saveAll([obj1, obj2, obj3]);
166+
const point = new Parse.GeoPoint(0.5, 0.5);
167+
const query = new Parse.Query(TestObject);
168+
query.polygonContains('polygon', point);
169+
const results = await query.find();
170+
assert.equal(results.length, 2);
187171
});
188172

189173
it('polygonContains invalid input', done => {

integration/test/ParseQueryAggregateTest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('Parse Aggregate Query', () => {
3737
const query = new Parse.Query(TestObject);
3838
try {
3939
query.aggregate(pipeline).then(() => {});
40-
} catch (e) {
40+
} catch (_) {
4141
done();
4242
}
4343
});

integration/test/ParseSchemaTest.js

+27-45
Original file line numberDiff line numberDiff line change
@@ -517,84 +517,66 @@ describe('Schema', () => {
517517
});
518518
});
519519

520-
it('invalid field name', done => {
520+
it('invalid field name', () => {
521521
const testSchema = new Parse.Schema('SchemaTest');
522-
try {
522+
expect(function () {
523523
testSchema.addField(null);
524-
} catch (e) {
525-
done();
526-
}
524+
}).toThrow();
527525
});
528526

529-
it('invalid field type', done => {
527+
it('invalid field type', () => {
530528
const testSchema = new Parse.Schema('SchemaTest');
531-
try {
529+
expect(function () {
532530
testSchema.addField('name', 'UnknownType');
533-
} catch (e) {
534-
done();
535-
}
531+
}).toThrow();
536532
});
537533

538-
it('invalid index name', done => {
534+
it('invalid index name', () => {
539535
const testSchema = new Parse.Schema('SchemaTest');
540-
try {
536+
expect(function () {
541537
testSchema.addIndex(null);
542-
} catch (e) {
543-
done();
544-
}
538+
}).toThrow();
545539
});
546540

547-
it('invalid index', done => {
541+
it('invalid index', () => {
548542
const testSchema = new Parse.Schema('SchemaTest');
549-
try {
543+
expect(function () {
550544
testSchema.addIndex('name', null);
551-
} catch (e) {
552-
done();
553-
}
545+
}).toThrow();
554546
});
555547

556-
it('invalid pointer name', done => {
548+
it('invalid pointer name', () => {
557549
const testSchema = new Parse.Schema('SchemaTest');
558-
try {
550+
expect(function () {
559551
testSchema.addPointer(null);
560-
} catch (e) {
561-
done();
562-
}
552+
}).toThrow();
563553
});
564554

565-
it('invalid pointer class', done => {
555+
it('invalid pointer class', () => {
566556
const testSchema = new Parse.Schema('SchemaTest');
567-
try {
557+
expect(function () {
568558
testSchema.addPointer('name', null);
569-
} catch (e) {
570-
done();
571-
}
559+
}).toThrow();
572560
});
573561

574-
it('invalid relation name', done => {
562+
it('invalid relation name', () => {
575563
const testSchema = new Parse.Schema('SchemaTest');
576-
try {
564+
expect(function () {
577565
testSchema.addRelation(null);
578-
} catch (e) {
579-
done();
580-
}
566+
}).toThrow();
581567
});
582568

583-
it('invalid relation class', done => {
569+
it('invalid relation class', () => {
584570
const testSchema = new Parse.Schema('SchemaTest');
585-
try {
571+
expect(function () {
586572
testSchema.addRelation('name', null);
587-
} catch (e) {
588-
done();
589-
}
573+
}).toThrow();
590574
});
591575

592-
it('assert class name', done => {
576+
it('assert class name', () => {
593577
const testSchema = new Parse.Schema();
594-
try {
578+
expect(function () {
595579
testSchema.assertClassName();
596-
} catch (e) {
597-
done();
598-
}
580+
}).toThrow();
599581
});
600582
});

integration/test/ParseSubclassTest.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Parse = require('../../node');
66
describe('Parse Object Subclasses', () => {
77
it('uses subclasses when doing query find', done => {
88
const Subclass = Parse.Object.extend('Subclass', {
9-
initialize(attributes, options, number) {
9+
initialize(_attributes, _options, number) {
1010
this.number = number || -1;
1111
},
1212
});
@@ -29,7 +29,7 @@ describe('Parse Object Subclasses', () => {
2929

3030
it('uses subclasses when doing query get', done => {
3131
const Subclass = Parse.Object.extend('Subclass', {
32-
initialize(attributes, options, number) {
32+
initialize(_attributes, _options, number) {
3333
this.number = number || -1;
3434
},
3535
});

0 commit comments

Comments
 (0)