Skip to content

Commit 11c943d

Browse files
authored
Merge pull request #1486 from maxmind/kevin/precious
Replace husky with precious
2 parents f72991a + 24831f6 commit 11c943d

File tree

15 files changed

+130
-684
lines changed

15 files changed

+130
-684
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ jobs:
2020
run: npm run lint
2121
- name: Run prettier
2222
run: npm run prettier:ci
23+
- name: Test compile
24+
run: npx tsc --noEmit

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ typings/
6262

6363
# next.js build output
6464
.next
65+
66+
# Precious install
67+
local

.husky/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.husky/_/husky.sh

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

.husky/pre-commit

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

.precious.toml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[commands.prettier-scripts]
2+
type = "both"
3+
cmd = [
4+
"npx",
5+
"prettier",
6+
"--parser",
7+
"typescript"
8+
]
9+
lint-flags = ["--check"]
10+
tidy-flags = ["--write"]
11+
path-args = "absolute-file"
12+
include = ["src/**/*.ts"]
13+
ok-exit-codes = 0
14+
15+
[commands.prettier-json]
16+
type = "both"
17+
cmd = [
18+
"npx",
19+
"prettier",
20+
"--parser",
21+
"json"
22+
]
23+
lint-flags = ["--check"]
24+
tidy-flags = ["--write"]
25+
path-args = "absolute-file"
26+
include = ["**/*.json"]
27+
ok-exit-codes = 0
28+
29+
[commands.eslint-scripts]
30+
type = "both"
31+
cmd = [
32+
"npx",
33+
"eslint",
34+
"--config",
35+
"eslint.config.mjs",
36+
]
37+
lint-flags = []
38+
tidy-flags = ["--fix"]
39+
path-args = "absolute-file"
40+
include = ["src/**/*.ts", "src/**/*.js", "e2e/**/*.ts", "e2e/**/*.js"]
41+
ok-exit-codes = 0
42+
43+
[commands.tsc-scripts]
44+
type = "lint"
45+
cmd = [
46+
"npx",
47+
"tsc",
48+
"--noEmit"
49+
]
50+
include = ["src/**/*.ts"]
51+
invoke = "once"
52+
path-args = "none"
53+
ok-exit-codes = 0

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/package.json
2+
**/package-lock.json

README.dev.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Steps for releasing:
1919
[GitHub](https://github.com/maxmind/minfraud-api-node/releases) and
2020
[NPM](https://npmjs.com/package/@maxmind/minfraud-api-node).
2121

22-
## Set up pre-commit hooks
22+
## Set up Precious to tidy and lint
2323

24-
`npm run setup` to install husky pre-commit hooks
24+
1. Run `mkdir -p local && ./bin/install-precious local` to set up Precious locally
25+
2. Run `./git/setup.sh` to set up pre-commit hook that invokes Precious

bin/install-precious

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# This is for installing precious and other 3rd party libs needed for linting
4+
# in CI
5+
6+
set -euo pipefail
7+
set -x
8+
9+
if [ -z "${1:-}" ]; then
10+
echo "💥 You need to specify where to install precious. usage: ./bin/install-precious /path/to/bin/dir"
11+
exit 1
12+
fi
13+
14+
TARGET=$1
15+
export TARGET
16+
17+
curl --silent --location \
18+
https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |
19+
sh
20+
21+
./"$TARGET"/ubi --project houseabsolute/omegasort --in "$TARGET"
22+
./"$TARGET"/ubi --project houseabsolute/precious --in "$TARGET"

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default tseslint.config(
4242
"jest.config.js",
4343
"eslint.config.mjs",
4444
"coverage",
45+
"prettier.config.mjs",
4546
],
4647
},
4748
);

0 commit comments

Comments
 (0)