Lint with Prettier

This commit is contained in:
KingRainbow44 2023-05-23 16:40:46 -04:00
parent 2609912468
commit 6f851acc1d
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
16 changed files with 153 additions and 107 deletions

12
.prettierrc Normal file
View File

@ -0,0 +1,12 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"jsxSingleQuote": false,
"jsxBracketSameLine": false,
"semi": true,
"singleQuote": false,
"tabWidth": 4,
"trailingComma": "none",
"useTabs": false
}

View File

@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Grasscutters</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>

View File

@ -16,9 +16,10 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.8.0",
"react-markdown": "^8.0.7",
"react-router-dom": "^6.11.1",
"react-syntax-highlighter": "^15.5.0",
"react-markdown": "^8.0.7",
"rehype-raw": "^6.1.1"
},

View File

@ -106,7 +106,8 @@
margin-top: 0;
}
.Downloads_More_Grasscutter, .Downloads_More_Cultivation {
.Downloads_More_Grasscutter,
.Downloads_More_Cultivation {
display: flex;
flex-direction: row;
align-items: center;
@ -122,7 +123,8 @@
box-sizing: border-box;
}
.Downloads_More_Grasscutter h5, .Downloads_More_Cultivation h5 {
.Downloads_More_Grasscutter h5,
.Downloads_More_Cultivation h5 {
font-size: 20px;
font-weight: 500;
margin: 0;

View File

@ -91,7 +91,7 @@
color: #fff;
font-size: 16px;
line-height: 1.5;
font-family: 'Roboto', sans-serif;
font-family: "Roboto", sans-serif;
font-weight: 400;
max-width: 1200px;
width: 100%;
@ -173,7 +173,7 @@
padding: 5px;
background-color: rgba(26, 26, 26, 0.35);
border-radius: 5px;
font-family: 'Roboto Mono', monospace;
font-family: "Roboto Mono", monospace;
word-break: break-all;
}
@ -185,7 +185,7 @@
border-radius: 5px;
overflow: auto;
width: 100%;
font-family: 'Roboto Mono', monospace;
font-family: "Roboto Mono", monospace;
}
.Wiki_Markdown pre code {
@ -194,7 +194,7 @@
line-height: 1.5;
overflow: auto;
width: 100%;
font-family: 'Roboto Mono', monospace;
font-family: "Roboto Mono", monospace;
}
.Wiki_Markdown table {
@ -243,9 +243,8 @@
transform: translateX(0);
}
.Wiki_Markdown pre, .Wiki_Markdown pre code {
.Wiki_Markdown pre,
.Wiki_Markdown pre code {
width: auto;
}
}

View File

@ -166,5 +166,5 @@ export type DocsObject = {
self: string;
git: string;
html: string;
}
}
};
};

View File

@ -20,7 +20,7 @@ class Header extends React.Component<{}, IState> {
this.state = {
isOpaque: false,
isMobile: window.innerWidth < 875,
isMenuOpen: false,
isMenuOpen: false
};
}

View File

@ -28,7 +28,7 @@ class BasicButton extends React.Component<IProps> {
backgroundColor: !this.props.outline
? this.props.color
: "transparent",
border: this.props.outline ? `1px solid #fff` : "none",
border: this.props.outline ? `1px solid #fff` : "none"
}}
onClick={this.props.onClick}
>

View File

@ -54,7 +54,7 @@ class Loader extends React.Component {
"Downloading more RAM...",
"Optimizing the optimizer...",
"Never let a computer know you're in a hurry.",
"Deleting your \"homework\" folder...",
'Deleting your "homework" folder...',
"Discovering new ways of making you wait...",
"Your time is very important to us. Please wait while we ignore you...",
"Sorry we are busy catching em' all, we'll be done soon",
@ -79,7 +79,9 @@ class Loader extends React.Component {
];
private getRandomLoadingText(): string {
return this.loadingText[Math.floor(Math.random() * this.loadingText.length)];
return this.loadingText[
Math.floor(Math.random() * this.loadingText.length)
];
}
render() {

View File

@ -2,10 +2,10 @@ import React from "react";
import { useParams } from "react-router-dom";
const Router = (Children: React.ComponentClass<any>) => {
return(props: any) => {
return (props: any) => {
const match = { params: useParams() };
return <Children {...props} match={match}/>
}
}
return <Children {...props} match={match} />;
};
};
export default Router;

View File

@ -29,7 +29,7 @@ class TeamMember extends React.Component<IProps, never> {
backgroundColor:
this.props.badge === "CREATOR"
? "#ffe35a"
: "#f67d69",
: "#f67d69"
}}
>
{this.props.badge}

