owlcorp/cli-json-lint

JSON linting command line support mimicking Symfony-way of doing things

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

v1.0.0 2025-06-16 22:20 UTC

This package is auto-updated.

Last update: 2025-06-16 22:27:25 UTC


README

This small package adds a more advanced CLI interface over industry-standard Seldaek's JSON Lint. The CLI interface is compatible with Symfony's YAML lint commands and integrates nicely with workflows using both JSON and YAML commands.

Installation

With Symfony

Install package with composer req --dev owlcorp/cli-json-lint. The command will be automatically available in your application's console:

% composer req --dev owlcorp/cli-json-lint
% bin/console list lint | grep json
  lint:json          Lint JSON file(s) and report errors
% bin/console lint:json --help

If you're not using Symfony Flex, you need to add the following to your config/bundles.php:

<?php

return [
    //...
    OwlCorp\CliJsonLint\CliJsonLintBundle::class => ['dev' => true, 'test' => true],
];

Without Symfony

Install package with composer req --dev owlcorp/cli-json-lint. The command will be available to use via vendor/bin/json-lint: application's console:

% composer req --dev owlcorp/cli-json-lint
% vendor/bin/json-lint --help
Description:
  Lint JSON file(s) and report errors

Usage:
  lint:json [options] [--] <source>...
# ...

Usage

The command is available either via bin/console lint:json (if using Symfony) or vendor/bin/json-lint. Use --help to get information about all options. Examples below work with or without Symfony.

Cheatsheet:

  • Lint ./vendor with subdirectories: vendor/bin/json-lint config
  • Lint only files within ./: vendor/bin/json-lint --d 0 .
  • Show detailed error information: vendor/bin/json-lint -v vendor
  • Show all files parsed: vendor/bin/json-lint -vv vendor
  • You can also use wildcards using glob syntax: vendor/bin/json-lint *end*

Practical example

This package was created to unify linting all configs on production. This is usually achieved by adding a script to composer.json like so:

{
    //...
    "scripts": {
        "sc": "bin/console",
        "lint": [
            "@composer validate --strict",
            "@sc lint:yaml config/",
            "@sc lint:yaml config_runtime/",
            "@sc lint:json config_runtime/"
        ]
  }
}