Skip to content

Commit 4972bbd

Browse files
bardvacekj
andauthored
enh: run code checks in pre-commit and pre-push hooks (gitcoinco#2314)
Co-authored-by: Atris <vacekj@outlook.com>
1 parent d4133af commit 4972bbd

14 files changed

Lines changed: 727 additions & 126 deletions

File tree

lefthook.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,34 @@ pre-commit:
55
parallel: true
66
commands:
77
prettier:
8-
glob: "*.{js,ts,jsx,tsx}"
9-
run: pnpm prettier --write {staged_files}
8+
glob: "**/*.{js,ts,jsx,tsx}"
9+
run: pnpm format {staged_files}
10+
stage_fixed: true
11+
12+
lint-ge:
13+
root: "packages/builder"
14+
glob: "**/*.{js,ts,jsx,tsx}"
15+
run: pnpm --filter "builder" lint:local {staged_files}
16+
stage_fixed: true
17+
18+
lint-rm:
19+
root: "packages/round-manager"
20+
glob: "**/*.{js,ts,jsx,tsx}"
21+
run: pnpm --filter "round-manager" lint:local {staged_files}
22+
stage_fixed: true
23+
24+
lint-builder:
25+
root: "packages/grant-explorer"
26+
glob: "**/*.{js,ts,jsx,tsx}"
27+
run: pnpm --filter "grant-explorer" lint:local {staged_files}
28+
stage_fixed: true
1029

1130
pre-push:
1231
parallel: true
1332
commands:
14-
eslint:
15-
glob: "*.{js,ts,jsx,tsx}"
16-
run: turbo lint:ci
33+
typecheck:
34+
run: turbo run typecheck
35+
build:
36+
run: turbo run build
37+
test:
38+
run: turbo run test

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"compile": "pnpm --filter contracts run compile ",
1313
"test": "pnpm run test",
1414
"typecheck": "turbo run typecheck",
15+
"format": "prettier --write",
1516
"// round manager script": "====== packages/round-manager specific ======",
1617
"rm-build": "pnpm --filter round-manager run build",
1718
"rm-test": "turbo run test --filter=round-manager",
@@ -35,7 +36,8 @@
3536
"@commitlint/config-conventional": "^17.6.3"
3637
},
3738
"dependencies": {
38-
"turbo": "^1.10.14"
39+
"prettier": "^3.0.3",
40+
"turbo": "^1.10.9"
3941
},
4042
"pnpm": {
4143
"overrides": {

packages/builder/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474
"ts-jest": "^27.0",
7575
"typescript": "^4.6.3",
7676
"url": "^0.11.0",
77+
"verify-env": "*",
7778
"wagmi": "^0.12.19",
7879
"web-vitals": "^2.1.4",
79-
"yup": "^0.32.11",
80-
"verify-env": "*"
80+
"yup": "^0.32.11"
8181
},
8282
"scripts": {
8383
"start": "craco start",
@@ -86,8 +86,9 @@
8686
"test:dev": "jest --watch",
8787
"test:coverage": "jest --watchAll=false --coverage",
8888
"eject": "react-scripts eject",
89+
"lint:local": "eslint",
8990
"lint": "eslint --ext .js,.jsx,.ts,.tsx ./src --cache",
90-
"lint:ci": "pnpm lint --max-warnings=0",
91+
"lint:ci": "CI=false pnpm lint",
9192
"lint:fix": "eslint ./src --fix --cache",
9293
"typecheck": "tsc --noEmit"
9394
},
@@ -137,6 +138,6 @@
137138
"lokijs": "^1.5.12",
138139
"msw": "^0.47.4",
139140
"postcss-import": "^14.1.0",
140-
"prettier": "^2.6.2"
141+
"prettier": "2"
141142
}
142143
}

packages/eslint-config-gitcoin/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ module.exports = {
2424
files: ["**/*.{ts,tsx,js,jsx}"],
2525
rules: {
2626
"@typescript-eslint/explicit-module-boundary-types": "off",
27-
"no-debugger": "off",
2827
"@typescript-eslint/no-var-requires": "off",
2928
},
3029
},

packages/eslint-config-gitcoin/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"main": "index.js",
55
"private": true,
66
"dependencies": {
7-
"@typescript-eslint/eslint-plugin": "^6.5.0",
8-
"@typescript-eslint/parser": "^6.5.0",
9-
"eslint": "^8.22.0",
10-
"eslint-config-turbo": "latest",
7+
"@typescript-eslint/eslint-plugin": "^6.7.2",
8+
"@typescript-eslint/parser": "^6.7.2",
9+
"typescript": "^5.2.2",
10+
"eslint": "^8.49.0",
11+
"eslint-config-turbo": "^1.10.14",
1112
"eslint-plugin-react": "^7.31.7",
1213
"eslint-plugin-react-hooks": "^4.6.0"
1314
}

