Skip to content

Commit

Permalink
lint: add lefthook, prettier, typos
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
noahp committed Jul 17, 2024
1 parent 248e84b commit 254461a
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# See https://bun.sh/docs/install/lockfile
*.lockb binary diff=lockb
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ _site/
/vendor
/example/*/build
/.venv
/node_modules

# Yarn 2
.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*
4 changes: 4 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
overrides:
- files: "*.md"
options:
proseWrap: always
13 changes: 5 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"grammarly.files.include": [
"**/readme.md",
"**/README.md",
"**/*.txt",
"**/*.md"
],
"grammarly.config.documentDialect": "american",
"grammarly.config.suggestions.OxfordComma": true
"editor.formatOnSave": true,
"[markdown]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
}
}
12 changes: 12 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# See config documentation here:
# https://github.com/crate-ci/typos/blob/master/docs/reference.md
[default.extend-words]

[default]
# extend-ignore-re list operates on sequences, not identifiers, so we can
# have very targeted ignores
extend-ignore-re = []

[files]
# list of files to exclude
extend-exclude = []
15 changes: 15 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Lefthook configuration:
#
# Refer for explanation to following link:
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
#

pre-commit:
parallel: true
commands:
prettier:
glob: "*.md"
run: yarn prettier --write --prose-wrap=always {staged_files}
typos:
glob: "*.md"
run: yarn typos --config _typos.toml {staged_files}
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"scripts": {
"lint:prettier": "prettier --check _posts _drafts",
"lint:typos": "typos _posts _drafts",
"lint:prettier:fix": "prettier --write _posts _drafts"
},
"dependencies": {
"lefthook": "^1.6.16",
"prettier": "^3.3.2"
},
"devDependencies": {
"typos-rs-npm": "dalisoft/typos-rs-npm"
}
}
36 changes: 27 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ Interrupt is a community for embedded software makers and professionals alike.

Interrupt welcomes submissions on embedded software topics.

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

To submit your content, either email us at [email protected], or open a pull request!
To submit your content, either email us at [email protected], or open a
pull request!

