Skip to content

Commit c4e2fd1

Browse files
committed
Lint: migrate function expressions to arrow functions or declarations
1 parent ca5cf10 commit c4e2fd1

File tree

50 files changed

+158
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+158
-153
lines changed

files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_babylon.js/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ const boxMaterial = new BABYLON.StandardMaterial("material", scene);
205205
boxMaterial.emissiveColor = new BABYLON.Color3(0, 0.58, 0.86);
206206
box.material = boxMaterial;
207207

208-
const renderLoop = function () {
208+
function renderLoop() {
209209
scene.render();
210-
};
210+
}
211211

212212
engine.runRenderLoop(renderLoop);
213213
```
@@ -367,13 +367,13 @@ cylinderMaterial.emissiveColor = new BABYLON.Color3(1, 0.58, 0);
367367
cylinder.material = cylinderMaterial;
368368

369369
let t = 0;
370-
const renderLoop = function () {
370+
function renderLoop() {
371371
scene.render();
372372
t -= 0.01;
373373
box.rotation.y = t * 2;
374374
torus.scaling.z = Math.abs(Math.sin(t * 2)) + 0.5;
375375
cylinder.position.y = Math.sin(t * 3);
376-
};
376+
}
377377
engine.runRenderLoop(renderLoop);
378378
```
379379

