Skip to content

Commit

Permalink
refactor: Bump ESLint to 9.6.0 (#2214)
Browse files Browse the repository at this point in the history
  • Loading branch information
dplewis authored Jul 8, 2024
1 parent c856289 commit d7e66b0
Show file tree
Hide file tree
Showing 36 changed files with 1,755 additions and 712 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.15.0
68 changes: 44 additions & 24 deletions .eslintrc.json → eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:jsdoc/recommended",
"plugin:@typescript-eslint/recommended"
const eslint = require('@eslint/js');
const tseslint = require('typescript-eslint');
const jsdoc = require('eslint-plugin-jsdoc');

module.exports = tseslint.config({
files: ['**/*.js', '**/*.ts'],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
],
"env": {
"node": true,
"es6": true
},
"parser": "@typescript-eslint/parser",
"globals": {
"wx": true
},
"plugins": [
"jsdoc",
"@typescript-eslint"
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"requireConfigFile": false
plugins: {
'@typescript-eslint': tseslint.plugin,
jsdoc,
},
"rules": {
"indent": ["error", 2],
Expand All @@ -44,6 +34,18 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"args": "all",
"argsIgnorePattern": "^_",
"caughtErrors": "all",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"jsdoc/require-jsdoc": 0,
"jsdoc/require-returns-description": 0,
"jsdoc/require-param-description": 0,
Expand All @@ -67,5 +69,23 @@
]
}
]
}
}
},
languageOptions: {
parser: tseslint.parser,
globals: {
__dirname: true,
beforeEach: true,
Buffer: true,
console: true,
describe: true,
fail: true,
expect: true,
global: true,
it: true,
jasmine: true,
process: true,
spyOn: true,
},
},
});

