Skip to content

Add linting, formatting, and type checking via CI and pre-commit hooks #4

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

Merged
merged 11 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
{
"extends": [
"next/core-web-vitals",
"next/typescript"
]
"next/typescript",
"plugin:prettier/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript"
],
"plugins": ["prettier", "import"],
"rules": {
// Code quality
"no-console": "warn",
"no-debugger": "error",
"no-unused-vars": "off", // Handled by TS version above

// Import sorting and cleanliness
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"object",
"type"
],
"newlines-between": "always",
"alphabetize": { "order": "asc", "caseInsensitive": true }
}
],
"import/newline-after-import": "error",
"import/no-duplicates": "error",

// Prettier takes over formatting rules now
"prettier/prettier": "error"
}
}
83 changes: 83 additions & 0 deletions .github/workflows/lint-and-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Lint and Type-checking

on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

jobs:
lint:
name: ESLint & Prettier
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: npm ci

- name: Get list of changed files
id: files
run: |
echo "CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref || github.ref_name }} | tr '\n' ' ')" >> $GITHUB_ENV

- name: Lint JS/TS files with ESLint (no auto-fix)
if: ${{ env.CHANGED_FILES != ''}}
run: |
FILES=$(echo "$CHANGED_FILES" | tr ' ' '\n' | grep -E '\.(js|jsx|ts|tsx)$' | xargs)
if [ -n "$FILES" ]; then
echo "Running ESLint on:"
echo "$FILES"
npx next lint --file $FILES
else
echo "No JS/TS files to lint."
fi

- name: Format other files with Prettier
if: ${{ env.CHANGED_FILES != ''}}
run: |
FILES=$(echo "$CHANGED_FILES" | tr ' ' '\n' | grep -E '\.(json|md|css|scss|html)$' | xargs)
if [ -n "$FILES" ]; then
echo "Running Prettier on:"
echo "$FILES"
npx prettier --check $FILES
else
echo "No files to format with Prettier."
fi

- name: Type Check
run: |
echo "Running TypeScript type checking..."
npx tsc --noEmit

type-check:
name: Type Checking
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: npm ci

- name: Type Check
run: |
echo "Running TypeScript type checking..."
npx tsc --noEmit
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
11 changes: 11 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require('path');

const buildEslintCommand = (filenames) =>
`next lint --fix --file ${filenames
.map((f) => path.relative(process.cwd(), f))
.join(' --file ')}`;

module.exports = {
'*.{js,jsx,ts,tsx}': [buildEslintCommand, 'prettier --write'],
'*.{json,md,css,scss,html}': ['prettier --write'],
};
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"singleQuote": true,
"semi": true,
"trailingComma": "all",
"printWidth": 100,
"tabWidth": 2,
"arrowParens": "always",
"plugins": ["prettier-plugin-tailwindcss"]
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
# steadyfall.github.io

## color-palette

main:

- `text-pink-500`
- `text-thunderbird-600`
- `text-azure-radiance-600`
- `text-neon-green-500 dark:text-neon-green-400`

across_colors:

- `text-midnight-blue-500`
- `text-pink-500`
- `text-orange-500`
- `text-blue-violet-500`

highlighter:

- cyan: `bg-cyan-300 dark:bg-cyan-500/30`
- pink/violet-web: `bg-[#ff77e4]`
- slate-blue: `bg-[#7777ff]`
- red: `bg-[#ff7777]`
- yellow/lemon/laser-lemon: `bg-[#ffff77]`

## to-do:

- [x] check out about highlighting words
- [ ] YAML file parser for experience, projects
- [x] skills, education section
Expand Down
6 changes: 5 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
eslint: {
ignoreDuringBuilds: true,
},
};

export default nextConfig;

Expand Down
Loading