Skip to content

Commit 43d675a

Browse files
authored
Use GitHub Actions to enforce code formatting and lint rules (#72)
1 parent fe0d689 commit 43d675a

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

.eslintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"env": {
3+
"es2021": true
4+
},
5+
"extends": ["eslint:recommended"],
6+
"parserOptions": {
7+
"ecmaVersion": "latest",
8+
"sourceType": "module"
9+
},
10+
"rules": {}
11+
}

.github/workflows/validate.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: validate
2+
on:
3+
# run on push but only for the main branch
4+
push:
5+
branches:
6+
- main
7+
# run for every pull request
8+
pull_request: {}
9+
jobs:
10+
main:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: ⬇️ Checkout repo
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: ⎔ Setup node
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: 18
22+
23+
- name: 🧹 Check code formatting with Prettier
24+
run: find . -name package.json -maxdepth 2 -type f -execdir npm run format:check ';'
25+
26+
- name: 👕 Lint Node.js code with ESLint
27+
run: find . -name package.json -maxdepth 2 -type f -execdir npm run lint ';'

advanced-integration/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"scripts": {
88
"test": "echo \"Error: no test specified\" && exit 1",
99
"start": "node server/server.js",
10-
"format": "npx prettier --write **.js"
10+
"format": "npx prettier --write **.{js,md}",
11+
"format:check": "npx prettier --check **.{js,md}",
12+
"lint": "npx eslint server/*.js --env=node && npx eslint client/*.js --env=browser"
1113
},
1214
"license": "Apache-2.0",
1315
"dependencies": {

standard-integration/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"scripts": {
88
"test": "echo \"Error: no test specified\" && exit 1",
99
"start": "node server/server.js",
10-
"format": "npx prettier --write **.js"
10+
"format": "npx prettier --write **.{js,md}",
11+
"format:check": "npx prettier --check **.{js,md}",
12+
"lint": "npx eslint server/*.js --env=node && npx eslint client/*.js --env=browser"
1113
},
1214
"license": "Apache-2.0",
1315
"dependencies": {

0 commit comments

Comments
 (0)