Skip to content

Commit 271255f

Browse files
committed
Add prettier
1 parent 21b9b57 commit 271255f

23 files changed

+3418
-1086
lines changed

.github/workflows/CI.yml

+20-21
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,30 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312

1413
steps:
15-
- uses: actions/checkout@v3
16-
- name: Use Node.js 18
17-
uses: actions/setup-node@v3
18-
with:
19-
node-version: 18
20-
- run: npm install
21-
- run: npm test
22-
- run: npm run build
23-
- uses: actions/upload-artifact@v2
24-
with:
25-
name: Chessweeper
26-
path: ./build
27-
- run: npm run coverage
28-
- name: Upload coverage to Codacy
29-
uses: codacy/codacy-coverage-reporter-action@master
30-
with:
31-
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
32-
coverage-reports: coverage/clover.xml
14+
- uses: actions/checkout@v3
15+
- name: Use Node.js 18
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: 18
19+
- run: npm install
20+
- run: npm test
21+
- run: npm run build
22+
- uses: actions/upload-artifact@v2
23+
with:
24+
name: Chessweeper
25+
path: ./build
26+
- run: npm run coverage
27+
- name: Upload coverage to Codacy
28+
uses: codacy/codacy-coverage-reporter-action@master
29+
with:
30+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
31+
coverage-reports: coverage/clover.xml

.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build
2+
coverage
3+
dist
4+
.cache
5+
node_modules

.prettierrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Chessweeper
2+
23
Chess X Minesweeper
34

45
![Preview](.github/preview.png)
@@ -16,7 +17,8 @@ To build a release version of the game, run `npm run build`. The output is place
1617
- [Discord](https://discord.gg/VjJ95N2mV9)
1718

1819
## Credits
19-
- Chess icons and favicon from https://github.com/oakmac/chessboardjs
20-
- Shovel icon from Vectors Market, Flaticon, https://www.flaticon.com/free-icons/shovel
21-
- Shogi icons from Wikimedia Commons by Hari Seldon under Creative Commons Attribution-Share Alike 3.0 Unported
22-
- Idea taken from https://www.reddit.com/r/AnarchyChess/comments/ytw69b/new_chess_2_update_just_dropped_numbers_are_based/
20+
21+
- Chess icons and favicon from https://github.com/oakmac/chessboardjs
22+
- Shovel icon from Vectors Market, Flaticon, https://www.flaticon.com/free-icons/shovel
23+
- Shogi icons from Wikimedia Commons by Hari Seldon under Creative Commons Attribution-Share Alike 3.0 Unported
24+
- Idea taken from https://www.reddit.com/r/AnarchyChess/comments/ytw69b/new_chess_2_update_just_dropped_numbers_are_based/

index.html

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<title>Chessweeper</title>
5-
<link rel="icon" href="/logo128.png" />
6-
<link rel="apple-touch-icon" href="/logo128.png" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8-
<meta charset="utf-8" />
9-
<meta name="description" content="Chess X Minesweeper" />
10-
<meta property="og:title" content="Chessweeper"/>
11-
<meta property="og:description" content="Chess X Minesweeper"/>
12-
<meta property="og:image" content="/social_image.png"/>
13-
<meta name="twitter:card" content="summary_large_image" />
14-
<link rel="manifest" href="/manifest.json" />
15-
</head>
16-
<body>
17-
<div id="root"></div>
18-
<script type="module" src="/src/main.jsx"></script>
19-
</body>
20-
</html>
3+
<head>
4+
<title>Chessweeper</title>
5+
<link rel="icon" href="/logo128.png" />
6+
<link rel="apple-touch-icon" href="/logo128.png" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<meta charset="utf-8" />
9+
<meta name="description" content="Chess X Minesweeper" />
10+
<meta property="og:title" content="Chessweeper" />
11+
<meta property="og:description" content="Chess X Minesweeper" />
12+
<meta property="og:image" content="/social_image.png" />
13+
<meta name="twitter:card" content="summary_large_image" />
14+
<link rel="manifest" href="/manifest.json" />
15+
</head>
16+
<body>
17+
<div id="root"></div>
18+
<script type="module" src="/src/main.jsx"></script>
19+
</body>
20+
</html>

package-lock.json

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"preview": "vite preview",
1212
"build": "vite build",
1313
"test": "vitest",
14-
"coverage": "vitest run --coverage"
14+
"coverage": "vitest run --coverage",
15+
"format": "npx prettier --write ."
1516
},
1617
"browserslist": "defaults and supports async-functions",
1718
"repository": {
@@ -37,6 +38,7 @@
3738
"@vitejs/plugin-react": "^2.2.0",
3839
"@vitest/coverage-c8": "^0.25.2",
3940
"jsdom": "^20.0.2",
41+
"prettier": "2.7.1",
4042
"vite": "^3.2.4",
4143
"vitest": "^0.25.2"
4244
}

