diff --git a/.dependency-cruiser.cjs b/.dependency-cruiser.cjs
index 08daf98fca4..8b956a11a11 100644
--- a/.dependency-cruiser.cjs
+++ b/.dependency-cruiser.cjs
@@ -5,9 +5,7 @@ module.exports = {
name: "no-non-type-@type-exports",
severity: "error",
comment:
- "Files in @types should not export anything but types and interfaces. " +
- "The folder is intended to house imports that are removed at runtime, " +
- "and thus should not contain anything with a bearing on runtime code.",
+ "Files in @types should not export anything but types and interfaces. The folder is intended to house imports that are removed at runtime, and thus should not contain anything with a bearing on runtime code.",
from: {},
to: {
path: "(^|/)src/@types",
@@ -29,8 +27,7 @@ module.exports = {
name: "no-circular-at-runtime",
severity: "error",
comment:
- "This dependency is part of a circular relationship. You might want to revise " +
- "your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ",
+ "This dependency is part of a circular relationship. You might want to revise your solution (i.e. use dependency inversion, make sure the modules have a single responsibility) ",
from: {},
to: {
circular: true,
@@ -42,11 +39,7 @@ module.exports = {
{
name: "no-orphans",
comment:
- "This is an orphan module - it's likely not used (anymore?). Either use it or " +
- "remove it. If it's logical this module is an orphan (i.e. it's a config file), " +
- "add an exception for it in your dependency-cruiser configuration. By default " +
- "this rule does not scrutinize dot-files (e.g. .eslintrc.js), TypeScript declaration " +
- "files (.d.ts), tsconfig.json and some of the babel and webpack configs.",
+ "This is an orphan module - it's likely not used (anymore?). Either use it or remove it. If it's logical this module is an orphan (i.e. it's a config file), add an exception for it in your dependency-cruiser configuration. By default this rule does not scrutinize dot-files (e.g. .eslintrc.js), TypeScript declaration files (.d.ts), tsconfig.json and some of the babel and webpack configs.",
severity: "error",
from: {
orphan: true,
@@ -63,8 +56,7 @@ module.exports = {
{
name: "no-deprecated-core",
comment:
- "A module depends on a node core module that has been deprecated. Find an alternative - these are " +
- "bound to exist - node doesn't deprecate lightly.",
+ "A module depends on a node core module that has been deprecated. Find an alternative - these are bound to exist - node doesn't deprecate lightly.",
severity: "error",
from: {},
to: {
@@ -96,8 +88,7 @@ module.exports = {
{
name: "not-to-deprecated",
comment:
- "This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later " +
- "version of that module, or find an alternative. Deprecated modules are a security risk.",
+ "This module uses a (version of an) npm module that has been deprecated. Either upgrade to a later version of that module, or find an alternative. Deprecated modules are a security risk.",
severity: "error",
from: {},
to: {
@@ -108,10 +99,7 @@ module.exports = {
name: "no-non-package-json",
severity: "error",
comment:
- "This module depends on an npm package that isn't in the 'dependencies' section of your package.json. " +
- "That's problematic as the package either (1) won't be available on live (2 - worse) will be " +
- "available on live with an non-guaranteed version. Fix it by adding the package to the dependencies " +
- "in your package.json.",
+ "This module depends on an npm package that isn't in the 'dependencies' section of your package.json. That's problematic as the package either (1) won't be available on live (2 - worse) will be available on live with an non-guaranteed version. Fix it by adding the package to the dependencies in your package.json.",
from: {},
to: {
dependencyTypes: ["npm-no-pkg", "npm-unknown"],
@@ -120,8 +108,7 @@ module.exports = {
{
name: "not-to-unresolvable",
comment:
- "This module depends on a module that cannot be found ('resolved to disk'). If it's an npm " +
- "module: add it to your package.json. In all other cases you likely already know what to do.",
+ "This module depends on a module that cannot be found ('resolved to disk'). If it's an npm module: add it to your package.json. In all other cases you likely already know what to do.",
severity: "error",
from: {},
to: {
@@ -131,9 +118,7 @@ module.exports = {
{
name: "no-duplicate-dep-types",
comment:
- "Likely this module depends on an external ('npm') package that occurs more than once " +
- "in your package.json i.e. bot as a devDependencies and in dependencies. This will cause " +
- "maintenance problems later on.",
+ "Likely this module depends on an external ('npm') package that occurs more than once in your package.json i.e. bot as a devDependencies and in dependencies. This will cause maintenance problems later on.",
severity: "error",
from: {},
to: {
@@ -150,9 +135,7 @@ module.exports = {
{
name: "not-to-spec",
comment:
- "This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. " +
- "If there's something in a spec that's of use to other modules, it doesn't have that single " +
- "responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.",
+ "This module depends on a spec (test) file. The sole responsibility of a spec file is to test code. If there's something in a spec that's of use to other modules, it doesn't have that single responsibility anymore. Factor it out into (e.g.) a separate utility/ helper or a mock.",
severity: "error",
from: {},
to: {
@@ -163,11 +146,7 @@ module.exports = {
name: "not-to-dev-dep",
severity: "error",
comment:
- "This module depends on an npm package from the 'devDependencies' section of your " +
- "package.json. It looks like something that ships to production, though. To prevent problems " +
- "with npm packages that aren't there on production declare it (only!) in the 'dependencies'" +
- "section of your package.json. If this module is development only - add it to the " +
- "from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration",
+ "This module depends on an npm package from the 'devDependencies' section of your package.json. It looks like something that ships to production, though. To prevent problems with npm packages that aren't there on production declare it (only!) in the 'dependencies'section of your package.json. If this module is development only - add it to the from.pathNot re of the not-to-dev-dep rule in the dependency-cruiser configuration",
from: {
path: "^(src)",
pathNot: ["[.](?:spec|test|setup|script)[.](?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$", "./test"],
@@ -184,10 +163,7 @@ module.exports = {
name: "optional-deps-used",
severity: "info",
comment:
- "This module depends on an npm package that is declared as an optional dependency " +
- "in your package.json. As this makes sense in limited situations only, it's flagged here. " +
- "If you're using an optional dependency here by design - add an exception to your" +
- "dependency-cruiser configuration.",
+ "This module depends on an npm package that is declared as an optional dependency in your package.json. As this makes sense in limited situations only, it's flagged here. If you're using an optional dependency here by design - add an exception to yourdependency-cruiser configuration.",
from: {},
to: {
dependencyTypes: ["npm-optional"],
@@ -196,10 +172,7 @@ module.exports = {
{
name: "peer-deps-used",
comment:
- "This module depends on an npm package that is declared as a peer dependency " +
- "in your package.json. This makes sense if your package is e.g. a plugin, but in " +
- "other cases - maybe not so much. If the use of a peer dependency is intentional " +
- "add an exception to your dependency-cruiser configuration.",
+ "This module depends on an npm package that is declared as a peer dependency in your package.json. This makes sense if your package is e.g. a plugin, but in other cases - maybe not so much. If the use of a peer dependency is intentional add an exception to your dependency-cruiser configuration.",
severity: "error",
from: {},
to: {
diff --git a/.editorconfig b/.editorconfig
index be478a2b5fa..fc5cfbe61e3 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -3,7 +3,7 @@
# top-most EditorConfig file
root = true
-[src/*.{js,ts}]
+[**/*.{js,ts,json,jsonc}]
indent_style = space
indent_size = 2
end_of_line = lf
diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index 35a31f6b4d1..f2e17898334 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -20,6 +20,7 @@ permissions:
jobs:
create-release:
if: github.repository == 'pagefaultgames/pokerogue' && (vars.BETA_DEPLOY_BRANCH == '' || ! startsWith(vars.BETA_DEPLOY_BRANCH, 'release'))
+ timeout-minutes: 10
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed for github cli commands
runs-on: ubuntu-latest
@@ -36,14 +37,24 @@ jobs:
exit 1
fi
shell: bash
+
+ - uses: actions/create-github-app-token@v2
+ id: app-token
+ with:
+ app-id: ${{ secrets.PAGEFAULT_APP_ID }}
+ private-key: ${{ secrets.PAGEFAULT_APP_PRIVATE_KEY }}
+
- name: Check out code
uses: actions/checkout@v4
with:
submodules: "recursive"
# Always base off of beta branch, regardless of the branch the workflow was triggered from.
ref: beta
+ token: ${{ steps.app-token.outputs.token }}
+
- name: Create release branch
run: git checkout -b release
+
# In order to be able to open a PR into beta, we need the branch to have at least one change.
- name: Overwrite RELEASE file
run: |
@@ -52,11 +63,14 @@ jobs:
echo "Release v${{ github.event.inputs.versionName }}" > RELEASE
git add RELEASE
git commit -m "Stage release v${{ github.event.inputs.versionName }}"
+
- name: Push new branch
run: git push origin release
+
# The repository variable is used by the deploy-beta workflow to determine whether to deploy from beta or release.
- name: Set repository variable
- run: GITHUB_TOKEN="${{ secrets.RW_VARS_PAT }}" gh variable set BETA_DEPLOY_BRANCH --body "release"
+ run: GITHUB_TOKEN="${{ steps.app-token.outputs.token }}" gh variable set BETA_DEPLOY_BRANCH --body "release"
+
- name: Create pull request to main
run: |
gh pr create --base main \
@@ -64,6 +78,7 @@ jobs:
--title "Release v${{ github.event.inputs.versionName }} to main" \
--body "This PR is for the release of v${{ github.event.inputs.versionName }}, and was created automatically by the GitHub Actions workflow invoked by ${{ github.actor }}" \
--draft
+
- name: Create pull request to beta
run: |
gh pr create --base beta \
diff --git a/.github/workflows/deploy-beta.yml b/.github/workflows/deploy-beta.yml
index 0894032c8ad..341999dcd45 100644
--- a/.github/workflows/deploy-beta.yml
+++ b/.github/workflows/deploy-beta.yml
@@ -12,6 +12,7 @@ on:
jobs:
deploy:
if: github.repository == 'pagefaultgames/pokerogue' && github.ref_name == (vars.BETA_DEPLOY_BRANCH || 'beta')
+ timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 0e7102a41dd..528906196e5 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -11,6 +11,7 @@ on:
jobs:
deploy:
if: github.repository == 'pagefaultgames/pokerogue'
+ timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml
index 1588a15afeb..6e056bc4032 100644
--- a/.github/workflows/github-pages.yml
+++ b/.github/workflows/github-pages.yml
@@ -5,10 +5,14 @@ on:
branches:
- main
- beta
+ - release
+ - 'hotfix*'
pull_request:
branches:
- main
- beta
+ - release
+ - 'hotfix*'
merge_group:
types: [checks_requested]
@@ -16,9 +20,12 @@ jobs:
pages:
name: Github Pages
if: github.repository == 'pagefaultgames/pokerogue'
+ timeout-minutes: 10
runs-on: ubuntu-latest
env:
- api-dir: ./
+ docs-dir: ./pokerogue_docs
+ # Only push docs when running on pushes to main/beta
+ DRY_RUN: ${{github.event_name != 'push' || (github.ref_name != 'beta' && github.ref_name != 'main')}}
strategy:
fail-fast: false
@@ -40,7 +47,7 @@ jobs:
with:
version: 10
- - name: Setup Node 22.14.1
+ - name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: "pokerogue_docs/.nvmrc"
@@ -53,26 +60,24 @@ jobs:
ref: gh-pages
- name: Install Node.js dependencies
- working-directory: ${{env.api-dir}}
- run: |
- cd pokerogue_docs
- pnpm i
+ working-directory: ${{env.docs-dir}}
+ run: pnpm i
- name: Generate Typedoc docs
- working-directory: ${{env.api-dir}}
- run: |
- cd pokerogue_docs
- pnpm exec typedoc --out /tmp/docs --githubPages false --entryPoints ./src/
+ working-directory: ${{env.docs-dir}}
+ env:
+ REF_NAME: ${{github.ref_name}}
+ DRY_RUN: ${{env.DRY_RUN}}
+ run: pnpm typedoc
- name: Commit & Push docs
- if: github.event_name == 'push'
+ # env vars are stored as strings instead of booleans (hence why an explicit check is required)
+ if: ${{ env.DRY_RUN == 'false'}}
run: |
cd pokerogue_gh
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
- mkdir -p $GITHUB_REF_NAME
- rm -rf $GITHUB_REF_NAME/*
- cp -r /tmp/docs/. $GITHUB_REF_NAME
+ rsync -rd --delete /tmp/docs/ $GITHUB_REF_NAME
git add $GITHUB_REF_NAME
- git commit --allow-empty -m "[skip ci] Deploy docs"
- git push
\ No newline at end of file
+ git commit -m "[skip ci] Deploy docs"
+ git push
diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml
index 82f5abd23a1..edecae64f95 100644
--- a/.github/workflows/linting.yml
+++ b/.github/workflows/linting.yml
@@ -5,43 +5,107 @@ on:
branches:
- main
- beta
+ - release
+ - 'hotfix*'
pull_request:
branches:
- main
- beta
+ - release
+ - 'hotfix*'
merge_group:
types: [checks_requested]
jobs:
run-linters:
- name: Run linters
+ name: Run all linters
+ timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v4
with:
- submodules: 'recursive'
+ submodules: "recursive"
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- - name: Set up Node.js
+ - name: Set up Node
uses: actions/setup-node@v4
with:
- node-version-file: '.nvmrc'
- cache: 'pnpm'
+ node-version-file: ".nvmrc"
+ cache: "pnpm"
- - name: Install Node.js dependencies
+ - name: Install Node modules
run: pnpm i
- - name: Lint with Biome
+ # Lint files with Biome-Lint - https://biomejs.dev/linter/
+ - name: Run Biome-Lint
run: pnpm biome-ci
+ id: biome_lint
+ continue-on-error: true
- - name: Check dependencies with depcruise
+ # Validate dependencies with dependency-cruiser - https://github.com/sverweij/dependency-cruiser
+ - name: Run Dependency-Cruise
run: pnpm depcruise
-
- - name: Lint with ls-lint
- run: pnpm ls-lint
\ No newline at end of file
+ id: depcruise
+ continue-on-error: true
+
+ # Validate types with tsc - https://www.typescriptlang.org/docs/handbook/compiler-options.html#using-the-cli
+ - name: Run Typecheck
+ run: pnpm typecheck
+ id: typecheck
+ continue-on-error: true
+
+ # The exact same thing
+ - name: Run Typecheck (scripts)
+ run: pnpm typecheck:scripts
+ id: typecheck-scripts
+ continue-on-error: true
+
+ - name: Evaluate for Errors
+ env:
+ BIOME_LINT_OUTCOME: ${{ steps.biome_lint.outcome }}
+ DEPCRUISE_OUTCOME: ${{ steps.depcruise.outcome }}
+ TYPECHECK_OUTCOME: ${{ steps.typecheck.outcome }}
+ TYPECHECK_SCRIPTS_OUTCOME: ${{ steps.typecheck-scripts.outcome }}
+ run: |
+ # Check for Errors
+
+ # Make text red.
+ red () {
+ printf "\e[31m%s\e[0m" "$1"
+ }
+
+ # Make text green.
+ green () {
+ printf "\e[32m%s\e[0m" "$1"
+ }
+
+ print_result() {
+ local name=$1
+ local outcome=$2
+ if [ "$outcome" == "success" ]; then
+ printf "$(green "✅ $name: $outcome")\n"
+ else
+ printf "$(red "❌ $name: $outcome")\n"
+ fi
+ }
+
+ print_result "Biome" "$BIOME_LINT_OUTCOME"
+ print_result "Depcruise" "$DEPCRUISE_OUTCOME"
+ print_result "Typecheck" "$TYPECHECK_OUTCOME"
+ print_result "Typecheck scripts" "$TYPECHECK_SCRIPTS_OUTCOME"
+
+ if [[ "$BIOME_LINT_OUTCOME" != "success" || \
+ "$DEPCRUISE_OUTCOME" != "success" || \
+ "$TYPECHECK_OUTCOME" != "success" || \
+ "$TYPECHECK_SCRIPTS_OUTCOME" != "success" ]]; then
+ printf "$(red "❌ One or more checks failed!")\n" >&2
+ exit 1
+ fi
+
+ printf "$(green "✅ All checks passed!")\n"
diff --git a/.github/workflows/post-release-deleted.yml b/.github/workflows/post-release-deleted.yml
index 65447e7826b..fe542365da4 100644
--- a/.github/workflows/post-release-deleted.yml
+++ b/.github/workflows/post-release-deleted.yml
@@ -6,6 +6,7 @@ jobs:
# Set the BETA_DEPLOY_BRANCH variable to beta when a release branch is deleted
update-release-var:
if: github.repository == 'pagefaultgames/pokerogue' && github.event.ref_type == 'branch' && github.event.ref == 'release'
+ timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Set BETA_DEPLOY_BRANCH to beta
diff --git a/.github/workflows/test-shard-template.yml b/.github/workflows/test-shard-template.yml
index 124004f380f..79aea56bbd0 100644
--- a/.github/workflows/test-shard-template.yml
+++ b/.github/workflows/test-shard-template.yml
@@ -21,6 +21,7 @@ jobs:
test:
# We can't use dynmically named jobs until https://github.com/orgs/community/discussions/13261 is implemented
name: Shard
+ timeout-minutes: 10
runs-on: ubuntu-latest
if: ${{ !inputs.skip }}
steps:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 764a35ace60..39506096298 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -5,16 +5,21 @@ on:
branches:
- main
- beta
+ - release
+ - 'hotfix*'
pull_request:
branches:
- main
- beta
+ - release
+ - 'hotfix*'
merge_group:
types: [checks_requested]
workflow_dispatch:
jobs:
check-path-change-filter:
+ timeout-minutes: 5
runs-on: ubuntu-latest
permissions:
pull-requests: read
@@ -33,6 +38,8 @@ jobs:
name: Run Tests
needs: check-path-change-filter
strategy:
+ # don't stop upon 1 shard failing
+ fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5]
uses: ./.github/workflows/test-shard-template.yml
diff --git a/.gitignore b/.gitignore
index 299767e742a..cdc0660d68c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.local
+build
# Editor directories and files (excluding `extensions.json` for devcontainer)
*.code-workspace
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 81abc8df2c0..2197ad03ef2 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -10,4 +10,4 @@
"aaron-bond.better-comments",
"MuTsunTsai.jsdoc-link"
]
-}
\ No newline at end of file
+}
diff --git a/README.md b/README.md
index 1bb8c7772f3..73477968bc0 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,9 @@
-
+

+
+[](https://discord.gg/pokerogue)
+[](https://pagefaultgames.github.io/pokerogue/beta)
+[](https://github.com/pagefaultgames/pokerogue/actions/workflows/tests.yml)
+[](https://www.gnu.org/licenses/agpl-3.0)
PokéRogue is a browser based Pokémon fangame heavily inspired by the roguelite genre. Battle endlessly while gathering stacking items, exploring many different biomes, fighting trainers, bosses, and more!
@@ -7,7 +12,7 @@ PokéRogue is a browser based Pokémon fangame heavily inspired by the roguelite
See [CONTRIBUTING.md](./CONTRIBUTING.md), this includes instructions on how to set up the game locally.
# 📝 Credits
->
+
> If this project contains assets you have produced and you do not see your name, **please** reach out, either [here on GitHub](https://github.com/pagefaultgames/pokerogue/issues/new) or via [Discord](https://discord.gg/pokerogue).
Thank you to all the wonderful people that have contributed to the PokéRogue project! You can find the credits [here](./CREDITS.md).
diff --git a/RELEASE b/RELEASE
new file mode 100644
index 00000000000..a1a9f30b0e8
--- /dev/null
+++ b/RELEASE
@@ -0,0 +1 @@
+Release v1.10.0
diff --git a/biome.jsonc b/biome.jsonc
index a63ce0ee07d..e1aac032597 100644
--- a/biome.jsonc
+++ b/biome.jsonc
@@ -1,7 +1,7 @@
{
- "$schema": "https://biomejs.dev/schemas/2.0.0/schema.json",
+ "$schema": "https://biomejs.dev/schemas/2.2.3/schema.json",
"vcs": {
- "enabled": false,
+ "enabled": true,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "beta"
@@ -10,7 +10,7 @@
"enabled": true,
"useEditorconfig": true,
"indentStyle": "space",
- "includes": ["**", "!**/src/enums/**/*", "!**/src/data/balance/**/*"],
+ "includes": ["**", "!**/src/data/balance/**"],
"lineWidth": 120
},
"files": {
@@ -19,14 +19,12 @@
// and having to verify whether each individual file is ignored
"includes": [
"**",
- "!**/dist/**/*",
- "!**/build/**/*",
- "!**/coverage/**/*",
- "!**/public/**/*",
- "!**/.github/**/*",
- "!**/node_modules/**/*",
- "!**/.vscode/**/*",
- "!**/typedoc/**/*",
+ "!**/dist",
+ "!**/coverage",
+ "!**/public",
+ "!**/.github",
+ "!**/node_modules",
+ "!**/typedoc",
// TODO: lint css and html?
"!**/*.css",
"!**/*.html",
@@ -48,28 +46,75 @@
}
}
},
+ // TODO: Remove unneeded `options` blocks once biome's JSON schema is fixed to not require them
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
- "noUndeclaredVariables": "off",
+ "noUndeclaredVariables": "error",
"noUnusedVariables": "error",
"noSwitchDeclarations": "error",
"noVoidTypeReturn": "error",
"noUnusedImports": {
"level": "error",
- "fix": "safe"
+ "fix": "safe",
+ "options": {}
},
"noUnusedFunctionParameters": "error",
"noUnusedLabels": "error",
- "noPrivateImports": "error"
+ "noPrivateImports": "error",
+ "useSingleJsDocAsterisk": "error",
+ "useJsonImportAttributes": "off" // "Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. ts(2823)"
},
"style": {
- "useEnumInitializers": "off", // large enums like Moves/Species would make this cumbersome
+ "useExplicitLengthCheck": {
+ "level": "error",
+ "fix": "safe",
+ "options": {}
+ },
+ "useAtIndex": "error",
+ "noNegationElse": {
+ "level": "info", // TODO: Promote to error eventually
+ "fix": "unsafe", // duplicates else blocks
+ "options": {}
+ },
+ // TODO: Fix all instances of this and promote to `error` - this and enums are the 2 things
+ // barring us from `esModuleInterop`
+ "noParameterProperties": "warn",
+ "useConsistentBuiltinInstantiation": {
+ "level": "error",
+ "fix": "safe",
+ "options": {}
+ },
+ "noDefaultExport": "warn", // TODO: Fix `overrides.ts` and enable
+ "noShoutyConstants": "error",
+ "useThrowNewError": {
+ "level": "error",
+ "fix": "safe",
+ "options": {}
+ },
+ "useThrowOnlyError": "error",
+ "useTrimStartEnd": "error",
+ "useReadonlyClassProperties": {
+ "level": "info", // TODO: Graduate to error eventually
+ "options": { "checkAllProperties": true }
+ },
+ "useConsistentObjectDefinitions": {
+ "level": "error",
+ "options": { "syntax": "shorthand" }
+ },
+ "useCollapsedIf": "error",
+ "useCollapsedElseIf": "error",
+
+ "noSubstr": "error",
+ "noYodaExpression": "error",
+ "useForOf": "error",
+ "useEnumInitializers": "off", // large enums like MoveId/SpeciesId would make this cumbersome
"useBlockStatements": {
"level": "error",
- "fix": "safe"
+ "fix": "safe",
+ "options": {}
},
"useConst": "error",
"useImportType": "error",
@@ -80,9 +125,14 @@
// TODO: Fix spots in the codebase where this flag would be triggered
// and then set to "error" and re-enable the fixer
"level": "warn",
- "fix": "none"
+ "fix": "none",
+ "options": {}
+ },
+ "useSingleVarDeclarator": {
+ "level": "error",
+ "fix": "safe",
+ "options": {}
},
- "useSingleVarDeclarator": "off",
"useNodejsImportProtocol": "off",
"useTemplate": "off", // string concatenation is faster: https://stackoverflow.com/questions/29055518/are-es6-template-literals-faster-than-string-concatenation
"useAsConstAssertion": "error",
@@ -100,58 +150,80 @@
}
}
}
- }
+ },
+
+ // TODO: Wait until the rule gets options for ignoring doc comments and/or different parameter names,
+ // and THEN enable it codebase-wide
+ "useUnifiedTypeSignatures": {
+ "level": "info",
+ "fix": "none",
+ "options": {}
+ },
+ "useGroupedAccessorPairs": "error",
+ "useObjectSpread": "error",
+ "useNumericSeparators": "off" // TODO: Consider enabling?
},
"suspicious": {
+ "useErrorMessage": "error",
+ "noEvolvingTypes": "warn", // TODO: Review and enable ASAP - this is VERY VERY BAD
+ "useNumberToFixedDigitsArgument": "error",
+ "useGuardForIn": "warn", // TODO: Review and enable ASAP - this is EVEN FRICKING WORSE
"noDoubleEquals": "error",
// While this would be a nice rule to enable, the current structure of the codebase makes this infeasible
// due to being used for move/ability `args` params and save data-related code.
// This can likely be enabled for all non-utils files once these are eventually reworked, but until then we leave it off.
"noExplicitAny": "off",
"noAssignInExpressions": "off",
- "noPrototypeBuiltins": "off",
+ "noPrototypeBuiltins": "off", // TODO: enable this
"noFallthroughSwitchClause": "error", // Prevents accidental automatic fallthroughs in switch cases (use disable comment if needed)
"noImplicitAnyLet": "warn", // TODO: Refactor and make this an error
"noRedeclare": "info", // TODO: Refactor and make this an error
- "noGlobalIsNan": "off",
+ "noGlobalIsNan": "error",
"noAsyncPromiseExecutor": "warn", // TODO: Refactor and make this an error
"noVar": "error",
- "noDocumentCookie": "off" // Firefox has minimal support for the "Cookie Store API"
+ "noDocumentCookie": "off", // Firefox has minimal support for the "Cookie Store API"
+ "noConstantBinaryExpressions": "error",
+ "noTsIgnore": "error",
+ "useIterableCallbackReturn": "warn" // TODO: Refactor and change to error
},
"complexity": {
+ "useWhile": "error",
+ "noVoid": "warn", // TODO: Review and enable ASAP - this is also bad
+ "noUselessStringConcat": "error",
"noExcessiveCognitiveComplexity": "info", // TODO: Refactor and make this an error
- "useLiteralKeys": "off",
+ "useLiteralKeys": "off", // TODO: enable?
"noForEach": "off", // Foreach vs for of is not that simple.
"noUselessSwitchCase": "off", // Explicit > Implicit
"noUselessConstructor": "error",
"noBannedTypes": "warn", // TODO: Refactor and make this an error
"noThisInStatic": "error",
"noUselessThisAlias": "error",
- "noUselessTernary": "error"
+ "noUselessTernary": "error",
+ "useIndexOf": "error"
},
"performance": {
"noNamespaceImport": "error",
- "noDelete": "error"
+ "noDelete": "error",
+ "noBarrelFile": "error"
},
"nursery": {
- "useAdjacentGetterSetter": "error",
- "noConstantBinaryExpression": "error",
- "noTsIgnore": "error",
- "noAwaitInLoop": "off",
- "useJsonImportAttribute": "off", // "Import attributes are only supported when the '--module' option is set to 'esnext', 'node18', 'nodenext', or 'preserve'. ts(2823)"
- "useIndexOf": "error",
- "useObjectSpread": "error",
- "useNumericSeparators": "off", // TODO: enable?
- "useIterableCallbackReturn": "warn", // TODO: refactor and make "error"
- "noShadow": "warn" // TODO: refactor and make "error"
+ "noUselessUndefined": "error",
+ "useMaxParams": {
+ "level": "warn", // TODO: Change to "error"... eventually...
+ "options": { "max": 4 } // A lot of stuff has a few params, but
+ },
+ "noShadow": "warn", // TODO: refactor and make "error"
+ "noNonNullAssertedOptionalChain": "warn" // TODO: refactor and make "error"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
- "arrowParentheses": "asNeeded"
+ "arrowParentheses": "asNeeded",
+ "operatorLinebreak": "before"
},
+ "globals": ["Phaser"],
"parser": {
"jsxEverywhere": false
}
@@ -166,7 +238,7 @@
"noNamespaceImport": "off" // this is required for `vi.spyOn` to work in some tests
},
"style": {
- "noNonNullAssertion": "off"
+ "noNonNullAssertion": "off" // tedious in some tests
},
"nursery": {
"noFloatingPromises": "error"
@@ -175,10 +247,17 @@
}
},
- // Overrides to prevent unused import removal inside `overrides.ts` and enums files (for TSDoc linkcodes),
- // as well as in all TS files in `scripts/` (which are assumed to be boilerplate templates).
+ // Overrides to prevent unused import removal inside `overrides.ts`, enums & `.d.ts` files (for TSDoc linkcodes),
+ // as well as inside script boilerplate files.
{
- "includes": ["**/src/overrides.ts", "**/src/enums/**/*", "**/scripts/**/*.ts", "**/*.d.ts"],
+ // TODO: Rename existing boilerplates in the folder and remove this last alias
+ "includes": [
+ "**/src/overrides.ts",
+ "**/src/enums/**/*",
+ "**/*.d.ts",
+ "scripts/**/*.boilerplate.ts",
+ "**/boilerplates/*.ts"
+ ],
"linter": {
"rules": {
"correctness": {
@@ -188,7 +267,7 @@
}
},
{
- "includes": ["**/src/overrides.ts", "**/scripts/**/*.ts"],
+ "includes": ["**/src/overrides.ts"],
"linter": {
"rules": {
"style": {
diff --git a/docs/linting.md b/docs/linting.md
index d925b2f29af..9301917ae79 100644
--- a/docs/linting.md
+++ b/docs/linting.md
@@ -1,48 +1,57 @@
# Linting & Formatting
-Writing clean, readable code is important, and linters and formatters are an integral part of ensuring code quality and readability.
+Writing clean, readable code is important, and linters and formatters are an integral part of ensuring code quality and readability. \
It is for this reason we are using [Biome](https://biomejs.dev), an opinionated linter/formatter (akin to Prettier) with a heavy focus on speed and performance.
### Installation
-You probably installed Biome already without noticing it - it's included inside `package.json` and should've been downloaded when you ran `pnpm install` after cloning the repo. If you haven't done that yet, go do it.
+You probably installed Biome already without noticing it - it's included inside `package.json` and should've been downloaded when you ran `pnpm install` after cloning the repo. If you haven't done that yet, go do that first.
# Using Biome
-For the most part, Biome attempts to stay "out of your hair", letting you write code while enforcing a consistent formatting standard and only notifying for errors it can't automatically fix.\
+For the most part, Biome attempts to stay "out of your hair", letting you write code while enforcing a consistent formatting standard and only notifying for errors it can't automatically fix. \
On the other hand, if Biome complains about a piece of code, **there's probably a good reason why**. Disable comments should be used sparingly or when readabilty demands it - your first instinct should be to fix the code in question, not disable the rule.
## Editor Integration
Biome has integration with many popular code editors. See [these](https://biomejs.dev/guides/editors/first-party-extensions/) [pages](https://biomejs.dev/guides/editors/third-party-extensions/) for information about enabling Biome in your editor of choice.
## Automated Runs
-Generally speaking, most users shouldn't need to run Biome directly; in addition to editor integration, [pre-commit hook](../lefthook.yml) will periodically run Biome before each commit.
-You will **not** be able to push code with `error`-level linting problems - fix them beforehand.
+Generally speaking, most users shouldn't need to run Biome directly; in addition to editor integration, a [pre-commit hook](../lefthook.yml) will automatically format and lint all staged files before each commit.
-We also have a [Github Action](../.github/workflows/quality.yml) to verify code quality each time a PR is updated, preventing bad code from inadvertently making its way upstream.
+> ![WARNING]
+> You will **not** be able to commit code if any staged files contain `error`-level linting problems. \
+> If you, for whatever reason, _absolutely need_ to bypass Lefthook for a given commit,
+> pass the `--no-verify` flag to `git commit`.
+
+We also have a [Github Action](../.github/workflows/linting.yml) to verify code quality each time a PR is updated, preventing bad code from inadvertently making its way upstream. \
+These are effectively the same commands as run by Lefthook, merely on a project-wide scale.
## Running Biome via CLI
-If you want Biome to check your files manually, you can run it from the command line like so:
+To run you Biome on your files manually, you have 2 main options:
+1. Run the scripts included in `package.json` (`pnpm biome` and `pnpm biome:all`). \
+ These have sensible defaults for command-line options, but do not allow altering certain flags (as some cannot be specified twice in the same command)
-```sh
-pnpm exec biome check --[flags]
-```
+2. Execute the Biome executable manually from the command line like so:
+ ```sh
+ pnpm exec biome check --[flags]
+ ```
+ This allows customizing non-overridable flags like `--diagnostic-level` on a more granular level, but requires slightly more verbosity and specifying more options.
A full list of flags and options can be found on [their website](https://biomejs.dev/reference/cli/), but here's a few useful ones to keep in mind:
-- `--write` will cause Biome to write all "safe" fixes and formatting changes directly to your files (rather than just complaining and doing nothing).
-- `--changed` and `--staged` will only perform checks on all changed or staged files respectively. Biome sources this info from the relevant version control system (in this case Git).
+- `--write` will cause Biome to write all "safe" fixes and formatting changes directly to your files (rather than just complaining and erroring out).
+- `--changed` and `--staged` will limit checking to all changed or staged files respectively. Biome sources this info from the relevant version control system (in this case `git`).
- `diagnostic-level=XXX` will only show diagnostics with at least the given severity level (`info/warn/error`). Useful to only focus on errors causing a failed workflow run or similar.
## Linting Rules
-We primarily use Biome's [recommended ruleset](https://biomejs.dev/linter/rules/) for linting JS/TS, with some customizations to better suit our project's needs[^1].
+We primarily use Biome's [recommended ruleset](https://biomejs.dev/linter/rules/) for linting JS/TS files, with some customizations to better suit our project's needs[^1].
Some things to consider:
- We have disabled rules that prioritize style over performance, such as `useTemplate`.
-- Some rules are currently disabled or marked as warnings (`warn`) to allow for gradual refactoring without blocking development. **Do not write new code that triggers these warnings.**
+- Some rules are currently marked as warnings (`warn`) to allow for gradual refactoring without blocking development. **Do not write new code that triggers these rules!**
- The linter is configured to ignore specific files and folders (such as excessively large files or ones in need of refactoring) to improve performance and focus on actionable areas.
-Any questions about linting rules should be brought up in the `#dev-corner` channel in the discord.
+Any questions about linting rules can be brought up in the `#dev-corner` channel in the community Discord.
-[^1]: A complete list of rules can be found in the `biome.jsonc` file in the project root.
+[^1]: A complete list of rules can be found in the [`biome.jsonc`](../biome.jsonc) file in the project root. Many rules are accompanied by comments explaining the reasons for their inclusion (or lack thereof).
diff --git a/docs/localization.md b/docs/localization.md
index c325aaf55a9..e153d070818 100644
--- a/docs/localization.md
+++ b/docs/localization.md
@@ -1,6 +1,6 @@
# Localization 101
-PokéRogue's localization team puts immense effort into making the game accessible around the world, supporting over 12 different languages at the time of writing this document.
+PokéRogue's localization team puts immense effort into making the game accessible around the world, supporting over 12 different languages at the time of writing this document. \
As a developer, it's important to help maintain global accessibility by effectively coordinating with the Translation Team on any new features or enhancements.
This document aims to cover everything you need to know to help keep the integration process for localization smooth and simple.
@@ -19,11 +19,12 @@ This repository is integrated into the main one as a [git submodule](https://git
## What Is a Submodule?
-In essence, a submodule is a way for one repository (i.e. `pokerogue`) to use another repository (i.e. `pokerogue-locales`) internally.
+In essence, a submodule is a way for one repository (i.e. `pokerogue`) to use another repository (i.e. `pokerogue-locales`) internally.
The parent repo (the "superproject") houses a cloned version of the 2nd repository (the "submodule") inside it, making locales effectively a "repository within a repository", so to speak.
>[!TIP]
> Many popular IDEs have integrated `git` support with special handling around submodules:
+>
> 
>
> 
@@ -32,14 +33,14 @@ The parent repo (the "superproject") houses a cloned version of the 2nd reposito
The following command will initialize your branch's locales repository and update its HEAD:
```bash
-git submodule update --init --recursive
+pnpm update-locales
```
> [!TIP]
> This command is run _automatically_ after cloning, merging or changing branches, so you should rarely have to run it manually.
> [!IMPORTANT]
-> If you run into issues with the `locales` submodule, try deleting the `.git/modules/public` and `public/locales` folders before re-running the command.
+> If you EVER run into issues with the `locales` submodule, try deleting the `.git/modules/public` and `public/locales` folders before re-initializing it again.
## How Are Translations Integrated?
@@ -65,7 +66,7 @@ The basic process for fetching translated text goes roughly as follows:
```
# Submitting Locales Changes
-If you have a feature or enhancement that requires additions or changes to in-game text, you will need to make a fork of the `pokerogue-locales` repo and submit your text changes as a pull request _in addition_ to your pull request to the main project.
+If you have a feature or enhancement that requires additions or changes to in-game text, you will need to make a fork of the `pokerogue-locales` repo and submit your text changes as a pull request _in addition_ to your pull request to the main project. \
Since these two PRs aren't _technically_ linked, it's important to coordinate with the Translation Team to ensure that both PRs are integrated safely into the project.
> [!CAUTION]
@@ -73,29 +74,29 @@ Since these two PRs aren't _technically_ linked, it's important to coordinate wi
## Making Changes
-One perk of submodules is you don't actually _need_ to clone the locales repository to start contributing - initializing the submodule already does that for you.
+One perk of submodules is you don't actually _need_ to clone the locales repository to start contributing - `git` already does that for you on initialization.
Given `pokerogue-locales` is a full-fledged `git` repository _inside_ `pokerogue`, making changes is roughly the same as normal, merely using `public/locales` as your root directory.
> [!WARNING]
-> Make sure to checkout or rebase onto `upstream/HEAD` **BEFORE** creating a PR!
+> Make sure to checkout or rebase onto `upstream/main` (`pnpm update-locales:remote`) **BEFORE** creating a locales PR!
> The checked-out commit is based on the superproject's SHA-1 by default, so hastily making changes may see you basing your commits on last week's `HEAD`.
## Requirements for Adding Translated Text
-When your new feature or enhancement requires adding a new locales key **without changing text in existing keys**, we require the following workflow with regards to localization:
+When a new feature or enhancement requires adding a new locales key **without changing text in existing keys**, we have the following workflow with regards to localization:
1. You (the developer) make a pull request to the main repository for your new feature.
If this feature requires new text, the text should be integrated into the code with a new `i18next` key pointing to where you plan to add it into the locales repository.
2. You then make another pull request — this time to the `pokerogue-locales` repository — adding a new entry with text for each key you added to your main PR.
- - You must add the corresponding **English keys** while making the PR; the Translation Team can take care of the rest[^2].
- - For any feature pulled from the mainline Pokémon games (e.g. a Move or Ability implementation), it's best practice to include a source link for any added text.
- [Poké Corpus](https://abcboy101.github.io/poke-corpus/) is a great resource for finding text from the mainline games; otherwise, a video/picture showing the text being displayed should suffice.
- - You should also [notify the current Head of Translation](#notifying-translation) to ensure a fast response.
+ - You must add the corresponding **English keys** while making the PR; the Translation Team can take care of the rest[^2].
+ - For any feature pulled from the mainline Pokémon games (e.g. a Move or Ability implementation), it's best practice to include a source link for any added text. \
+ [Poké Corpus](https://abcboy101.github.io/poke-corpus/) is a great resource for finding text from the mainline games; otherwise, a video/picture showing the text being displayed should suffice.
+ - You should also [notify the current Head of Translation](#notifying-translation) to ensure a fast response.
3. Your locales should use the following format:
- File names should be in `kebab-case`. Example: `trainer-names.json`
- Key names should be in `camelCase`. Example: `aceTrainer`
- If you make use of i18next's inbuilt [context support](https://www.i18next.com/translation-function/context), you need to use `snake_case` for the context key. Example: `aceTrainer_male`
4. At this point, you may begin [testing locales integration in your main PR](#documenting-locales-changes).
-5. The Translation Team will approve the locale PR (after corrections, if necessary), then merge it into `pokerogue-locales`.
+5. The Translation Team will approve the locales PR (after corrections, if necessary), then merge it into `pokerogue-locales`.
6. The Dev Team will approve your main PR for your feature, then merge it into PokéRogue's beta environment.
[^2]: For those wondering, the reason for choosing English specifically is due to it being the master language set in Pontoon (the program used by the Translation Team to perform locale updates).
@@ -106,7 +107,7 @@ If a key is present in any language _except_ the master language, it won't appea
PRs that modify existing text have different risks with respect to coordination between development and translation, so their requirements are slightly different:
- As above, you set up 2 PRs: one for the feature itself in the main repo, and another for the associated locales changes in the locale repo.
- Now, however, you need to have your main PR be approved by the Dev Team **before** your corresponding locale changes are merged in.
-- After your main PR is approved, the Translation Team will merge your locale PR, and you may update the submodule and post video evidence of integration into the **locales PR**.
+- After your main PR is approved, you may update the submodule and post video evidence of integration into the **locales PR**.
- A Lead or Senior Translator from the Translation Team will then approve your main PR (if all is well), clearing your feature for merging into `beta`.
## Documenting Locales Changes
@@ -115,12 +116,12 @@ After making a PR involving any outwards-facing behavior (but _especially_ local
The basic procedure is roughly as follows:
1. Update your locales submodule to point to **the branch you used to make the locales PR**. \
- Many IDEs with `git` integration support doing this from the GUI, \
- or you can simply do it via command-line:
- ```bash
- cd public/locales
- git checkout your-branch-name-here
- ```
+ Many IDEs with `git` integration support doing this from the GUI, \
+ or you can simply do it via command-line:
+ ```bash
+ cd public/locales
+ git checkout your-branch-name-here
+ ```
2. Set some of the [in-game overrides](../CONTRIBUTING.md#1---manual-testing) inside `overrides.ts` to values corresponding to the interactions being tested.
3. Start a local dev server (`pnpm start:dev`) and open localhost in your browser.
4. Take screenshots or record a video of the locales changes being displayed in-game using the software of your choice[^2].
diff --git a/global.d.ts b/global.d.ts
index 8b79d966e3c..92a883f40c9 100644
--- a/global.d.ts
+++ b/global.d.ts
@@ -18,3 +18,14 @@ declare global {
call