Skip to content

Commit

Permalink
Added js-eslint.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
dmotte committed Aug 29, 2024
1 parent d25fc88 commit 84281c8
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions scripts/cicd/js-eslint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

set -e

# shellcheck source=/dev/null
. "$(dirname "$0")/../../bash-libs/fetch-and-check.sh"

readonly toolchain_dir=/tmp/toolchain-eslint
readonly eslint_config_mjs='import globals from "globals";
import html from "eslint-plugin-html";
import js from "@eslint/js";
export default [
{ files: ["**/*.html"], plugins: { html } },
{ languageOptions: { globals: globals.browser } },
js.configs.all,
];'

echo "::group::$0: Preparation"
if ! command -v npm; then
bash <(fetch_and_check \
'https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh' \
'69da4f89f430cd5d6e591c2ccfa2e9e3ad55564ba60f651f00da85e04010c640')
# shellcheck source=/dev/null
. ~/.nvm/nvm.sh
nvm install --lts
fi
npm --version

if [ ! -d "$toolchain_dir" ]; then
mkdir "$toolchain_dir"
( # Subshell
cd "$toolchain_dir"
npm init -y
npm install eslint @eslint/js eslint-plugin-html globals
)
fi
"$toolchain_dir/node_modules/.bin/eslint" --version

echo "$eslint_config_mjs" | tee "$toolchain_dir/eslint.config.mjs"
echo '::endgroup::'

"$toolchain_dir/node_modules/.bin/eslint" \
--config="$toolchain_dir/eslint.config.mjs" \
.

0 comments on commit 84281c8

Please sign in to comment.