name: Code Style Checks
on: [push, pull_request]
jobs:
  lint:
    name: Check file endings
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - 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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - 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
