Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
import stylistic from "@stylistic/eslint-plugin";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand Down Expand Up @@ -35,6 +36,7 @@ export default [
"@typescript-eslint": typescriptEslint,
prettier,
header,
"@stylistic": stylistic,
},

languageOptions: {
Expand All @@ -58,6 +60,7 @@ export default [
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-empty-object-type": "off",
"eqeqeq": ["error", "smart"],
"no-case-declarations": "off",
"no-constant-condition": "off",
Expand All @@ -67,7 +70,7 @@ export default [
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/member-delimiter-style": "error",
"@stylistic/member-delimiter-style": "error",
"@typescript-eslint/no-floating-promises": "error",

"@typescript-eslint/no-inferrable-types": [
Expand All @@ -79,8 +82,8 @@ export default [
],

"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/semi": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@stylistic/semi": "error",
"@stylistic/type-annotation-spacing": "error",
"computed-property-spacing": ["error", "never"],
"curly": "error",
"eol-last": "error",
Expand Down
18 changes: 9 additions & 9 deletions examples/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function clear() {

const fiddler = new EventEmitter();

function GobanTestPage(): JSX.Element {
function GobanTestPage(): React.JSX.Element {
const [_update, _setUpdate] = React.useState(1);
const [svg_or_canvas, setSVGOrCanvas] = React.useState("svg");
function forceUpdate() {
Expand Down Expand Up @@ -341,7 +341,7 @@ interface ReactGobanProps {}
function ReactGoban<GobanClass extends Goban>(
ctor: { new (x: CanvasRendererGobanConfig | SVGRendererGobanConfig): GobanClass },
props: ReactGobanProps,
): JSX.Element {
): React.JSX.Element {
const [elapsed, setElapsed] = React.useState(0);
const container = React.useRef(null);
const move_tree_container = React.useRef(null);
Expand Down Expand Up @@ -549,7 +549,7 @@ function ReactGoban<GobanClass extends Goban>(
);
}

function StoneSamples(): JSX.Element {
function StoneSamples(): React.JSX.Element {
const div = React.useRef(null);

React.useEffect(() => {
Expand Down Expand Up @@ -721,15 +721,15 @@ function StoneSamples(): JSX.Element {
return <div ref={div} />;
}

function ReactGobanCanvas(props: ReactGobanProps): JSX.Element {
function ReactGobanCanvas(props: ReactGobanProps): React.JSX.Element {
return ReactGoban<GobanCanvas>(GobanCanvas, props);
}

function ReactGobanSVG(props: ReactGobanProps): JSX.Element {
function ReactGobanSVG(props: ReactGobanProps): React.JSX.Element {
return ReactGoban<SVGRenderer>(SVGRenderer, props);
}

function Main(props: { children: any }): JSX.Element {
function Main(props: { children: any }): React.JSX.Element {
return <div className="Main">{props.children}</div>;
}

Expand All @@ -745,7 +745,7 @@ new Goban({
});
`;

function Examples(): JSX.Element {
function Examples(): React.JSX.Element {
/*
return (
<div className="Default">
Expand Down Expand Up @@ -773,7 +773,7 @@ function CodeExample({
}: {
source: string;
scope: { [key: string]: any };
}): JSX.Element {
}): React.JSX.Element {
const [output, setOutput] = React.useState(null);
const goban_container = React.useRef(null);

Expand Down Expand Up @@ -805,7 +805,7 @@ function CodeExample({
);
}

export function LeftNav(): JSX.Element {
export function LeftNav(): React.JSX.Element {
return (
<div className="LeftNav">
<Link to="/">Home</Link>
Expand Down
61 changes: 33 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,48 +45,49 @@
},
"homepage": "https://github.com/online-go/goban#readme",
"devDependencies": {
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.7.0",
"@eslint/compat": "^1.4.0",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "9.38.0",
"@stylistic/eslint-plugin": "^5.5.0",
"@tony.ganchev/eslint-plugin-header": "^3.1.8",
"@types/cli-color": "^2.0.6",
"@types/jest": "^29.5.12",
"@types/node": "^18.15.5",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"@types/node": "^24.9.1",
"@types/react": "19.2.2",
"@types/react-dom": "19.2.2",
"@typescript-eslint/eslint-plugin": "^8.46.2",
"@typescript-eslint/parser": "^8.46.2",
"bufferutil": "^4.0.7",
"canvas": "^3.1.0",
"cli-color": "^2.0.4",
"cspell": "^8.3.2",
"cspell": "^9.2.2",
"dts-bundle-generator": "^9.5.1",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"@tony.ganchev/eslint-plugin-header": "^3.1.2",
"eslint-plugin-jsdoc": "^46.9.1",
"eslint": "9.38.0",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-jsdoc": "^61.1.9",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-unicorn": "^49.0.0",
"eslint-plugin-prettier": ">=5.2.1",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-unicorn": "^62.0.0",
"fork-ts-checker-webpack-plugin": "^9.0.0",
"globals": "^15.8.0",
"husky": "^8.0.1",
"globals": "^16.4.0",
"husky": "^9.1.7",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-transform-stub": "^2.0.0",
"jest-websocket-mock": "^2.4.0",
"jest-websocket-mock": "^2.5.0",
"jscpd": "^4.0.1",
"lint-staged": "^15.0.1",
"prettier": "^3.1.1",
"prettier-eslint": "^16.1.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.23.1",
"react-router-dom": "^6.23.1",
"stylus": "^0.63.0",
"lint-staged": "^16.2.6",
"prettier": "3.6.2",
"prettier-eslint": "^16.4.2",
"react": "19.2.0",
"react-dom": "19.2.0",
"react-router": "^7.9.4",
"react-router-dom": "7.9.4",
"stylus": "0.64.0",
"svg-inline-loader": "0.8.2",
"thread-loader": "^3.0.4",
"ts-jest": "^29.1.4",
"ts-jest": "^29.4.5",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
Expand All @@ -98,6 +99,10 @@
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.13.1"
},
"overrides": {
"react": "=19.2.0",
"react-dom": "=19.2.0"
},
"dependencies": {
"eventemitter3": "^5.0.0"
},
Expand Down
3 changes: 1 addition & 2 deletions src/Goban/OGSConnectivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,7 @@ export abstract class OGSConnectivity extends GobanInteractive {
if ("f" in obj && typeof obj.m === "string") {
/* specifying node */
const t = this.done_loading_review;
this.done_loading_review =
false; /* this prevents drawing from being drawn when we do a follow path. */
this.done_loading_review = false; /* this prevents drawing from being drawn when we do a follow path. */
this.engine.followPath(obj.f || 0, obj.m);
this.drawSquare(this.engine.cur_move.x, this.engine.cur_move.y);
this.done_loading_review = t;
Expand Down
22 changes: 11 additions & 11 deletions test/unit_tests/GoEngine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ describe("GobanEngine.place()", () => {
*/
goban_callback.set.mockClear();
expect(engine.place(0, 0)).toBe(1);
expect(goban_callback.set).toBeCalledWith(0, 0, 0);
expect(goban_callback.set).toHaveBeenCalledWith(0, 0, 0);
});

test("removed_stones parameter", () => {
Expand Down Expand Up @@ -408,13 +408,13 @@ describe("moves", () => {
engine.setAsCurrentReviewMove();

expect(engine.cur_review_move).toBe(engine.cur_move);
expect(on_cur_review_move).toBeCalledTimes(1);
expect(on_cur_review_move).toHaveBeenCalledTimes(1);

on_cur_review_move.mockClear();
engine.setAsCurrentReviewMove();

// the signal shouldn't be emitted if the value doesn't actually change
expect(on_cur_review_move).not.toBeCalled();
expect(on_cur_review_move).not.toHaveBeenCalled();
});

test("cur_move", () => {
Expand All @@ -429,7 +429,7 @@ describe("moves", () => {

expect(engine.cur_move.x).toBe(2);
expect(engine.cur_move.y).toBe(3);
expect(on_cur_move).toBeCalledTimes(1);
expect(on_cur_move).toHaveBeenCalledTimes(1);
});

describe("setLastOfficialMove", () => {
Expand All @@ -442,19 +442,19 @@ describe("moves", () => {

engine.place(10, 10, false, false, false, false, true /* isTrunkMove */);

expect(on_last_official_move).not.toBeCalled();
expect(on_last_official_move).not.toHaveBeenCalled();
expect(engine.last_official_move).not.toBe(engine.cur_move);

engine.setLastOfficialMove();

expect(engine.last_official_move).toBe(engine.cur_move);
expect(on_last_official_move).toBeCalledTimes(1);
expect(on_last_official_move).toHaveBeenCalledTimes(1);

on_last_official_move.mockClear();

engine.setLastOfficialMove();
// nothing changed, so no message is emitted
expect(on_last_official_move).toBeCalledTimes(0);
expect(on_last_official_move).toHaveBeenCalledTimes(0);
});

test("cur_move not on trunk is an error", () => {
Expand Down Expand Up @@ -635,7 +635,7 @@ describe("groups", () => {

engine.toggleSingleGroupRemoval(0, 0);

expect(on_removal_updated).toBeCalledTimes(1);
expect(on_removal_updated).toHaveBeenCalledTimes(1);

expect(engine.removal).toEqual([
[true, false, false, false],
Expand Down Expand Up @@ -667,7 +667,7 @@ describe("groups", () => {
engine.addListener("stone-removal.updated", on_removal_updated);

expect(engine.toggleSingleGroupRemoval(0, 4)).toEqual({ removed: false, group: [] });
expect(on_removal_updated).toBeCalledTimes(0);
expect(on_removal_updated).toHaveBeenCalledTimes(0);
});

test("toggleSingleGroupRemoval empty area doesn't do anything", () => {
Expand All @@ -686,7 +686,7 @@ describe("groups", () => {
engine.addListener("stone-removal.updated", on_removal_updated);

expect(engine.toggleSingleGroupRemoval(0, 1)).toEqual({ removed: false, group: [] });
expect(on_removal_updated).toBeCalledTimes(0);
expect(on_removal_updated).toHaveBeenCalledTimes(0);
});

test("clearRemoved", () => {
Expand All @@ -706,7 +706,7 @@ describe("groups", () => {
engine.addListener("stone-removal.updated", on_removal_updated);
engine.clearRemoved();

expect(on_removal_updated).toBeCalledTimes(1);
expect(on_removal_updated).toHaveBeenCalledTimes(1);
expect(engine.removal).toEqual(makeMatrix(4, 2, false));
});

Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/GoEngine_sgf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ test.each(SGF_TEST_CASES)(
expect(rmNewlines(moves_gen)).toBe(rmNewlines(moves));
expect(goban.engine.move_tree.size()).toBe(size);
if (num_errors) {
expect(log_spy).toBeCalledTimes(num_errors);
expect(log_spy).toHaveBeenCalledTimes(num_errors);
}
},
);
Expand Down
14 changes: 7 additions & 7 deletions test/unit_tests/GobanCanvas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ describe("onTap", () => {
[0, 0, 0],
[0, 0, 0],
]);
expect(log_spy).toBeCalledWith(
expect(log_spy).toHaveBeenCalledWith(
"Submit button pressed only ",
40,
"ms after stone was placed, presuming bad click",
Expand Down Expand Up @@ -383,10 +383,10 @@ describe("onTap", () => {

// Unmodified clicks in stone removal send a "game/removed_stones/set" message
jest.setSystemTime(50);
expect(addCoordinatesToChatInput).toBeCalledTimes(1);
expect(addCoordinatesToChatInput).toHaveBeenCalledTimes(1);
// Note: "A2" is the correct pretty coordinate for (0,0) on a 2x4 board
// because the y coordinate is flipped
expect(addCoordinatesToChatInput).toBeCalledWith("A2");
expect(addCoordinatesToChatInput).toHaveBeenCalledWith("A2");
jest.useRealTimers();
});

Expand Down Expand Up @@ -430,8 +430,8 @@ describe("onTap", () => {

goban.setScoringMode(true);

expect(goban.engine.estimateScore).toBeCalledTimes(1);
expect(goban.engine.estimateScore).toBeCalledWith(
expect(goban.engine.estimateScore).toHaveBeenCalledTimes(1);
expect(goban.engine.estimateScore).toHaveBeenCalledWith(
SCORE_ESTIMATION_TRIALS,
SCORE_ESTIMATION_TOLERANCE,
false,
Expand All @@ -442,8 +442,8 @@ describe("onTap", () => {
simulateMouseClick(canvas, { x: 1, y: 0 });

// estimateScore is NOT called on tap
expect(goban.engine.estimateScore).toBeCalledTimes(0);
expect(mock_score_estimate.handleClick).toBeCalledTimes(1);
expect(goban.engine.estimateScore).toHaveBeenCalledTimes(0);
expect(mock_score_estimate.handleClick).toHaveBeenCalledTimes(1);
});

test("puzzle mode", () => {
Expand Down
Loading
Loading