Skip to content

Commit

Permalink
Check code formatting
Browse files Browse the repository at this point in the history
Uses Prettier (https://prettier.io/) to find style issues in the code.

It runs on every commit to the main branch and every pull request using GitHub Actions (https://github.com/features/actions).
  • Loading branch information
thewilkybarkid committed Nov 29, 2023
1 parent 9610984 commit a5483ab
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
push:
branches:
- 'main'
pull_request:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
format:
name: 'Format'
runs-on: ubuntu-22.04
timeout-minutes: 30

steps:
- name: 'Checkout code'
uses: actions/[email protected]

- name: 'Set up Node.js'
uses: actions/[email protected]
with:
node-version-file: package.json
cache: ${{ !env.ACT && 'npm' || '' }}

- name: 'Install dependencies'
run: npm ci

- name: 'Run formatter'
run: npx prettier --ignore-unknown --check '**'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
audit = false
engine-strict = true
fund = false
Empty file added .prettierignore
Empty file.
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"arrowParens": "avoid",
"printWidth": 120,
"semi": false,
"singleQuote": true,
"plugins": ["prettier-plugin-sh"]
}
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: fix format

node_modules: package.json package-lock.json
npm install
touch node_modules

fix: node_modules
npx prettier --ignore-unknown --write '**'

format: node_modules
npx prettier --ignore-unknown --check '**'
78 changes: 78 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"private": true,
"engines": {
"node": "20",
"npm": "9 || 10"
},
"devDependencies": {
"prettier": "^3.1.0",
"prettier-plugin-sh": "^0.13.1"
}
}

0 comments on commit a5483ab

Please sign in to comment.