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

add js linting #51

Closed
wants to merge 17 commits into from
Closed
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
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
quote_type = single
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore datapack/resourcepack
datapacks
resourcepack
9 changes: 9 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
env:
commonjs: true
es2021: true
node: true
extends: eslint:recommended
parserOptions:
ecmaVersion: latest
rules:
no-var: 'error'
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
name: validate
name: datapack

on: [push, workflow_dispatch]
on:
pull_request:
push:
branches:
- main

# TODO(37): add linting
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: CarbonSmasher/packtest_runner@86d606f25d2bd2faa08b017326fe99964ac3aa5c
- name: Run PackTest
uses: CarbonSmasher/packtest_runner@86d606f25d2bd2faa08b017326fe99964ac3aa5c
with:
packs: 'datapacks/omega-flowey'
packtest-url: 'https://github.com/misode/packtest/releases/download/v1.0/packtest-1.0-mc1.20.4.jar'
41 changes: 41 additions & 0 deletions .github/workflows/scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: scripts

on:
pull_request:
push:
branches:
- main

jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Yarn 3.6.3
run: corepack enable
- name: Setup cache
uses: actions/setup-node@v4
with:
cache: 'yarn'
cache-dependency-path: yarn.lock
node-version-file: package.json
- run: yarn
- name: Run Prettier
run: yarn start lint.prettier.check

lint:
runs-on: ubuntu-latest
needs: format
steps:
- uses: actions/checkout@v4
- name: Install Yarn 3.6.3
run: corepack enable
- name: Setup cache
uses: actions/setup-node@v4
with:
cache: 'yarn'
cache-dependency-path: yarn.lock
node-version-file: package.json
- run: yarn
- name: Run ESLint
run: yarn start lint.eslint.check
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore datapack/resourcepack
datapacks
resourcepack
5 changes: 4 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"recommendations": [
"minecraftcommands.syntax-mcfunction",
"spgoding.datapack-language-server"
"spgoding.datapack-language-server",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"arcanis.vscode-zipfs"
]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
},
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs"
}
4 changes: 2 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
defaultSemverRangePrefix: ""
yarnPath: .yarn/releases/yarn-3.6.3.cjs
# save exact npm package by default when running `yarn add`
defaultSemverRangePrefix: ''
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ Since then I've gained a lot of skills both in Minecraft map development and in

### Setup

#### Workspace

<!-- TODO upgrade to yarn 4? -->

1. Install [`Node.js >= 16.10`](https://nodejs.org/en/download)
1. Install [`Yarn 3.6.3`](https://v3.yarnpkg.com/getting-started/install) by running `corepack enable`
1. Initialize the repo by running `yarn`
1. Enable Yarn's Plug'n'Play with VSCode by running `yarn dlx @yarnpkg/sdks vscode`

#### Testing

1. Download the [Fabric mod loader](https://fabricmc.net/) and install a new profile to your Minecraft launcher
Expand Down
4 changes: 4 additions & 0 deletions omega-flowey.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
},
{
"name": "minecraft",
// TODO: dev agnostic minecraft assets path? ideally through `.env`, but not possible until
// https://github.com/microsoft/vscode/issues/44755 is complete
"path": "C:\\Users\\afro\\AppData\\Roaming\\.minecraft\\versions\\1.20.1\\1.20.1\\assets\\minecraft"
}
],
Expand Down Expand Up @@ -36,6 +38,8 @@
},
"datapack.trace.server": "messages",

"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.tabSize": 2,

