name: Static Analysis
on:
    pull_request: {}
    push:
        branches: [develop, master]
permissions: {} # No permissions needed
jobs:
    ts_lint:
        name: "Typescript Syntax Check"
        runs-on: ubuntu-24.04
        steps:
            - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

            - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
              with:
                  node-version-file: package.json
                  cache: "yarn"

            # Does not need branch matching as only analyses this layer
            - name: Install Deps
              run: "yarn install --frozen-lockfile"

            - name: Typecheck
              run: "yarn run lint:types"

    i18n_lint:
        name: "i18n Check"
        uses: matrix-org/matrix-web-i18n/.github/workflows/i18n_check.yml@main
        permissions:
            pull-requests: read
        with:
            hardcoded-words: "Element"

    js_lint:
        name: "ESLint"
        runs-on: ubuntu-24.04
        steps:
            - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

            - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
              with:
                  node-version-file: package.json
                  cache: "yarn"

            # Does not need branch matching as only analyses this layer
            - name: Install Deps
              run: "yarn install --frozen-lockfile"

            - name: Run Linter
              run: "yarn run lint:js"

    workflow_lint:
        name: "Workflow Lint"
        runs-on: ubuntu-24.04
        steps:
            - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

            - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
              with:
                  node-version-file: package.json
                  cache: "yarn"

            # Does not need branch matching as only analyses this layer
            - name: Install Deps
              run: "yarn install --frozen-lockfile"

            - name: Run Linter
              run: "yarn lint:workflows"

    analyse_dead_code:
        name: "Analyse Dead Code"
        runs-on: ubuntu-24.04
        steps:
            - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

            - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
              with:
                  node-version-file: package.json
                  cache: "yarn"

            - name: Install Deps
              run: "yarn install --frozen-lockfile"

            - name: Run linter
              run: "yarn run lint:knip"
