Skip to content

Commit 70986d4

Browse files
noahpgminn
andauthored
lint: add lefthook, prettier, typos (memfault#481)
Install from npm, because it's simpler, so use lefthook as the pre-commit runner (`yarn install` automatically installs the hooks, which is somewhat nice too). I removed the reference to the `grammarly` vscode extension, since it's no longer available in the marketplace and the github repo is archived. Update to yarn 3 to support modern lefthook plugin. --------- Co-authored-by: Gillian Minnehan <gillian@memfault.com>
1 parent 9146493 commit 70986d4

9 files changed

Lines changed: 1120 additions & 18 deletions

File tree

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,12 @@ _site/
88
/vendor
99
/example/*/build
1010
/.venv
11+
/node_modules
12+
13+
# Yarn 2
14+
.yarn/*
15+
!.yarn/releases
16+
!.yarn/plugins
17+
!.yarn/sdks
18+
!.yarn/versions
19+
.pnp.*

.vscode/settings.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
{
2-
"grammarly.files.include": [
3-
"**/readme.md",
4-
"**/README.md",
5-
"**/*.txt",
6-
"**/*.md"
7-
],
8-
"grammarly.config.documentDialect": "american",
9-
"grammarly.config.suggestions.OxfordComma": true,
2+
"editor.formatOnSave": true,
103
"[markdown]": {
11-
"editor.formatOnSave": true
4+
"editor.formatOnSave": true,
5+
"editor.defaultFormatter": "esbenp.prettier-vscode"
126
}
137
}

.yarn/releases/yarn-3.6.3.cjs

Lines changed: 874 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
yarnPath: .yarn/releases/yarn-3.6.3.cjs
2+
nodeLinker: node-modules

_typos.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# See config documentation here:
2+
# https://github.com/crate-ci/typos/blob/master/docs/reference.md
3+
[default.extend-words]
4+
5+
[default]
6+
# extend-ignore-re list operates on sequences, not identifiers, so we can
7+
# have very targeted ignores
8+
extend-ignore-re = []
9+
10+
[files]
11+
# list of files to exclude
12+
extend-exclude = []

lefthook.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Lefthook configuration:
2+
#
3+
# Refer for explanation to following link:
4+
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
5+
#
6+
7+
pre-commit:
8+
parallel: true
9+
commands:
10+
prettier:
11+
glob: "*.md"
12+
run: yarn prettier --write --prose-wrap=always {staged_files}
13+
stage_fixed: true
14+
typos:
15+
glob: "*.md"
16+
run: yarn typos --config _typos.toml {staged_files}

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"scripts": {
3+
"lint:prettier": "prettier --check _posts _drafts",
4+
"lint:typos": "typos _posts _drafts",
5+
"lint:prettier:fix": "prettier --write _posts _drafts"
6+
},
7+
"dependencies": {
8+
"lefthook": "^1.6.16",
9+
"prettier": "^3.3.2"
10+
},
11+
"devDependencies": {
12+
"typos-rs-npm": "dalisoft/typos-rs-npm"
13+
},
14+
"packageManager": "yarn@3.6.3"
15+
}

readme.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ Interrupt is a community for embedded software makers and professionals alike.
1111

1212
Interrupt welcomes submissions on embedded software topics.
1313

