Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Split ESLint action into three #49165

Merged
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.github/actions/**/index.js
*.config.js
**/.eslintrc.js
**/.eslintrc.changed.js
**/node_modules/**
**/dist/**
android/**/build/**
Expand Down
10 changes: 10 additions & 0 deletions .eslintrc.changed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
plugins: ['@typescript-eslint', 'deprecation'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
rules: {
'deprecation/deprecation': 'error',
},
};
7 changes: 0 additions & 7 deletions .eslintrc.pr.js

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/lint-changed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Changed files 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 }}-changed-lint
cancel-in-progress: true

jobs:
lint-changed:
name: Changed files 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: |
# This will just fetch the latest commit from main
git fetch origin main --no-tags --depth=1

# shellcheck disable=SC2046
npm run lint-changed
22 changes: 2 additions & 20 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint code
name: ESLint check

on:
workflow_call:
Expand All @@ -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:
Expand All @@ -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
3 changes: 3 additions & 0 deletions .github/workflows/preDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
lint:
uses: ./.github/workflows/lint.yml

prettier:
uses: ./.github/workflows/prettier.yml

test:
uses: ./.github/workflows/test.yml

Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "eslint --fix $(git diff --diff-filter=AM --name-only main -- \"*.js\" \"*.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\")",
blazejkustra marked this conversation as resolved.
Show resolved Hide resolved
"lint-watch": "npx eslint-watch --watch --changed",
"shellcheck": "./scripts/shellCheck.sh",
"prettier": "prettier --write .",
Expand Down
Loading