Skip to content

Commit c677ab1

Browse files
authored
Add linting, formatting, and type checking via CI and pre-commit hooks (#4)
This PR adds a bunch of improvements to help keep the codebase clean and consistent.
2 parents 538e949 + 549bee9 commit c677ab1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2143
-1060
lines changed

.eslintrc.json

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
11
{
22
"extends": [
33
"next/core-web-vitals",
4-
"next/typescript"
5-
]
4+
"next/typescript",
5+
"plugin:prettier/recommended",
6+
"plugin:import/errors",
7+
"plugin:import/warnings",
8+
"plugin:import/typescript"
9+
],
10+
"plugins": ["prettier", "import"],
11+
"rules": {
12+
// Code quality
13+
"no-console": "warn",
14+
"no-debugger": "error",
15+
"no-unused-vars": "off", // Handled by TS version above
16+
17+
// Import sorting and cleanliness
18+
"import/order": [
19+
"error",
20+
{
21+
"groups": [
22+
"builtin",
23+
"external",
24+
"internal",
25+
"parent",
26+
"sibling",
27+
"index",
28+
"object",
29+
"type"
30+
],
31+
"newlines-between": "always",
32+
"alphabetize": { "order": "asc", "caseInsensitive": true }
33+
}
34+
],
35+
"import/newline-after-import": "error",
36+
"import/no-duplicates": "error",
37+
38+
// Prettier takes over formatting rules now
39+
"prettier/prettier": "error"
40+
}
641
}

.github/workflows/lint-and-check.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Lint and Type-checking
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
branches:
10+
- main
11+
- dev
12+
13+
jobs:
14+
lint:
15+
name: ESLint & Prettier
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '18'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Get list of changed files
31+
id: files
32+
run: |
33+
echo "CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref || github.ref_name }} | tr '\n' ' ')" >> $GITHUB_ENV
34+
35+
- name: Lint JS/TS files with ESLint (no auto-fix)
36+
if: ${{ env.CHANGED_FILES != ''}}
37+
run: |
38+
FILES=$(echo "$CHANGED_FILES" | tr ' ' '\n' | grep -E '\.(js|jsx|ts|tsx)$' | xargs)
39+
if [ -n "$FILES" ]; then
40+
echo "Running ESLint on:"
41+
echo "$FILES"
42+
npx next lint --file $FILES
43+
else
44+
echo "No JS/TS files to lint."
45+
fi
46+
47+
- name: Format other files with Prettier
48+
if: ${{ env.CHANGED_FILES != ''}}
49+
run: |
50+
FILES=$(echo "$CHANGED_FILES" | tr ' ' '\n' | grep -E '\.(json|md|css|scss|html)$' | xargs)
51+
if [ -n "$FILES" ]; then
52+
echo "Running Prettier on:"
53+
echo "$FILES"
54+
npx prettier --check $FILES
55+
else
56+
echo "No files to format with Prettier."
57+
fi
58+
59+
- name: Type Check
60+
run: |
61+
echo "Running TypeScript type checking..."
62+
npx tsc --noEmit
63+
64+
type-check:
65+
name: Type Checking
66+
runs-on: ubuntu-latest
67+
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
72+
- name: Setup Node.js
73+
uses: actions/setup-node@v4
74+
with:
75+
node-version: '18'
76+
77+
- name: Install dependencies
78+
run: npm ci
79+
80+
- name: Type Check
81+
run: |
82+
echo "Running TypeScript type checking..."
83+
npx tsc --noEmit

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.lintstagedrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const path = require('path');
2+
3+
const buildEslintCommand = (filenames) =>
4+
`next lint --fix --file ${filenames
5+
.map((f) => path.relative(process.cwd(), f))
6+
.join(' --file ')}`;
7+
8+
module.exports = {
9+
'*.{js,jsx,ts,tsx}': [buildEslintCommand, 'prettier --write'],
10+
'*.{json,md,css,scss,html}': ['prettier --write'],
11+
};

.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"singleQuote": true,
3+
"semi": true,
4+
"trailingComma": "all",
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"arrowParens": "always",
8+
"plugins": ["prettier-plugin-tailwindcss"]
9+
}

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
# steadyfall.github.io
22

33
## color-palette
4+
45
main:
6+
57
- `text-pink-500`
68
- `text-thunderbird-600`
79
- `text-azure-radiance-600`
810
- `text-neon-green-500 dark:text-neon-green-400`
911

1012
across_colors:
13+
1114
- `text-midnight-blue-500`
1215
- `text-pink-500`
1316
- `text-orange-500`
1417
- `text-blue-violet-500`
1518

1619
highlighter:
20+
1721
- cyan: `bg-cyan-300 dark:bg-cyan-500/30`
1822
- pink/violet-web: `bg-[#ff77e4]`
1923
- slate-blue: `bg-[#7777ff]`
2024
- red: `bg-[#ff7777]`
2125
- yellow/lemon/laser-lemon: `bg-[#ffff77]`
2226

2327
## to-do:
28+
2429
- [x] check out about highlighting words
2530
- [ ] YAML file parser for experience, projects
2631
- [x] skills, education section

next.config.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/** @type {import('next').NextConfig} */
2-
const nextConfig = {};
2+
const nextConfig = {
3+
eslint: {
4+
ignoreDuringBuilds: true,
5+
},
6+
};
37

48
export default nextConfig;
59

0 commit comments

Comments
 (0)