From c411c002bdf944fcbc7ef09969584cab232453eb Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 13 Sep 2024 13:08:56 +0200 Subject: [PATCH 01/10] Add lint depracation script --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 183590b7f30..6a67029a657 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "test": "TZ=utc NODE_OPTIONS=--experimental-vm-modules jest", "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=0 --cache --cache-location=node_modules/.cache/eslint", + "lint-deprecation": "NODE_OPTIONS=--max_old_space_size=8192 eslint --max-warnings=0 --config ./.eslintrc.pr.js $(git diff --diff-filter=AM --name-only main -- \"*.ts\" \"*.tsx\")", "lint-changed": "eslint --fix $(git diff --diff-filter=AM --name-only main -- \"*.js\" \"*.ts\" \"*.tsx\")", "lint-watch": "npx eslint-watch --watch --changed", "shellcheck": "./scripts/shellCheck.sh", From de5a3b183bce53822027dcfa5c3ad9e0577ac345 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 13 Sep 2024 13:09:07 +0200 Subject: [PATCH 02/10] Update eslint ignore file --- .eslintignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintignore b/.eslintignore index 3d966d096ad..a5805dfe4ee 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,6 +3,7 @@ .github/actions/**/index.js *.config.js **/.eslintrc.js +**/.eslintrc.pr.js **/node_modules/** **/dist/** android/**/build/** From 7d702701beaaa25269e702f805dcf230cf09dc21 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 13 Sep 2024 13:09:57 +0200 Subject: [PATCH 03/10] Adjust the deprecation eslint config --- .eslintrc.pr.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.eslintrc.pr.js b/.eslintrc.pr.js index 63e058bf600..c279c3e67a5 100644 --- a/.eslintrc.pr.js +++ b/.eslintrc.pr.js @@ -1,6 +1,9 @@ module.exports = { - extends: './.eslintrc', - plugins: ['deprecation'], + plugins: ['@typescript-eslint', 'deprecation'], + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.json', + }, rules: { 'deprecation/deprecation': 'error', }, From b77cb180cb24e6954d260e04a6534c50468cf46b Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 13 Sep 2024 13:10:11 +0200 Subject: [PATCH 04/10] Split actions into three files --- .github/workflows/deprecation-lint.yml | 31 +++++++++++++++++++++ .github/workflows/lint.yml | 22 ++------------- .github/workflows/prettier.yml | 37 ++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/deprecation-lint.yml create mode 100644 .github/workflows/prettier.yml diff --git a/.github/workflows/deprecation-lint.yml b/.github/workflows/deprecation-lint.yml new file mode 100644 index 00000000000..efe95ee2ba9 --- /dev/null +++ b/.github/workflows/deprecation-lint.yml @@ -0,0 +1,31 @@ +name: Deprecation ESLint check + +on: + workflow_call: + pull_request: + types: [opened, synchronize] + branches-ignore: [staging, production] + paths: ['**.js', '**.ts', '**.tsx', '**.json', '**.mjs', '**.cjs', 'config/.editorconfig', '.watchmanconfig', '.imgbotconfig'] + +concurrency: + group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-deprecation-lint + cancel-in-progress: true + +jobs: + deprecation-lint: + name: Deprecation ESLint check + if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: ./.github/actions/composite/setupNode + + - name: Run ESLint to check for deprecation warnings + run: | + git fetch origin main --no-tags --depth=1 + + # shellcheck disable=SC2046 + npm run lint-deprecation \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4cf5c3eb287..af6bfa17fb6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: Lint code +name: ESLint check on: workflow_call: @@ -13,7 +13,7 @@ concurrency: jobs: lint: - name: Run ESLint + name: ESLint check if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }} runs-on: ubuntu-latest steps: @@ -27,21 +27,3 @@ jobs: run: npm run lint env: CI: true - - - name: Run ESLint with stricter checks on changed files - run: | - # shellcheck disable=SC2046 - npx eslint --config ./.eslintrc.pr.js $(git diff --diff-filter=AM --name-only main -- "*.js" "*.ts" "*.tsx") - - - name: Verify there's no Prettier diff - run: | - npm run prettier -- --loglevel silent - if ! git diff --name-only --exit-code; then - # shellcheck disable=SC2016 - echo 'Error: Prettier diff detected! Please run `npm run prettier` and commit the changes.' - exit 1 - fi - - - name: Run unused style searcher - shell: bash - run: ./.github/scripts/findUnusedKeys.sh diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 00000000000..d5cff2d9b83 --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,37 @@ +name: Prettier check + +on: + workflow_call: + pull_request: + types: [opened, synchronize] + branches-ignore: [staging, production] + paths: ['**.js', '**.ts', '**.tsx', '**.json', '**.mjs', '**.cjs', 'config/.editorconfig', '.watchmanconfig', '.imgbotconfig'] + +concurrency: + group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-prettier + cancel-in-progress: true + +jobs: + prettier: + name: Prettier check + if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: ./.github/actions/composite/setupNode + + - name: Verify there's no Prettier diff + run: | + npm run prettier -- --loglevel silent + if ! git diff --name-only --exit-code; then + # shellcheck disable=SC2016 + echo 'Error: Prettier diff detected! Please run `npm run prettier` and commit the changes.' + exit 1 + fi + + - name: Run unused style searcher + shell: bash + run: ./.github/scripts/findUnusedKeys.sh From 6d080e7ed2535174101f111d4e714cc74ed8b0e0 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 13 Sep 2024 13:23:31 +0200 Subject: [PATCH 05/10] Fix git command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6a67029a657..95495424d95 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=0 --cache --cache-location=node_modules/.cache/eslint", "lint-deprecation": "NODE_OPTIONS=--max_old_space_size=8192 eslint --max-warnings=0 --config ./.eslintrc.pr.js $(git diff --diff-filter=AM --name-only main -- \"*.ts\" \"*.tsx\")", - "lint-changed": "eslint --fix $(git diff --diff-filter=AM --name-only main -- \"*.js\" \"*.ts\" \"*.tsx\")", + "lint-changed": "eslint --fix $(git diff --diff-filter=AM --name-only origin/main HEAD -- \"*.js\" \"*.ts\" \"*.tsx\")", "lint-watch": "npx eslint-watch --watch --changed", "shellcheck": "./scripts/shellCheck.sh", "prettier": "prettier --write .", From 1c0e7722d00c0e972f4289d73d7dafc04a4da0c7 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 13 Sep 2024 13:26:26 +0200 Subject: [PATCH 06/10] Fix git command v2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 95495424d95..3ca14cdb4d6 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "test": "TZ=utc NODE_OPTIONS=--experimental-vm-modules jest", "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=0 --cache --cache-location=node_modules/.cache/eslint", - "lint-deprecation": "NODE_OPTIONS=--max_old_space_size=8192 eslint --max-warnings=0 --config ./.eslintrc.pr.js $(git diff --diff-filter=AM --name-only main -- \"*.ts\" \"*.tsx\")", + "lint-deprecation": "NODE_OPTIONS=--max_old_space_size=8192 eslint --max-warnings=0 --config ./.eslintrc.pr.js $(git diff --diff-filter=AM --name-only origin/main HEAD -- \"*.ts\" \"*.tsx\")", "lint-changed": "eslint --fix $(git diff --diff-filter=AM --name-only origin/main HEAD -- \"*.js\" \"*.ts\" \"*.tsx\")", "lint-watch": "npx eslint-watch --watch --changed", "shellcheck": "./scripts/shellCheck.sh", From ad9d9ec542f2a71c38d5d1a8580be8ac15db38bd Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Fri, 13 Sep 2024 13:36:14 +0200 Subject: [PATCH 07/10] Add endline --- .github/workflows/deprecation-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deprecation-lint.yml b/.github/workflows/deprecation-lint.yml index efe95ee2ba9..faa0c594ed5 100644 --- a/.github/workflows/deprecation-lint.yml +++ b/.github/workflows/deprecation-lint.yml @@ -28,4 +28,4 @@ jobs: git fetch origin main --no-tags --depth=1 # shellcheck disable=SC2046 - npm run lint-deprecation \ No newline at end of file + npm run lint-deprecation From 979b90a60ab44bc93ed2efae1da382d214fa37fb Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Mon, 16 Sep 2024 09:47:08 +0200 Subject: [PATCH 08/10] Change depracation lint to changed files lint --- .../{deprecation-lint.yml => lint-changed.yml} | 11 ++++++----- package.json | 3 +-- 2 files changed, 7 insertions(+), 7 deletions(-) rename .github/workflows/{deprecation-lint.yml => lint-changed.yml} (77%) diff --git a/.github/workflows/deprecation-lint.yml b/.github/workflows/lint-changed.yml similarity index 77% rename from .github/workflows/deprecation-lint.yml rename to .github/workflows/lint-changed.yml index faa0c594ed5..ddb640bfe9c 100644 --- a/.github/workflows/deprecation-lint.yml +++ b/.github/workflows/lint-changed.yml @@ -1,4 +1,4 @@ -name: Deprecation ESLint check +name: Changed files ESLint check on: workflow_call: @@ -8,12 +8,12 @@ on: paths: ['**.js', '**.ts', '**.tsx', '**.json', '**.mjs', '**.cjs', 'config/.editorconfig', '.watchmanconfig', '.imgbotconfig'] concurrency: - group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-deprecation-lint + group: ${{ github.ref == 'refs/heads/main' && format('{0}-{1}', github.ref, github.sha) || github.ref }}-changed-lint cancel-in-progress: true jobs: - deprecation-lint: - name: Deprecation ESLint check + lint-changed: + name: Changed files ESLint check if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }} runs-on: ubuntu-latest steps: @@ -25,7 +25,8 @@ jobs: - name: Run ESLint to check for deprecation warnings run: | + # This will just fetch the latest commit from main git fetch origin main --no-tags --depth=1 # shellcheck disable=SC2046 - npm run lint-deprecation + npm run lint-changed diff --git a/package.json b/package.json index 862824fca0e..28a3b7b244d 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,7 @@ "test": "TZ=utc NODE_OPTIONS=--experimental-vm-modules jest", "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=0 --cache --cache-location=node_modules/.cache/eslint", - "lint-deprecation": "NODE_OPTIONS=--max_old_space_size=8192 eslint --max-warnings=0 --config ./.eslintrc.pr.js $(git diff --diff-filter=AM --name-only origin/main HEAD -- \"*.ts\" \"*.tsx\")", - "lint-changed": "eslint --fix $(git diff --diff-filter=AM --name-only origin/main HEAD -- \"*.js\" \"*.ts\" \"*.tsx\")", + "lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 eslint --max-warnings=0 --config ./.eslintrc.pr.js $(git diff --diff-filter=AM --name-only origin/main HEAD -- \"*.ts\" \"*.tsx\")", "lint-watch": "npx eslint-watch --watch --changed", "shellcheck": "./scripts/shellCheck.sh", "prettier": "prettier --write .", From 569c165b4090c30b589e784c6b189232cc90d552 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Mon, 16 Sep 2024 09:49:52 +0200 Subject: [PATCH 09/10] Change name of the file from pr to changed --- .eslintignore | 2 +- .eslintrc.pr.js => .eslintrc.changed.js | 0 package.json | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename .eslintrc.pr.js => .eslintrc.changed.js (100%) diff --git a/.eslintignore b/.eslintignore index a5805dfe4ee..5c4b73d8a68 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,7 +3,7 @@ .github/actions/**/index.js *.config.js **/.eslintrc.js -**/.eslintrc.pr.js +**/.eslintrc.changed.js **/node_modules/** **/dist/** android/**/build/** diff --git a/.eslintrc.pr.js b/.eslintrc.changed.js similarity index 100% rename from .eslintrc.pr.js rename to .eslintrc.changed.js diff --git a/package.json b/package.json index 28a3b7b244d..72f01fc06d9 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "test": "TZ=utc NODE_OPTIONS=--experimental-vm-modules jest", "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=0 --cache --cache-location=node_modules/.cache/eslint", - "lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 eslint --max-warnings=0 --config ./.eslintrc.pr.js $(git diff --diff-filter=AM --name-only origin/main HEAD -- \"*.ts\" \"*.tsx\")", + "lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 eslint --max-warnings=0 --config ./.eslintrc.changed.js $(git diff --diff-filter=AM --name-only origin/main HEAD -- \"*.ts\" \"*.tsx\")", "lint-watch": "npx eslint-watch --watch --changed", "shellcheck": "./scripts/shellCheck.sh", "prettier": "prettier --write .", From bf4ebdeab56db764eee1f42f0925c72d2d98db3d Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Mon, 16 Sep 2024 12:03:42 +0200 Subject: [PATCH 10/10] Add prettier to run on main --- .github/workflows/preDeploy.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index e5ccdfa5307..79646817027 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -13,6 +13,9 @@ jobs: lint: uses: ./.github/workflows/lint.yml + prettier: + uses: ./.github/workflows/prettier.yml + test: uses: ./.github/workflows/test.yml