Skip to content

Commit c2b04ec

Browse files
authored
style: sort, check and align jsDoc (kaplayjs#795)
1 parent 25b7499 commit c2b04ec

File tree

9 files changed

+135
-59
lines changed

9 files changed

+135
-59
lines changed

eslint.config.mjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,39 @@ export default tseslint.config(
1111
},
1212
rules: {
1313
"jsdoc/require-hyphen-before-param-description": "error",
14+
"jsdoc/check-alignment": "warn",
15+
"jsdoc/check-tag-names": ["error", {
16+
"definedTags": ["group", "experimental"],
17+
}],
18+
"jsdoc/sort-tags": ["error", {
19+
tagSequence: [{
20+
tags: [
21+
"deprecated",
22+
],
23+
}, {
24+
tags: [
25+
"param",
26+
],
27+
}, {
28+
tags: [
29+
"template",
30+
],
31+
}, {
32+
tags: [
33+
"example",
34+
],
35+
}, {
36+
tags: [
37+
"default",
38+
"readonly",
39+
"static",
40+
"returns",
41+
"since",
42+
"group",
43+
"experimental",
44+
],
45+
}],
46+
}],
1447
},
1548
files: ["./src/**/*.ts"],
1649
},

src/core/engine.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/**
2-
The engine is what KAPLAY needs for running and proccesing all it's stuff
3-
**/
1+
// The engine is what KAPLAY needs for running and proccesing all it's stuff
42

53
import { initApp } from "../app/app";
64
import { initAssets } from "../assets/asset";

