Skip to content

Commit 67bb8e9

Browse files
author
Roshan Jossy
committed
add lint configuration with eslint, prettier, lint-staged, husky
1 parent ebf5341 commit 67bb8e9

File tree

6 files changed

+661
-53
lines changed

6 files changed

+661
-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
"@editorjs/code": "^2.7.0",
@@ -34,16 +38,39 @@
3438
"@types/react-relay": "^13.0.1",
3539
"@types/relay-runtime": "^13.0.1",
3640
"@types/simple-oauth2": "^4.1.1",
41+
"@typescript-eslint/eslint-plugin": "^5.28.0",
42+
"@typescript-eslint/parser": "^5.28.0",
3743
"autoprefixer": "^10.4.2",
3844
"babel-plugin-relay": "^13.0.2",
39-
"eslint": "8.8.0",
45+
"eslint": "^8.18.0",
4046
"eslint-config-next": "12.0.10",
47+
"eslint-config-prettier": "^8.5.0",
48+
"eslint-import-resolver-typescript": "^2.7.1",
49+
"eslint-plugin-prettier": "^4.0.0",
4150
"graphql": "^16.3.0",
51+
"husky": "^8.0.0",
52+
"lint-staged": "^13.0.2",
4253
"postcss": "^8.4.6",
54+
"prettier": "^2.7.1",
4355
"relay-compiler": "^13.0.2",
4456
"relay-compiler-language-typescript": "^15.0.1",
4557
"relay-config": "^12.0.1",
4658
"tailwindcss": "^3.0.23",
4759
"typescript": "4.5.5"
60+
},
61+
"husky": {
62+
"hooks": {
63+
"pre-commit": "lint-staged"
64+
}
65+
},
66+
"lint-staged": {
67+
"*.{js,jsx,ts,tsx}": [
68+
"prettier --write",
69+
"eslint --fix",
70+
"eslint"
71+
],
72+
"*.json": [
73+
"prettier --write"
74+
]
4875
}
4976
}

0 commit comments

Comments
 (0)