name: Code Style Checks
on: [push, pull_request]
jobs:
  lint:
    name: Check file endings
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - run: |
          disallowedFiles=`find data/ -type f -not -iname "*.json" -not -iname "*.md"`
          for f in $disallowedFiles
          do
            echo "::error file=$f::File $f is not a .json or .md file."
          done
          if [ ! -z "$disallowedFiles" ]; then exit 1; fi

  prettier:
    name: Check for code formatting mistakes
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
        with:
          node-version-file: '.nvmrc'
      - run: npm clean-install
      - run: npm run lint

  codespell:
    name: Check for spelling errors
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - uses: codespell-project/actions-codespell@v2
        with:
          check_filenames: true
          skip: ./.git,./dist,./data/deprecated.json,./data/discarded.json,package.json,package-lock.json,./scripts
          ignore_words_list: "auxilary,brunch,casette,cemetary,chancel,discus,extentions,faiway,goverment,guerilla,guyser,kindergarden,linz,ore,pavillion,sculpter,storys,te,trough"
          only_warn: 1