packages/grant-explorer/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
"license": "AGPL-3.0-only",
66
"scripts": {
77
"build": "env REACT_APP_GIT_SHA=$(git rev-parse --short HEAD) craco build",
8-
"lint:ci": "pnpm lint:fix --max-warnings=0",
8+
"lint:local": "eslint",
9+
"lint:ci": "CI=false pnpm lint",
910
"lint:fix": "eslint ./src --fix",
11+
"lint": "eslint ./src --cache",
1012
"typecheck": "tsc --noEmit",
1113
"start": "craco start",
1214
"test": "vitest run",
@@ -119,7 +121,6 @@
119121
"eslint-config-gitcoin": "workspace:*",
120122
"happy-dom": "^11.0.2",
121123
"postcss": "^8.4.14",
122-
"prettier": "^2.8.3",
123124
"resize-observer-polyfill": "^1.5.1",
124125
"tailwind-styled-components": "^2.1.7",
125126
"tailwindcss": "^3.0.24",

packages/round-manager/.prettierignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/round-manager/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
"test:dev": "craco test --watchAll=true",
1515
"test:coverage": "craco test --watchAll=false --silent --coverage",
1616
"eject": "react-scripts eject",
17-
"format": "prettier . --write",
18-
"lint:ci": "pnpm lint:fix --max-warnings=0",
17+
"lint:local": "eslint",
18+
"lint": "eslint ./src --cache",
19+
"lint:ci": "CI=false pnpm lint",
1920
"lint:fix": "eslint ./src --fix",
2021
"typecheck": "tsc --noEmit",
2122
"typechain": "typechain --target=ethers-v5 ./src/features/**/*.json --out-dir ./src/types/generated/typechain/",
@@ -128,7 +129,6 @@
128129
"craco-esbuild": "^0.5.2",
129130
"husky": "^8.0.1",
130131
"postcss": "^8.4.14",
131-
"prettier": "^2.7.1",
132132
"resize-observer-polyfill": "^1.5.1",
133133
"tailwind-styled-components": "2.1.6",
134134
"tailwindcss": "^3.0.24",

packages/round-manager/src/features/round/RoundDetailForm.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const RoundValidationSchema = yup.object().shape({
4242
.required("You must select a support type.")
4343
.notOneOf(
4444
["Select what type of input."],
45-
"You must select a support type."
45+
"You must select a support type.",
4646
),
4747
info: yup
4848
.string()
@@ -61,7 +61,7 @@ export const RoundValidationSchema = yup.object().shape({
6161
/*Matches www.example.com, example.com, http and https prefixes, but not www.invalid */
6262
.matches(
6363
/^(http:\/\/|https:\/\/|ipfs:\/\/)?\S+\.\S+$|^(ipfs:\/\/)\S+$/,
64-
"Must be a valid URL"
64+
"Must be a valid URL",
6565
)
6666
.required("You must provide a valid URL."),
6767
}),
@@ -883,7 +883,7 @@ function SupportTypeDropdown(props: {
883883
<SupportTypeButton
884884
errors={props.errors}
885885
supportType={props.supportTypes.find(
886-
(supportType) => supportType.name === field.value
886+
(supportType) => supportType.name === field.value,
887887
)}
888888
/>
889889
<Transition
@@ -904,7 +904,7 @@ function SupportTypeDropdown(props: {
904904
active
905905
? "text-white bg-indigo-600"
906906
: "text-gray-900",
907-
"relative cursor-default select-none py-2 pl-3 pr-9"
907+
"relative cursor-default select-none py-2 pl-3 pr-9",
908908
)
909909
}
910910
value={type.name}
@@ -916,7 +916,7 @@ function SupportTypeDropdown(props: {
916916
<span
917917
className={classNames(
918918
selected ? "font-semibold" : "font-normal",
919-
"ml-3 block truncate"
919+
"ml-3 block truncate",
920920
)}
921921
>
922922
{type.name}
@@ -927,7 +927,7 @@ function SupportTypeDropdown(props: {
927927
<span
928928
className={classNames(
929929
active ? "text-white" : "text-indigo-600",
930-
"absolute inset-y-0 right-0 flex items-center pr-4"
930+
"absolute inset-y-0 right-0 flex items-center pr-4",
931931
)}
932932
>
933933
<CheckIcon
@@ -939,7 +939,7 @@ function SupportTypeDropdown(props: {
939939
</>
940940
)}
941941
</Listbox.Option>
942-
)
942+
),
943943
)}
944944
</Listbox.Options>
945945
</Transition>
@@ -1074,7 +1074,7 @@ function RoundType(props: {
10741074
? "bg-indigo-600 border-transparent"
10751075
: "bg-white border-gray-300",
10761076
active ? "ring-2 ring-offset-2 ring-indigo-500" : "",
1077-
"h-4 w-4 mt-1 rounded-full border flex items-center justify-center"
1077+
"h-4 w-4 mt-1 rounded-full border flex items-center justify-center",
10781078
)}
10791079
aria-hidden="true"
10801080
>
@@ -1103,7 +1103,7 @@ function RoundType(props: {
11031103
? "bg-indigo-600 border-transparent"
11041104
: "bg-white border-gray-300",
11051105
active ? "ring-2 ring-offset-2 ring-indigo-500" : "",
1106-
"h-4 w-4 mt-1 rounded-full border flex items-center justify-center"
1106+
"h-4 w-4 mt-1 rounded-full border flex items-center justify-center",
11071107
)}
11081108
aria-hidden="true"
11091109
>

0 commit comments

Comments
 (0)