Skip to content

Commit 889dbb5

Browse files
authoredFeb 1, 2025··
refactor: Upgrade to eslint 9.19.0 (#9580)
1 parent 239e692 commit 889dbb5

18 files changed

+1260
-765
lines changed
 

Diff for: ‎.eslintignore

-3
This file was deleted.

Diff for: ‎.eslintrc.json

-35
This file was deleted.

Diff for: ‎.releaserc.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ async function config() {
3030

3131
// Get branch
3232
const branch = ref?.split('/')?.pop()?.split('-')[0] || '(current branch could not be determined)';
33+
// eslint-disable-next-line no-console
3334
console.log(`Running on branch: ${branch}`);
3435

3536
// Set changelog file
3637
const changelogFile = `./changelogs/CHANGELOG_${branch}.md`;
38+
// eslint-disable-next-line no-console
3739
console.log(`Changelog file output to: ${changelogFile}`);
3840

3941
// Load template file contents
@@ -108,7 +110,7 @@ async function config() {
108110

109111
async function loadTemplates() {
110112
for (const template of Object.keys(templates)) {
111-
113+
112114
// For ES6 modules use:
113115
// const fileUrl = import.meta.url;
114116
// const __dirname = dirname(fileURLToPath(fileUrl));

Diff for: ‎ci/CiVersionCheck.js

+2
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ class CiVersionCheck {
220220
* Runs the check.
221221
*/
222222
async check() {
223+
/* eslint-disable no-console */
223224
try {
224225
console.log(`\nChecking ${this.packageName} versions in CI environments...`);
225226

@@ -284,6 +285,7 @@ class CiVersionCheck {
284285
const msg = `Failed to check ${this.packageName} versions with error: ${e}`;
285286
core.setFailed(msg);
286287
}
288+
/* eslint-enable no-console */
287289
}
288290
}
289291

Diff for: ‎ci/definitionsCheck.js

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const util = require('util');
1414
fs.readFile('./src/Options/docs.js', 'utf8'),
1515
]);
1616
if (currentDefinitions !== newDefinitions || currentDocs !== newDocs) {
17+
// eslint-disable-next-line no-console
1718
console.error(
1819
'\x1b[31m%s\x1b[0m',
1920
'Definitions files cannot be updated manually. Please update src/Options/index.js then run `npm run definitions` to generate definitions.'

Diff for: ‎ci/nodeEngineCheck.js

+3
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class NodeEngineCheck {
8787
nodeVersion: version
8888
});
8989
} catch(e) {
90+
// eslint-disable-next-line no-console
9091
console.log(`Ignoring file because it is not valid JSON: ${file}`);
9192
core.warning(`Ignoring file because it is not valid JSON: ${file}`);
9293
}
@@ -171,6 +172,7 @@ async function check() {
171172
// Get highest version
172173
const highestVersion = higherVersions.map(v => v.nodeMinVersion).pop();
173174

175+
/* eslint-disable no-console */
174176
// If there are higher versions
175177
if (higherVersions.length > 0) {
176178
console.log(`\nThere are ${higherVersions.length} dependencies that require a higher node engine version than the parent package (${parentVersion.nodeVersion}):`);
@@ -189,6 +191,7 @@ async function check() {
189191
}
190192

191193
console.log(`✅ All dependencies satisfy the node version requirement of the parent package (${parentVersion.nodeVersion}).`);
194+
/* eslint-enable no-console */
192195
}
193196

194197
check();

Diff for: ‎eslint.config.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const js = require("@eslint/js");
2+
const babelParser = require("@babel/eslint-parser");
3+
const globals = require("globals");
4+
module.exports = [
5+
{
6+
ignores: ["**/lib/**", "**/coverage/**", "**/out/**"],
7+
},
8+
js.configs.recommended,
9+
{
10+
languageOptions: {
11+
parser: babelParser,
12+
ecmaVersion: 6,
13+
sourceType: "module",
14+
globals: {
15+
Parse: "readonly",
16+
...globals.node,
17+
},
18+
parserOptions: {
19+
requireConfigFile: false,
20+
},
21+
},
22+
rules: {
23+
indent: ["error", 2, { SwitchCase: 1 }],
24+
"linebreak-style": ["error", "unix"],
25+
"no-trailing-spaces": "error",
26+
"eol-last": "error",
27+
"space-in-parens": ["error", "never"],
28+
"no-multiple-empty-lines": "warn",
29+
"prefer-const": "error",
30+
"space-infix-ops": "error",
31+
"no-useless-escape": "off",
32+
"require-atomic-updates": "off",
33+
"object-curly-spacing": ["error", "always"],
34+
curly: ["error", "all"],
35+
"block-spacing": ["error", "always"],
36+
"no-unused-vars": "off",
37+
"no-console": "warn"
38+
},
39+
},
40+
];

Diff for: ‎package-lock.json

+1,141-670
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@
8888
"clean-jsdoc-theme": "4.3.0",
8989
"cross-env": "7.0.3",
9090
"deep-diff": "1.0.2",
91-
"eslint": "8.57.0",
92-
"eslint-plugin-flowtype": "8.0.3",
91+
"eslint": "9.19.0",
9392
"flow-bin": "0.119.1",
9493
"form-data": "4.0.1",
94+
"globals": "15.14.0",
9595
"graphql-tag": "2.12.6",
9696
"husky": "9.1.7",
9797
"jasmine": "3.5.0",
@@ -118,8 +118,8 @@
118118
"ci:definitionsCheck": "node ./ci/definitionsCheck.js",
119119
"definitions": "node ./resources/buildConfigDefinitions.js && prettier --write 'src/Options/*.js'",
120120
"docs": "jsdoc -c ./jsdoc-conf.json",
121-
"lint": "eslint --cache ./",
122-
"lint-fix": "eslint --fix --cache ./",
121+
"lint": "eslint --cache ./ --flag unstable_config_lookup_from_file",
122+
"lint-fix": "eslint --fix --cache ./ --flag unstable_config_lookup_from_file",
123123
"build": "babel src/ -d lib/ --copy-files --extensions '.ts,.js'",
124124
"build:types": "tsc",
125125
"watch": "babel --watch src/ -d lib/ --copy-files",

Diff for: ‎spec/.eslintrc.json

-45
This file was deleted.

Diff for: ‎spec/eslint.config.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const js = require("@eslint/js");
2+
const globals = require("globals");
3+
module.exports = [
4+
js.configs.recommended,
5+
{
6+
languageOptions: {
7+
ecmaVersion: "latest",
8+
sourceType: "module",
9+
globals: {
10+
...globals.node,
11+
...globals.jasmine,
12+
Parse: "readonly",
13+
reconfigureServer: "readonly",
14+
createTestUser: "readonly",
15+
jfail: "readonly",
16+
ok: "readonly",
17+
strictEqual: "readonly",
18+
TestObject: "readonly",
19+
Item: "readonly",
20+
Container: "readonly",
21+
equal: "readonly",
22+
expectAsync: "readonly",
23+
notEqual: "readonly",
24+
it_id: "readonly",
25+
fit_id: "readonly",
26+
it_only_db: "readonly",
27+
it_only_mongodb_version: "readonly",
28+
it_only_postgres_version: "readonly",
29+
it_only_node_version: "readonly",
30+
fit_only_mongodb_version: "readonly",
31+
fit_only_postgres_version: "readonly",
32+
fit_only_node_version: "readonly",
33+
it_exclude_dbs: "readonly",
34+
fit_exclude_dbs: "readonly",
35+
describe_only_db: "readonly",
36+
fdescribe_only_db: "readonly",
37+
describe_only: "readonly",
38+
on_db: "readonly",
39+
defaultConfiguration: "readonly",
40+
range: "readonly",
41+
jequal: "readonly",
42+
create: "readonly",
43+
arrayContains: "readonly",
44+
databaseAdapter: "readonly",
45+
databaseURI: "readonly"
46+
},
47+
},
48+
rules: {
49+
"no-console": "off",
50+
"no-var": "error",
51+
"no-unused-vars": "off",
52+
"no-useless-escape": "off",
53+
}
54+
},
55+
];

Diff for: ‎spec/support/CurrentSpecReporter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ global.retryFlakyTests = function() {
119119
};
120120
}
121121

122-
module.exports = CurrentSpecReporter;
122+
module.exports = CurrentSpecReporter;

Diff for: ‎src/Adapters/AdapterLoader.js

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export function loadAdapter<T>(adapter, defaultAdapter, options): T {
2828
}
2929
}
3030
} else if (typeof adapter === 'string') {
31-
/* eslint-disable */
3231
adapter = require(adapter);
3332
// If it's define as a module, get the default
3433
if (adapter.default) {

Diff for: ‎src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ const handleDotFields = object => {
189189
if (value && value.__op === 'Delete') {
190190
value = undefined;
191191
}
192-
/* eslint-disable no-cond-assign */
193192
while ((next = components.shift())) {
194-
/* eslint-enable no-cond-assign */
195193
currentObj[next] = currentObj[next] || {};
196194
if (components.length === 0) {
197195
currentObj[next] = value;
@@ -819,6 +817,7 @@ const buildWhereClause = ({ schema, query, index, caseInsensitive }): WhereClaus
819817
if (parserResult.status === 'success') {
820818
postgresValue = toPostgresValue(parserResult.result);
821819
} else {
820+
// eslint-disable-next-line no-console
822821
console.error('Error while parsing relative date', parserResult);
823822
throw new Parse.Error(
824823
Parse.Error.INVALID_JSON,
@@ -917,6 +916,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
917916
this._stream
918917
.none('NOTIFY $1~, $2', ['schema.change', { senderId: this._uuid }])
919918
.catch(error => {
919+
// eslint-disable-next-line no-console
920920
console.log('Failed to Notify:', error); // unlikely to ever happen
921921
});
922922
}
@@ -2376,7 +2376,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
23762376
debug(`initializationDone in ${ctx.duration}`);
23772377
})
23782378
.catch(error => {
2379-
/* eslint-disable no-console */
2379+
// eslint-disable-next-line no-console
23802380
console.error(error);
23812381
});
23822382
}

Diff for: ‎src/GraphQL/helpers/objectsQueries.js

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const getObject = async (
5050
options.keys = keys;
5151
}
5252
} catch (e) {
53+
// eslint-disable-next-line no-console
5354
console.error(e);
5455
}
5556
if (include) {

Diff for: ‎src/ParseServer.js

+4
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ class ParseServer {
201201
Config.put(this.config);
202202
return this;
203203
} catch (error) {
204+
// eslint-disable-next-line no-console
204205
console.error(error);
205206
this.config.state = 'error';
206207
throw error;
@@ -370,6 +371,7 @@ class ParseServer {
370371
try {
371372
await this.start();
372373
} catch (e) {
374+
// eslint-disable-next-line no-console
373375
console.error('Error on ParseServer.startApp: ', e);
374376
throw e;
375377
}
@@ -482,6 +484,7 @@ class ParseServer {
482484
};
483485
const url = `${Parse.serverURL.replace(/\/$/, '')}/health`;
484486
if (!isValidHttpUrl(url)) {
487+
// eslint-disable-next-line no-console
485488
console.warn(
486489
`\nWARNING, Unable to connect to '${Parse.serverURL}' as the URL is invalid.` +
487490
` Cloud code and push notifications may be unavailable!\n`
@@ -543,6 +546,7 @@ function injectDefaults(options: ParseServerOptions) {
543546
if (options.appId) {
544547
const regex = /[!#$%'()*+&/:;=?@[\]{}^,|<>]/g;
545548
if (options.appId.match(regex)) {
549+
// eslint-disable-next-line no-console
546550
console.warn(
547551
`\nWARNING, appId that contains special characters can cause issues while using with urls.\n`
548552
);

Diff for: ‎src/SchemaMigrations/DefinedSchemas.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export class DefinedSchemas {
387387
logger.warn(`classLevelPermissions not provided for ${localSchema.className}.`);
388388
}
389389
// Use spread to avoid read only issue (encountered by Moumouls using directAccess)
390-
const clp = ({ ...localSchema.classLevelPermissions } || {}: Parse.CLP.PermissionsMap);
390+
const clp = ({ ...localSchema.classLevelPermissions || {} }: Parse.CLP.PermissionsMap);
391391
// To avoid inconsistency we need to remove all rights on addField
392392
clp.addField = {};
393393
newLocalSchema.setCLP(clp);

Diff for: ‎src/vendor/mongodbUrl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ function urlFormat(obj) {
505505
if (typeof obj === 'string') { obj = urlParse(obj); }
506506
else if (typeof obj !== 'object' || obj === null)
507507
{ throw new TypeError(
508-
'Parameter "urlObj" must be an object, not ' + obj === null ? 'null' : typeof obj
508+
'Parameter "urlObj" must be an object, not ' + (obj === null ? 'null' : typeof obj)
509509
); }
510510
else if (!(obj instanceof Url)) { return Url.prototype.format.call(obj); }
511511

0 commit comments

Comments
 (0)
Please sign in to comment.