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 -->
## 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))
- [ ] `.zmk.yml` metadata file added
- [ ] 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)
- [ ] General consistent formatting of DeviceTree files
- [ ] Keymaps do not use deprecated key defines (Check using the [upgrader tool](https://zmk.dev/docs/codes/keymap-upgrader))
- [ ] `&pro_micro` used in favor of `&pro_micro_d/a` if applicable
- [ ] If split, no name added for the right/peripheral half
- [ ] Kconfig.defconfig file correctly wraps *all* configuration in conditional on the shield symbol
- [ ] `.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)
- [ ] 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))
- [ ] `.zmk.yml` metadata file added
- [ ] 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)
- [ ] General consistent formatting of DeviceTree files
- [ ] Keymaps do not use deprecated key defines (Check using the [upgrader tool](https://zmk.dev/docs/codes/keymap-upgrader))
- [ ] `&pro_micro` used in favor of `&pro_micro_d/a` if applicable
- [ ] If split, no name added for the right/peripheral half
- [ ] Kconfig.defconfig file correctly wraps _all_ configuration in conditional on the shield symbol
- [ ] `.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
type: string
archive_name:
description: 'Archive output file name'
default: 'firmware'
description: "Archive output file name"
default: "firmware"
required: false
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
run: npm run lint
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:
runs-on: ubuntu-latest
steps:

View File

@ -15,17 +15,6 @@ on:
- "app/scripts/west_commands/metadata.py"
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:
runs-on: ubuntu-latest
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
repos:
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.1.1
rev: v1.3.5
hooks:
- id: clang-format
args:
- -i
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
rev: v2.7.1
hooks:
- 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,3 +1,3 @@
module.exports = {
endOfLine: "auto",
endOfLine: "auto",
};

View File

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

View File

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

View File

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

View File

@ -4,9 +4,9 @@ Customizable full-size split ortholinear.
## Features
* 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.
* RGB LED connections
- 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.
- RGB LED connections
## Hardware Notes

View File

@ -6,20 +6,22 @@ Keyboard Designer: [clicketysplit.ca](https://clicketysplit.ca)
GitHub: [ClicketySplit](https://github.com/ClicketySplit)
Hardware Supported: Pro Micro, Elite-C, nice!nano v2
Albeit, there is no doubt where Leeloo's heritage is derived from—Lily58, and Corne. It is not a copy-paste-modify implementation.
Albeit, there is no doubt where Leeloo's heritage is derived from—Lily58, and Corne. It is not a copy-paste-modify implementation.
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:
* 4x6x5m Split Keyboard
* Support for MX/Box or Low Profile Choc switches.
* 90% of the switches are socketed; with the exception to the rotary encoder positions—6 positions require soldering.
* Support for 128x32 OLED Displays.
* The option to select one of three positions for an EC11 rotary encoder on each half.
* Support for Alps Alpine Micro Switch
* Support for 3.7v 301230 LiPo Battery
- 4x6x5m Split Keyboard
- Support for MX/Box or Low Profile Choc switches.
- 90% of the switches are socketed; with the exception to the rotary encoder positions—6 positions require soldering.
- Support for 128x32 OLED Displays.
- The option to select one of three positions for an EC11 rotary encoder on each half.
- Support for Alps Alpine Micro Switch
- Support for 3.7v 301230 LiPo Battery
# Building Your Firmware
ZMK Firmware: [Introduction to ZMK](https://zmk.dev/docs/)
Installation: [Installing ZMK](https://zmk.dev/docs/user-setup)
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"
# Support
If you have any questions with regards to Leeloo, please [Contact Us](https://clicketysplit.ca/pages/contact-us).
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.
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.
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.

View File

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

View File

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

View File

@ -5,24 +5,24 @@
#
description: >
This is a representation of the Maxim MAX7318 I2C Gpio Expander.
This is a representation of the Maxim MAX7318 I2C Gpio Expander.
compatible: "maxim,max7318"
include: [gpio-controller.yaml, i2c-device.yaml]
properties:
label:
required: true
label:
required: true
"#gpio-cells":
const: 2
"#gpio-cells":
const: 2
ngpios:
type: int
required: true
const: 16
description: Number of gpios supported
ngpios:
type: int
required: true
const: 16
description: Number of gpios supported
gpio-cells:
- pin

View File

@ -8,54 +8,54 @@ compatible: "gooddisplay,il0323"
include: spi-device.yaml
properties:
height:
type: int
required: true
description: Height in pixel of the panel driven by the controller
height:
type: int
required: true
description: Height in pixel of the panel driven by the controller
width:
type: int
required: true
description: Width in pixel of the panel driven by the controller
width:
type: int
required: true
description: Width in pixel of the panel driven by the controller
reset-gpios:
type: phandle-array
required: true
description: RESET pin.
reset-gpios:
type: phandle-array
required: true
description: RESET pin.
The RESET pin of GD7965 is active low.
If connected directly the MCU pin should be configured
as active low.
The RESET pin of GD7965 is active low.
If connected directly the MCU pin should be configured
as active low.
dc-gpios:
type: phandle-array
required: true
description: DC pin.
dc-gpios:
type: phandle-array
required: true
description: DC pin.
The DC pin of GD7965 is active low (transmission command byte).
If connected directly the MCU pin should be configured
as active low.
The DC pin of GD7965 is active low (transmission command byte).
If connected directly the MCU pin should be configured
as active low.
busy-gpios:
type: phandle-array
required: true
description: BUSY pin.
busy-gpios:
type: phandle-array
required: true
description: BUSY pin.
The BUSY pin of GD7965 is active low.
If connected directly the MCU pin should be configured
as active low.
The BUSY pin of GD7965 is active low.
If connected directly the MCU pin should be configured
as active low.
pwr:
type: uint8-array
required: true
description: Power Setting (PWR) values
pwr:
type: uint8-array
required: true
description: Power Setting (PWR) values
cdi:
type: int
required: true
description: VCOM and data interval value
cdi:
type: int
required: true
description: VCOM and data interval value
tcon:
type: int
required: true
description: TCON setting value
tcon:
type: int
required: true
description: TCON setting value

View File

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

View File

@ -74,8 +74,8 @@ void activity_work_handler(struct k_work *work) {
} else
#endif /* IS_ENABLED(CONFIG_ZMK_SLEEP) */
if (inactive_time > MAX_IDLE_MS) {
set_state(ZMK_ACTIVITY_IDLE);
}
set_state(ZMK_ACTIVITY_IDLE);
}
}
K_WORK_DEFINE(activity_work, activity_work_handler);

17
docs/package-lock.json generated
View File

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

View File

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

View File

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