Skip to content

Commit 00db32c

Browse files
Merge pull request #80 from AbdulSnk/chore/linting-prettier-husky-setup
chore/linting-prettier-husky-setup
2 parents 0e13dec + f2022bd commit 00db32c

8 files changed

Lines changed: 57 additions & 4 deletions

File tree

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
.next/
3+
public/
4+
build/
5+
coverage/

.eslintrc.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
{
22
"extends": [
33
"next/core-web-vitals",
4-
"next/typescript"
4+
"next/typescript",
5+
"prettier"
6+
],
7+
"plugins": [
8+
"prettier"
59
],
610
"rules": {
711
"@typescript-eslint/no-unused-vars": "off",
8-
"@typescript-eslint/no-explicit-any": "off"
12+
"@typescript-eslint/no-explicit-any": "off",
13+
"prettier/prettier": "error"
914
}
1015
}

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
# Run lint-staged
5+
npx --no -- lint-staged

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
.next/
3+
dist/
4+
build/
5+
coverage/
6+
public/
7+
*.min.js
8+
*.log

.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "all",
8+
"bracketSpacing": true,
9+
"arrowParens": "always",
10+
"endOfLine": "lf",
11+
"plugins": []
12+
}

lint-staged.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
'*.{js,jsx,ts,tsx}': (filenames) => [
3+
// run eslint --fix on changed files
4+
`eslint --max-warnings=0 --fix ${filenames.join(' ')}`,
5+
// then format with prettier
6+
`prettier --write ${filenames.join(' ')}`
7+
],
8+
'*.{json,md,css,scss,html}': [`prettier --write ${filenames.join(' ')}`]
9+
};

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"dev": "next dev --turbopack",
77
"build": "next build",
88
"start": "next start",
9-
"lint": "next lint",
9+
"lint": "next lint --max-warnings=0",
10+
"lint:fix": "eslint --ext .ts,.tsx,.js,.jsx . --fix",
11+
"format": "prettier --write .",
12+
"prepare": "husky install",
1013
"test": "vitest run",
1114
"test:coverage": "vitest run --coverage",
1215
"test:ui": "vitest --ui",
@@ -68,6 +71,11 @@
6871
"@vitejs/plugin-react-swc": "^3.10.2",
6972
"eslint": "^9",
7073
"eslint-config-next": "15.3.1",
74+
"eslint-config-prettier": "^8.8.0",
75+
"eslint-plugin-prettier": "^4.2.1",
76+
"prettier": "^2.8.8",
77+
"husky": "^8.0.3",
78+
"lint-staged": "^14.3.0",
7179
"fast-check": "^3.22.0",
7280
"jsdom": "^26.1.0",
7381
"postcss": "^8.5.6",

src/eslint.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const eslintConfig = [
1919
"**/form-management/**/*.test.ts",
2020
],
2121
},
22-
...compat.extends("next/core-web-vitals", "next/typescript"),
22+
// include Prettier at the end to avoid rule conflicts
23+
...compat.extends("next/core-web-vitals", "next/typescript", "prettier"),
2324
{
2425
rules: {
2526
"@typescript-eslint/no-unused-vars": "off",

0 commit comments

Comments
 (0)