Skip to content

Commit dab3428

Browse files
authored
Merge pull request #174 from link-foundation/issue-166-0169a4dd2a40
Add automatic linter/static checks for all supported languages
2 parents 6501dcb + 91c8918 commit dab3428

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1166
-675
lines changed

.github/workflows/csharp.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,28 @@ jobs:
4747
echo "isCsFilesChanged=${isCsFilesChanged}" >> $GITHUB_OUTPUT
4848
echo "isCsFilesChanged: ${isCsFilesChanged}"
4949
50-
test:
50+
lint:
5151
needs: [findChangedCsFiles]
5252
if: ${{ needs.findChangedCsFiles.outputs.isCsFilesChanged == 'true' }}
5353
runs-on: ubuntu-latest
54+
timeout-minutes: 10
55+
steps:
56+
- uses: actions/checkout@v5
57+
with:
58+
submodules: true
59+
- name: Setup .NET SDK
60+
uses: actions/setup-dotnet@v5
61+
with:
62+
dotnet-version: '8.0.x'
63+
- name: Restore Dependencies
64+
run: dotnet restore
65+
- name: Check formatting
66+
run: dotnet format --verify-no-changes --verbosity diagnostic
67+
68+
test:
69+
needs: [findChangedCsFiles, lint]
70+
if: ${{ needs.findChangedCsFiles.outputs.isCsFilesChanged == 'true' }}
71+
runs-on: ubuntu-latest
5472
timeout-minutes: 15
5573
steps:
5674
- uses: actions/checkout@v5
@@ -67,7 +85,6 @@ jobs:
6785
- name: Test
6886
run: dotnet test --configuration Release --no-build -f net8
6987

70-
7188
pushToNuget:
7289
runs-on: ubuntu-latest
7390
timeout-minutes: 15

.github/workflows/js.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,28 @@ jobs:
4747
echo "isJsFilesChanged=${isJsFilesChanged}" >> $GITHUB_OUTPUT
4848
echo "isJsFilesChanged: ${isJsFilesChanged}"
4949
50-
test:
50+
lint:
5151
needs: [findChangedJsFiles]
5252
if: ${{ needs.findChangedJsFiles.outputs.isJsFilesChanged == 'true' }}
5353
runs-on: ubuntu-latest
54+
timeout-minutes: 10
55+
steps:
56+
- uses: actions/checkout@v5
57+
with:
58+
submodules: true
59+
- name: Setup Bun
60+
uses: oven-sh/setup-bun@v2
61+
with:
62+
bun-version: latest
63+
- name: Install Dependencies
64+
run: bun install
65+
- name: Lint
66+
run: bun run lint
67+
68+
test:
69+
needs: [findChangedJsFiles, lint]
70+
if: ${{ needs.findChangedJsFiles.outputs.isJsFilesChanged == 'true' }}
71+
runs-on: ubuntu-latest
5472
timeout-minutes: 15
5573
steps:
5674
- uses: actions/checkout@v5

.github/workflows/python.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,34 @@ jobs:
4747
echo "isPythonFilesChanged=${isPythonFilesChanged}" >> $GITHUB_OUTPUT
4848
echo "isPythonFilesChanged: ${isPythonFilesChanged}"
4949
50-
test:
50+
lint:
5151
needs: [findChangedPythonFiles]
5252
if: ${{ needs.findChangedPythonFiles.outputs.isPythonFilesChanged == 'true' }}
5353
runs-on: ubuntu-latest
54+
timeout-minutes: 10
55+
steps:
56+
- uses: actions/checkout@v5
57+
with:
58+
submodules: true
59+
- name: Set up Python 3.13
60+
uses: actions/setup-python@v6
61+
with:
62+
python-version: '3.13'
63+
- name: Install linting tools
64+
run: |
65+
python -m pip install --upgrade pip
66+
pip install black isort flake8
67+
- name: Check formatting with Black
68+
run: black --check --diff .
69+
- name: Check import sorting with isort
70+
run: isort --check-only --diff .
71+
- name: Lint with flake8
72+
run: flake8 --max-line-length=120
73+
74+
test:
75+
needs: [findChangedPythonFiles, lint]
76+
if: ${{ needs.findChangedPythonFiles.outputs.isPythonFilesChanged == 'true' }}
77+
runs-on: ubuntu-latest
5478
timeout-minutes: 15
5579
steps:
5680
- uses: actions/checkout@v5

