diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..dc8558d0 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,85 @@ +name: Lint Code + +on: [push, pull_request] + +jobs: + lint_js: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install ESLint globally + run: | + sudo apt-get update + sudo apt-get install -y eslint # Install ESLint globally + + - name: Lint JavaScript + run: npx eslint . + + lint_html: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install HTMLHint globally + run: | + sudo npm install -g htmlhint + + - name: Lint HTML + run: npx htmlhint . + + fix_html: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install HTML Tidy globally + run: | + sudo apt-get update + sudo apt-get install -y tidy + + - name: Lint and Fix HTML files + run: | + tidy -qe **/*.html + + lint_css: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Stylelint globally + run: | + sudo npm install -g stylelint + + - name: Lint CSS + run: npx stylelint "**/*.css" + + lint_shell: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install ShellCheck globally + run: | + sudo apt-get install -y shellcheck + + - name: Lint Shell scripts + run: shellcheck **/*.sh + + lint_cpp: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Clang-Tidy globally + run: | + sudo apt-get install -y clang-tidy + + - name: Lint C++ code + run: clang-tidy **/*.cpp diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..852856d6 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,25 @@ +// eslint.config.js +module.exports = [ + { + languageOptions: { + globals: { + // Define any global variables here (e.g., for browsers) + window: 'readonly', + document: 'readonly', + }, + parserOptions: { + ecmaVersion: 12, // ES2021 + sourceType: 'module', // Enable ES6 modules + }, + }, + rules: { + 'no-console': 'warn', // Warn on console statements + 'semi': ['error', 'always'], // Enforce semicolons + 'quotes': ['error', 'single'], // Enforce single quotes + 'eqeqeq': 'error', // Enforce strict equality (===) + 'curly': 'error', // Enforce curly braces for control statements + 'no-unused-vars': 'warn', // Warn about unused variables + 'no-magic-numbers': 'off', // Optional: disable rule for magic numbers if you want + }, + }, +];