files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_playcanvas/editor/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Animating 3D models might be considered an [advanced](https://developer.playcanv
110110
If you double click on it, you'll be moved to a code editor. As you can see, the file contains some boilerplate code already:
111111

112112
```js
113-
pc.script.create("boxAnimation", function (app) {
113+
pc.script.create("boxAnimation", (app) => {
114114
class BoxAnimation {
115115
constructor(entity) {
116116
this.entity = entity;

files/en-us/games/techniques/3d_on_the_web/building_up_a_basic_demo_with_playcanvas/engine/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ boxMaterial.diffuse.set(0, 0.58, 0.86);
208208
boxMaterial.update();
209209
box.model.model.meshInstances[0].material = boxMaterial;
210210

211-
window.addEventListener("resize", function () {
211+
window.addEventListener("resize", () => {
212212
app.resizeCanvas(canvas.width, canvas.height);
213213
});
214214
```
@@ -393,7 +393,7 @@ cone.model.model.meshInstances[0].material = coneMaterial;
393393

394394
// Animate shapes
395395
let timer = 0;
396-
app.on("update", function (deltaTime) {
396+
app.on("update", (deltaTime) => {
397397
timer += deltaTime;
398398
box.rotate(deltaTime * 10, deltaTime * 20, deltaTime * 3);
399399
cylinder.setLocalScale(1, Math.abs(Math.sin(timer)), 1);

files/en-us/games/tutorials/2d_breakout_game_pure_javascript/bounce_off_the_walls/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,10 @@ function startGame() {
149149
setInterval(draw, 10);
150150
}
151151

152-
document.getElementById("runButton").addEventListener("click", function () {
152+
const runButton = document.getElementById("runButton");
153+
runButton.addEventListener("click", () => {
153154
startGame();
154-
this.disabled = true;
155+
runButton.disabled = true;
155156
});
156157
```
157158

files/en-us/games/tutorials/2d_breakout_game_pure_javascript/build_the_brick_field/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,10 @@ function startGame() {
239239
interval = setInterval(draw, 10);
240240
}
241241

242-
document.getElementById("runButton").addEventListener("click", function () {
242+
const runButton = document.getElementById("runButton");
243+
runButton.addEventListener("click", () => {
243244
startGame();
244-
this.disabled = true;
245+
runButton.disabled = true;
245246
});
246247
```
247248

files/en-us/games/tutorials/2d_breakout_game_pure_javascript/collision_detection/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,10 @@ function startGame() {
282282
interval = setInterval(draw, 10);
283283
}
284284

285-
document.getElementById("runButton").addEventListener("click", function () {
285+
const runButton = document.getElementById("runButton");
286+
runButton.addEventListener("click", () => {
286287
startGame();
287-
this.disabled = true;
288+
runButton.disabled = true;
288289
});
289290
```
290291

files/en-us/games/tutorials/2d_breakout_game_pure_javascript/finishing_up/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,10 @@ function draw() {
283283
requestAnimationFrame(draw);
284284
}
285285

286-
document.getElementById("runButton").addEventListener("click", function () {
287-
draw();
288-
this.disabled = true;
286+
const runButton = document.getElementById("runButton");
287+
runButton.addEventListener("click", () => {
288+
startGame();
289+
runButton.disabled = true;
289290
});
290291
```
291292

files/en-us/games/tutorials/2d_breakout_game_pure_javascript/game_over/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,10 @@ function startGame() {
183183
interval = setInterval(draw, 10);
184184
}
185185

186-
document.getElementById("runButton").addEventListener("click", function () {
186+
const runButton = document.getElementById("runButton");
187+
runButton.addEventListener("click", () => {
187188
startGame();
188-
this.disabled = true;
189+
runButton.disabled = true;
189190
});
190191
```
191192

files/en-us/games/tutorials/2d_breakout_game_pure_javascript/mouse_controls/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,10 @@ function startGame() {
217217
interval = setInterval(draw, 10);
218218
}
219219

220-
document.getElementById("runButton").addEventListener("click", function () {
220+
const runButton = document.getElementById("runButton");
221+
runButton.addEventListener("click", () => {
221222
startGame();
223+
runButton.disabled = true;
222224
});
223225
```
224226

files/en-us/games/tutorials/2d_breakout_game_pure_javascript/move_the_ball/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,10 @@ function startGame() {
179179
setInterval(draw, 10);
180180
}
181181

182-
document.getElementById("runButton").addEventListener("click", function () {
182+
const runButton = document.getElementById("runButton");
183+
runButton.addEventListener("click", () => {
183184
startGame();
184-
this.disabled = true;
185+
runButton.disabled = true;
185186
});
186187
```
187188

files/en-us/games/tutorials/2d_breakout_game_pure_javascript/paddle_and_keyboard_controls/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,10 @@ function startGame() {
211211
setInterval(draw, 10);
212212
}
213213

214-
document.getElementById("runButton").addEventListener("click", function () {
214+
const runButton = document.getElementById("runButton");
215+
runButton.addEventListener("click", () => {
215216
startGame();
216-
this.disabled = true;
217+
runButton.disabled = true;
217218
});
218219
```
219220

files/en-us/games/tutorials/2d_breakout_game_pure_javascript/track_the_score_and_win/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,10 @@ function startGame() {
261261
interval = setInterval(draw, 10);
262262
}
263263

264-
document.getElementById("runButton").addEventListener("click", function () {
264+
const runButton = document.getElementById("runButton");
265+
runButton.addEventListener("click", () => {
265266
startGame();
267+
runButton.disabled = true;
266268
});
267269
```
268270

files/en-us/learn_web_development/core/accessibility/wai-aria_basics/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ class TabsManual {
11951195

11961196
// Initialize tablist
11971197

1198-
window.addEventListener("load", function () {
1198+
window.addEventListener("load", () => {
11991199
const tablists = document.querySelectorAll("[role=tablist].manual");
12001200
for (let i = 0; i < tablists.length; i++) {
12011201
new TabsManual(tablists[i]);

files/en-us/learn_web_development/core/scripting/loops/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,15 +670,15 @@ function updateCode() {
670670
eval(textarea.value);
671671
}
672672

673-
reset.addEventListener("click", function () {
673+
reset.addEventListener("click", () => {
674674
textarea.value = code;
675675
userEntry = textarea.value;
676676
solutionEntry = jsSolution;
677677
solution.value = "Show solution";
678678
updateCode();
679679
});
680680

681-
solution.addEventListener("click", function () {
681+
solution.addEventListener("click", () => {
682682
if (solution.value === "Show solution") {
683683
textarea.value = solutionEntry;
684684
solution.value = "Hide solution";
@@ -851,15 +851,15 @@ function updateCode() {
851851
eval(textarea.value);
852852
}
853853

854-
reset.addEventListener("click", function () {
854+
reset.addEventListener("click", () => {
855855
textarea.value = code;
856856
userEntry = textarea.value;
857857
solutionEntry = jsSolution;
858858
solution.value = "Show solution";
859859
updateCode();
860860
});
861861

862-
solution.addEventListener("click", function () {
862+
solution.addEventListener("click", () => {
863863
if (solution.value === "Show solution") {
864864
textarea.value = solutionEntry;
865865
solution.value = "Hide solution";

files/en-us/learn_web_development/core/scripting/useful_string_methods/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,15 +462,15 @@ function updateCode() {
462462
eval(textarea.value);
463463
}
464464

465-
reset.addEventListener("click", function () {
465+
reset.addEventListener("click", () => {
466466
textarea.value = code;
467467
userEntry = textarea.value;
468468
solutionEntry = jsSolution;
469469
solution.value = "Show solution";
470470
updateCode();
471471
});
472472

473-
solution.addEventListener("click", function () {
473+
solution.addEventListener("click", () => {
474474
if (solution.value === "Show solution") {
475475
textarea.value = solutionEntry;
476476
solution.value = "Hide solution";
@@ -641,15 +641,15 @@ function updateCode() {
641641
eval(textarea.value);
642642
}
643643

644-
reset.addEventListener("click", function () {
644+
reset.addEventListener("click", () => {
645645
textarea.value = code;
646646
userEntry = textarea.value;
647647
solutionEntry = jsSolution;
648648
solution.value = "Show solution";
649649
updateCode();
650650
});
651651

652-
solution.addEventListener("click", function () {
652+
solution.addEventListener("click", () => {
653653
if (solution.value === "Show solution") {
654654
textarea.value = solutionEntry;
655655
solution.value = "Hide solution";

files/en-us/learn_web_development/core/structuring_content/general_embedding_technologies/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ function updateCode() {
119119
output.innerHTML = textarea.value;
120120
}
121121

122-
reset.addEventListener("click", function () {
122+
reset.addEventListener("click", () => {
123123
textarea.value = code;
124124
userEntry = textarea.value;
125125
solutionEntry = htmlSolution;
126126
solution.value = "Show solution";
127127
updateCode();
128128
});
129129

130-
solution.addEventListener("click", function () {
130+
solution.addEventListener("click", () => {
131131
if (solution.value === "Show solution") {
132132
textarea.value = solutionEntry;
133133
solution.value = "Hide solution";

files/en-us/learn_web_development/core/structuring_content/including_vector_graphics_in_html/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ function updateCode() {
252252
output.innerHTML = textarea.value;
253253
}
254254

255-
reset.addEventListener("click", function () {
255+
reset.addEventListener("click", () => {
256256
textarea.value = code;
257257
userEntry = textarea.value;
258258
solutionEntry = htmlSolution;
259259
solution.value = "Show solution";
260260
updateCode();
261261
});
262262

263-
solution.addEventListener("click", function () {
263+
solution.addEventListener("click", () => {
264264
if (solution.value === "Show solution") {
265265
textarea.value = solutionEntry;
266266
solution.value = "Hide solution";
@@ -280,7 +280,7 @@ window.addEventListener("load", updateCode);
280280
// stop tab key tabbing out of textarea and
281281
// make it write a tab at the caret position instead
282282

283-
textarea.onkeydown = function (e) {
283+
textarea.onkeydown = (e) => {
284284
if (e.code === "Tab") {
285285
e.preventDefault();
286286
insertAtCaret("\t");
@@ -310,7 +310,7 @@ function insertAtCaret(text) {
310310

311311
// Update the saved userCode every time the user updates the text area code
312312

313-
textarea.onkeyup = function () {
313+
textarea.onkeyup = () => {
314314
// We only want to save the state when the user code is being shown,
315315
// not the solution, so that solution is not saved over the user code
316316
if (solution.value === "Show solution") {

0 commit comments

Comments
 (0)