From 254461a75d796ea4576213aa7bf220f0fd5e3185 Mon Sep 17 00:00:00 2001 From: Noah Pendleton <2538614+noahp@users.noreply.github.com> Date: Wed, 17 Jul 2024 08:40:28 -0400 Subject: [PATCH] lint: add lefthook, prettier, typos 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. --- .gitattributes | 2 + .gitignore | 9 +++ .prettierrc.yml | 4 ++ .vscode/settings.json | 13 ++-- _typos.toml | 12 ++++ lefthook.yml | 15 +++++ package.json | 14 +++++ readme.md | 36 +++++++++--- yarn.lock | 134 ++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 222 insertions(+), 17 deletions(-) create mode 100644 .gitattributes create mode 100644 .prettierrc.yml create mode 100644 _typos.toml create mode 100644 lefthook.yml create mode 100644 package.json create mode 100644 yarn.lock diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..96637e4fd --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# See https://bun.sh/docs/install/lockfile +*.lockb binary diff=lockb diff --git a/.gitignore b/.gitignore index 300f54ddf..b5f8d04b7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,12 @@ _site/ /vendor /example/*/build /.venv +/node_modules + +# Yarn 2 +.yarn/* +!.yarn/releases +!.yarn/plugins +!.yarn/sdks +!.yarn/versions +.pnp.* diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 000000000..ec3b3e2f7 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,4 @@ +overrides: + - files: "*.md" + options: + proseWrap: always diff --git a/.vscode/settings.json b/.vscode/settings.json index 737749e86..340f5c63d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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", + } } \ No newline at end of file diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 000000000..f8c33a201 --- /dev/null +++ b/_typos.toml @@ -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 = [] diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 000000000..9f01c15cf --- /dev/null +++ b/lefthook.yml @@ -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} diff --git a/package.json b/package.json new file mode 100644 index 000000000..db029e67d --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/readme.md b/readme.md index 5e0adefc7..fe5d602a7 100644 --- a/readme.md +++ b/readme.md @@ -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 interrupt@memfault.com, or open a pull request! +To submit your content, either email us at interrupt@memfault.com, 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: @@ -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: @@ -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: @@ -67,9 +76,16 @@ $ 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 @@ -77,7 +93,9 @@ $ 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). --- diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 000000000..8e5710e80 --- /dev/null +++ b/yarn.lock @@ -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://git@github.com/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://git@github.com/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