#!/usr/bin/env bash
_SCRIPT_DIR=$(dirname $0);

pushd $_SCRIPT_DIR;

# Enable debugging if the script is run with --debug
if [[ "$1" == "--debug" ]]; then
    set -x
fi

. ./_build_env frontend

setup || exit $?

ALLOWED_RULES="-D static_mut_refs"

# ./lint --fix
if [[ "$1" == "--fix" ]]; then
    cargo clippy \
        --fix --allow-dirty \
        --target=wasm32-unknown-emscripten \
        --all-targets \
        -- -D warnings \
        $ALLOWED_RULES
else
    cargo clippy \
        --target=wasm32-unknown-emscripten \
        --all-targets \
        -- -D warnings \
        $ALLOWED_RULES
fi

RESULT=$?

popd

exit $RESULT
