Skip to content

Commit 8285f24

Browse files
committed
fix linting warnings
Signed-off-by: Vaivaswat <vaivaswat2244@gmail.com>
1 parent 2a43fb0 commit 8285f24

46 files changed

Lines changed: 141 additions & 265 deletions

Some content is hidden

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

src/color/p5.Color.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
import {
2020
ColorSpace,
2121
to,
22-
toGamut,
2322
serialize,
2423
parse,
2524
range,
@@ -128,7 +127,7 @@ class Color {
128127
});
129128
this._cachedMode = mode;
130129
this._cachedColor = to(this._cachedColor, this._cachedColor.spaceId);
131-
} catch (err) {
130+
} catch {
132131
// TODO: Invalid color string
133132
throw new Error('Invalid color string');
134133
}
@@ -305,11 +304,6 @@ class Color {
305304
});
306305
}
307306

308-
// Will do conversion in-Gamut as out of Gamut conversion is only really useful for futher conversions
309-
#toColorMode(mode) {
310-
return new Color(this._color, mode);
311-
}
312-
313307
// Get raw coordinates of underlying library, can differ between libraries
314308
get _array() {
315309
return this._getRGBA();

src/core/filterShaders.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function makeFilterShader(renderer, operation, p5) {
101101
const maxSamples = 64.0;
102102

103103
let numSamples = p5.floor(radius * 7.0);
104-
if (p5.mod(numSamples, 2) == 0.0) {
104+
if (p5.mod(numSamples, 2) === 0.0) {
105105
numSamples++;
106106
}
107107

@@ -162,7 +162,7 @@ export function makeFilterShader(renderer, operation, p5) {
162162

163163
for (let x = -1; x <= 1; x++) {
164164
for (let y = -1; y <= 1; y++) {
165-
if (x != 0 || y != 0) {
165+
if (x !== 0 || y !== 0) {
166166
const offset = p5.vec2(x, y) * inputs.texelSize;
167167
const neighborColor = p5.getTexture(
168168
canvasContent,
@@ -198,7 +198,7 @@ export function makeFilterShader(renderer, operation, p5) {
198198

199199
for (let x = -1; x <= 1; x++) {
200200
for (let y = -1; y <= 1; y++) {
201-
if (x != 0 || y != 0) {
201+
if (x !== 0 || y !== 0) {
202202
const offset = p5.vec2(x, y) * inputs.texelSize;
203203
const neighborColor = p5.getTexture(
204204
canvasContent,

src/core/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,15 +400,15 @@ class p5 {
400400
for (const p in p5.prototype) {
401401
try {
402402
delete window[p];
403-
} catch (x) {
403+
} catch {
404404
window[p] = undefined;
405405
}
406406
}
407407
for (const p2 in this) {
408408
if (this.hasOwnProperty(p2)) {
409409
try {
410410
delete window[p2];
411-
} catch (x) {
411+
} catch {
412412
window[p2] = undefined;
413413
}
414414
}

src/core/p5.Renderer.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -447,25 +447,5 @@ function renderer(p5, fn) {
447447
p5.Renderer = Renderer;
448448
}
449449

450-
/**
451-
* Helper fxn to measure ascent and descent.
452-
* Adapted from http://stackoverflow.com/a/25355178
453-
* @private
454-
*/
455-
function calculateOffset(object) {
456-
let currentLeft = 0,
457-
currentTop = 0;
458-
if (object.offsetParent) {
459-
do {
460-
currentLeft += object.offsetLeft;
461-
currentTop += object.offsetTop;
462-
} while ((object = object.offsetParent));
463-
} else {
464-
currentLeft += object.offsetLeft;
465-
currentTop += object.offsetTop;
466-
}
467-
return [currentLeft, currentTop];
468-
}
469-
470450
export default renderer;
471451
export { Renderer };

src/core/p5.Renderer2D.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { Matrix } from '../math/p5.Matrix';
1111
import { PrimitiveToPath2DConverter } from '../shape/custom_shapes';
1212
import { DefaultFill, textCoreConstants } from '../type/textCore';
1313

14-
const styleEmpty = 'rgba(0,0,0,0)';
15-
1614
class Renderer2D extends Renderer {
1715
constructor(pInst, w, h, isMainCanvas, elt, attributes = {}) {
1816
super(pInst, w, h, isMainCanvas);
@@ -151,7 +149,7 @@ class Renderer2D extends Renderer {
151149
for (const savedKey in props) {
152150
try {
153151
this.drawingContext[savedKey] = props[savedKey];
154-
} catch (err) {
152+
} catch {
155153
// ignore read-only property errors
156154
}
157155
}

src/core/p5.Renderer3D.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,6 @@ export class Renderer3D extends Renderer {
436436
}
437437
}
438438

439-
remove() {
440-
this.wrappedElt.remove();
441-
this.wrappedElt = null;
442-
this.canvas = null;
443-
this.elt = null;
444-
}
445-
446439
//////////////////////////////////////////////
447440
// Geometry Building
448441
//////////////////////////////////////////////
@@ -1350,7 +1343,7 @@ export class Renderer3D extends Renderer {
13501343
for (const savedKey in props) {
13511344
try {
13521345
this.drawingContext[savedKey] = props[savedKey];
1353-
} catch (err) {
1346+
} catch {
13541347
// ignore read-only property errors
13551348
}
13561349
}
@@ -1933,7 +1926,7 @@ export class Renderer3D extends Renderer {
19331926
throw Error('_yAlignOffset: height is required');
19341927
}
19351928

1936-
let { textLeading, textBaseline, textSize, textFont } = this.states;
1929+
let { textLeading, textBaseline, textSize } = this.states;
19371930
let yOff = 0,
19381931
numLines = dataArr.length;
19391932
let totalHeight =
@@ -2175,6 +2168,10 @@ export class Renderer3D extends Renderer {
21752168
if (this._textCanvas) {
21762169
this._textCanvas.parentElement.removeChild(this._textCanvas);
21772170
}
2171+
this.wrappedElt.remove();
2172+
this.wrappedElt = null;
2173+
this.canvas = null;
2174+
this.elt = null;
21782175
super.remove();
21792176
}
21802177
}

src/dom/p5.MediaElement.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { Element } from './p5.Element';
77
// import { friendlyAutoplayError } from '../friendly_errors/fes_core';
8-
import { FES, TL } from '../friendly_errors/fes';
8+
import { FES } from '../friendly_errors/fes';
99

1010
/**
1111
* @typedef {'video'} VIDEO
@@ -934,7 +934,7 @@ class MediaElement extends Element {
934934
try {
935935
audioContext = obj.context;
936936
mainOutput = audioContext.destination;
937-
} catch (e) {
937+
} catch {
938938
throw 'connect() is meant to be used with Web Audio API or p5.sound.js';
939939
}
940940
}
@@ -1639,7 +1639,7 @@ function media(p5, fn) {
16391639
} else {
16401640
domElement.src = window.URL.createObjectURL(stream);
16411641
}
1642-
} catch (err) {
1642+
} catch {
16431643
domElement.src = stream;
16441644
}
16451645
})

src/friendly_errors/param_validator.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@ function validateParams(p5, fn, lifecycles) {
555555
message = FES.log`Expected ${match[1]} at the ${position} parameter in ${func + '()'}.`;
556556
break;
557557
}
558+
// Unrecognized custom errors fall through to the default logging below.
559+
// falls through
558560
}
559561
default: {
560562
console.log('Zod error object', currentError);
@@ -564,7 +566,7 @@ function validateParams(p5, fn, lifecycles) {
564566
if (isVersionError) {
565567
FES.log`${message}`();
566568
} else {
567-
const [_null, stacktrace] = processStack(
569+
const [, stacktrace] = processStack(
568570
null,
569571
errorStackParser.parse(Error()).slice(3)
570572
);
@@ -624,7 +626,7 @@ function validateParams(p5, fn, lifecycles) {
624626
success: true,
625627
data: funcSchemas.parse(args)
626628
};
627-
} catch (error) {
629+
} catch {
628630
const closestSchema = findClosestSchema(funcSchemas, args);
629631
const zodError = closestSchema.safeParse(args).error;
630632
const errorMessage = friendlyParamError(zodError, func, args);

src/friendly_errors/stacktrace.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,6 @@ export const processStack = (error, stacktrace) => {
325325
// from user's code
326326
if (friendlyStack.length === 0) return [true, null];
327327

328-
// get the function just above the topmost frame in the friendlyStack.
329-
// i.e the name of the library function called from user's code
330-
const func = stacktrace[friendlyStack[0].frameIndex - 1].functionName
331-
.split('.')
332-
.slice(-1)[0];
333-
334328
// Try and get the location (line no.) from the top element of the stack
335329
let locationObj;
336330
if (
@@ -351,6 +345,8 @@ export const processStack = (error, stacktrace) => {
351345
}
352346

353347
// Library error
348+
// `func` below is the name of the library function called from user's code,
349+
// i.e. stacktrace[friendlyStack[0].frameIndex - 1].functionName.
354350
// const message = TL.tl`${locationObj ? TL.tl`[${locationObj.file}, line ${locationObj.line}]` : ''} An error with message "${error.message}" occurred inside the p5js library when ${func} was called. If not stated otherwise, it might be an issue with the arguments passed to ${func}.`;
355351
// p5._friendlyError(
356352
// message,

src/image/p5.Image.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,7 @@ class Image {
4848
if (typeof density !== 'undefined') {
4949
// Setter: set the density and handle resize
5050
if (density <= 0) {
51-
const errorObj = {
52-
type: 'INVALID_VALUE',
53-
format: { types: ['Number'] },
54-
position: 1
55-
};
56-
57-
// p5._friendlyParamError(errorObj, 'pixelDensity');
51+
// TODO: report an INVALID_VALUE param error through the FES here.
5852

5953
// Default to 1 in case of an invalid value
6054
density = 1;

0 commit comments

Comments
 (0)