View File

@ -19,7 +19,7 @@ import {
Config,
RunMode,
ServerDebugMode,
LogLevel,
LogLevel
} from "@app/types";
import { getDefaultConfig } from "@app/utils";
@ -40,7 +40,7 @@ class ConfigGen extends React.Component<{}, IState> {
this.state = {
mailItems: [],
regions: [],
config: null,
config: null
};
}
@ -70,9 +70,9 @@ class ConfigGen extends React.Component<{}, IState> {
"config-add-item-level"
) as HTMLInputElement
)?.value || "0"
),
},
],
)
}
]
});
} else {
this.setState({
@ -103,9 +103,9 @@ class ConfigGen extends React.Component<{}, IState> {
document.getElementById(
"config-add-region-ip"
) as HTMLInputElement
)?.value || "",
},
],
)?.value || ""
}
]
});
}
};
@ -113,11 +113,11 @@ class ConfigGen extends React.Component<{}, IState> {
private deleteListItem = (item: MailItem | Region) => {
if (item.hasOwnProperty("itemId")) {
this.setState({
mailItems: this.state.mailItems.filter((i) => i !== item),
mailItems: this.state.mailItems.filter((i) => i !== item)
});
} else {
this.setState({
regions: this.state.regions.filter((i) => i !== item),
regions: this.state.regions.filter((i) => i !== item)
});
}
};
@ -712,7 +712,7 @@ class ConfigGen extends React.Component<{}, IState> {
private downloadConfig = () => {
const element = document.createElement("a");
const file = new Blob([JSON.stringify(this.state.config, null, 4)], {
type: "text/plain",
type: "text/plain"
});
element.href = URL.createObjectURL(file);
element.download = "config.json";

View File

@ -23,7 +23,7 @@ class Downloads extends React.Component<{}, IState> {
grasscutterVersion: "",
grasscutterDownloadLink: "",
cultivationVersion: "",
cultivationDownloadLink: "",
cultivationDownloadLink: ""
};
}
@ -34,7 +34,7 @@ class Downloads extends React.Component<{}, IState> {
grasscutterVersion: data.grasscutter.version,
grasscutterDownloadLink: data.grasscutter.url,
cultivationVersion: data.cultivation.version,
cultivationDownloadLink: data.cultivation.url,
cultivationDownloadLink: data.cultivation.url
});
};

View File

@ -25,7 +25,7 @@ class Home extends React.Component<{}, IState> {
this.state = {
stars: 0,
forks: 0,
watchers: 0,
watchers: 0
};
}
@ -43,7 +43,7 @@ class Home extends React.Component<{}, IState> {
this.setState({
stars: stats.stars,
forks: stats.forks,
watchers: stats.watchers,
watchers: stats.watchers
});
};

View File