"files.exclude": {
Expand Down
49 changes: 32 additions & 17 deletions package-scripts.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
const { concurrent, series } = require("nps-utils");
const { concurrent, series } = require('nps-utils');

const minecraftPath = "C:/Users/afro/AppData/Roaming/.minecraft";
const worldName = "omega-flowey-remastered";
const resourcePackName = "omega-flowey-remastered-resourcepack";
const minecraftPath = 'C:/Users/afro/AppData/Roaming/.minecraft';
const worldName = 'omega-flowey-remastered';
const resourcePackName = 'omega-flowey-remastered-resourcepack';

const minecraftWorldPath = `${minecraftPath}/saves/${worldName}`;
const minecraftResourcePackPath = `${minecraftPath}/resourcepacks/${resourcePackName}`;

module.exports = {
scripts: {
default: concurrent.nps("watch.datapacks", "watch.resourcepack"),
default: concurrent.nps('watch.datapacks', 'watch.resourcepack'),
watch: {
datapacks: 'watch --wait=1 "nps sync.datapacks" datapacks',
resourcepack: 'watch --wait=1 "nps sync.resourcepack" resourcepack',
},
sync: {
datapacks: series(
"echo syncing datapacks",
"nps delete.datapacks",
"nps copy.datapacks",
"echo finished datapacks",
"mpg123 -f -5000 -q ./temp/anyway.mp3 || echo mpg123 not found on your system -- cannot play notification sound"
'echo syncing datapacks',
'nps delete.datapacks',
'nps copy.datapacks',
'echo finished datapacks',
'mpg123 -f -5000 -q ./temp/anyway.mp3 || echo mpg123 not found on your system -- cannot play notification sound',
),
resourcepack: series(
"echo syncing resourcepack",
"nps delete.resourcepack",
"nps copy.resourcepack",
"echo finished resourcepack",
"mpg123 -f -5000 -q ./temp/fnaf.mp3 || echo mpg123 not found on your system -- cannot play notification sound"
'echo syncing resourcepack',
'nps delete.resourcepack',
'nps copy.resourcepack',
'echo finished resourcepack',
'mpg123 -f -5000 -q ./temp/fnaf.mp3 || echo mpg123 not found on your system -- cannot play notification sound',
),
world: series(
"rimraf world.zip",
`bestzip world.zip ${minecraftWorldPath}/*`
'rimraf world.zip',
`bestzip world.zip ${minecraftWorldPath}/*`,
),
},
copy: {
Expand All @@ -42,5 +42,20 @@ module.exports = {
datapacks: `yarn rimraf --glob ${minecraftWorldPath}/datapacks/**/*`,
resourcepacks: `yarn rimraf --glob ${minecraftResourcePackPath}/**/*`,
},
lint: {
default: 'nps lint.check',
check: series('nps lint.prettier.check', 'nps lint.eslint.check'),
fix: series('nps lint.prettier.fix', 'nps lint.eslint.fix'),
eslint: {
default: 'nps lint.eslint.check',
check: 'eslint .',
fix: 'eslint --fix .',
},
prettier: {
default: 'nps lint.prettier.check',
check: 'prettier --check .',
fix: 'prettier --write .',
},
},
},
};
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
"name": "omega-flowey-minecraft-remastered",
"packageManager": "[email protected]",
"scripts": {
"lint": "nps lint",
"lint.fix": "nps lint.fix",
"start": "nps",
"sync": "nps sync.world"
},
"engines": {
"node": ">=16.10"
},
"devDependencies": {
"bestzip": "1.1.6",
"cpy-cli": "5.0.0",
"eslint": "8.56.0",
"nps": "5.10.0",
"nps-utils": "1.7.0",
"prettier": "3.1.1",
"rimraf": "5.0.1",
"watch": "1.0.2"
}
Expand Down
11 changes: 9 additions & 2 deletions pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Summary

<!--
what is the primary purpose of this PR?
- does it address any existing tickets?
Expand All @@ -8,13 +9,15 @@ what is the primary purpose of this PR?
---

## Test plan

<!--
does this PR include any unit tests for its new code?
if yes, briefly describe them.
if no, explain why.
-->

## Reproducing in-game

<!--
how to view the thing you added in-game (Minecraft), if applicable.
- are there certain commands to run?
Expand All @@ -29,18 +32,22 @@ function entity:hostile/omega-flowey/attack/x-bullets-lower/start
-->

## Preview

<!--
provide visuals (GIFs preferred) showing a before/after of your PR's purpose.
contrasts between in-game (Minecraft) and Undertale are also great.
-->

| in-game -- before | in-game -- after | undertale |
|-|-|-|
| | | |
| ----------------- | ---------------- | --------- |
| | | |

<!-- `in-game -- before` can be `N/A` if this is a new addition to the map -->

---

## Supplemental changes

<!--
describe what other changes this PR makes which aren't specific to its main purpose.
- does it contain a world backup? (recommended)
Expand Down
Loading