Skip to content

Commit 719282f

Browse files
authored
Merge pull request #96 from CodinGame/update-dependencies
Update dependencies
2 parents 457f32e + 16575d8 commit 719282f

30 files changed

+11834
-13376
lines changed

.eslintrc.cjs

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

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
dist/*
22
stats.html
3-
.vscode
43
node_modules
54
/extensions

.prettierrc.cjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
singleQuote: true,
3+
jsxSingleQuote: true,
4+
trailingComma: 'none',
5+
semi: false,
6+
printWidth: 100
7+
}

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"[typescript]": {
3+
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"editor.formatOnSave": true
5+
},
6+
"[javascript]": {
7+
"editor.defaultFormatter": "esbenp.prettier-vscode",
8+
"editor.formatOnSave": true
9+
},
10+
}

FixJSDOMEnvironment.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ import { TestEnvironment } from 'jest-environment-jsdom'
22

33
class FixJSDOMEnvironment extends TestEnvironment {
44
constructor(...args) {
5-
super(...args);
5+
super(...args)
6+
7+
this.dom.virtualConsole.removeAllListeners('jsdomError')
8+
this.dom.virtualConsole.on('jsdomError', (error) => {
9+
if (error.message.startsWith('Could not parse CSS stylesheet')) {
10+
return
11+
}
12+
context.console.error(error)
13+
})
614

715
// FIXME https://github.com/jsdom/jsdom/issues/3363
8-
this.global.structuredClone = structuredClone;
16+
this.global.structuredClone = structuredClone
917
}
1018
}
1119

browserMock.js

Lines changed: 69 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,33 @@ import { performance } from 'perf_hooks'
33
import { fetch as fetchPolyfill } from 'whatwg-fetch'
44

55
Object.defineProperty(document, 'queryCommandSupported', {
6-
value: jest.fn().mockImplementation(() => true),
7-
});
6+
value: jest.fn().mockImplementation(() => true)
7+
})
88

99
window.process = undefined
1010

1111
Object.defineProperty(window, 'matchMedia', {
1212
writable: true,
13-
value: jest.fn().mockImplementation(query => ({
13+
value: jest.fn().mockImplementation((query) => ({
1414
matches: false,
1515
media: query,
1616
onchange: null,
1717
addListener: jest.fn(), // Deprecated
1818
removeListener: jest.fn(), // Deprecated
1919
addEventListener: jest.fn(),
2020
removeEventListener: jest.fn(),
21-
dispatchEvent: jest.fn(),
22-
})),
23-
});
21+
dispatchEvent: jest.fn()
22+
}))
23+
})
2424

2525
Object.defineProperty(window, 'fetch', {
2626
value: jest.fn(async (url, options) => {
2727
if (url.startsWith('file:')) {
2828
const content = await fs.readFile(new URL(url).pathname)
2929
return {
3030
json: async () => JSON.stringify(JSON.parse(content.toString())),
31-
arrayBuffer: async () => content.buffer.slice(content.byteOffset, content.byteOffset + content.byteLength),
31+
arrayBuffer: async () =>
32+
content.buffer.slice(content.byteOffset, content.byteOffset + content.byteLength),
3233
status: 200
3334
}
3435
} else {
@@ -47,8 +48,8 @@ Object.defineProperty(window, 'Worker', {
4748
value: class Worker {
4849
constructor(stringUrl) {}
4950
postMessage(msg) {}
50-
terminate () {}
51-
removeEventListener () {}
51+
terminate() {}
52+
removeEventListener() {}
5253
}
5354
})
5455

@@ -62,77 +63,77 @@ Object.defineProperty(window, 'ResizeObserver', {
6263
// These 2 classes come from https://gist.github.com/Yaffle/5458286
6364
Object.defineProperty(window, 'TextEncoder', {
6465
value: class TextEncoder {
65-
encode (string) {
66-
var octets = [];
67-
var length = string.length;
68-
var i = 0;
66+
encode(string) {
67+
var octets = []
68+
var length = string.length
69+
var i = 0
6970
while (i < length) {
70-
var codePoint = string.codePointAt(i);
71-
var c = 0;
72-
var bits = 0;
73-
if (codePoint <= 0x0000007F) {
74-
c = 0;
75-
bits = 0x00;
76-
} else if (codePoint <= 0x000007FF) {
77-
c = 6;
78-
bits = 0xC0;
79-
} else if (codePoint <= 0x0000FFFF) {
80-
c = 12;
81-
bits = 0xE0;
82-
} else if (codePoint <= 0x001FFFFF) {
83-
c = 18;
84-
bits = 0xF0;
71+
var codePoint = string.codePointAt(i)
72+
var c = 0
73+
var bits = 0
74+
if (codePoint <= 0x0000007f) {
75+
c = 0
76+
bits = 0x00
77+
} else if (codePoint <= 0x000007ff) {
78+
c = 6
79+
bits = 0xc0
80+
} else if (codePoint <= 0x0000ffff) {
81+
c = 12
82+
bits = 0xe0
83+
} else if (codePoint <= 0x001fffff) {
84+
c = 18
85+
bits = 0xf0
8586
}
86-
octets.push(bits | (codePoint >> c));
87-
c -= 6;
87+
octets.push(bits | (codePoint >> c))
88+
c -= 6
8889
while (c >= 0) {
89-
octets.push(0x80 | ((codePoint >> c) & 0x3F));
90-
c -= 6;
90+
octets.push(0x80 | ((codePoint >> c) & 0x3f))
91+
c -= 6
9192
}
92-
i += codePoint >= 0x10000 ? 2 : 1;
93+
i += codePoint >= 0x10000 ? 2 : 1
9394
}
94-
return Uint8Array.from(octets);
95+
return Uint8Array.from(octets)
9596
}
9697
}
9798
})
9899
Object.defineProperty(window, 'TextDecoder', {
99100
value: class TextDecoder {
100-
decode (octets) {
101+
decode(octets) {
101102
if (octets == null) {
102103
return ''
103104
}
104-
var string = "";
105-
var i = 0;
105+
var string = ''
106+
var i = 0
106107
while (i < octets.length) {
107-
var octet = octets[i];
108-
var bytesNeeded = 0;
109-
var codePoint = 0;
110-
if (octet <= 0x7F) {
111-
bytesNeeded = 0;
112-
codePoint = octet & 0xFF;
113-
} else if (octet <= 0xDF) {
114-
bytesNeeded = 1;
115-
codePoint = octet & 0x1F;
116-
} else if (octet <= 0xEF) {
117-
bytesNeeded = 2;
118-
codePoint = octet & 0x0F;
119-
} else if (octet <= 0xF4) {
120-
bytesNeeded = 3;
121-
codePoint = octet & 0x07;
108+
var octet = octets[i]
109+
var bytesNeeded = 0
110+
var codePoint = 0
111+
if (octet <= 0x7f) {
112+
bytesNeeded = 0
113+
codePoint = octet & 0xff
114+
} else if (octet <= 0xdf) {
115+
bytesNeeded = 1
116+
codePoint = octet & 0x1f
117+
} else if (octet <= 0xef) {
118+
bytesNeeded = 2
119+
codePoint = octet & 0x0f
120+
} else if (octet <= 0xf4) {
121+
bytesNeeded = 3
122+
codePoint = octet & 0x07
122123
}
123124
if (octets.length - i - bytesNeeded > 0) {
124-
var k = 0;
125+
var k = 0
125126
while (k < bytesNeeded) {
126-
octet = octets[i + k + 1];
127-
codePoint = (codePoint << 6) | (octet & 0x3F);
128-
k += 1;
127+
octet = octets[i + k + 1]
128+
codePoint = (codePoint << 6) | (octet & 0x3f)
129+
k += 1
129130
}
130131
} else {
131-
codePoint = 0xFFFD;
132-
bytesNeeded = octets.length - i;
132+
codePoint = 0xfffd
133+
bytesNeeded = octets.length - i
133134
}
134-
string += String.fromCodePoint(codePoint);
135-
i += bytesNeeded + 1;
135+
string += String.fromCodePoint(codePoint)
136+
i += bytesNeeded + 1
136137
}
137138
return string
138139
}
@@ -145,15 +146,19 @@ Object.defineProperty(window, 'Buffer', {
145146

146147
// Force override performance, for some reason the implementation is empty otherwise
147148
let _performance = performance
149+
// remove nodeTiming because otherwise VSCode refuse to detect the env as a browser env, and it also fails to detect a node env (no `process`) so it generates an error
150+
performance.nodeTiming = undefined
148151
Object.defineProperty(global, 'performance', {
149-
get () { return _performance },
150-
set (v) {
152+
get() {
153+
return _performance
154+
},
155+
set(v) {
151156
// ignore
152157
}
153158
})
154159

155160
global.CSS = {
156-
escape: v => v
161+
escape: (v) => v
157162
}
158163

159-
Element.prototype.scrollIntoView = jest.fn();
164+
Element.prototype.scrollIntoView = jest.fn()

commitlint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default {
2-
extends: ['@codingame/commitlint-config-codingame']
3-
};
2+
extends: ['@codingame/commitlint-config-codingame']
3+
}

eslint.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import eslint from '@eslint/js'
2+
import tseslint from 'typescript-eslint'
3+
import globals from 'globals'
4+
5+
export default tseslint.config(eslint.configs.recommended, tseslint.configs.recommended, {
6+
rules: { '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }] },
7+
languageOptions: {
8+
globals: {
9+
...globals.browser
10+
}
11+
}
12+
})

0 commit comments

Comments
 (0)