Commit 640f8062 authored by Wohlgemuth, Jason's avatar Wohlgemuth, Jason
Browse files

feat: Add JSON and YAML linting and formatting with ESLint

parent 70b181a7
Loading
Loading
Loading
Loading

eslint.config.js

0 → 100644
+81 −0
Original line number Diff line number Diff line
import eslintPluginJsonc from 'eslint-plugin-jsonc';
import eslintPluginJsonSchemaValidator from "eslint-plugin-json-schema-validator";

export default [
    ...eslintPluginJsonc.configs['flat/base'],
    ...eslintPluginJsonSchemaValidator.configs['flat/recommended'],
    {
        files: [
            './.gitlab-ci.yml',
            './package.json',
            './tsconfig.json',
            './tspconfig.yaml',
            'src/content/projects/**/*.json',
        ],
        rules: {
            ...eslintPluginJsonc.configs['all'].rules,
            'jsonc/key-name-casing': 'off',
            'jsonc/indent': ['error', 2, {}],
            'jsonc/sort-keys': ['error',
                {
                    pathPattern: '^$',
                    order: [
                        'meta',
                        'title',
                        'subtitle',
                        'sections',
                        'contact'
                    ]
                },
                {
                    pathPattern: '^meta$',
                    order: [
                        'id',
                        'type',
                        'website',
                        'graphics',
                        'keywords',
                        'technology',
                    ]
                },
                {
                    pathPattern: '^sections$',
                    order: [
                        'introduction',
                        'challenge',
                        'approach',
                        'outcomes',
                        'research',
                    ]
                },
                {
                    pathPattern: '^sections[.]research$',
                    order: [
                        'focus',
                        'areas',
                    ]
                },
                {
                    pathPattern: '^contact$',
                    order: [
                        'title',
                        'first',
                        'last',
                        'email',
                        'phone',
                        'profile',
                        'division',
                    ]
                },
        ]
        }
    },
    {
        files: [
            'schemas/**/*.json',
        ],
        rules: {
            ...eslintPluginJsonSchemaValidator.configs['recommended'].rules,
        }
    }
];
+1136 −13

File changed.

Preview size limit exceeded, changes collapsed.

+5 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
    "compile": "tsp compile --config ./tspconfig.yaml ./specs/index.tsp",
    "sync": "vale --config ./.vale/.vale.ini sync",
    "lint": "vale --no-wrap --config ./.vale/.vale.ini ./src/content/projects/",
    "lint:json": "eslint --fix --config ./eslint.config.js",
    "postlint": "npm run lint:json",
    "prevalidate": "npm run compile",
    "validate": "pwsh -Command ./scripts/Invoke-Validate.ps1",
    "postvalidate": "npm run count",
@@ -43,6 +45,9 @@
    "ajv-cli": "^5.0.0",
    "ajv-formats": "^3.0.1",
    "ajv-keywords": "^5.1.0",
    "eslint": "^9.9.1",
    "eslint-plugin-json-schema-validator": "^5.1.2",
    "eslint-plugin-jsonc": "^2.16.0",
    "jsonlint": "^1.6.3"
  }
}
+5 −11
Original line number Diff line number Diff line
@@ -13,16 +13,16 @@
            "type": "string"
        },
        "email": {
            "$ref": "email.json"
            "$ref": "#/$defs/email"
        },
        "phone": {
            "$ref": "phone.json"
            "$ref": "#/$defs/phone"
        },
        "profile": {
            "type": "string"
        },
        "division": {
            "$ref": "Division.json"
            "$ref": "#/$defs/Division"
        }
    },
    "required": [
@@ -36,19 +36,13 @@
    "$defs": {
        "email": {
            "type": "string",
            "pattern": ".+@.+\\..+",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "$id": "email.json"
            "pattern": ".+@.+\\..+"
        },
        "phone": {
            "type": "string",
            "pattern": "^[0-9]{3}[.][0-9]{3}[.][0-9]{4}$",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "$id": "phone.json"
            "pattern": "^[0-9]{3}[.][0-9]{3}[.][0-9]{4}$"
        },
        "Division": {
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "$id": "Division.json",
            "type": "string",
            "enum": [
                "Cyber Resilience and Intelligence",
+2 −6
Original line number Diff line number Diff line
@@ -38,13 +38,13 @@
        "keywords": {
            "type": "array",
            "items": {
                "$ref": "Keyword.json"
                "$ref": "#/$defs/Keyword"
            }
        },
        "technology": {
            "type": "array",
            "items": {
                "$ref": "Technology.json"
                "$ref": "#/$defs/Technology"
            }
        }
    },
@@ -56,8 +56,6 @@
    ],
    "$defs": {
        "Keyword": {
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "$id": "Keyword.json",
            "type": "string",
            "enum": [
                "artificial-intelligence",
@@ -73,8 +71,6 @@
            ]
        },
        "Technology": {
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "$id": "Technology.json",
            "type": "string",
            "enum": [
                "conda:gdal",
Loading