Skip to content

Commit 5856532

Browse files
author
Roshan Jossy
committed
add lint configuration with eslint, prettier, lint-staged, husky
1 parent 8148ee0 commit 5856532

File tree

6 files changed

+664
-53
lines changed

6 files changed

+664
-53
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
out

.eslintrc.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
{
2-
"extends": "next/core-web-vitals"
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"plugin:@typescript-eslint/recommended",
8+
"next",
9+
"next/core-web-vitals",
10+
"prettier"
11+
],
12+
"parser": "@typescript-eslint/parser",
13+
"parserOptions": {
14+
"ecmaFeatures": {
15+
"jsx": true
16+
},
17+
"ecmaVersion": 12,
18+
"sourceType": "module"
19+
},
20+
"plugins": ["@typescript-eslint"]
321
}

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
# Disable concurent to run build-types after ESLint in lint-staged
5+
npx lint-staged --concurrent false

.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
printWidth: 80,
3+
semi: false,
4+
singleQuote: true,
5+
tabWidth: 2,
6+
useTabs: false,
7+
}

package.json

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
"build": "next build",
77
"start": "next start",
88
"lint": "next lint",
9-
"relay": "relay-compiler"
9+
"relay": "relay-compiler",
10+
"check-lint": "eslint . --ext ts --ext tsx --ext js",
11+
"check-types": "tsc --pretty --noEmit",
12+
"format": "prettier --write .",
13+
"prepare": "husky install"
1014
},
1115
"dependencies": {
1216
"@react-icons/all-files": "^4.1.0",
@@ -25,16 +29,39 @@
2529
"@types/react-relay": "^13.0.1",
2630
"@types/relay-runtime": "^13.0.1",
2731
"@types/simple-oauth2": "^4.1.1",
32+
"@typescript-eslint/eslint-plugin": "^5.28.0",
33+
"@typescript-eslint/parser": "^5.28.0",
2834
"autoprefixer": "^10.4.2",
2935
"babel-plugin-relay": "^13.0.2",
30-
"eslint": "8.8.0",
36+
"eslint": "^8.18.0",
3137
"eslint-config-next": "12.0.10",
38+
"eslint-config-prettier": "^8.5.0",
39+
"eslint-import-resolver-typescript": "^2.7.1",
40+
"eslint-plugin-prettier": "^4.0.0",
3241
"graphql": "^16.3.0",
42+
"husky": "^8.0.0",
43+
"lint-staged": "^13.0.2",
3344
"postcss": "^8.4.6",
45+
"prettier": "^2.7.1",
3446
"relay-compiler": "^13.0.2",
3547
"relay-compiler-language-typescript": "^15.0.1",
3648
"relay-config": "^12.0.1",
3749
"tailwindcss": "^3.0.23",
3850
"typescript": "4.5.5"
51+
},
52+
"husky": {
53+
"hooks": {
54+
"pre-commit": "lint-staged"
55+
}
56+
},
57+
"lint-staged": {
58+
"*.{js,jsx,ts,tsx}": [
59+
"prettier --write",
60+
"eslint --fix",
61+
"eslint"
62+
],
63+
"*.json": [
64+
"prettier --write"
65+
]
3966
}
4067
}

0 commit comments

Comments
 (0)