Skip to content

Commit 664f79c

Browse files
committed
style: update configuration for eslint@9, e-c-s@12
and fix lint errors introduced by these updates
1 parent cdbaea7 commit 664f79c

File tree

12 files changed

+55
-50
lines changed

12 files changed

+55
-50
lines changed

.eslintignore

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

.eslintrc.js

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

eslint.config.mjs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {eslintConfigScratch} from 'eslint-config-scratch';
2+
import {globalIgnores} from 'eslint/config';
3+
import globals from 'globals';
4+
5+
export default eslintConfigScratch.defineConfig(
6+
eslintConfigScratch.legacy.base,
7+
{
8+
files: [
9+
'*.{js,cjs,mjs,ts}' // for example, webpack.config.js
10+
],
11+
extends: [eslintConfigScratch.legacy.node]
12+
},
13+
{
14+
files: ['src/**/*.{js,cjs,mjs,jsx,ts,tsx}'],
15+
extends: [
16+
eslintConfigScratch.legacy.es6,
17+
eslintConfigScratch.legacy.typescript
18+
],
19+
languageOptions: {
20+
globals: globals.node
21+
},
22+
rules: {
23+
// TODO: Enable these rules after fixing existing violations. This will change the API!
24+
'@typescript-eslint/no-redeclare': 'off', // allow types and values with the same name
25+
'@typescript-eslint/prefer-promise-reject-errors': 'off' // allow rejecting with non-Error values
26+
}
27+
},
28+
{
29+
files: ['test/**/*.{js,cjs,mjs,jsx,ts,tsx}'],
30+
extends: [
31+
eslintConfigScratch.legacy.es6
32+
],
33+
languageOptions: {
34+
globals: {
35+
...globals.jest,
36+
...globals.node
37+
}
38+
},
39+
rules: {
40+
'no-console': 'off'
41+
}
42+
},
43+
globalIgnores([
44+
'dist/**',
45+
'node_modules/**'
46+
])
47+
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"test": "npm run test:lint && jest \"test[\\\\/](unit|integration)\"",
2222
"test:clearCache": "jest --clearCache",
2323
"test:integration": "jest \"test[\\\\/]integration\"",
24-
"test:lint": "eslint .",
24+
"test:lint": "eslint",
2525
"test:unit": "jest \"test[\\\\/]unit\"",
2626
"version": "json -f package.json -I -e \"this.repository.sha = '$(git log -n1 --pretty=format:%H)'\"",
2727
"watch": "webpack --watch"

src/.eslintrc.js

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

src/ScratchStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class ScratchStorage {
9797
* @param {Helper} helper - the helper to be added.
9898
* @param {number} [priority] - the priority for this new helper (default: 0).
9999
*/
100-
addHelper (helper: Helper, priority: number = 0) {
100+
addHelper (helper: Helper, priority = 0) {
101101
this._helpers.push({helper, priority});
102102
this._helpers.sort((a, b) => b.priority - a.priority);
103103
}

src/Tool.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ export type ScratchGetRequest = {url: string} & RequestInit;
22
export type ScratchSendRequest = {url: string, withCredentials?: boolean} & RequestInit;
33

44
export interface Tool {
5-
get isGetSupported (): boolean;
6-
get (request: ScratchGetRequest): Promise<Uint8Array | null>;
5+
get isGetSupported (): boolean;
6+
get (request: ScratchGetRequest): Promise<Uint8Array | null>;
77

8-
get isSendSupported (): boolean;
9-
send (request: ScratchSendRequest): Promise<string>;
8+
get isSendSupported (): boolean;
9+
send (request: ScratchSendRequest): Promise<string>;
1010
}

src/WebHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export default class WebHelper extends Helper {
208208
if (typeof body === 'string') {
209209
try {
210210
body = JSON.parse(body);
211-
} catch (parseError) {
211+
} catch (parseError) { // eslint-disable-line @typescript-eslint/no-unused-vars
212212
// If it's not parseable, then we can't add the id even
213213
// if we want to, so stop here
214214
return body;

test/.eslintrc.js

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

test/integration/download-known-assets.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ test('load', () => {
106106
}
107107

108108
if (e instanceof Array) {
109-
/* global AggregateError */
110109
// we must have >1 error, so report it as an AggregateError (supported in Node 15+)
111110
e = new AggregateError(
112111
e.flat(),
@@ -132,7 +131,6 @@ test('load', () => {
132131
expect(asset.clean).toBeTruthy();
133132

134133
if (assetInfo.md5) {
135-
// eslint-disable-next-line jest/no-conditional-expect
136134
expect(md5(asset.data)).toBe(assetInfo.md5);
137135
}
138136
});

0 commit comments

Comments
 (0)