2 changes: 1 addition & 1 deletion integration/test/IncrementTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('Increment', () => {
object.save().then(() => {
try {
object.increment('not_score');
} catch (e) {
} catch (_) {
done();
}
});
Expand Down
6 changes: 3 additions & 3 deletions integration/test/ParseLiveQueryTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Parse LiveQuery', () => {
query.equalTo('objectId', object.id);
const subscription = await query.subscribe();
const promise = resolvingPromise();
subscription.on('update', (object, original, response) => {
subscription.on('update', (object, _original, response) => {
assert.equal(object.get('foo'), 'bar');
assert.equal(response.installationId, installationId);
promise.resolve();
Expand All @@ -51,7 +51,7 @@ describe('Parse LiveQuery', () => {
}
const subscription = client.subscribe(query);
const promise = resolvingPromise();
subscription.on('update', (object, original, response) => {
subscription.on('update', (object, _original, response) => {
assert.equal(object.get('foo'), 'bar');
assert.equal(response.installationId, installationId);
promise.resolve();
Expand Down Expand Up @@ -427,7 +427,7 @@ describe('Parse LiveQuery', () => {
query.equalTo('objectId', object.id);
const subscription = await query.subscribe();
const promise = resolvingPromise();
subscription.on('update', (object, original, response) => {
subscription.on('update', (object, _original, response) => {
assert.equal(object.get('foo'), 'bar');
assert.equal(response.installationId, installationId);
promise.resolve();
Expand Down
2 changes: 1 addition & 1 deletion integration/test/ParseLocalDatastoreTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2481,7 +2481,7 @@ function runTest(controller) {
assert.equal(objAgain.get('owner').get('age'), 21);
try {
await Parse.User.logOut();
} catch (e) {
} catch (_) {
/* */
}
});
Expand Down
4 changes: 2 additions & 2 deletions integration/test/ParseObjectTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ describe('Parse Object', () => {
const lo = new LimitedObject();
try {
lo.set('immutable', 'mutable');
} catch (e) {
} catch (_) {
done();
}
});
Expand All @@ -1961,7 +1961,7 @@ describe('Parse Object', () => {
const lo = new LimitedObject();
try {
lo.unset('immutable');
} catch (e) {
} catch (_) {
done();
}
});
Expand Down
52 changes: 18 additions & 34 deletions integration/test/ParsePolygonTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,25 @@ describe('Polygon', () => {
}, done.fail);
});

it('fail save with 3 point minumum', done => {
try {
it('fail save with 3 point minumum', () => {
expect(function () {
new Parse.Polygon([[0, 0]]);
} catch (e) {
done();
}
}).toThrow();
});

it('fail save with non array', done => {
try {
it('fail save with non array', () => {
expect(function () {
new Parse.Polygon(123);
} catch (e) {
done();
}
}).toThrow();
});

it('fail save with invalid array', done => {
try {
it('fail save with invalid array', () => {
expect(function () {
new Parse.Polygon([['str1'], ['str2'], ['str3']]);
} catch (e) {
done();
}
}).toThrow();
});

it('containsPoint', done => {
it('containsPoint', () => {
const points = [
[0, 0],
[0, 1],
Expand All @@ -113,10 +107,9 @@ describe('Polygon', () => {

assert.equal(polygon.containsPoint(inside), true);
assert.equal(polygon.containsPoint(outside), false);
done();
});

it('equality', done => {
it('equality', () => {
const points = [
[0, 0],
[0, 1],
Expand All @@ -129,7 +122,6 @@ describe('Polygon', () => {
[2, 2],
[2, 0],
];

const polygonA = new Parse.Polygon(points);
const polygonB = new Parse.Polygon(points);
const polygonC = new Parse.Polygon(diff);
Expand All @@ -140,11 +132,9 @@ describe('Polygon', () => {

assert.equal(polygonA.equals(true), false);
assert.equal(polygonA.equals(polygonC), false);

done();
});

it('supports polygonContains', done => {
it('supports polygonContains', async () => {
const p1 = [
[0, 0],
[0, 1],
Expand All @@ -164,7 +154,6 @@ describe('Polygon', () => {
[15, 10],
[10, 10],
];

const polygon1 = new Parse.Polygon(p1);
const polygon2 = new Parse.Polygon(p2);
const polygon3 = new Parse.Polygon(p3);
Expand All @@ -173,17 +162,12 @@ describe('Polygon', () => {
const obj2 = new TestObject({ polygon: polygon2 });
const obj3 = new TestObject({ polygon: polygon3 });

Parse.Object.saveAll([obj1, obj2, obj3])
.then(() => {
const point = new Parse.GeoPoint(0.5, 0.5);
const query = new Parse.Query(TestObject);
query.polygonContains('polygon', point);
return query.find();
})
.then(results => {
assert.equal(results.length, 2);
done();
}, done.fail);
await Parse.Object.saveAll([obj1, obj2, obj3]);
const point = new Parse.GeoPoint(0.5, 0.5);
const query = new Parse.Query(TestObject);
query.polygonContains('polygon', point);
const results = await query.find();
assert.equal(results.length, 2);
});

it('polygonContains invalid input', done => {
Expand Down
2 changes: 1 addition & 1 deletion integration/test/ParseQueryAggregateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Parse Aggregate Query', () => {
const query = new Parse.Query(TestObject);
try {
query.aggregate(pipeline).then(() => {});
} catch (e) {
} catch (_) {
done();
}
});
Expand Down
72 changes: 27 additions & 45 deletions integration/test/ParseSchemaTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,84 +517,66 @@ describe('Schema', () => {
});
});

it('invalid field name', done => {
it('invalid field name', () => {
const testSchema = new Parse.Schema('SchemaTest');
try {
expect(function () {
testSchema.addField(null);
} catch (e) {
done();
}
}).toThrow();
});

it('invalid field type', done => {
it('invalid field type', () => {
const testSchema = new Parse.Schema('SchemaTest');
try {
expect(function () {
testSchema.addField('name', 'UnknownType');
} catch (e) {
done();
}
}).toThrow();
});

it('invalid index name', done => {
it('invalid index name', () => {
const testSchema = new Parse.Schema('SchemaTest');
try {
expect(function () {
testSchema.addIndex(null);
} catch (e) {
done();
}
}).toThrow();
});

it('invalid index', done => {
it('invalid index', () => {
const testSchema = new Parse.Schema('SchemaTest');
try {
expect(function () {
testSchema.addIndex('name', null);
} catch (e) {
done();
}
}).toThrow();
});

it('invalid pointer name', done => {
it('invalid pointer name', () => {
const testSchema = new Parse.Schema('SchemaTest');
try {
expect(function () {
testSchema.addPointer(null);
} catch (e) {
done();
}
}).toThrow();
});

it('invalid pointer class', done => {
it('invalid pointer class', () => {
const testSchema = new Parse.Schema('SchemaTest');
try {
expect(function () {
testSchema.addPointer('name', null);
} catch (e) {
done();
}
}).toThrow();
});

it('invalid relation name', done => {
it('invalid relation name', () => {
const testSchema = new Parse.Schema('SchemaTest');
try {
expect(function () {
testSchema.addRelation(null);
} catch (e) {
done();
}
}).toThrow();
});

it('invalid relation class', done => {
it('invalid relation class', () => {
const testSchema = new Parse.Schema('SchemaTest');
try {
expect(function () {
testSchema.addRelation('name', null);
} catch (e) {
done();
}
}).toThrow();
});

it('assert class name', done => {
it('assert class name', () => {
const testSchema = new Parse.Schema();
try {
expect(function () {
testSchema.assertClassName();
} catch (e) {
done();
}
}).toThrow();
});
});
4 changes: 2 additions & 2 deletions integration/test/ParseSubclassTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Parse = require('../../node');
describe('Parse Object Subclasses', () => {
it('uses subclasses when doing query find', done => {
const Subclass = Parse.Object.extend('Subclass', {
initialize(attributes, options, number) {
initialize(_attributes, _options, number) {
this.number = number || -1;
},
});
Expand All @@ -29,7 +29,7 @@ describe('Parse Object Subclasses', () => {

it('uses subclasses when doing query get', done => {
const Subclass = Parse.Object.extend('Subclass', {
initialize(attributes, options, number) {
initialize(_attributes, _options, number) {
this.number = number || -1;
},
});
Expand Down
Loading

0 comments on commit d7e66b0

Please sign in to comment.