@ -13,8 +13,7 @@ import { getDocsAsync, getDocsContentAsync, getReadmeAsync } from "@app/utils";
import "@css/pages/Wiki.css";
interface IProps {
match: { params: { page: string; } };
match: { params: { page: string } };
}
interface IState {
@ -29,7 +28,7 @@ class Wiki extends React.Component<IProps, IState> {
this.state = {
docs: [],
content: ""
}
};
}
private setDocPages = async () => {
@ -41,40 +40,52 @@ class Wiki extends React.Component<IProps, IState> {
});
this.setState({ docs });
}
};
private loadDocContent = async () => {
if (this.props.match.params.page === "Home") {
let content = await getReadmeAsync();
content = content.replaceAll("(docs/", "(https://github.com/Grasscutters/Grasscutter/tree/development/docs/");
content = content.replaceAll(
"(docs/",
"(https://github.com/Grasscutters/Grasscutter/tree/development/docs/"
);
this.setState({ content });
} else {
const doc = this.state.docs.find(doc => doc.name === `${this.props.match.params.page}.md`);
const doc = this.state.docs.find(
(doc) => doc.name === `${this.props.match.params.page}.md`
);
if (doc) {
const content = await getDocsContentAsync(doc.download_url);
this.setState({ content });
}
}
}
};
toggleOpaqueHeader = (opaque: boolean) => {
const header = document.getElementsByClassName("Header")[0] as HTMLElement;
const header = document.getElementsByClassName(
"Header"
)[0] as HTMLElement;
if (opaque) {
header.style.background = "#1186ce";
} else {
header.style.background = "linear-gradient(0deg, transparent, rgba(0, 0, 0, 0.7))";
}
header.style.background =
"linear-gradient(0deg, transparent, rgba(0, 0, 0, 0.7))";
}
};
openSidebar = () => {
const sidebar = document.getElementsByClassName("Wiki_Sidebar")[0] as HTMLElement;
const sidebar = document.getElementsByClassName(
"Wiki_Sidebar"
)[0] as HTMLElement;
sidebar.style.transform = "translateX(0)";
}
};
closeSidebar = () => {
const sidebar = document.getElementsByClassName("Wiki_Sidebar")[0] as HTMLElement;
const sidebar = document.getElementsByClassName(
"Wiki_Sidebar"
)[0] as HTMLElement;
sidebar.style.transform = "translateX(-100%)";
}
};
async componentDidMount() {
this.toggleOpaqueHeader(true);
@ -100,30 +111,46 @@ class Wiki extends React.Component<IProps, IState> {
<BsChevronRight />
</div>
<div className={"Wiki_Sidebar"}>
<BsChevronLeft className={"Wiki_Sidebar_Close"} onClick={this.closeSidebar} />
<BsChevronLeft
className={"Wiki_Sidebar_Close"}
onClick={this.closeSidebar}
/>
{
this.state.docs.map((doc, index) => {
{this.state.docs.map((doc, index) => {
return (
<NavLink
key={index}
to={`/wiki/${doc.path.substring(0, doc.path.length - 3)}`}
to={`/wiki/${doc.path.substring(
0,
doc.path.length - 3
)}`}
>
{({ isActive }) => {
return (
<>
{isActive && (<div className={"Wiki_Sidebar_Item_Active"}/>)}
{doc.name.substring(0, doc.name.length - 3)}
{isActive && (
<div
className={
"Wiki_Sidebar_Item_Active"
}
/>
)}
{doc.name.substring(
0,
doc.name.length - 3
)}
</>
);
}}
</NavLink>
);
})
}
})}
</div>
<div className={"Wiki_Content"}>
<ReactMarkdown className={"Wiki_Markdown"} rehypePlugins={[rehypeRaw]}>
<ReactMarkdown
className={"Wiki_Markdown"}
rehypePlugins={[rehypeRaw]}
>
{this.state.content}
</ReactMarkdown>
</div>

View File

@ -7,7 +7,7 @@ const gc_docs: string = "grasscutters/grasscutter-docs";
*/
export async function getStatsAsync() {
const res = await fetch(`https://api.github.com/repos/${grasscutter}`, {
headers: { Accept: "application/vnd.github.v3+json" },
headers: { Accept: "application/vnd.github.v3+json" }
});
const data = await res.json();
@ -15,7 +15,7 @@ export async function getStatsAsync() {
return {
stars: data.stargazers_count,
forks: data.forks_count,
watchers: data.subscribers_count,
watchers: data.subscribers_count
};
}
@ -26,7 +26,7 @@ export async function getLatestReleaseAsync() {
const resGC = await fetch(
`https://api.github.com/repos/${grasscutter}/releases/latest`,
{
headers: { Accept: "application/vnd.github.v3+json" },
headers: { Accept: "application/vnd.github.v3+json" }
}
);
@ -35,7 +35,7 @@ export async function getLatestReleaseAsync() {
const resC = await fetch(
`https://api.github.com/repos/${cultivation}/releases/latest`,
{
headers: { Accept: "application/vnd.github.v3+json" },
headers: { Accept: "application/vnd.github.v3+json" }
}
);
@ -51,12 +51,12 @@ export async function getLatestReleaseAsync() {
return {
grasscutter: {
version: dataGC.tag_name,
url: dataGC.assets[0].browser_download_url,
url: dataGC.assets[0].browser_download_url
},
cultivation: {
version: dataC.tag_name,
url: dataC.assets[0].browser_download_url,
},
url: dataC.assets[0].browser_download_url
}
};
}
@ -72,28 +72,28 @@ export function getDefaultConfig(): Config {
data: "./data/",
packets: "./packets/",
scripts: "resources:Scripts/",
plugins: "./plugins/",
plugins: "./plugins/"
},
databaseInfo: {
server: {
connectionUri: "mongodb://localhost:27017",
collection: "grasscutter",
collection: "grasscutter"
},
game: {
connectionUri: "mongodb://localhost:27017",
collection: "grasscutter",
},
collection: "grasscutter"
}
},
language: {
language: "en_US",
fallback: "en_US",
document: "EN",
document: "EN"
},
account: {
autoCreate: false,
EXPERIMENTAL_RealPassword: false,
defaultPermissions: [],
maxPlayers: -1,
maxPlayers: -1
},
server: {
debugWhitelist: [],
@ -109,18 +109,18 @@ export function getDefaultConfig(): Config {
useEncryption: true,
useInRouting: true,
keystore: "./keystore.p12",
keystorePassword: "123456",
keystorePassword: "123456"
},
policies: {
cors: {
enabled: false,
allowedOrigins: ["*"],
},
allowedOrigins: ["*"]
}
},
files: {
indexFile: "./index.html",
errorFile: "./error.html",
},
errorFile: "./error.html"
}
},
game: {
bindAddress: "0.0.0.0",
@ -140,11 +140,11 @@ export function getDefaultConfig(): Config {
relics: 2000,
materials: 2000,
furniture: 2000,
all: 30000,
all: 30000
},
avatarLimits: {
singlePlayerTeam: 4,
multiPlayerTeam: 4,
multiPlayerTeam: 4
},
sceneEntityLimit: 1000,
watchGachaConfig: false,
@ -155,8 +155,8 @@ export function getDefaultConfig(): Config {
resinOptions: {
resinUsage: false,
cap: 160,
rechargeTime: 480,
},
rechargeTime: 480
}
},
serverAccount: {
avatarId: 10000007,
@ -164,7 +164,7 @@ export function getDefaultConfig(): Config {
adventureRank: 1,
worldLevel: 0,
nickname: "Server",
signature: "Welcome to Grasscutter!",
signature: "Welcome to Grasscutter!"
},
joinOptions: {
welcomeEmotes: [2007, 1002, 4010],
@ -178,21 +178,21 @@ export function getDefaultConfig(): Config {
{
itemId: 13509,
itemCount: 1,
itemLevel: 1,
itemLevel: 1
},
{
itemId: 201,
itemCount: 99999,
itemLevel: 1,
},
],
},
},
itemLevel: 1
}
]
}
}
},
dispatch: {
regions: [],
defaultName: "Grasscutter",
logRequests: "NONE",
logRequests: "NONE"
},
debugMode: {
serverLoggerLevel: "DEBUG",
@ -200,9 +200,9 @@ export function getDefaultConfig(): Config {
logPackets: "ALL",
isShowPacketPayload: false,
isShowLoopPackets: false,
logRequests: "ALL",
},
},
logRequests: "ALL"
}
}
};
}
@ -215,7 +215,7 @@ export async function getDocsAsync(): Promise<DocsObject[]> {
const res = await fetch(
`https://api.github.com/repos/${gc_docs}/contents/`,
{
headers: { Accept: "application/vnd.github.v3+json" },
headers: { Accept: "application/vnd.github.v3+json" }
}
);
@ -226,7 +226,9 @@ export async function getDocsAsync(): Promise<DocsObject[]> {
* Fetches the content of the docs file
* @param download_url The download url of the file
*/
export async function getDocsContentAsync(download_url: string): Promise<string> {
export async function getDocsContentAsync(
download_url: string
): Promise<string> {
const res = await fetch(download_url);
return await res.text();