.github/workflows/rust.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,38 @@ jobs:
4747
echo "isRustFilesChanged=${isRustFilesChanged}" >> $GITHUB_OUTPUT
4848
echo "isRustFilesChanged: ${isRustFilesChanged}"
4949
50-
test:
50+
lint:
5151
needs: [findChangedRustFiles]
5252
if: ${{ needs.findChangedRustFiles.outputs.isRustFilesChanged == 'true' }}
5353
runs-on: ubuntu-latest
54+
timeout-minutes: 10
55+
steps:
56+
- uses: actions/checkout@v5
57+
with:
58+
submodules: true
59+
- name: Setup Rust
60+
uses: dtolnay/rust-toolchain@stable
61+
with:
62+
components: rustfmt, clippy
63+
- name: Cache Cargo registry
64+
uses: actions/cache@v4
65+
with:
66+
path: ~/.cargo/registry
67+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
68+
- name: Cache Cargo index
69+
uses: actions/cache@v4
70+
with:
71+
path: ~/.cargo/git
72+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
73+
- name: Check formatting
74+
run: cargo fmt --all -- --check
75+
- name: Run Clippy
76+
run: cargo clippy --all-targets --all-features -- -D warnings
77+
78+
test:
79+
needs: [findChangedRustFiles, lint]
80+
if: ${{ needs.findChangedRustFiles.outputs.isRustFilesChanged == 'true' }}
81+
runs-on: ubuntu-latest
5482
timeout-minutes: 20
5583
steps:
5684
- uses: actions/checkout@v5

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ repos:
4949
hooks:
5050
- id: fmt
5151
- id: cargo-check
52+
- id: clippy
5253

5354
# Markdown
5455
- repo: https://github.com/igorshubovych/markdownlint-cli

csharp/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,35 @@ mama has house
141141
- **IListExtensions.Format()**: Converts list of links back to string format
142142
- **ILinksGroupListExtensions**: Additional operations for link groups
143143

144+
## Maintenance
145+
146+
### Linting and Formatting
147+
148+
Check code formatting:
149+
150+
```bash
151+
dotnet format --verify-no-changes --verbosity diagnostic
152+
```
153+
154+
Auto-fix formatting:
155+
156+
```bash
157+
dotnet format
158+
```
159+
160+
### Pre-commit Hooks
161+
162+
This project uses pre-commit hooks. To set up pre-commit hooks locally:
163+
164+
```bash
165+
# From repository root
166+
pip install pre-commit
167+
pre-commit install
168+
```
169+
170+
Note: C# formatting checks are integrated into the CI pipeline using
171+
`dotnet format`.
172+
144173
## Dependencies
145174

146175
- .NET 8.0

js/.eslintrc.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"env": {
3+
"browser": false,
4+
"es2021": true,
5+
"node": true
6+
},
7+
"parserOptions": {
8+
"ecmaVersion": "latest",
9+
"sourceType": "module"
10+
},
11+
"globals": {
12+
"describe": "readonly",
13+
"test": "readonly",
14+
"it": "readonly",
15+
"expect": "readonly",
16+
"beforeEach": "readonly",
17+
"afterEach": "readonly",
18+
"beforeAll": "readonly",
19+
"afterAll": "readonly"
20+
},
21+
"rules": {
22+
"no-unused-vars": "warn",
23+
"no-undef": "error",
24+
"semi": ["error", "always"],
25+
"quotes": ["warn", "single", { "avoidEscape": true }]
26+
},
27+
"ignorePatterns": [
28+
"dist/",
29+
"node_modules/",
30+
"src/parser-generated.js"
31+
]
32+
}

js/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,33 @@ Container for grouping related links.
207207
- `src/index.js` - Main entry point
208208
- `tests/` - Test files
209209

210+
## Maintenance
211+
212+
### Linting
213+
214+
Run ESLint to check for code style issues:
215+
216+
```bash
217+
bun run lint
218+
```
219+
220+
Auto-fix linting issues:
221+
222+
```bash
223+
bun run lint:fix
224+
```
225+
226+
### Pre-commit Hooks
227+
228+
This project uses pre-commit hooks that automatically run ESLint before commits.
229+
To set up pre-commit hooks locally:
230+
231+
```bash
232+
# From repository root
233+
pip install pre-commit
234+
pre-commit install
235+
```
236+
210237
## Dependencies
211238

212239
- Peggy.js (5.0.6) - Parser generator

js/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"build": "bun run build:grammar && bun build src/index.js --outdir=dist --target=node",
99
"build:grammar": "peggy --format es -o src/parser-generated.js src/grammar.pegjs",
1010
"test": "bun test",
11-
"test:watch": "bun test --watch"
11+
"test:watch": "bun test --watch",
12+
"lint": "eslint src/ tests/",
13+
"lint:fix": "eslint src/ tests/ --fix"
1214
},
1315
"keywords": [
1416
"lino",
@@ -20,6 +22,7 @@
2022
"license": "Unlicense",
2123
"devDependencies": {
2224
"bun-types": "^1.2.19",
25+
"eslint": "^8.56.0",
2326
"peggy": "^5.0.6"
2427
},
2528
"dependencies": {}

python/.flake8

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
max-line-length = 120
3+
extend-ignore = E203, W503
4+
per-file-ignores =
5+
# E402: module level import not at top of file - needed for path setup
6+
run_tests.py:E402
7+
tests/test_links_group.py:E402
8+
tests/test_nested_self_reference.py:E402

0 commit comments

Comments
 (0)