src/ecs/components/misc/animate.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class AnimateChannel {
170170
* Returns the first key index for the given time, as well as the relative time towards the second key.
171171
* @param t - The time in seconds.
172172
* @param timing - The optional timestamps in percent.
173+
*
173174
* @returns The first key index for the given time, as well as the relative time towards the second key.
174175
*/
175176
getLowerKeyIndexAndRelativeTime(
@@ -269,6 +270,7 @@ class AnimateChannel {
269270
* Reflects a point around another point
270271
* @param a - Point to reflect
271272
* @param b - Point to reflect around
273+
*
272274
* @returns Reflected point
273275
*/
274276
function reflect(a: Vec2, b: Vec2) {
@@ -647,6 +649,7 @@ export function animate(gopts: AnimateCompOpt = {}): AnimateComp {
647649
* Serializes an animation to javascript objects for serialization to JSON.
648650
* @param obj - The root object to serialize from.
649651
* @param name - Optional name of the root object.
652+
*
650653
* @returns A javascript object serialization of the animation.
651654
*/
652655
export function serializeAnimation(obj: GameObj<any>, name: string): any {

src/ecs/entity/GameObjRaw.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ export interface GameObjRaw {
362362
* Trigger an event.
363363
*
364364
* @param event - The event name.
365-
* @parm args - The arguments to pass to the event action.
365+
* @param args - The arguments to pass to the event action.
366366
*
367367
* @since v2000.0
368368
*/

src/events/events.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class Registry<T> extends Map<number, T> {
3131
* logHi.cancel();
3232
*
3333
* ```
34+
*
3435
* @group Events
3536
*/
3637
export class KEventController {

src/math/Vec2.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export class Vec2 {
8989
* @param x - The x of the second term
9090
* @param y - The y of the second term
9191
* @param out - The vector sum
92+
*
9293
* @returns The sum of the vectors
9394
*/
9495
static addc(v: Vec2, x: number, y: number, out: Vec2): Vec2 {
@@ -102,6 +103,7 @@ export class Vec2 {
102103
* @param v - The first term
103104
* @param other - The second term
104105
* @param out - The vector sum
106+
*
105107
* @returns The sum of the vectors
106108
*/
107109
static add(v: Vec2, other: Vec2, out: Vec2): Vec2 {
@@ -122,6 +124,7 @@ export class Vec2 {
122124
* @param x - The x of the second term
123125
* @param y - The y of the second term
124126
* @param out - The vector difference
127+
*
125128
* @returns The difference of the vectors
126129
*/
127130
static subc(v: Vec2, x: number, y: number, out: Vec2): Vec2 {
@@ -135,6 +138,7 @@ export class Vec2 {
135138
* @param v - The first term
136139
* @param other - The second term
137140
* @param out - The vector difference
141+
*
138142
* @returns The difference of the vectors
139143
*/
140144
static sub(v: Vec2, other: Vec2, out: Vec2): Vec2 {
@@ -155,6 +159,7 @@ export class Vec2 {
155159
* @param x - The x scale
156160
* @param y - The y scale
157161
* @param out - The scaled vector
162+
*
158163
* @returns The scale of the vector
159164
*/
160165
static scale(v: Vec2, s: number, out: Vec2): Vec2 {
@@ -169,6 +174,7 @@ export class Vec2 {
169174
* @param x - The x scale
170175
* @param y - The y scale
171176
* @param out - The scaled vector
177+
*
172178
* @returns The scale of the vector
173179
*/
174180
static scalec(v: Vec2, x: number, y: number, out: Vec2): Vec2 {
@@ -182,6 +188,7 @@ export class Vec2 {
182188
* @param v - The vector
183189
* @param other - The scale
184190
* @param out - The scaled vector
191+
*
185192
* @returns The scale of the vector
186193
*/
187194
static scalev(v: Vec2, other: Vec2, out: Vec2): Vec2 {
@@ -206,6 +213,7 @@ export class Vec2 {
206213
* Calculates the distance between the vectors
207214
* @param v - The vector
208215
* @param other - The other vector
216+
*
209217
* @returns The between the vectors
210218
*/
211219
static dist(v: Vec2, other: Vec2): number {
@@ -224,6 +232,7 @@ export class Vec2 {
224232
* Calculates the squared distance between the vectors
225233
* @param v - The vector
226234
* @param other - The other vector
235+
*
227236
* @returns The distance between the vectors
228237
*/
229238
static sdist(v: Vec2, other: Vec2): number {
@@ -244,6 +253,7 @@ export class Vec2 {
244253
/**
245254
* Calculates the length of the vector
246255
* @param v - The vector
256+
*
247257
* @returns The length of the vector
248258
*/
249259
static len(v: Vec2) {
@@ -262,6 +272,7 @@ export class Vec2 {
262272
/**
263273
* Calculates the squared length of the vector
264274
* @param v - The vector
275+
*
265276
* @returns The squared length of the vector
266277
*/
267278
static slen(v: Vec2) {
@@ -346,6 +357,7 @@ export class Vec2 {
346357
* @param v - The vector
347358
* @param dir - The rotation vector
348359
* @param out - The rotated vector
360+
*
349361
* @returns The rotated vector
350362
*/
351363
static rotate(v: Vec2, dir: Vec2, out: Vec2): Vec2 {
@@ -360,6 +372,7 @@ export class Vec2 {
360372
* @param v - The vector
361373
* @param angle - The angle in radians
362374
* @param out - The rotated vector
375+
*
363376
* @returns The rotated vector
364377
*/
365378
static rotateByAngle(v: Vec2, angle: number, out: Vec2): Vec2 {
@@ -385,6 +398,7 @@ export class Vec2 {
385398
* @param v - The vector
386399
* @param dir - The rotation vector
387400
* @param out - The rotated vector
401+
*
388402
* @returns The rotated vector
389403
*/
390404
static inverseRotate(v: Vec2, dir: Vec2, out: Vec2): Vec2 {
@@ -439,6 +453,7 @@ export class Vec2 {
439453
/**
440454
* Calculates the angle represented by the vector in radians
441455
* @param v - The vector
456+
*
442457
* @returns Angle represented by the vector in radians
443458
*/
444459
static toAngle(v: Vec2) {
@@ -459,6 +474,7 @@ export class Vec2 {
459474
* Calculates the angle between the vectors in radians
460475
* @param v - First vector
461476
* @param other - Second vector
477+
*
462478
* @returns Angle between the vectors in radians
463479
*/
464480
static angleBetween(v: Vec2, other: Vec2) {
@@ -481,6 +497,7 @@ export class Vec2 {
481497
* @param dst - Second vector
482498
* @param t - Percentage
483499
* @param out - The linear interpolation between src and dst by t
500+
*
484501
* @returns The linear interpolation between src and dst by t
485502
*/
486503
static lerp(src: Vec2, dst: Vec2, t: number, out: Vec2): Vec2 {
@@ -510,6 +527,7 @@ export class Vec2 {
510527
* @param dst - Second vector
511528
* @param t - Percentage
512529
* @param out - The spherical interpolation between src and dst by t
530+
*
513531
* @returns The spherical interpolation between src and dst by t
514532
*/
515533
static slerp(src: Vec2, dst: Vec2, t: number, out: Vec2): Vec2 {

src/math/gjk.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ function evolveSimplex(
221221
* Returns true if the colliders intersect.
222222
* @param colliderA - The first collider to test
223223
* @param colliderB - The second collider to test
224+
*
224225
* @returns True if the colliders intersect
225226
*/
226227
function gjkIntersects(colliderA: Collider, colliderB: Collider): boolean {
@@ -249,6 +250,7 @@ type Edge = {
249250
* Returns the edge closest to the origin.
250251
* @param simplex - The simplex whose edges we will check to find the closest edge to the origin
251252
* @param winding - The winding order of the simplex
253+
*
252254
* @returns The edge closest to the origin.
253255
*/
254256
function findClosestEdge(simplex: Vec2[], winding: PolygonWinding): Edge {
@@ -303,6 +305,7 @@ export type GjkCollisionResult = {
303305
* Returns true if the shapes collide
304306
* @param colliderA - The first collider to test
305307
* @param colliderB - The second collider to test
308+
*
306309
* @returns True if the shapes collide
307310
*/
308311
function getIntersection(
@@ -364,6 +367,7 @@ function getIntersection(
364367
* Returns a collision result if there was a collision
365368
* @param colliderA - The first collider to test
366369
* @param colliderB - The second collider to test
370+
*
367371
* @returns A collision result or null
368372
*/
369373
function gjkIntersection(
@@ -389,6 +393,7 @@ function gjkIntersection(
389393
/**
390394
* Returns a collider for the given shape.
391395
* @param shape - The shape to get a collider for.
396+
*
392397
* @returns
393398
*/
394399
function shapeToCollider(shape: Shape): Collider {
@@ -421,6 +426,7 @@ function shapeToCollider(shape: Shape): Collider {
421426
* Returns true if the shapes collide
422427
* @param shapeA - The first shape to test
423428
* @param shapeB - The second shape to test
429+
*
424430
* @returns True if the shapes collide
425431
*/
426432
export function gjkShapeIntersects(shapeA: Shape, shapeB: Shape): boolean {
@@ -433,6 +439,7 @@ export function gjkShapeIntersects(shapeA: Shape, shapeB: Shape): boolean {
433439
* Returns a collision result if there was a collision
434440
* @param shapeA - The first shape to test
435441
* @param shapeB - The second shape to test
442+
*
436443
* @returns A collision result or null
437444
*/
438445
export function gjkShapeIntersection(

src/math/math.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,6 +2404,7 @@ export function curveLengthApproximation(
24042404
* @param m1 - First control point (tangent)
24052405
* @param m2 - Second control point (tangent)
24062406
* @param pt2 - Second point
2407+
*
24072408
* @returns A function which gives the value on the 1D Hermite curve at t
24082409
*/
24092410
export function hermite(pt1: number, m1: number, m2: number, pt2: number) {
@@ -2427,6 +2428,7 @@ export function hermite(pt1: number, m1: number, m2: number, pt2: number) {
24272428
* @param pt4 - Next point
24282429
* @param tension - The tension of the curve, [0..1] from round to tight.
24292430
* @param h - The hermite function or one of its derivatives.
2431+
*
24302432
* @returns A function which gives the value on the 2D Cardinal curve at t
24312433
*/
24322434
export function cardinal(
@@ -2460,6 +2462,7 @@ export function cardinal(
24602462
* @param pt2 - First point
24612463
* @param pt3 - Second point
24622464
* @param pt4 - Next point
2465+
*
24632466
* @returns A function which gives the value on the 2D Catmull-Rom curve at t
24642467
*/
24652468
export function catmullRom(
@@ -2479,6 +2482,7 @@ export function catmullRom(
24792482
* @param pt2 - First control point
24802483
* @param pt3 - Second control point
24812484
* @param pt4 - Second point
2485+
*
24822486
* @returns A function which gives the value on the 2D quadratic Bezier curve at t
24832487
*/
24842488
export function bezier(
@@ -2507,6 +2511,7 @@ export function bezier(
25072511
* @param tension - The tension of the curve, [-1..1] from round to tight.
25082512
* @param continuity - The continuity of the curve, [-1..1] from box corners to inverted corners.
25092513
* @param bias - The bias of the curve, [-1..1] from pre-shoot to post-shoot.
2514+
*
25102515
* @returns A function which gives the value on the 2D Kochanek–Bartels curve at t
25112516
*/
25122517
export function kochanekBartels(
@@ -2550,6 +2555,7 @@ export function kochanekBartels(
25502555
* @param m1 - First control point (tangent)
25512556
* @param m2 - Second control point (tangent)
25522557
* @param pt2 - Second point
2558+
*
25532559
* @returns A function which gives the first derivative on the 1D Hermite curve at t
25542560
*/
25552561
export function hermiteFirstDerivative(

0 commit comments

Comments
 (0)