Add JSON linting (#36192)

Uses https://github.com/eslint/json to lint all JSON and JSONC files in the repo.
This commit is contained in:
silverwind
2025-12-19 07:27:21 +01:00
committed by GitHub
parent 36aa39fffe
commit b915e6908c
6 changed files with 80 additions and 0 deletions

View File

@@ -19,6 +19,8 @@ on:
value: ${{ jobs.detect.outputs.swagger }}
yaml:
value: ${{ jobs.detect.outputs.yaml }}
json:
value: ${{ jobs.detect.outputs.json }}
jobs:
detect:
@@ -35,6 +37,7 @@ jobs:
docker: ${{ steps.changes.outputs.docker }}
swagger: ${{ steps.changes.outputs.swagger }}
yaml: ${{ steps.changes.outputs.yaml }}
json: ${{ steps.changes.outputs.json }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v3
@@ -100,3 +103,6 @@ jobs:
- "**/*.yaml"
- ".yamllint.yaml"
- "pyproject.toml"
json:
- "**/*.json"

View File

@@ -63,6 +63,21 @@ jobs:
- run: make deps-py
- run: make lint-yaml
lint-json:
if: needs.files-changed.outputs.json == 'true'
needs: files-changed
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v5
with:
node-version: 24
- run: make deps-frontend
- run: make lint-json
lint-swagger:
if: needs.files-changed.outputs.swagger == 'true'
needs: files-changed

View File

@@ -413,6 +413,14 @@ lint-templates: .venv node_modules ## lint template files
lint-yaml: .venv ## lint yaml files
@uv run --frozen yamllint -s .
.PHONY: lint-json
lint-json: node_modules ## lint json files
$(NODE_VARS) pnpm exec eslint -c eslint.json.config.ts --color --max-warnings=0
.PHONY: lint-json-fix
lint-json-fix: node_modules ## lint and fix json files
$(NODE_VARS) pnpm exec eslint -c eslint.json.config.ts --color --max-warnings=0 --fix
.PHONY: watch
watch: ## watch everything and continuously rebuild
@bash tools/watch.sh

30
eslint.json.config.ts Normal file
View File

@@ -0,0 +1,30 @@
import {defineConfig, globalIgnores} from 'eslint/config';
import json from '@eslint/json';
export default defineConfig([
globalIgnores([
'**/.venv',
'**/node_modules',
'**/public',
]),
{
files: ['**/*.json'],
plugins: {json},
language: 'json/json',
extends: ['json/recommended'],
},
{
files: [
'tsconfig.json',
'.devcontainer/*.json',
'.vscode/*.json',
'contrib/ide/vscode/*.json',
],
plugins: {json},
language: 'json/jsonc',
languageOptions: {
allowTrailingCommas: true,
},
extends: ['json/recommended'],
},
]);

View File

@@ -66,6 +66,7 @@
},
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "4.5.0",
"@eslint/json": "0.14.0",
"@playwright/test": "1.57.0",
"@stylistic/eslint-plugin": "5.6.1",
"@stylistic/stylelint-plugin": "4.0.0",

20
pnpm-lock.yaml generated
View File

@@ -201,6 +201,9 @@ importers:
'@eslint-community/eslint-plugin-eslint-comments':
specifier: 4.5.0
version: 4.5.0(eslint@9.39.2(jiti@2.6.1))
'@eslint/json':
specifier: 0.14.0
version: 0.14.0
'@playwright/test':
specifier: 1.57.0
version: 1.57.0
@@ -856,6 +859,10 @@ packages:
resolution: {integrity: sha512-q1mjIoW1VX4IvSocvM/vbTiveKC4k9eLrajNEuSsmjymSDEbpGddtpfOoN7YGAqBK3NG+uqo8ia4PDTt8buCYA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@eslint/json@0.14.0':
resolution: {integrity: sha512-rvR/EZtvUG3p9uqrSmcDJPYSH7atmWr0RnFWN6m917MAPx82+zQgPUmDu0whPFG6XTyM0vB/hR6c1Q63OaYtCQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@eslint/object-schema@2.1.7':
resolution: {integrity: sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
@@ -894,6 +901,10 @@ packages:
resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==}
engines: {node: '>=12.22'}
'@humanwhocodes/momoa@3.3.10':
resolution: {integrity: sha512-KWiFQpSAqEIyrTXko3hFNLeQvSK8zXlJQzhhxsyVn58WFRYXST99b3Nqnu+ttOtjds2Pl2grUHGpe2NzhPynuQ==}
engines: {node: '>=18'}
'@humanwhocodes/retry@0.4.3':
resolution: {integrity: sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==}
engines: {node: '>=18.18'}
@@ -4815,6 +4826,13 @@ snapshots:
'@eslint/js@9.39.2': {}
'@eslint/json@0.14.0':
dependencies:
'@eslint/core': 0.17.0
'@eslint/plugin-kit': 0.4.1
'@humanwhocodes/momoa': 3.3.10
natural-compare: 1.4.0
'@eslint/object-schema@2.1.7': {}
'@eslint/plugin-kit@0.4.1':
@@ -4846,6 +4864,8 @@ snapshots:
'@humanwhocodes/module-importer@1.0.1': {}
'@humanwhocodes/momoa@3.3.10': {}
'@humanwhocodes/retry@0.4.3': {}
'@iconify/types@2.0.0': {}