src/App.jsx

+46-34
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,56 @@
1-
import { Client as BgioClient } from 'boardgame.io/react';
2-
import { Game } from './Game';
3-
import { BoardWrapper } from './components/BoardWrapper';
4-
import { parseUrl } from './Parsing';
5-
import { Footer } from './components/Footer';
6-
import { useState } from 'react';
1+
import { Client as BgioClient } from "boardgame.io/react";
2+
import { Game } from "./Game";
3+
import { BoardWrapper } from "./components/BoardWrapper";
4+
import { parseUrl } from "./Parsing";
5+
import { Footer } from "./components/Footer";
6+
import { useState } from "react";
77

88
const wrapBoardWithReload = ({ reload, board: RawBoard }) => {
9-
const Board = (props) => {
9+
const Board = (props) => {
1010
const boardProps = { ...props, reload };
1111
return <RawBoard {...boardProps} />;
1212
};
13-
return Board;
14-
}
13+
return Board;
14+
};
1515

1616
export const App = () => {
17-
const { seed, setupData } = parseUrl();
18-
const [game, setGame] = useState({...Game(setupData), seed})
17+
const { seed, setupData } = parseUrl();
18+
const [game, setGame] = useState({ ...Game(setupData), seed });
1919

20-
const reload = () => {
21-
setGame({...Game(setupData), seed});
22-
}
20+
const reload = () => {
21+
setGame({ ...Game(setupData), seed });
22+
};
23+
24+
const Client = BgioClient({
25+
game,
26+
board: wrapBoardWithReload({ reload, board: BoardWrapper }),
27+
numPlayers: 1,
28+
debug: {
29+
collapseOnLoad: true,
30+
},
31+
});
2332

24-
const Client = BgioClient({
25-
game,
26-
board: wrapBoardWithReload({ reload, board: BoardWrapper }),
27-
numPlayers: 1,
28-
debug: {
29-
collapseOnLoad: true,
30-
}
31-
});
33+
console.log(
34+
`Loading game: ${
35+
setupData.gamemode === "c" ? "classic" : "puzzle"
36+
} gamemode${seed != null ? ` with a seed of \"${seed}\"` : ""}, ${
37+
setupData.count
38+
} piece${setupData.count > 1 ? "s" : ""}, ${setupData.size}x${
39+
setupData.size
40+
} grid, piece${
41+
Object.keys(setupData.pieces).length > 1 ? "s" : ""
42+
} allowed: ${Object.keys(setupData.pieces)
43+
.map((x) => `${x} (x${setupData.pieces[x]})`)
44+
.join(", ")}`
45+
);
3246

33-
console.log(`Loading game: ${setupData.gamemode === 'c' ? "classic" : "puzzle"} gamemode${seed != null ? ` with a seed of \"${seed}\"` : ""}, ${setupData.count} piece${setupData.count > 1 ? "s" : ""}, ${setupData.size}x${setupData.size} grid, piece${Object.keys(setupData.pieces).length > 1 ? "s" : ""} allowed: ${Object.keys(setupData.pieces).map(x => `${x} (x${setupData.pieces[x]})`).join(', ')}`)
34-
35-
return (
36-
<div>
37-
<div className="flex">
38-
<Client />
39-
</div>
40-
<hr/>
41-
<Footer />
42-
</div>
43-
);
44-
}
47+
return (
48+
<div>
49+
<div className="flex">
50+
<Client />
51+
</div>
52+
<hr />
53+
<Footer />
54+
</div>
55+
);
56+
};

0 commit comments

Comments
 (0)