#!/bin/bash

set -euo pipefail

ROOT=$(mktemp -d)

function finish {
  rm -rf "$ROOT"
}

trap finish EXIT

REPO_PATH=$(pwd)

cd $ROOT

cat << EOF > index.html
<script>
console.log(1)
</script>
EOF

cat << EOF > .eslintrc.js
module.exports = {
  plugins: ["html"],
  rules: {
    "no-console": "error",
  },
}
EOF

cat << EOF | diff -u <(eslint --format compact index.html 2>&1) -
$(pwd)/index.html: line 2, col 1, Error - Unexpected console statement. (no-console)

1 problem
EOF

echo "All passed"
