Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Integrating Husky Pre-Commit Hook with ESLint and Prettier #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions frontend/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cd ./frontend && npx lint-staged && npm run lint:fix
3 changes: 3 additions & 0 deletions frontend/.lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.{js,ts,tsx,scss,css,md}": ["eslint", "prettier --write"]
}
3 changes: 3 additions & 0 deletions frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore artifacts:
build
coverage
7 changes: 7 additions & 0 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"endOfLine": "auto"
}
15 changes: 12 additions & 3 deletions frontend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import prettier from 'eslint-config-prettier'
import prettierPlugin from 'eslint-plugin-prettier'

export default tseslint.config(
{ ignores: ['dist'] },
{ ignores: ['dist', 'node_modules'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
prettier, // Disables conflicting ESLint rules
],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
Expand All @@ -16,13 +22,16 @@ export default tseslint.config(
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
prettier: prettierPlugin,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'prettier/prettier': 'error', // Ensures Prettier formatting is enforced
'@typescript-eslint/no-explicit-any': 'off',
},
},
}
)
Loading