Skip to content

Commit

Permalink
Lebovits/issu643 add frontend formatting check (#752)
Browse files Browse the repository at this point in the history
* add formatting + linting checks to front end workflows
* have checks run on PRs to staging, not main
  • Loading branch information
nlebovits committed Jul 18, 2024
1 parent 05157d9 commit 00fb39b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 22 deletions.
17 changes: 14 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@
"sourceType": "module",
"project": "./tsconfig.json"
},
"extends": ["next/core-web-vitals", "plugin:react/recommended", "prettier"],
"extends": [
"next/core-web-vitals",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"custom-rules/no-text-size-class": "warn"
"custom-rules/no-text-size-class": "warn",
"prettier/prettier": "error"
},
"plugins": ["react", "eslint-plugin-custom-rules"],
"plugins": [
"react",
"eslint-plugin-custom-rules",
"@typescript-eslint",
"prettier"
],
"settings": {
"react": {
"version": "detect"
Expand Down
51 changes: 32 additions & 19 deletions .github/workflows/pr_checks.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
name: Frontend PR Checks
on: # see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
workflow_dispatch:
pull_request:
paths:
- "src/**/*"
- "package.json"
- "package-lock.json"
- "*.js"
name: PR Checks

on:
push:
branches:
- staging

jobs:
lint_and_build:
lint:
runs-on: ubuntu-latest

steps:
- name: Check out repository code
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: "package-lock.json"
node-version: '20'

- name: Install dependencies
run: npm ci
- name: Run lints
run: npm install

- name: Run ESLint
run: npm run lint
- name: Check the build
run: npm run build
continue-on-error: true

- name: Run Prettier Check
run: npm run format:check
continue-on-error: true

- name: Check linting and formatting
if: failure()
run: |
echo "Linting or formatting issues found. Please run 'npm run lint:fix' and 'npm run format' to fix them."
exit 1
- name: Linting and formatting success
if: success()
run: echo "No linting or formatting issues found. Good job!"
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": "es5"
}

0 comments on commit 00fb39b

Please sign in to comment.