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 linting for scripts and markdown files #52

Merged
merged 18 commits into from
Dec 31, 2023
Merged

Conversation

TheAfroOfDoom
Copy link
Owner

replaces #51
relates to #8

Summary

This PR adds Prettier for style formatting and ESLint for code correctness.

#8 is being actively worked on will add a new .js script to the repo once complete, so we want to have consistent formatting and linting to keep the repo clean and readable.

We also add these modules to run in our GitHub workflows, with the prettier job needing to pass before the eslint job runs. These workflows use dependency caching to re-use a previously installed .yarn directory if the yarn.lock file is the same and saves a bunch of time. See: https://github.com/actions/setup-node#caching-global-packages-data

Configs

For Prettier, we use its default config with the exception of preferring single quoted strings over double quoted.

For ESLint, we use its eslint:recommended base config and added the additional no-var rule.


Test plan

Tested scripts locally with yarn lint / yarn lint.fix and intentionally pushed commits with formatting/linting errors to ensure the workflows caught them.

See:

Reproducing in-game

To run the new scripts, run one of the following:

  • yarn lint / yarn start lint: runs the formatter and linter but does not auto-fix problems
  • yarn lint.fix / yarn start lint.fix: runs the formatter and linter and auto-fixes problems
  • yarn start eslint.check / yarn start eslint.fix: runs only eslint and checks/fixes problems
  • yarn start prettier.check / yarn start prettier.fix: runs only prettier and checks/fixes problems

Preview

😮
image

Supplemental changes

  • updates README.md formatting and adds yarn installation steps
    • a particular non-obvious step is requiring the user to run yarn dlx @yarnpkg/sdks vscode since our config uses PnP
  • ran prettier/eslint auto fixers on .md and .js files
  • add strict node version check to package.json (>=16.10)

- it was inconsistent for Aidan, this should be better?
use `.editorconfig` for settings
- rename test workflow to `validate_datapack`
- change test workflow to only run on commits on PRs and commits that are pushed to main
- run with `yarn lint`
- just ran `yarn start lint.fix`
- also run `yarn dlx @yarnpkg/sdks vscode` to make eslint work -- moves some auto generated settings into `.vscode/settings.json`
  - unavoidable but nbd
  - adds annoying extension to workspace recommendations `zipfs` but i guess useful similar to `node_modules` stuff idk
- no need to specify `--exact`
- revert deleting the whole file earlier (woops)
- convert to using `yarn` directly to run prettier too with dependency caching

maybe
- matches README's recommendation, which is based on minimum node version (`16.10`) needed for `corepack enable` / yarn 3.6.3
- any push to any branch since our workflows are very short
- no need for `workflow_dispatch` (manual trigger) for now me thinks
- pretty sure `push` supercedes `pull_request`
@TheAfroOfDoom TheAfroOfDoom changed the title add linting for scripts and .md files add linting for scripts and markdown files Dec 29, 2023
Copy link
Collaborator

@aidant19 aidant19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good idea and implementation looks good to me

@TheAfroOfDoom TheAfroOfDoom merged commit fd65aec into main Dec 31, 2023
@TheAfroOfDoom TheAfroOfDoom deleted the add-js-linting branch December 31, 2023 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants