Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Validate typescript types for modifier data #685

Merged
merged 3 commits into from
Mar 13, 2024
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
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"prettier"
],
"parser": "@typescript-eslint/parser",
"ignorePatterns": ["/plugins/*", "wasm_module/"],
"ignorePatterns": ["/plugins/*", "src/assets/typevalidation/output", "wasm_module/"],
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
- name: Test modifier and preset data
run: pnpm testData

- name: Validate modifier and preset data types
run: pnpm validateDataTypes

- name: Lint with ESLint
run: pnpm eslint

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ install.bat
.DS_Store
.mf/

wasm_module/target/
wasm_module/target/
/src/assets/typevalidation/output
4 changes: 3 additions & 1 deletion docs/Contributing/Data Format/Modifiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

The data located in [/src/assets/modifierdata](../../../src/assets/modifierdata) specifies what effect each trait, passive-buffing skill, rune, sigil, food, utility, and buff has on your character.

You can run `pnpm testData` in a clone of the repository to run the testData.js script, which will check every YAML file in this folder for most possible mistakes or omissions. This script will be run automatically by GitHub when you push to a the source branch of an open pull request, including draft PRs, so don't worry if you don't want to set up Node and PNPM just for this!
You can run `pnpm testData` in a clone of the repository to run the `testData.js` script, which will check every YAML file in this folder for most possible mistakes or omissions. This script will be run automatically by GitHub when you push to a the source branch of an open pull request, including draft PRs, so don't worry if you don't want to set up Node and PNPM just for this!

Note that this script is not perfect and may have bugs, so ask in Discord if something seems off or if you're not sure what the problem is!

You can also run `pnpm validateDataTypes` in the same way, which will verify that the Typescript types in `metadata.ts` describe the data correctly.

# Format

This data format was originally proposed in the [data format notes wiki page](https://github.com/discretize/discretize-gear-optimizer/wiki/data-format-notes) and some of the information there about future plans is still relevant.
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
"prettierCheck": "prettier --check . \"!**/*.{md,json,yaml,yml}\"",
"eslint": "eslint --ignore-path .gitignore --max-warnings 0 . --ext .js,.jsx,.ts,.tsx",
"tscCheck": "tsc --noEmit",
"checkAll": "pnpm testData && pnpm eslint && pnpm prettierCheck && pnpm tscCheck",
"checkAll": "pnpm testData && pnpm validateDataTypes && pnpm eslint && pnpm prettierCheck && pnpm tscCheck",
"updateMappings": "node updateMappings.js",
"testData": "tsx ./src/assets/testData.js",
"validateDataTypes": "typia generate --input ./src/assets/typevalidation/ --output ./src/assets/typevalidation/output && tsx ./src/assets/typevalidation/output",
"extractLocale": "babel --config-file ./babel-extract.config.js 'src/**/*.{js,jsx,ts,tsx}' > /dev/null",
"extractLocaleEn": "babel --config-file ./babel-extract-en.config.js 'src/**/*.{js,jsx,ts,tsx}' > /dev/null && node cleanupLocale.js",
"extractLocaleCMD": "babel --config-file ./babel-extract.config.js \"src/**/*.{js,jsx,ts,tsx}\" > NUL",
Expand Down Expand Up @@ -106,6 +107,7 @@
"prettier": "^3.2.5",
"tsx": "^4.7.1",
"typescript": "^5.4.2",
"typia": "^5.5.4",
"vite": "^5.1.5",
"vite-plugin-wasm": "^3.3.0",
"wasm-pack": "^0.12.1",
Expand Down
Loading
Loading