refactor: Add more checks to pre-commit

Updated existing pre-commit hooks and added some new hooks:

- Remove trailing whitespace
- Ensure every non-empty file ends with a new line
- Check YAML file validity
- Prevent adding large files
- Ensure any scripts with shebangs are executable

Added a GitHub action to run pre-commit on every commit. Removed any
existing actions which duplicate pre-commit.

Ran pre-commit on the codebase.
This commit is contained in:
Joel Spadin 2023-04-22 23:16:36 -05:00 committed by Pete Johanson
parent 9c4f1e02d1
commit 32ae776c42
247 changed files with 759 additions and 797 deletions

View file

@ -1,13 +1,15 @@
<!-- If you're adding a board/shield please fill out this check-list, otherwise you can delete it --> <!-- If you're adding a board/shield please fill out this check-list, otherwise you can delete it -->
## Board/Shield Check-list ## Board/Shield Check-list
- [ ] This board/shield is tested working on real hardware
- [ ] Definitions follow the general style of other shields/boards upstream ([Reference](https://zmk.dev/docs/development/new-shield)) - [ ] This board/shield is tested working on real hardware
- [ ] `.zmk.yml` metadata file added - [ ] Definitions follow the general style of other shields/boards upstream ([Reference](https://zmk.dev/docs/development/new-shield))
- [ ] Proper Copyright + License headers added to applicable files (Generally, we stick to "The ZMK Contributors" for copyrights to help avoid churn when files get edited) - [ ] `.zmk.yml` metadata file added
- [ ] General consistent formatting of DeviceTree files - [ ] Proper Copyright + License headers added to applicable files (Generally, we stick to "The ZMK Contributors" for copyrights to help avoid churn when files get edited)
- [ ] Keymaps do not use deprecated key defines (Check using the [upgrader tool](https://zmk.dev/docs/codes/keymap-upgrader)) - [ ] General consistent formatting of DeviceTree files
- [ ] `&pro_micro` used in favor of `&pro_micro_d/a` if applicable - [ ] Keymaps do not use deprecated key defines (Check using the [upgrader tool](https://zmk.dev/docs/codes/keymap-upgrader))
- [ ] If split, no name added for the right/peripheral half - [ ] `&pro_micro` used in favor of `&pro_micro_d/a` if applicable
- [ ] Kconfig.defconfig file correctly wraps *all* configuration in conditional on the shield symbol - [ ] If split, no name added for the right/peripheral half
- [ ] `.conf` file has optional extra features commented out - [ ] Kconfig.defconfig file correctly wraps _all_ configuration in conditional on the shield symbol
- [ ] Keyboard/PCB is part of a shipped group buy or is generally available in stock to purchase (OSH/personal projects without general availability should create a zmk-config repo instead) - [ ] `.conf` file has optional extra features commented out
- [ ] Keyboard/PCB is part of a shipped group buy or is generally available in stock to purchase (OSH/personal projects without general availability should create a zmk-config repo instead)

View file

@ -19,8 +19,8 @@ on:
required: false required: false
type: string type: string
archive_name: archive_name:
description: 'Archive output file name' description: "Archive output file name"
default: 'firmware' default: "firmware"
required: false required: false
type: string type: string

View file

@ -1,29 +0,0 @@
name: Clang Format
on:
push:
paths:
- ".github/workflows/clang-format-lint.yml"
- "app/boards/**/*.c"
- "app/include/**/*.h"
- "app/src/**"
- "app/drivers/**/*.c"
- "app/drivers/**/*.h"
pull_request:
paths:
- ".github/workflows/clang-format-lint.yml"
- "app/boards/**/*.c"
- "app/include/**/*.h"
- "app/src/**"
- "app/drivers/**/*.c"
- "app/drivers/**/*.h"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DoozyX/clang-format-lint-action@v0.13
with:
source: "./app"
extensions: "h,c"

View file

@ -21,16 +21,6 @@ jobs:
- name: ESLint - name: ESLint
run: npm run lint run: npm run lint
working-directory: docs working-directory: docs
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: bahmutov/npm-install@v1
with:
working-directory: docs
- name: Prettier check
run: npm run prettier:check
working-directory: docs
typecheck: typecheck:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View file

@ -15,17 +15,6 @@ on:
- "app/scripts/west_commands/metadata.py" - "app/scripts/west_commands/metadata.py"
jobs: jobs:
check-metadata-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
- uses: bahmutov/npm-install@v1
with:
working-directory: app
- name: Prettier Check
run: npm run prettier:check
working-directory: app
validate-metadata: validate-metadata:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:

15
.github/workflows/pre-commit.yml vendored Normal file
View file

@ -0,0 +1,15 @@
name: pre-commit
on:
pull_request:
push:
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/action@v3.0.0

View file

@ -1,12 +1,20 @@
fail_fast: false fail_fast: false
repos: repos:
- repo: https://github.com/pocc/pre-commit-hooks - repo: https://github.com/pocc/pre-commit-hooks
rev: v1.1.1 rev: v1.3.5
hooks: hooks:
- id: clang-format - id: clang-format
args: args:
- -i - -i
- repo: https://github.com/pre-commit/mirrors-prettier - repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1 rev: v2.7.1
hooks: hooks:
- id: prettier - id: prettier
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- id: check-shebang-scripts-are-executable
exclude: "\\.mustache$"

View file

@ -1,6 +1,5 @@
# Building ZMK for the Ferris 0.2 # Building ZMK for the Ferris 0.2
## Standard Build ## Standard Build
``` ```

View file

@ -1,9 +1,11 @@
# nice!60 # nice!60
![nice!60](https://i.imgur.com/0YWv5PE.png) ![nice!60](https://i.imgur.com/0YWv5PE.png)
The nice!60 is a hotswap 60% made by Nice Keyboards. https://nicekeyboards.com/nice-60 The nice!60 is a hotswap 60% made by Nice Keyboards. https://nicekeyboards.com/nice-60
## Building nice!60 ZMK firmware ## Building nice!60 ZMK firmware
``` ```
west build -p -b nice60 west build -p -b nice60
``` ```

View file

@ -1,9 +1,11 @@
# S40NC # S40NC
![S40NC](https://i.imgur.com/fk8587n.jpg) ![S40NC](https://i.imgur.com/fk8587n.jpg)
Shorty40NoCordy (S40NC) is a limited run 40% bluetooth keyboard originally made and sold by MechWild. Shorty40NoCordy (S40NC) is a limited run 40% bluetooth keyboard originally made and sold by MechWild.
## Building S40NC ZMK firmware ## Building S40NC ZMK firmware
``` ```
west build -p -b s40nc west build -p -b s40nc
``` ```

View file

@ -4,9 +4,9 @@ Customizable full-size split ortholinear.
## Features ## Features
* Compatible with MX-compatible, Alps-compatible, and Kailh Low-Profile Choc switches. - Compatible with MX-compatible, Alps-compatible, and Kailh Low-Profile Choc switches.
* Breakoff pieces to allow for 4 to 6 rows and 7 to 9 columns. - Breakoff pieces to allow for 4 to 6 rows and 7 to 9 columns.
* RGB LED connections - RGB LED connections
## Hardware Notes ## Hardware Notes

View file

@ -11,15 +11,17 @@ Albeit, there is no doubt where Leeloo's heritage is derived from—Lily58, and
Leeloo has been designed from scratch; everything from the schematic to its PCB footprints, and column stagger. There are some subtle differences that may not be apparent; however, its subtle changes enable an interesting future. Leeloo has been designed from scratch; everything from the schematic to its PCB footprints, and column stagger. There are some subtle differences that may not be apparent; however, its subtle changes enable an interesting future.
Features: Features:
* 4x6x5m Split Keyboard
* Support for MX/Box or Low Profile Choc switches. - 4x6x5m Split Keyboard
* 90% of the switches are socketed; with the exception to the rotary encoder positions—6 positions require soldering. - Support for MX/Box or Low Profile Choc switches.
* Support for 128x32 OLED Displays. - 90% of the switches are socketed; with the exception to the rotary encoder positions—6 positions require soldering.
* The option to select one of three positions for an EC11 rotary encoder on each half. - Support for 128x32 OLED Displays.
* Support for Alps Alpine Micro Switch - The option to select one of three positions for an EC11 rotary encoder on each half.
* Support for 3.7v 301230 LiPo Battery - Support for Alps Alpine Micro Switch
- Support for 3.7v 301230 LiPo Battery
# Building Your Firmware # Building Your Firmware
ZMK Firmware: [Introduction to ZMK](https://zmk.dev/docs/) ZMK Firmware: [Introduction to ZMK](https://zmk.dev/docs/)
Installation: [Installing ZMK](https://zmk.dev/docs/user-setup) Installation: [Installing ZMK](https://zmk.dev/docs/user-setup)
Customization: [Customizing ZMK](https://zmk.dev/docs/customization) Customization: [Customizing ZMK](https://zmk.dev/docs/customization)
@ -36,6 +38,7 @@ Build command for your custom keymap of Leeloo:
west build -d build/left -p -b nice_nano_v2 -- -DSHIELD=leeloo_left -DZMK_CONFIG="C:/dev/zmk/[yourName]/leeloo/config" west build -d build/left -p -b nice_nano_v2 -- -DSHIELD=leeloo_left -DZMK_CONFIG="C:/dev/zmk/[yourName]/leeloo/config"
# Support # Support
If you have any questions with regards to Leeloo, please [Contact Us](https://clicketysplit.ca/pages/contact-us). If you have any questions with regards to Leeloo, please [Contact Us](https://clicketysplit.ca/pages/contact-us).
Clickety Split Clickety Split

View file

@ -2,4 +2,4 @@
The nice!view is a low power, high refresh rate display meant to replace I2C OLEDs traditionally used. The nice!view is a low power, high refresh rate display meant to replace I2C OLEDs traditionally used.
This shield requires that an `&nice_view_spi` labelled SPI bus is provided with *at least* MOSI, SCK, and CS pins defined. This shield requires that an `&nice_view_spi` labelled SPI bus is provided with _at least_ MOSI, SCK, and CS pins defined.

View file

@ -2,7 +2,7 @@
This shield is used as an adapter between the nice!view and existing shields/boards that expose an I2C OLED header. This shield is used as an adapter between the nice!view and existing shields/boards that expose an I2C OLED header.
To use this shield, you should add this shield to your list of shields *before* `nice_view`. To use this shield, you should add this shield to your list of shields _before_ `nice_view`.
The nice!view will use the SDA/SCL pins of the OLED, and then the adapter expects a final pin to be "bodged" from your microcontroller to the nice!view CS pin. This adapter assumes that the CS pin bodged is the `&pro_micro 1` pin or "D1", which is the top left pin when looking at the front of the board. If you can't use this pin, you'll need to override the `cs-gpios` for the `&nice_view_spi` bus (in your `zmk-config` keymap for example) or you will want to define your own `&nice_view_spi` bus without using this adapter. The nice!view will use the SDA/SCL pins of the OLED, and then the adapter expects a final pin to be "bodged" from your microcontroller to the nice!view CS pin. This adapter assumes that the CS pin bodged is the `&pro_micro 1` pin or "D1", which is the top left pin when looking at the front of the board. If you can't use this pin, you'll need to override the `cs-gpios` for the `&nice_view_spi` bus (in your `zmk-config` keymap for example) or you will want to define your own `&nice_view_spi` bus without using this adapter.

View file

@ -6,6 +6,6 @@ Standard setup for the [TG4x](https://github.com/MythosMann/tg4x/) 40% keyboard.
This TG4x implementation is for... This TG4x implementation is for...
* rev 2.1 of the board - rev 2.1 of the board
* Split spacebar with 2.25U on the left and 2.75U on the right - Split spacebar with 2.25U on the left and 2.75U on the right
* 2U right shift - 2U right shift

View file

@ -1,35 +1,35 @@
board: board:
- nice_nano_v2 - nice_nano_v2
- nrfmicro_13 - nrfmicro_13
- proton_c - proton_c
shield: shield:
- corne_left - corne_left
- corne_right - corne_right
- romac - romac
- settings_reset - settings_reset
- tidbit - tidbit
include: include:
- board: bdn9_rev2 - board: bdn9_rev2
- board: nice60 - board: nice60
- board: seeeduino_xiao_ble - board: seeeduino_xiao_ble
shield: hummingbird shield: hummingbird
- board: nrf52840_m2 - board: nrf52840_m2
shield: m60 shield: m60
- board: planck_rev6 - board: planck_rev6
- board: proton_c - board: proton_c
shield: clueboard_california shield: clueboard_california
- board: nice_nano_v2 - board: nice_nano_v2
shield: kyria_left shield: kyria_left
cmake-args: "-DCONFIG_ZMK_DISPLAY=y" cmake-args: "-DCONFIG_ZMK_DISPLAY=y"
nickname: "display" nickname: "display"
- board: nice_nano_v2 - board: nice_nano_v2
shield: kyria_right shield: kyria_right
cmake-args: "-DCONFIG_ZMK_DISPLAY=y" cmake-args: "-DCONFIG_ZMK_DISPLAY=y"
nickname: "display" nickname: "display"
- board: nice_nano - board: nice_nano
shield: romac_plus shield: romac_plus
cmake-args: "-DCONFIG_ZMK_RGB_UNDERGLOW=y -DCONFIG_WS2812_STRIP=y" cmake-args: "-DCONFIG_ZMK_RGB_UNDERGLOW=y -DCONFIG_WS2812_STRIP=y"
nickname: "underglow" nickname: "underglow"
- board: nice_nano_v2 - board: nice_nano_v2
shield: lily58_left nice_view_adapter nice_view shield: lily58_left nice_view_adapter nice_view
nickname: "niceview" nickname: "niceview"

View file

@ -18,6 +18,6 @@
}, },
"homepage": "https://zmk.dev/", "homepage": "https://zmk.dev/",
"devDependencies": { "devDependencies": {
"prettier": "^2.4.0" "prettier": "^2.7.1"
} }
} }

17
docs/package-lock.json generated
View file

@ -39,7 +39,7 @@
"mustache": "^4.2.0", "mustache": "^4.2.0",
"null-loader": "^4.0.0", "null-loader": "^4.0.0",
"prebuild-webpack-plugin": "^1.1.1", "prebuild-webpack-plugin": "^1.1.1",
"prettier": "2.3.1", "prettier": "^2.7.1",
"string-replace-loader": "^3.1.0", "string-replace-loader": "^3.1.0",
"typescript": "^4.6.3", "typescript": "^4.6.3",
"webpack": "^5.72.1" "webpack": "^5.72.1"
@ -12201,15 +12201,18 @@
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "2.3.1", "version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.1.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-p+vNbgpLjif/+D+DwAZAbndtRrR0md0MwfmOVN9N+2RgyACMT+7tfaRnT+WDPkqnuVwleyuBIG2XBxKDme3hPA==", "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true, "dev": true,
"bin": { "bin": {
"prettier": "bin-prettier.js" "prettier": "bin-prettier.js"
}, },
"engines": { "engines": {
"node": ">=10.13.0" "node": ">=10.13.0"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
} }
}, },
"node_modules/pretty-error": { "node_modules/pretty-error": {
@ -24675,9 +24678,9 @@
"integrity": "sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==" "integrity": "sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA=="
}, },
"prettier": { "prettier": {
"version": "2.3.1", "version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.1.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-p+vNbgpLjif/+D+DwAZAbndtRrR0md0MwfmOVN9N+2RgyACMT+7tfaRnT+WDPkqnuVwleyuBIG2XBxKDme3hPA==", "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true "dev": true
}, },
"pretty-error": { "pretty-error": {

View file

@ -58,7 +58,7 @@
"mustache": "^4.2.0", "mustache": "^4.2.0",
"null-loader": "^4.0.0", "null-loader": "^4.0.0",
"prebuild-webpack-plugin": "^1.1.1", "prebuild-webpack-plugin": "^1.1.1",
"prettier": "2.3.1", "prettier": "^2.7.1",
"string-replace-loader": "^3.1.0", "string-replace-loader": "^3.1.0",
"typescript": "^4.6.3", "typescript": "^4.6.3",
"webpack": "^5.72.1" "webpack": "^5.72.1"

View file

@ -31,10 +31,7 @@
}, },
{ {
"type": "object", "type": "object",
"required": [ "required": ["id", "features"],
"id",
"features"
],
"properties": { "properties": {
"id": { "id": {
"$ref": "#/$defs/id" "$ref": "#/$defs/id"
@ -89,9 +86,7 @@
"title": "InterconnectNodeLabels", "title": "InterconnectNodeLabels",
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": ["gpio"],
"gpio"
],
"properties": { "properties": {
"gpio": { "type": "string" }, "gpio": { "type": "string" },
"i2c": { "type": "string" }, "i2c": { "type": "string" },
@ -104,14 +99,7 @@
"title": "Interconnect", "title": "Interconnect",
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": ["file_format", "id", "name", "description", "url", "type"],
"file_format",
"id",
"name",
"description",
"url",
"type"
],
"properties": { "properties": {
"file_format": { "file_format": {
"type": "string", "type": "string",
@ -200,10 +188,7 @@
"type": "array", "type": "array",
"items": { "items": {
"type": "string", "type": "string",
"enum": [ "enum": ["usb", "ble"]
"usb",
"ble"
]
} }
}, },
"features": { "features": {
@ -224,14 +209,7 @@
"title": "Shield", "title": "Shield",
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": ["file_format", "id", "name", "url", "type", "requires"],
"file_format",
"id",
"name",
"url",
"type",
"requires"
],
"properties": { "properties": {
"file_format": { "file_format": {
"type": "string", "type": "string",