Skip to content

Commit f336c5b

Browse files
authored
Lint: camelCase JavaScript identifiers (mdn#41775)
* Lint: camelCase JavaScript identifiers * Revert * Fix more
1 parent 0b58591 commit f336c5b

File tree

74 files changed

+280
-289
lines changed

Some content is hidden

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

74 files changed

+280
-289
lines changed

files/en-us/learn_web_development/core/frameworks_libraries/svelte_stores/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ As you can see, our store is just an object containing `subscribe()`, `set()`, a
486486
Just for reference, here's a basic working store implemented from scratch:
487487

488488
```js
489-
export const writable = (initial_value = 0) => {
490-
let value = initial_value; // content of the store
489+
export const writable = (initialValue = 0) => {
490+
let value = initialValue; // content of the store
491491
let subs = []; // subscriber's handlers
492492

493493
const subscribe = (handler) => {
@@ -496,13 +496,13 @@ export const writable = (initial_value = 0) => {
496496
return () => (subs = subs.filter((sub) => sub !== handler)); // return unsubscribe function
497497
};
498498

499-
const set = (new_value) => {
500-
if (value === new_value) return; // same value, exit
501-
value = new_value; // update value
499+
const set = (newValue) => {
500+
if (value === newValue) return; // same value, exit
501+
value = newValue; // update value
502502
subs.forEach((sub) => sub(value)); // update subscribers
503503
};
504504

505-
const update = (update_fn) => set(update_fn(value)); // update function
505+
const update = (updateFn) => set(updateFn(value)); // update function
506506

507507
return { subscribe, set, update }; // store contract
508508
};

files/en-us/learn_web_development/extensions/testing/feature_detection/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ Common patterns for detectable features include:
149149
This example shows a way of detecting [Canvas API](/en-US/docs/Web/API/Canvas_API) support:
150150

151151
```js
152-
function supports_canvas() {
152+
function supportsCanvas() {
153153
return !!document.createElement("canvas").getContext;
154154
}
155155
156-
if (supports_canvas()) {
156+
if (supportsCanvas()) {
157157
// Create and draw on canvas elements
158158
}
159159
```

files/en-us/learn_web_development/extensions/testing/your_own_automation_environment/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ There is also nothing to stop you running the test on multiple browsers simultan
137137
```js
138138
const { Builder, Browser, By, Key } = require("selenium-webdriver");
139139

140-
const driver_fx = new Builder().forBrowser(Browser.FIREFOX).build();
141-
const driver_chr = new Builder().forBrowser(Browser.CHROME).build();
140+
const driverFx = new Builder().forBrowser(Browser.FIREFOX).build();
141+
const driverChr = new Builder().forBrowser(Browser.CHROME).build();
142142

143143
async function searchTest(driver) {
144144
try {
@@ -156,8 +156,8 @@ There is also nothing to stop you running the test on multiple browsers simultan
156156
}
157157
}
158158

159-
searchTest(driver_fx);
160-
searchTest(driver_chr);
159+
searchTest(driverFx);
160+
searchTest(driverChr);
161161
```
162162

163163
3. In terminal, make sure you are inside your project folder, then enter the following command:

files/en-us/web/api/baseaudiocontext/createwaveshaper/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ const distortion = audioCtx.createWaveShaper();
4949

5050
function makeDistortionCurve(amount) {
5151
const k = typeof amount === "number" ? amount : 50;
52-
const n_samples = 44100;
53-
const curve = new Float32Array(n_samples);
52+
const numSamples = 44100;
53+
const curve = new Float32Array(numSamples);
5454
const deg = Math.PI / 180;
5555

56-
for (let i = 0; i < n_samples; i++) {
57-
const x = (i * 2) / n_samples - 1;
56+
for (let i = 0; i < numSamples; i++) {
57+
const x = (i * 2) / numSamples - 1;
5858
curve[i] = ((3 + k) * x * 20 * deg) / (Math.PI + k * Math.abs(x));
5959
}
6060
return curve;

files/en-us/web/api/canvasrenderingcontext2d/arcto/index.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -371,18 +371,18 @@ function findConstruction([P0, P1, P2], r, canvasSize, errorTolCenter) {
371371
const dir2Mag = Math2D.L2(dir2);
372372

373373
/* Make direction vectors unit length */
374-
const dir1_unit = Math2D.vector(dir1.x / dir1Mag, dir1.y / dir1Mag);
375-
const dir2_unit = Math2D.vector(dir2.x / dir2Mag, dir2.y / dir2Mag);
374+
const dir1Unit = Math2D.vector(dir1.x / dir1Mag, dir1.y / dir1Mag);
375+
const dir2Unit = Math2D.vector(dir2.x / dir2Mag, dir2.y / dir2Mag);
376376

377377
/* Angle between lines -- cos angle = a.b/(|a||b|)
378378
* Using unit vectors, so |a| = |b| = 1 */
379-
const dp = Math2D.dot(dir1_unit, dir2_unit);
379+
const dp = Math2D.dot(dir1Unit, dir2Unit);
380380
/* Test for collinearity */
381381
if (Math.abs(dp) > 0.999999) {
382382
/* Angle 0 or 180 degrees, or nearly so */
383383
return [false];
384384
}
385-
const angle = Math.acos(Math2D.dot(dir1_unit, dir2_unit));
385+
const angle = Math.acos(Math2D.dot(dir1Unit, dir2Unit));
386386

387387
/* Distance to tangent points from P1 --
388388
* (T1, P1, C) form a right triangle (T2, P1, C) same triangle.
@@ -391,16 +391,16 @@ function findConstruction([P0, P1, P2], r, canvasSize, errorTolCenter) {
391391
const distToTangent = r / Math.tan(0.5 * angle);
392392

393393
/* Locate tangent points */
394-
const T1 = Math2D.linePointAt(P1, distToTangent, dir1_unit);
395-
const T2 = Math2D.linePointAt(P1, distToTangent, dir2_unit);
394+
const T1 = Math2D.linePointAt(P1, distToTangent, dir1Unit);
395+
const T2 = Math2D.linePointAt(P1, distToTangent, dir2Unit);
396396

397397
/* Center is along normal to tangent at tangent point at
398398
* a distance equal to the radius of the circle.
399399
* Locate center two ways. Should be equal */
400-
const dirT2_T1 = Math2D.vector(T2.x - T1.x, T2.y - T1.y);
401-
const dirT1_T2 = Math2D.vector(-dirT2_T1.x, -dirT2_T1.y);
402-
const C1 = findCenter(T1, dir1_unit, r, dirT2_T1);
403-
const C2 = findCenter(T2, dir2_unit, r, dirT1_T2);
400+
const dirT2T1 = Math2D.vector(T2.x - T1.x, T2.y - T1.y);
401+
const dirT1T2 = Math2D.vector(-dirT2T1.x, -dirT2T1.y);
402+
const C1 = findCenter(T1, dir1Unit, r, dirT2T1);
403+
const C2 = findCenter(T2, dir2Unit, r, dirT1T2);
404404

405405
/* Error in center calculations */
406406
const deltaC = Math2D.vector(C2.x - C1.x, C2.y - C1.y);
@@ -423,8 +423,8 @@ function findConstruction([P0, P1, P2], r, canvasSize, errorTolCenter) {
423423
* is assured to be sufficiently far away and has the advantage of
424424
* being easily found. */
425425
const distToInf = canvasSize.x + canvasSize.y;
426-
const L1inf = Math2D.linePointAt(P1, distToInf, dir1_unit);
427-
const L2inf = Math2D.linePointAt(P1, distToInf, dir2_unit);
426+
const L1inf = Math2D.linePointAt(P1, distToInf, dir1Unit);
427+
const L2inf = Math2D.linePointAt(P1, distToInf, dir2Unit);
428428

429429
return [true, L1inf, L2inf, T1, T2, C];
430430
} /* end of function findConstruction */

files/en-us/web/api/canvasrenderingcontext2d/globalcompositeoperation/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ function createInterlace(size, color1, color2) {
401401
return pattern;
402402
}
403403

404-
const op_8x8 = createInterlace(8, "white", "#eeeeee");
404+
const op8x8 = createInterlace(8, "white", "#eeeeee");
405405
```
406406

407407
#### Start running
@@ -411,7 +411,7 @@ Finally, we call the functions to set everything in motion.
411411
```js
412412
lightMix();
413413
colorSphere();
414-
runComposite(op_8x8);
414+
runComposite(op8x8);
415415
```
416416

417417
#### Result

files/en-us/web/api/canvasrenderingcontext2d/lang/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const canvasElem = document.querySelector("canvas");
159159
const ctx = canvasElem.getContext("bitmaprenderer");
160160

161161
const offscreen = new OffscreenCanvas(canvasElem.width, canvasElem.height);
162-
const offscreen_ctx = offscreen.getContext("2d");
162+
const offscreenCtx = offscreen.getContext("2d");
163163

164164
const selectElem = document.querySelector("select");
165165

@@ -176,11 +176,11 @@ latoMediumFontFace.load().then((font) => {
176176

177177
function init() {
178178
function drawText() {
179-
offscreen_ctx.clearRect(0, 0, canvasElem.width, canvasElem.height);
180-
offscreen_ctx.lang = selectElem.value;
181-
offscreen_ctx.font = "30px Lato-Medium";
182-
offscreen_ctx.color = "black";
183-
offscreen_ctx.fillText("finish crafting", 50, 100);
179+
offscreenCtx.clearRect(0, 0, canvasElem.width, canvasElem.height);
180+
offscreenCtx.lang = selectElem.value;
181+
offscreenCtx.font = "30px Lato-Medium";
182+
offscreenCtx.color = "black";
183+
offscreenCtx.fillText("finish crafting", 50, 100);
184184

185185
const bitmap = offscreen.transferToImageBitmap();
186186
ctx.transferFromImageBitmap(bitmap);

files/en-us/web/api/cookiechangeevent/changed/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ cookieStore.addEventListener("change", (event) => {
4949
console.log(event.changed[0]);
5050
});
5151

52-
const one_day = 24 * 60 * 60 * 1000;
52+
const oneDay = 24 * 60 * 60 * 1000;
5353
cookieStore.set({
5454
name: "cookie1",
5555
value: "cookie1-value",
56-
expires: Date.now() + one_day,
56+
expires: Date.now() + oneDay,
5757
domain: "example.com",
5858
});
5959
```

files/en-us/web/api/cookiechangeevent/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ cookieStore.addEventListener("change", (event) => {
4141
console.log(event);
4242
});
4343

44-
const one_day = 24 * 60 * 60 * 1000;
44+
const oneDay = 24 * 60 * 60 * 1000;
4545
cookieStore.set({
4646
name: "cookie1",
4747
value: "cookie1-value",
48-
expires: Date.now() + one_day,
48+
expires: Date.now() + oneDay,
4949
domain: "example.com",
5050
});
5151
```

files/en-us/web/api/cssstyleproperties/index.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -103,41 +103,41 @@ Using the dot notation with a camel case property is the easiest way to access a
103103

104104
```js
105105
// Get style using dot notation
106-
const elem_borderTop = elementStyle.borderTop;
107-
const comp_borderTop = computedStyle.borderTop;
106+
const elemBorderTop = elementStyle.borderTop;
107+
const compBorderTop = computedStyle.borderTop;
108108

109109
log('Format: Style = "Element" / "Computed"');
110-
log(`"borderTop" = "${elem_borderTop}" / "${comp_borderTop}"'`);
110+
log(`"borderTop" = "${elemBorderTop}" / "${compBorderTop}"'`);
111111
```
112112

113113
We can also get the same property using the {{DOMxRef("CSSStyleDeclaration/getPropertyPriority", "getPropertyValue()")}} method or bracket notation.
114114

115115
```js
116116
// Get style using dashed-name property value
117-
const elem_border_top = elementStyle.getPropertyValue("border-top");
118-
const comp_border_top = computedStyle.getPropertyValue("border-top");
119-
log(`"border-top" = "${elem_border_top}" / "${elem_border_top}"'`);
117+
const elemBorderTop = elementStyle.getPropertyValue("border-top");
118+
const compBorderTop = computedStyle.getPropertyValue("border-top");
119+
log(`"border-top" = "${elemBorderTop}" / "${compBorderTop}"'`);
120120
```
121121

122122
The following code gets each of the longhand properties that correspond to the shorthand property `border-top`, using the dot notation for simplicity.
123123

124124
```js
125125
// Get shorthand properties using dot notation
126-
const elem_borderTopWidth = elementStyle.borderTopWidth;
127-
const comp_borderTopWidth = computedStyle.borderTopWidth;
128-
log(`"borderTopWidth" = "${elem_borderTopWidth}" / "${comp_borderTopWidth}"'`);
126+
const elemBorderTopWidth = elementStyle.borderTopWidth;
127+
const compBorderTopWidth = computedStyle.borderTopWidth;
128+
log(`"borderTopWidth" = "${elemBorderTopWidth}" / "${compBorderTopWidth}"'`);
129129

130-
const elem_borderTopColor = elementStyle.borderTopColor;
131-
const comp_borderTopColor = computedStyle.borderTopColor;
132-
log(`"borderTopColor" = "${elem_borderTopColor}" / "${comp_borderTopColor}"'`);
130+
const elemBorderTopColor = elementStyle.borderTopColor;
131+
const compBorderTopColor = computedStyle.borderTopColor;
132+
log(`"borderTopColor" = "${elemBorderTopColor}" / "${compBorderTopColor}"'`);
133133

134-
const elem_borderTopStyle = elementStyle.borderTopStyle;
135-
const comp_borderTopStyle = computedStyle.borderTopStyle;
136-
log(`"borderTopStyle" = "${elem_borderTopStyle}" / "${comp_borderTopStyle}"'`);
134+
const elemBorderTopStyle = elementStyle.borderTopStyle;
135+
const compBorderTopStyle = computedStyle.borderTopStyle;
136+
log(`"borderTopStyle" = "${elemBorderTopStyle}" / "${compBorderTopStyle}"'`);
137137

138-
const elem_fontWeight = elementStyle.fontWeight;
139-
const comp_fontWeight = computedStyle.fontWeight;
140-
log(`"fontWeight" = "${elem_fontWeight}" / "${comp_fontWeight}"'`);
138+
const elemFontWeight = elementStyle.fontWeight;
139+
const compFontWeight = computedStyle.fontWeight;
140+
log(`"fontWeight" = "${elemFontWeight}" / "${compFontWeight}"'`);
141141
```
142142

143143
Lastly we demonstrate how you can use the dot notation to set a property value.

0 commit comments

Comments
 (0)