Skip to content

Commit

Permalink
Format and lint files in this repository
Browse files Browse the repository at this point in the history
We want to maintain a consistent style in this repository to make it
easier to collaborate in it. For this purpose, linters and formatters
have been set up. They can be run via pre-commit hooks locally and are
run on every pull request to ensure the default branch is healthy.
  • Loading branch information
jdno committed Apr 11, 2024
1 parent 64372aa commit c20a99a
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
indent_style = space
24 changes: 24 additions & 0 deletions .github/workflows/json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: JSON

"on":
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
style:
name: Check style
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run prettier
uses: creyD/[email protected]
with:
dry: true
prettier_options: "--check **/*.json"
37 changes: 37 additions & 0 deletions .github/workflows/markdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Markdown

"on":
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
lint:
name: Lint code
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run markdownlint
uses: nosborn/[email protected]
with:
files: "**.md"

style:
name: Check style
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run prettier
uses: creyD/[email protected]
with:
dry: true
prettier_options: "--check **/*.md"
35 changes: 35 additions & 0 deletions .github/workflows/yaml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: YAML

"on":
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
lint:
name: Lint code
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run yamllint
uses: actionshub/[email protected]

style:
name: Check style
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run prettier
uses: creyD/[email protected]
with:
dry: true
prettier_options: "--check **/*.{yml,yaml}"
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# pre-commit configuration
#
# We use pre-commit to enforce a consistency in our repositories. By default,
# YAML and Markdown files get linted, and Prettier runs to auto-format the file
# types it supports. Depending on the project, other rules can be added here to
# support the needs of the project.
#
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
7 changes: 7 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
extends: default

rules:
line-length:
ignore: |
.github/workflows/*

0 comments on commit c20a99a

Please sign in to comment.