diff --git a/CI/linters/eslint.yml b/CI/linters/eslint.yml new file mode 100644 index 0000000..62c29dc --- /dev/null +++ b/CI/linters/eslint.yml @@ -0,0 +1,45 @@ +eslint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: npm ci + - name: Run ESLint + run: | + set -euo pipefail + ERROR_FOUND=0 + + CONFIG_FOUND=0 + for config in ".eslintrc.json" ".eslintrc.js" ".eslintrc.yml" ".eslintrc.yaml" "eslint.config.js" "eslint.config.mjs" "eslint.config.cjs"; do + if [ -f "$config" ]; then + CONFIG_FOUND=1 + break + fi + done + + if [ $CONFIG_FOUND -eq 0 ]; then + echo "::error::No ESLint config file found" + exit 1 + fi + + mapfile -t js_files < <(find . -type f \( -name "*.js" -o -name "*.jsx" -o -name "*.ts" -o -name "*.tsx" -o -name "*.mjs" -o -name "*.cjs" \) \ + -not -path "./_site/*" \ + -not -path "./node_modules/*" \ + -not -path "./.git/*") + + if [ ${#js_files[@]} -eq 0 ]; then + echo "⚠️ No JS/TS files found. Skipping." + exit 0 + fi + + for file in "${js_files[@]}"; do + echo "ℹ️ Checking ${file#./}..." + npx eslint "$file" || ERROR_FOUND=1 + done + + if [[ $ERROR_FOUND -eq 0 ]]; then + echo "✅ All JS/TS files passed ESLint checks!" + else + echo "❌ ESLint found issues!" + exit 1 + fi diff --git a/CI/linters/yamllint.yml b/CI/linters/yamllint.yml index 676038c..fb22fac 100644 --- a/CI/linters/yamllint.yml +++ b/CI/linters/yamllint.yml @@ -17,7 +17,8 @@ yamllint: mapfile -t yaml_files < <(find . -type f \( -name "*.yml" -o -name "*.yaml" \) \ -not -path "./_site/*" \ -not -path "./node_modules/*" \ - -not -path "./.git/*") + -not -path "./.git/*" \ + -not -name ".yamllint.yml") if [ ${#yaml_files[@]} -eq 0 ]; then echo "⚠️ No YAML files found. Skipping." diff --git a/scripts/CI/linters/eslint.yml b/scripts/CI/linters/eslint.yml new file mode 100644 index 0000000..2934c13 --- /dev/null +++ b/scripts/CI/linters/eslint.yml @@ -0,0 +1,8 @@ +eslint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: npm ci + - name: Run ESLint + run: bash scripts/shell/linters/eslint.sh diff --git a/scripts/shell/linters/eslint.sh b/scripts/shell/linters/eslint.sh new file mode 100644 index 0000000..334b211 --- /dev/null +++ b/scripts/shell/linters/eslint.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -euo pipefail +ERROR_FOUND=0 + +CONFIG_FOUND=0 +for config in ".eslintrc.json" ".eslintrc.js" ".eslintrc.yml" ".eslintrc.yaml" "eslint.config.js" "eslint.config.mjs" "eslint.config.cjs"; do + if [ -f "$config" ]; then + CONFIG_FOUND=1 + break + fi +done + +if [ $CONFIG_FOUND -eq 0 ]; then + echo "::error::No ESLint config file found" + exit 1 +fi + +mapfile -t js_files < <(find . -type f \( -name "*.js" -o -name "*.jsx" -o -name "*.ts" -o -name "*.tsx" -o -name "*.mjs" -o -name "*.cjs" \) \ + -not -path "./_site/*" \ + -not -path "./node_modules/*" \ + -not -path "./.git/*") + +if [ ${#js_files[@]} -eq 0 ]; then + echo "⚠️ No JS/TS files found. Skipping." + exit 0 +fi + +for file in "${js_files[@]}"; do + echo "ℹ️ Checking ${file#./}..." + npx eslint "$file" || ERROR_FOUND=1 +done + +if [[ $ERROR_FOUND -eq 0 ]]; then + echo "✅ All JS/TS files passed ESLint checks!" +else + echo "❌ ESLint found issues!" + exit 1 +fi diff --git a/scripts/shell/linters/yamllint.sh b/scripts/shell/linters/yamllint.sh index 21a7a71..166b200 100644 --- a/scripts/shell/linters/yamllint.sh +++ b/scripts/shell/linters/yamllint.sh @@ -10,7 +10,8 @@ fi mapfile -t yaml_files < <(find . -type f \( -name "*.yml" -o -name "*.yaml" \) \ -not -path "./_site/*" \ -not -path "./node_modules/*" \ - -not -path "./.git/*") + -not -path "./.git/*" \ + -not -name ".yamllint.yml") if [ ${#yaml_files[@]} -eq 0 ]; then echo "⚠️ No YAML files found. Skipping."