From 7a7cd1515ffe6381dc67bc9fbc9ce0919839334e Mon Sep 17 00:00:00 2001 From: tarunsinghofficial Date: Fri, 23 Aug 2024 20:12:41 +0530 Subject: [PATCH 1/6] added linting as a part of CI --- .github/workflows/ci.yml | 64 +++++++++++++++++++++++++++++++++++++++ .prettierignore | 4 +++ .prettierrc.json | 29 +++++++++++++++++- package.json | 2 ++ src/_data/build_info.json | 2 +- 5 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .prettierignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..4157ff89d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: CI and Lint + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install dependencies + run: npm ci + + - name: Run Prettier + run: npm run lint:prettier + + - name: Run ESLint + run: npm run lint:eslint + + - name: Lint changed files + if: github.event_name == 'pull_request' + run: | + git fetch origin ${{ github.base_ref }} + FILES=$(git diff --name-only origin/${{ github.base_ref }} ${{ github.sha }} | grep -E '\.(js|jsx|ts|tsx|html|css)$' || true) + if [ -n "$FILES" ]; then + echo "Linting changed files:" + echo "$FILES" + echo "$FILES" | xargs npx prettier --write + echo "$FILES" | grep -E '\.(js|jsx|ts|tsx)$' | xargs npx eslint --fix || true + else + echo "No relevant files changed." + fi + env: + CI: true + + - name: Check for uncommitted changes + run: | + if [[ -n $(git status -s) ]]; then + echo "There are uncommitted changes after linting. Please commit these changes." + git status + exit 1 + fi + + - name: Upload lint results + uses: actions/upload-artifact@v3 + if: failure() + with: + name: lint-results + path: | + **/lint-results.txt + **/prettier-results.txt + retention-days: 5 \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..f2cbf8ec2 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +# Package Managers +package-lock.json +pnpm-lock.yaml +yarn.lock \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json index 412837af4..8f8bdbc6e 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,3 +1,30 @@ { - "parser": "html" + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "useTabs": true, + "trailingComma": "es5", + "bracketSpacing": true, + "arrowParens": "always", + "printWidth": 80, + "overrides": [ + { + "files": "*.html", + "options": { + "parser": "html" + } + }, + { + "files": "*.js", + "options": { + "parser": "babel" + } + }, + { + "files": "*.njk", + "options": { + "parser": "html" + } + } + ] } \ No newline at end of file diff --git a/package.json b/package.json index ad4bad2bc..12fab6b29 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,8 @@ "start:eleventy": "eleventy --serve", "start:postcss": "postcss src/styles/*.css --dir _site --watch", "format": "npx eslint --fix _site/audio-worklet/**/*.js && npx prettier --write --loglevel silent _site/audio-worklet/**/*.html", + "lint:prettier": "prettier --check src/**/*.js src/**/*.html", + "lint:eslint": "eslint src/**/*.js", "test": "npx playwright test", "test-server": "npx http-server", "test-live": "npx http-server ./src/tests/playwright/pages/" diff --git a/src/_data/build_info.json b/src/_data/build_info.json index a90588ff9..f3d825a08 100644 --- a/src/_data/build_info.json +++ b/src/_data/build_info.json @@ -1 +1 @@ -{"version":"3.2.0","revision":"e45e5d0","lastUpdated":"2024-08-07","copyrightYear":2024} \ No newline at end of file +{"version":"3.2.0","revision":"15af0c2","lastUpdated":"2024-08-20","copyrightYear":2024} \ No newline at end of file From 2c2a48bd210d14744f26333e67abdbae6bb0ff87 Mon Sep 17 00:00:00 2001 From: tarunsinghofficial Date: Fri, 23 Aug 2024 20:16:57 +0530 Subject: [PATCH 2/6] refactor:updated the ci.yml without autofixing --- .github/workflows/ci.yml | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4157ff89d..12e38bdf4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,28 +37,10 @@ jobs: if [ -n "$FILES" ]; then echo "Linting changed files:" echo "$FILES" - echo "$FILES" | xargs npx prettier --write - echo "$FILES" | grep -E '\.(js|jsx|ts|tsx)$' | xargs npx eslint --fix || true + echo "$FILES" | xargs npx prettier --check + echo "$FILES" | grep -E '\.(js|jsx|ts|tsx)$' | xargs npx eslint || true else echo "No relevant files changed." fi env: - CI: true - - - name: Check for uncommitted changes - run: | - if [[ -n $(git status -s) ]]; then - echo "There are uncommitted changes after linting. Please commit these changes." - git status - exit 1 - fi - - - name: Upload lint results - uses: actions/upload-artifact@v3 - if: failure() - with: - name: lint-results - path: | - **/lint-results.txt - **/prettier-results.txt - retention-days: 5 \ No newline at end of file + CI: true \ No newline at end of file From c8a9a8faee944ecaa87d7145495b445584a714d5 Mon Sep 17 00:00:00 2001 From: tarunsinghofficial Date: Sat, 4 Jan 2025 14:37:29 +0530 Subject: [PATCH 3/6] chore: update CI config to remove 'master' branch and reduce redundant linting steps --- .github/workflows/ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12e38bdf4..b0b5e22ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: CI and Lint on: push: - branches: [ main, master ] + branches: [ main ] pull_request: - branches: [ main, master ] + branches: [ main ] jobs: lint: @@ -26,9 +26,6 @@ jobs: - name: Run Prettier run: npm run lint:prettier - - name: Run ESLint - run: npm run lint:eslint - - name: Lint changed files if: github.event_name == 'pull_request' run: | From 18f3abea6299782228e5a88afc493b736f4928b7 Mon Sep 17 00:00:00 2001 From: tarunsinghofficial Date: Sat, 4 Jan 2025 14:40:19 +0530 Subject: [PATCH 4/6] chore: clean up .prettierignore by removing redundant entries --- .prettierignore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.prettierignore b/.prettierignore index f2cbf8ec2..b52a79b7f 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,4 @@ # Package Managers -package-lock.json -pnpm-lock.yaml -yarn.lock \ No newline at end of file +# package-lock.json +# pnpm-lock.yaml +# yarn.lock \ No newline at end of file From 827b1801c0b03831f8b121fdfd0f088d8f216225 Mon Sep 17 00:00:00 2001 From: tarunsinghofficial Date: Sat, 4 Jan 2025 14:53:21 +0530 Subject: [PATCH 5/6] chore: remove unnecessary overrides section in Prettier config --- .prettierrc.json | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index 8f8bdbc6e..41fe45a0c 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -2,29 +2,9 @@ "semi": true, "singleQuote": true, "tabWidth": 2, - "useTabs": true, + "useTabs": false, "trailingComma": "es5", "bracketSpacing": true, "arrowParens": "always", - "printWidth": 80, - "overrides": [ - { - "files": "*.html", - "options": { - "parser": "html" - } - }, - { - "files": "*.js", - "options": { - "parser": "babel" - } - }, - { - "files": "*.njk", - "options": { - "parser": "html" - } - } - ] + "printWidth": 80 } \ No newline at end of file From 1956e6eb7ae4fa4403df4192ca76290aa627a9e9 Mon Sep 17 00:00:00 2001 From: tarunsinghofficial Date: Mon, 6 Jan 2025 14:37:38 +0530 Subject: [PATCH 6/6] chore(workflows): deleted .prettier ignore, remove lint:prettier and lint:eslint from package.json, and remove 'push' trigger from lint workflow --- .github/workflows/ci.yml | 5 ----- .prettierignore | 4 ---- package.json | 2 -- 3 files changed, 11 deletions(-) delete mode 100644 .prettierignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0b5e22ed..67738fb47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,6 @@ name: CI and Lint on: - push: - branches: [ main ] pull_request: branches: [ main ] @@ -23,9 +21,6 @@ jobs: - name: Install dependencies run: npm ci - - name: Run Prettier - run: npm run lint:prettier - - name: Lint changed files if: github.event_name == 'pull_request' run: | diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index b52a79b7f..000000000 --- a/.prettierignore +++ /dev/null @@ -1,4 +0,0 @@ -# Package Managers -# package-lock.json -# pnpm-lock.yaml -# yarn.lock \ No newline at end of file diff --git a/package.json b/package.json index 2e2dde2e3..6f3f85677 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,6 @@ "start:eleventy": "eleventy --serve", "start:postcss": "postcss src/styles/*.css --dir _site --watch", "format": "npx eslint --fix _site/audio-worklet/**/*.js && npx prettier --write --loglevel silent _site/audio-worklet/**/*.html", - "lint:prettier": "prettier --check src/**/*.js src/**/*.html", - "lint:eslint": "eslint src/**/*.js", "test": "npx playwright test", "test-server": "npx http-server", "test-live": "npx http-server ./src/tests/playwright/pages/"