14-
Prior to getting in touch, you should get yourself acquainted with our [Code of Conduct](https://interrupt.memfault.com/code-of-conduct).
14+
Prior to getting in touch, you should get yourself acquainted with our
15+
[Code of Conduct](https://interrupt.memfault.com/code-of-conduct).
1516

16-
To submit your content, either email us at interrupt@memfault.com, or open a pull request!
17+
To submit your content, either email us at interrupt@memfault.com, or open a
18+
pull request!
1719

18-
See [Contributing](https://interrupt.memfault.com/contributing) for more information.
20+
See [Contributing](https://interrupt.memfault.com/contributing) for more
21+
information.
1922

2023
## Running
2124

2225
### Docker (Recommended)
2326

24-
Follow the instructions in the [Install Docker Engine](https://docs.docker.com/engine/install/) according to your operating system.
27+
Follow the instructions in the
28+
[Install Docker Engine](https://docs.docker.com/engine/install/) according to
29+
your operating system.
2530

2631
Clone the repo, run in docker:
2732

@@ -40,6 +45,9 @@ You'll need:
4045
- Python 3.8 or later
4146
- Ruby 3.2.2
4247

48+
Optionally, to run the linters, you'll need `yarn` (easy way is via
49+
[`volta`](https://volta.sh/)).
50+
4351
#### Install Dependencies
4452

4553
Clone the repo and install Python dependencies:
@@ -56,9 +64,9 @@ $ pip install -r requirements.txt
5664

5765
The virtual environment can be deactivated with `deactivate`.
5866

59-
We highly recommend setting up a version manager for Ruby, such as
60-
`rbenv`. Follow the instructions [here](https://github.com/rbenv/rbenv) to set it
61-
up for your operating system and install the right version of Ruby.
67+
We highly recommend setting up a version manager for Ruby, such as `rbenv`.
68+
Follow the instructions [here](https://github.com/rbenv/rbenv) to set it up for
69+
your operating system and install the right version of Ruby.
6270

6371
Install Ruby dependencies:
6472

@@ -68,17 +76,26 @@ $ ruby -v
6876
$ bundle install
6977
```
7078

79+
Install `yarn` dependencies (this also installs the git hooks):
80+
81+
```bash
82+
$ yarn install
83+
```
84+
7185
#### Launch
7286

73-
Serve with the following command, which will also open up the site in your browser:
87+
Serve with the following command, which will also open up the site in your
88+
browser:
7489

7590
```bash
7691
$ bundle exec jekyll serve --drafts --livereload --open-url --future
7792
```
7893

7994
## Acknowledgements
8095

81-
Interrupt is based on the Emerald theme by [Jacopo Rabolini](https://www.jacoporabolini.com/). Emerald is available on [Github](https://github.com/KingFelix/emerald).
96+
Interrupt is based on the Emerald theme by
97+
[Jacopo Rabolini](https://www.jacoporabolini.com/). Emerald is available on
98+
[Github](https://github.com/KingFelix/emerald).
8299

83100
---
84101

yarn.lock

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# This file is generated by running "yarn install" inside your project.
2+
# Manual changes might be lost - proceed with caution!
3+
4+
__metadata:
5+
version: 6
6+
cacheKey: 8
7+
8+
"binary2npm@https://github.com/dalisoft/binary2npm#v0.4.4":
9+
version: 0.4.3
10+
resolution: "binary2npm@https://github.com/dalisoft/binary2npm.git#commit=ee4e0c76854e80728b4112a86d05cf742e03f8d3"
11+
dependencies:
12+
detect-libc: ^2.0.3
13+
checksum: a18a88820339bd10c66fe2c369c1ad91bf5b4058adaf0d7197486829b39571823f7fc400850327539493b150c6daf5dc4c20bf5803f7bc5eb1c728a4f9e92b72
14+
languageName: node
15+
linkType: hard
16+
17+
"detect-libc@npm:^2.0.3":
18+
version: 2.1.2
19+
resolution: "detect-libc@npm:2.1.2"
20+
checksum: 471740d52365084c4b2ae359e507b863f2b1d79b08a92835ebdf701918e08fc9cfba175b3db28483ca33b155e1311a91d69dc42c6d192b476f41a9e1f094ce6a
21+
languageName: node
22+
linkType: hard
23+
24+
"lefthook-darwin-arm64@npm:1.13.6":
25+
version: 1.13.6
26+
resolution: "lefthook-darwin-arm64@npm:1.13.6"
27+
conditions: os=darwin & cpu=arm64
28+
languageName: node
29+
linkType: hard
30+
31+
"lefthook-darwin-x64@npm:1.13.6":
32+
version: 1.13.6
33+
resolution: "lefthook-darwin-x64@npm:1.13.6"
34+
conditions: os=darwin & cpu=x64
35+
languageName: node
36+
linkType: hard
37+
38+
"lefthook-freebsd-arm64@npm:1.13.6":
39+
version: 1.13.6
40+
resolution: "lefthook-freebsd-arm64@npm:1.13.6"
41+
conditions: os=freebsd & cpu=arm64
42+
languageName: node
43+
linkType: hard
44+
45+
"lefthook-freebsd-x64@npm:1.13.6":
46+
version: 1.13.6
47+
resolution: "lefthook-freebsd-x64@npm:1.13.6"
48+
conditions: os=freebsd & cpu=x64
49+
languageName: node
50+
linkType: hard
51+
52+
"lefthook-linux-arm64@npm:1.13.6":
53+
version: 1.13.6
54+
resolution: "lefthook-linux-arm64@npm:1.13.6"
55+
conditions: os=linux & cpu=arm64
56+
languageName: node
57+
linkType: hard
58+
59+
"lefthook-linux-x64@npm:1.13.6":
60+
version: 1.13.6
61+
resolution: "lefthook-linux-x64@npm:1.13.6"
62+
conditions: os=linux & cpu=x64
63+
languageName: node
64+
linkType: hard
65+
66+
"lefthook-openbsd-arm64@npm:1.13.6":
67+
version: 1.13.6
68+
resolution: "lefthook-openbsd-arm64@npm:1.13.6"
69+
conditions: os=openbsd & cpu=arm64
70+
languageName: node
71+
linkType: hard
72+
73+
"lefthook-openbsd-x64@npm:1.13.6":
74+
version: 1.13.6
75+
resolution: "lefthook-openbsd-x64@npm:1.13.6"
76+
conditions: os=openbsd & cpu=x64
77+
languageName: node
78+
linkType: hard
79+
80+
"lefthook-windows-arm64@npm:1.13.6":
81+
version: 1.13.6
82+
resolution: "lefthook-windows-arm64@npm:1.13.6"
83+
conditions: os=win32 & cpu=arm64
84+
languageName: node
85+
linkType: hard
86+
87+
"lefthook-windows-x64@npm:1.13.6":
88+
version: 1.13.6
89+
resolution: "lefthook-windows-x64@npm:1.13.6"
90+
conditions: os=win32 & cpu=x64
91+
languageName: node
92+
linkType: hard
93+
94+
"lefthook@npm:^1.6.16":
95+
version: 1.13.6
96+
resolution: "lefthook@npm:1.13.6"
97+
dependencies:
98+
lefthook-darwin-arm64: 1.13.6
99+
lefthook-darwin-x64: 1.13.6
100+
lefthook-freebsd-arm64: 1.13.6
101+
lefthook-freebsd-x64: 1.13.6
102+
lefthook-linux-arm64: 1.13.6
103+
lefthook-linux-x64: 1.13.6
104+
lefthook-openbsd-arm64: 1.13.6
105+
lefthook-openbsd-x64: 1.13.6
106+
lefthook-windows-arm64: 1.13.6
107+
lefthook-windows-x64: 1.13.6
108+
dependenciesMeta:
109+
lefthook-darwin-arm64:
110+
optional: true
111+
lefthook-darwin-x64:
112+
optional: true
113+
lefthook-freebsd-arm64:
114+
optional: true
115+
lefthook-freebsd-x64:
116+
optional: true
117+
lefthook-linux-arm64:
118+
optional: true
119+
lefthook-linux-x64:
120+
optional: true
121+
lefthook-openbsd-arm64:
122+
optional: true
123+
lefthook-openbsd-x64:
124+
optional: true
125+
lefthook-windows-arm64:
126+
optional: true
127+
lefthook-windows-x64:
128+
optional: true
129+
bin:
130+
lefthook: bin/index.js
131+
checksum: 3f84a085285e58026774228a8d84dbb812e1e4556e1766a603bf824ca73ae2fd60733b09bac44e3b8846054dcbc34a950b16c1e43f66538e2de2dcf6138237bb
132+
languageName: node
133+
linkType: hard
134+
135+
"prettier@npm:^3.3.2":
136+
version: 3.7.4
137+
resolution: "prettier@npm:3.7.4"
138+
bin:
139+
prettier: bin/prettier.cjs
140+
checksum: 955e37e87b1151ca3b3282463f5295f4c415821884791df152ff66e6eb1c5257115153cccba61b13962546100dd00ae45670ff27077dcab04c977d84036eaf80
141+
languageName: node
142+
linkType: hard
143+
144+
"root-workspace-0b6124@workspace:.":
145+
version: 0.0.0-use.local
146+
resolution: "root-workspace-0b6124@workspace:."
147+
dependencies:
148+
lefthook: ^1.6.16
149+
prettier: ^3.3.2
150+
typos-rs-npm: dalisoft/typos-rs-npm
151+
languageName: unknown
152+
linkType: soft
153+
154+
typos-rs-npm@dalisoft/typos-rs-npm:
155+
version: 1.34.0
156+
resolution: "typos-rs-npm@https://github.com/dalisoft/typos-rs-npm.git#commit=834679ffc47249d4d37da4228697e7d6baa60675"
157+
dependencies:
158+
binary2npm: "https://github.com/dalisoft/binary2npm#v0.4.4"
159+
bin:
160+
typos: ./typos
161+
checksum: f0f1ad27623982f426c3c7f8514992f27f690a8e44028df82f5cf888d2f785346a47e65daffa11b832eb2195c82f69bba11ae0ade432af3c217b5b78884fa974
162+
languageName: node
163+
linkType: hard

0 commit comments

Comments
 (0)