Skip to content

Commit 8c7e2ee

Browse files
committed
Add linting support and github action to run it
1 parent c347c02 commit 8c7e2ee

4 files changed

Lines changed: 107 additions & 0 deletions

File tree

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[*.{css,js,json,less,md,py,rst,sass,scss,svg.j2,xml,yaml,yml}]
2+
charset = utf-8
3+
end_of_line = lf
4+
indent_size = 4
5+
indent_style = space
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.{json,yml,yaml,rst,md}]
10+
indent_size = 2

.github/workflows/pre-commit.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "main*"
7+
push:
8+
branches:
9+
- "main"
10+
11+
jobs:
12+
pre-commit:
13+
runs-on: ubuntu-22.04
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.11"
19+
- name: Get python version
20+
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
21+
- uses: actions/cache@v4
22+
with:
23+
path: ~/.cache/pre-commit
24+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
25+
- name: Install pre-commit
26+
run: pip install pre-commit
27+
- name: Run pre-commit
28+
run: pre-commit run --all-files --show-diff-on-failure --color=always
29+
- name: Check that all files generated by pre-commit are in git
30+
run: |
31+
newfiles="$(git ls-files --others --exclude-from=.gitignore)"
32+
if [ "$newfiles" != "" ] ; then
33+
echo "Please check-in the following files:"
34+
echo "$newfiles"
35+
exit 1
36+
fi

.pre-commit-config.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
default_language_version:
2+
python: python3
3+
node: "22.9.0"
4+
repos:
5+
- repo: local
6+
hooks:
7+
- id: prettier
8+
name: prettier (with plugin-xml)
9+
entry: prettier
10+
args:
11+
- --write
12+
- --list-different
13+
- --ignore-unknown
14+
types: [text]
15+
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
16+
language: node
17+
additional_dependencies:
18+
- "prettier@3.3.3"
19+
- "@prettier/plugin-xml@3.4.1"
20+
- repo: https://github.com/pre-commit/pre-commit-hooks
21+
rev: v4.6.0
22+
hooks:
23+
- id: trailing-whitespace
24+
- id: end-of-file-fixer
25+
- id: debug-statements
26+
- id: fix-encoding-pragma
27+
args: ["--remove"]
28+
- id: check-case-conflict
29+
- id: check-docstring-first
30+
- id: check-executables-have-shebangs
31+
- id: check-merge-conflict
32+
- id: check-symlinks
33+
- id: check-xml
34+
- id: mixed-line-ending
35+
args: ["--fix=lf"]
36+
- repo: https://github.com/astral-sh/ruff-pre-commit
37+
rev: v0.6.8
38+
hooks:
39+
- id: ruff
40+
args: [--fix, --exit-non-zero-on-fix]
41+
- id: ruff-format
42+
- repo: https://github.com/PyCQA/pylint
43+
rev: v3.3.4
44+
hooks:
45+
- id: pylint
46+
- id: pylint
47+
additional_dependencies:
48+
- "pdfbaker"

prettier.config.cjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/** @type {import('prettier').Config} */
2+
3+
const config = {
4+
plugins: [require.resolve("@prettier/plugin-xml")],
5+
bracketSpacing: false,
6+
printWidth: 88,
7+
proseWrap: "always",
8+
semi: true,
9+
trailingComma: "es5",
10+
xmlWhitespaceSensitivity: "strict",
11+
};
12+
13+
module.exports = config;

0 commit comments

Comments
 (0)