Skip to content

Commit 1d07e86

Browse files
feat: add pre-commit lint-staged (#6276)
1 parent d6cbddb commit 1d07e86

File tree

4 files changed

+103
-18
lines changed

4 files changed

+103
-18
lines changed

.husky/pre-commit

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22
. "$(dirname "$0")/_/husky.sh"
33

4-
cd ./frontend && npx lint-staged --allow-empty
4+
# Load nvm for GUI apps (supports both standard and Homebrew installations)
5+
export NVM_DIR="$HOME/.nvm"
6+
if [ -s "$NVM_DIR/nvm.sh" ]; then
7+
. "$NVM_DIR/nvm.sh"
8+
elif [ -s "/opt/homebrew/opt/nvm/nvm.sh" ]; then
9+
. "/opt/homebrew/opt/nvm/nvm.sh"
10+
fi
11+
12+
# Auto-load Node version from .nvmrc if NVM is available
13+
if command -v nvm &> /dev/null; then
14+
cd ./frontend
15+
# Try to use version from .nvmrc, fallback to default if not installed
16+
nvm use 2>/dev/null || nvm use default 2>/dev/null || nvm use node 2>/dev/null || true
17+
else
18+
cd ./frontend
19+
fi
20+
21+
npx lint-staged --allow-empty

frontend/.eslintrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ module.exports = {
111111
'sort-keys-fix',
112112
'sort-destructure-keys',
113113
'@typescript-eslint',
114+
'unused-imports',
114115
],
115116
'rules': {
116117
'@dword-design/import-alias/prefer-alias': [
@@ -129,12 +130,17 @@ module.exports = {
129130
'@typescript-eslint/no-explicit-any': 'off',
130131
'@typescript-eslint/no-namespace': 'off',
131132
'@typescript-eslint/no-var-requires': 'off',
133+
'@typescript-eslint/no-unused-vars': 'off',
132134
'default-case': 'error',
133135
'dot-notation': 'error',
136+
'eqeqeq': 'warn',
134137
'guard-for-in': 'error',
135138
'no-caller': 'error',
139+
'no-console': 'warn',
140+
'no-debugger': 'warn',
136141
'no-empty': 'off',
137142
'no-empty-pattern': 'off',
143+
'no-unused-vars': 'off',
138144
'no-var': 'error',
139145
'object-curly-spacing': ['error', 'always'],
140146
'prefer-template': 'error',
@@ -157,6 +163,14 @@ module.exports = {
157163
'sort-destructure-keys/sort-destructure-keys': 'warn',
158164
'sort-keys-fix/sort-keys-fix': 'warn',
159165
'typescript-eslint/no-empty-interface': 'off',
166+
'unused-imports/no-unused-imports': 'error',
167+
'unused-imports/no-unused-vars': [
168+
'warn',
169+
{
170+
'argsIgnorePattern': '^_',
171+
'varsIgnorePattern': '^_',
172+
},
173+
],
160174
},
161175
'settings': {
162176
'react': {

0 commit comments

Comments
 (0)