ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.32k stars 254 forks source link

Consider adding a typo check in github action? #219

Closed zhong-yiyu closed 2 months ago

zhong-yiyu commented 2 months ago

Given that there's already a github action workflow existing, how about adding a typos auto-correct step to it? There's a few typos in the code, and currently none of them is affecting the public API, so the extra workflow should have no side-effects on the final output. I recommend the Typos tool to perform this work since it's already a github action.

P.S. I've attached a diff file to show typos could be fixed automatically by the tool. diff.patch

diff --git a/src/map/digger.ts b/src/map/digger.ts
index 0fd870c..47d48e1 100644
--- a/src/map/digger.ts
+++ b/src/map/digger.ts
@@ -93,7 +93,7 @@ export default class Digger extends Dungeon {
            do {
                featureAttempts++;
                if (this._tryFeature(x, y, dir[0], dir[1])) { /* feature added */
-                   //if (this._rooms.length + this._corridors.length == 2) { this._rooms[0].addDoor(x, y); } /* first room oficially has doors */
+                   //if (this._rooms.length + this._corridors.length == 2) { this._rooms[0].addDoor(x, y); } /* first room officially has doors */
                    this._removeSurroundingWalls(x, y);
                    this._removeSurroundingWalls(x-dir[0], y-dir[1]);
                    break; 
diff --git a/src/map/rogue.ts b/src/map/rogue.ts
index e2fbf96..cc56abe 100644
--- a/src/map/rogue.ts
+++ b/src/map/rogue.ts
@@ -30,7 +30,7 @@ export interface Room {

 /**
- * Dungeon generator which uses the "orginal" Rogue dungeon generation algorithm. See https://github.com/Davidslv/rogue-like/blob/master/docs/references/Mark_Damon_Hughes/07_Roguelike_Dungeon_Generation.md
+ * Dungeon generator which uses the "original" Rogue dungeon generation algorithm. See https://github.com/Davidslv/rogue-like/blob/master/docs/references/Mark_Damon_Hughes/07_Roguelike_Dungeon_Generation.md
  * @author hyakugei
  */
 export default class Rogue extends Map {
diff --git a/src/map/uniform.ts b/src/map/uniform.ts
index 4095091..0af3ce9 100644
--- a/src/map/uniform.ts
+++ b/src/map/uniform.ts
@@ -116,8 +116,8 @@ export default class Uniform extends Dungeon {
    }

    /**
-    * Generates connectors beween rooms
-    * @returns {bool} success Was this attempt successfull?
+    * Generates connectors between rooms
+    * @returns {bool} success Was this attempt successful?
     */
    _generateCorridors() {
        let cnt = 0;
diff --git a/tests/spec/color.js b/tests/spec/color.js
index 6c15e6a..df3e447 100644
--- a/tests/spec/color.js
+++ b/tests/spec/color.js
@@ -104,7 +104,7 @@ describe("Color", function() {
        it("should handle named colors", function() {
            expect(ROT.Color.fromString("red")).toEqual([255, 0, 0]);
        });
-       it("should not handle nonexistant colors", function() {
+       it("should not handle nonexistent colors", function() {
            expect(ROT.Color.fromString("lol")).toEqual([0, 0, 0]);
        });
    });
@@ -128,7 +128,7 @@ describe("Color", function() {
    });

    describe("interpolate", function() {
-       it("should intepolate two colors", function() {
+       it("should interpolate two colors", function() {
            expect(ROT.Color.interpolate([10, 20, 40], [100, 200, 300], 0.1)).toEqual([19, 38, 66]);
        });
        it("should round values", function() {
@@ -140,7 +140,7 @@ describe("Color", function() {
    });

    describe("interpolateHSL", function() {
-       it("should intepolate two colors", function() {
+       it("should interpolate two colors", function() {
            expect(ROT.Color.interpolateHSL([10, 20, 40], [100, 200, 300], 0.1)).toEqual([12, 33, 73]);
        });
    });
diff --git a/tests/spec/eventqueue.js b/tests/spec/eventqueue.js
index 58ff4d2..a5dcfbc 100644
--- a/tests/spec/eventqueue.js
+++ b/tests/spec/eventqueue.js
@@ -45,7 +45,7 @@ describe("EventQueue", function() {
        expect(q.get()).toEqual(456);
    });

-   it("should survive removal of non-existant events", function() {
+   it("should survive removal of non-existent events", function() {
        var q = new ROT.EventQueue();
        q.add(0, 0);
        var result = q.remove(1);
diff --git a/tests/spec/path.js b/tests/spec/path.js
index b94a7e4..e5629fa 100644
--- a/tests/spec/path.js
+++ b/tests/spec/path.js
@@ -85,7 +85,7 @@ describe("Path", function() {
                expect(PATH.toString()).toEqual(PATH_B.toString());
            });

-           it("should survive non-existant path X", function() {
+           it("should survive non-existent path X", function() {
                dijkstra.compute(X[0], X[1], PATH_CALLBACK);
                expect(PATH.length).toEqual(0);
            });
@@ -106,7 +106,7 @@ describe("Path", function() {
                expect(PATH.toString()).toEqual(PATH_B.toString());
            });

-           it("should survive non-existant path X", function() {
+           it("should survive non-existent path X", function() {
                dijkstra.compute(X[0], X[1], PATH_CALLBACK);
                expect(PATH.length).toEqual(0);
            });
@@ -127,7 +127,7 @@ describe("Path", function() {
                expect(PATH.toString()).toEqual(PATH_B.toString());
            });

-           it("should survive non-existant path X", function() {
+           it("should survive non-existent path X", function() {
                dijkstra.compute(X6[0], X6[1], PATH_CALLBACK);
                expect(PATH.length).toEqual(0);
            });
@@ -151,7 +151,7 @@ describe("Path", function() {
                expect(PATH.toString()).toEqual(PATH_B.toString());
            });

-           it("should survive non-existant path X", function() {
+           it("should survive non-existent path X", function() {
                astar.compute(X[0], X[1], PATH_CALLBACK);
                expect(PATH.length).toEqual(0);
            });
@@ -178,7 +178,7 @@ describe("Path", function() {
                expect(PATH.toString()).toEqual(PATH_B.toString());
            });

-           it("should survive non-existant path X", function() {
+           it("should survive non-existent path X", function() {
                astar.compute(X[0], X[1], PATH_CALLBACK);
                expect(PATH.length).toEqual(0);
            });
@@ -199,7 +199,7 @@ describe("Path", function() {
                expect(PATH.toString()).toEqual(PATH_B.toString());
            });

-           it("should survive non-existant path X", function() {
+           it("should survive non-existent path X", function() {
                astar.compute(X6[0], X6[1], PATH_CALLBACK);
                expect(PATH.length).toEqual(0);
            });
ondras commented 2 months ago

Hi @zhong-yiyu ,

this sounds like a reasonable suggestion. If you have some experience with the said tool (I do not), please feel free to submit a PR (provided that the bot/check would only offer suggestions, i.e. no automatic string replacements).