Skip to content

Commit b915e69

Browse files
authored
Add JSON linting (#36192)
Uses https://github.com/eslint/json to lint all JSON and JSONC files in the repo.
1 parent 36aa39f commit b915e69

File tree

6 files changed

+80
-0
lines changed

6 files changed

+80
-0
lines changed

.github/workflows/files-changed.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ on:
1919
value: ${{ jobs.detect.outputs.swagger }}
2020
yaml:
2121
value: ${{ jobs.detect.outputs.yaml }}
22+
json:
23+
value: ${{ jobs.detect.outputs.json }}
2224

2325
jobs:
2426
detect:
@@ -35,6 +37,7 @@ jobs:
3537
docker: ${{ steps.changes.outputs.docker }}
3638
swagger: ${{ steps.changes.outputs.swagger }}
3739
yaml: ${{ steps.changes.outputs.yaml }}
40+
json: ${{ steps.changes.outputs.json }}
3841
steps:
3942
- uses: actions/checkout@v6
4043
- uses: dorny/paths-filter@v3
@@ -100,3 +103,6 @@ jobs:
100103
- "**/*.yaml"
101104
- ".yamllint.yaml"
102105
- "pyproject.toml"
106+
107+
json:
108+
- "**/*.json"

.github/workflows/pull-compliance.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ jobs:
6363
- run: make deps-py
6464
- run: make lint-yaml
6565

66+
lint-json:
67+
if: needs.files-changed.outputs.json == 'true'
68+
needs: files-changed
69+
runs-on: ubuntu-latest
70+
permissions:
71+
contents: read
72+
steps:
73+
- uses: actions/checkout@v6
74+
- uses: pnpm/action-setup@v4
75+
- uses: actions/setup-node@v5
76+
with:
77+
node-version: 24
78+
- run: make deps-frontend
79+
- run: make lint-json
80+
6681
lint-swagger:
6782
if: needs.files-changed.outputs.swagger == 'true'
6883
needs: files-changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,14 @@ lint-templates: .venv node_modules ## lint template files
413413
lint-yaml: .venv ## lint yaml files
414414
@uv run --frozen yamllint -s .
415415

416+
.PHONY: lint-json
417+
lint-json: node_modules ## lint json files
418+
$(NODE_VARS) pnpm exec eslint -c eslint.json.config.ts --color --max-warnings=0
419+
420+
.PHONY: lint-json-fix
421+
lint-json-fix: node_modules ## lint and fix json files
422+
$(NODE_VARS) pnpm exec eslint -c eslint.json.config.ts --color --max-warnings=0 --fix
423+
416424
.PHONY: watch
417425
watch: ## watch everything and continuously rebuild
418426
@bash tools/watch.sh

eslint.json.config.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {defineConfig, globalIgnores} from 'eslint/config';
2+
import json from '@eslint/json';
3+
4+
export default defineConfig([
5+
globalIgnores([
6+
'**/.venv',
7+
'**/node_modules',
8+
'**/public',
9+
]),
10+
{
11+
files: ['**/*.json'],
12+
plugins: {json},
13+
language: 'json/json',
14+
extends: ['json/recommended'],
15+
},
16+
{
17+
files: [
18+
'tsconfig.json',
19+
'.devcontainer/*.json',
20+
'.vscode/*.json',
21+
'contrib/ide/vscode/*.json',
22+
],
23+
plugins: {json},
24+
language: 'json/jsonc',
25+
languageOptions: {
26+
allowTrailingCommas: true,
27+
},
28+
extends: ['json/recommended'],
29+
},
30+
]);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
},
6767
"devDependencies": {
6868
"@eslint-community/eslint-plugin-eslint-comments": "4.5.0",
69+
"@eslint/json": "0.14.0",
6970
"@playwright/test": "1.57.0",
7071
"@stylistic/eslint-plugin": "5.6.1",
7172
"@stylistic/stylelint-plugin": "4.0.0",

pnpm-lock.yaml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)