See [Contributing](https://interrupt.memfault.com/contributing) for more information.
See [Contributing](https://interrupt.memfault.com/contributing) for more
information.

## Running

### Docker (Recommended)

Follow the instructions in the [Install Docker Engine](https://docs.docker.com/engine/install/) according to your operating system.
Follow the instructions in the
[Install Docker Engine](https://docs.docker.com/engine/install/) according to
your operating system.

Clone the repo, run in docker:

Expand All @@ -36,9 +41,13 @@ You can now access the server at [http://0.0.0.0:4000](http://0.0.0.0:4000)
### Locally

You'll need:

- Python 3.8 or later
- Ruby 2.7.7

Optionally, to run the linters, you'll need `yarn` (easy way is via
[`volta`](https://volta.sh/)).

#### Install Dependencies

Clone the repo and install Python dependencies:
Expand All @@ -55,9 +64,9 @@ $ pip install -r requirements.txt

The virtual environment can be deactivated with `deactivate`.

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

Install Ruby dependencies:

Expand All @@ -67,17 +76,26 @@ $ ruby -v
$ bundle install
```

Install `yarn` dependencies (this also installs the git hooks):

```bash
$ yarn install
```

#### Launch

Serve with the following command, which will also open up the site in your browser:
Serve with the following command, which will also open up the site in your
browser:

```bash
$ bundle exec jekyll serve --drafts --livereload --open-url
```

## Acknowledgements

Interrupt is based on the Emerald theme by [Jacopo Rabolini](https://www.jacoporabolini.com/). Emerald is available on [Github](https://github.com/KingFelix/emerald).
Interrupt is based on the Emerald theme by
[Jacopo Rabolini](https://www.jacoporabolini.com/). Emerald is available on
[Github](https://github.com/KingFelix/emerald).

---

Expand Down
134 changes: 134 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!

__metadata:
version: 8
cacheKey: 10c0

"binary2npm@https://github.com/dalisoft/binary2npm#v0.3.8":
version: 0.3.7
resolution: "binary2npm@git+ssh://[email protected]/dalisoft/binary2npm.git#commit=76b8dd261f75c0b672ccd29ed2b018f43fed0ddb"
checksum: 10c0/981594c3b1e846cee268f8cf8503200425a7cb6674fb678aa20c958fb43bfe3b8db30d7254c852527645da7e102c1cd1e5e0715eb341d3bdb5099820f36012b5
languageName: node
linkType: hard

"lefthook-darwin-arm64@npm:1.6.16":
version: 1.6.16
resolution: "lefthook-darwin-arm64@npm:1.6.16"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"lefthook-darwin-x64@npm:1.6.16":
version: 1.6.16
resolution: "lefthook-darwin-x64@npm:1.6.16"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"lefthook-freebsd-arm64@npm:1.6.16":
version: 1.6.16
resolution: "lefthook-freebsd-arm64@npm:1.6.16"
conditions: os=freebsd & cpu=arm64
languageName: node
linkType: hard

"lefthook-freebsd-x64@npm:1.6.16":
version: 1.6.16
resolution: "lefthook-freebsd-x64@npm:1.6.16"
conditions: os=freebsd & cpu=x64
languageName: node
linkType: hard

"lefthook-linux-arm64@npm:1.6.16":
version: 1.6.16
resolution: "lefthook-linux-arm64@npm:1.6.16"
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard

"lefthook-linux-x64@npm:1.6.16":
version: 1.6.16
resolution: "lefthook-linux-x64@npm:1.6.16"
conditions: os=linux & cpu=x64
languageName: node
linkType: hard

"lefthook-windows-arm64@npm:1.6.16":
version: 1.6.16
resolution: "lefthook-windows-arm64@npm:1.6.16"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard

"lefthook-windows-x64@npm:1.6.16":
version: 1.6.16
resolution: "lefthook-windows-x64@npm:1.6.16"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard

"lefthook@npm:^1.6.16":
version: 1.6.16
resolution: "lefthook@npm:1.6.16"
dependencies:
lefthook-darwin-arm64: "npm:1.6.16"
lefthook-darwin-x64: "npm:1.6.16"
lefthook-freebsd-arm64: "npm:1.6.16"
lefthook-freebsd-x64: "npm:1.6.16"
lefthook-linux-arm64: "npm:1.6.16"
lefthook-linux-x64: "npm:1.6.16"
lefthook-windows-arm64: "npm:1.6.16"
lefthook-windows-x64: "npm:1.6.16"
dependenciesMeta:
lefthook-darwin-arm64:
optional: true
lefthook-darwin-x64:
optional: true
lefthook-freebsd-arm64:
optional: true
lefthook-freebsd-x64:
optional: true
lefthook-linux-arm64:
optional: true
lefthook-linux-x64:
optional: true
lefthook-windows-arm64:
optional: true
lefthook-windows-x64:
optional: true
bin:
lefthook: bin/index.js
checksum: 10c0/1199bff516aafd31edac387abe9978b12278aec90903764dfc54fee4487cbe2f46481bd7095ecf5554a1c8fd103686ce74797c7e3777b38a7e0776122f586df3
languageName: node
linkType: hard

"prettier@npm:^3.3.2":
version: 3.3.2
resolution: "prettier@npm:3.3.2"
bin:
prettier: bin/prettier.cjs
checksum: 10c0/39ed27d17f0238da6dd6571d63026566bd790d3d0edac57c285fbab525982060c8f1e01955fe38134ab10f0951a6076da37f015db8173c02f14bc7f0803a384c
languageName: node
linkType: hard

"root-workspace-0b6124@workspace:.":
version: 0.0.0-use.local
resolution: "root-workspace-0b6124@workspace:."
dependencies:
lefthook: "npm:^1.6.16"
prettier: "npm:^3.3.2"
typos-rs-npm: dalisoft/typos-rs-npm
languageName: unknown
linkType: soft

typos-rs-npm@dalisoft/typos-rs-npm:
version: 1.22.7
resolution: "typos-rs-npm@git+ssh://[email protected]/dalisoft/typos-rs-npm.git#commit=98179e72aba777535d5d44745077885db9d00d90"
dependencies:
binary2npm: "https://github.com/dalisoft/binary2npm#v0.3.8"
bin:
typos: ./typos
checksum: 10c0/37f34d6cf57f0f329b194fa7ee5f05ee6391acc065413d2bb3a44f2fcfd4d3edcb26427c58ff9f75503cea3ed6b95745e95cb3fe703b6d27e14ee0bbe6237d8b
languageName: node
linkType: hard

0 comments on commit 254461a

Please sign in to comment.